Test the assembled D&D collection
This commit is contained in:
6
tests/converge.yml
Normal file
6
tests/converge.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
- name: Converge the installed D&D collection
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: true
|
||||||
|
roles:
|
||||||
|
- role: rakestraw.dnd.pipeline
|
||||||
79
tests/integration
Executable file
79
tests/integration
Executable file
@@ -0,0 +1,79 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
repository_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
||||||
|
workspace_venv="$repository_root/../.venv"
|
||||||
|
test_tmp=$(mktemp -d)
|
||||||
|
chmod 0700 "$test_tmp"
|
||||||
|
|
||||||
|
export ANSIBLE_COLLECTIONS_PATH="$test_tmp/collections"
|
||||||
|
export ANSIBLE_ROLES_PATH="$test_tmp/roles"
|
||||||
|
|
||||||
|
inventory="$repository_root/tests/inventory"
|
||||||
|
converge="$repository_root/tests/converge.yml"
|
||||||
|
ansible_playbook="$workspace_venv/bin/ansible-playbook"
|
||||||
|
campaigns_repository=$(cd "$repository_root/../assets/campaigns" && pwd)
|
||||||
|
prompt_library_repository=$(cd "$repository_root/../assets/narratio-prompts" && pwd)
|
||||||
|
campaigns_revision=$(git -C "$campaigns_repository" rev-parse HEAD)
|
||||||
|
prompt_library_revision=$(git -C "$prompt_library_repository" rev-parse HEAD)
|
||||||
|
synthetic_audita_api_key='audita-pipeline-synthetic-value'
|
||||||
|
synthetic_notarius_api_key='notarius-pipeline-synthetic-value'
|
||||||
|
baseline_args=(
|
||||||
|
-e 'dnd_pipeline_whisperx_transcribe_url=http://127.0.0.1:8000/transcribe'
|
||||||
|
-e "dnd_pipeline_campaigns_repository_url=file://$campaigns_repository"
|
||||||
|
-e "dnd_pipeline_campaigns_revision=$campaigns_revision"
|
||||||
|
-e "dnd_pipeline_prompt_library_repository_url=file://$prompt_library_repository"
|
||||||
|
-e "dnd_pipeline_prompt_library_revision=$prompt_library_revision"
|
||||||
|
-e '{"dnd_pipeline_secrets":{"AUDITA_LLM_API_KEY":"audita-pipeline-synthetic-value","OPENROUTER_API_KEY":"notarius-pipeline-synthetic-value"}}'
|
||||||
|
)
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
exit_status=$?
|
||||||
|
trap - EXIT
|
||||||
|
rm -rf -- "$test_tmp"
|
||||||
|
exit "$exit_status"
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
run_converge() {
|
||||||
|
output_file=$1
|
||||||
|
env -u AUDITA_LLM_API_KEY -u OPENROUTER_API_KEY \
|
||||||
|
"$ansible_playbook" -i "$inventory" "${baseline_args[@]}" "$converge" | \
|
||||||
|
tee "$output_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
cd "$repository_root"
|
||||||
|
mkdir -p "$ANSIBLE_COLLECTIONS_PATH" "$ANSIBLE_ROLES_PATH" "$test_tmp/build"
|
||||||
|
"$workspace_venv/bin/ansible-galaxy" install -r requirements.yml
|
||||||
|
"$workspace_venv/bin/ansible-galaxy" collection build --output-path "$test_tmp/build"
|
||||||
|
artifact="$test_tmp/build/rakestraw-dnd-0.1.0.tar.gz"
|
||||||
|
archive_contents="$test_tmp/archive.txt"
|
||||||
|
tar -tzf "$artifact" > "$archive_contents"
|
||||||
|
grep -Fxq 'roles/pipeline/tasks/main.yml' "$archive_contents"
|
||||||
|
if grep -Eq '(^|/)roles/pipeline/(\.git|tests|collections/requirements\.yml|requirements\.yml|ansible\.cfg|\.gitignore)(/|$)' "$archive_contents"; then
|
||||||
|
echo 'Built artifact includes development-only pipeline content' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
"$workspace_venv/bin/ansible-galaxy" collection install \
|
||||||
|
"$artifact" -p "$ANSIBLE_COLLECTIONS_PATH" --no-deps
|
||||||
|
|
||||||
|
"$ansible_playbook" -i "$inventory" --syntax-check "$converge"
|
||||||
|
"$workspace_venv/bin/ansible-lint" --offline --profile production "$converge"
|
||||||
|
|
||||||
|
baseline_log="$test_tmp/baseline.log"
|
||||||
|
run_converge "$baseline_log"
|
||||||
|
/usr/local/bin/seriatim --version
|
||||||
|
/usr/local/bin/audita config validate --config /usr/local/etc/audita/config.yml
|
||||||
|
/usr/local/bin/notarius config validate --config /usr/local/etc/notarius/config.yml \
|
||||||
|
--pipeline dnd-session
|
||||||
|
/usr/local/bin/scriptorium inspect prompt \
|
||||||
|
--config /usr/local/etc/scriptorium/config.yml \
|
||||||
|
--prompt dnd.session_recap --prompt-version 2.0.0 --format json >/dev/null
|
||||||
|
/usr/bin/sudo -u narratio /usr/local/bin/narratio config validate \
|
||||||
|
--config /usr/local/etc/narratio/pipeline.yml --campaign centaurs
|
||||||
|
! grep -Fq "$synthetic_audita_api_key" "$baseline_log"
|
||||||
|
! grep -Fq "$synthetic_notarius_api_key" "$baseline_log"
|
||||||
|
|
||||||
|
repeat_log="$test_tmp/repeat.log"
|
||||||
|
run_converge "$repeat_log"
|
||||||
|
grep -Eq 'changed=0 .*failed=0' "$repeat_log"
|
||||||
1
tests/inventory
Normal file
1
tests/inventory
Normal file
@@ -0,0 +1 @@
|
|||||||
|
localhost ansible_connection=local
|
||||||
Reference in New Issue
Block a user