93 lines
3.8 KiB
Bash
Executable File
93 lines
3.8 KiB
Bash
Executable File
#!/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="$(dirname "$repository_root")"
|
|
|
|
inventory="$repository_root/tests/inventory"
|
|
converge="$repository_root/tests/converge.yml"
|
|
verify_config="$repository_root/tests/verify-config.yml"
|
|
ansible_playbook="$workspace_venv/bin/ansible-playbook"
|
|
binary_path=/usr/local/bin/notarius
|
|
config_path=/usr/local/etc/notarius/config.yml
|
|
|
|
cleanup() {
|
|
exit_status=$?
|
|
trap - EXIT
|
|
"$ansible_playbook" -i "$inventory" "$converge" >/dev/null 2>&1 || true
|
|
rm -rf -- "$test_tmp"
|
|
exit "$exit_status"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
require_clean_recap() {
|
|
grep -Eq 'changed=0 .*failed=0' "$1"
|
|
}
|
|
|
|
run_converge() {
|
|
output_file=$1
|
|
shift
|
|
"$ansible_playbook" -i "$inventory" "$@" "$converge" | tee "$output_file"
|
|
}
|
|
|
|
validate_config() {
|
|
"$binary_path" config validate --config "$config_path"
|
|
}
|
|
|
|
cd "$repository_root"
|
|
"$workspace_venv/bin/ansible-galaxy" collection install \
|
|
-r collections/requirements.yml \
|
|
-p "$ANSIBLE_COLLECTIONS_PATH"
|
|
"$ansible_playbook" -i "$inventory" --syntax-check "$converge"
|
|
"$workspace_venv/bin/ansible-lint" "$converge" "$verify_config"
|
|
|
|
baseline_log="$test_tmp/baseline.log"
|
|
run_converge "$baseline_log"
|
|
"$binary_path" --version
|
|
validate_config
|
|
baseline_repeat_log="$test_tmp/baseline-repeat.log"
|
|
run_converge "$baseline_repeat_log"
|
|
require_clean_recap "$baseline_repeat_log"
|
|
|
|
selected_release_log="$test_tmp/selected-release.log"
|
|
run_converge "$selected_release_log" -e notarius_version=v0.5.0
|
|
[[ "$("$binary_path" --version)" == 'notarius v0.5.0' ]]
|
|
|
|
custom_go_binary="$test_tmp/go"
|
|
custom_go_invocations="$test_tmp/go-invocations.log"
|
|
printf '%s\n' \
|
|
'#!/usr/bin/env bash' \
|
|
'set -euo pipefail' \
|
|
"printf '%s\\n' \"\$*\" >> '$custom_go_invocations'" \
|
|
'exec /snap/bin/go "$@"' > "$custom_go_binary"
|
|
chmod 0755 "$custom_go_binary"
|
|
sudo rm -f -- "$binary_path"
|
|
recovery_log="$test_tmp/recovery.log"
|
|
run_converge "$recovery_log" \
|
|
-e notarius_version=v0.5.0 \
|
|
-e '{"notarius_manage_build_dependencies": false}' \
|
|
-e "notarius_go_binary=$custom_go_binary"
|
|
grep -q . "$custom_go_invocations"
|
|
[[ "$("$binary_path" --version)" == 'notarius v0.5.0' ]]
|
|
recovery_repeat_log="$test_tmp/recovery-repeat.log"
|
|
run_converge "$recovery_repeat_log" \
|
|
-e notarius_version=v0.5.0 \
|
|
-e '{"notarius_manage_build_dependencies": false}' \
|
|
-e "notarius_go_binary=$custom_go_binary"
|
|
require_clean_recap "$recovery_repeat_log"
|
|
|
|
pipeline_group_one='{"dnd-session":{"llm_profile":"dnd-extraction","input":"seriatim","artifacts":{"spells":{"extract":"dnd/spells","normalize":"dnd/spells"}}}}'
|
|
pipeline_group_two='{"dnd-archive":{"llm_profile":"dnd-extraction","input":"seriatim","artifacts":{"spells":{"extract":"dnd/spells","normalize":"dnd/spells"}}}}'
|
|
representative_config="{\"notarius_pipeline_group_one\":$pipeline_group_one,\"notarius_pipeline_group_two\":$pipeline_group_two,\"notarius_pipelines\":\"{{ notarius_pipeline_group_one | combine(notarius_pipeline_group_two) }}\",\"notarius_config_version\":4,\"notarius_promptkit_local_backend_endpoint\":\"http://localhost:8000/v1\",\"notarius_promptkit_local_backend_concurrency_limit\":0,\"notarius_cache_checkpoints_enabled\":false,\"notarius_cache_chunk_plans_directory\":\"\",\"notarius_output_directory\":\"/tmp/notarius-output\",\"notarius_promptkit_profile_dir\":null,\"notarius_promptkit_profile_file\":null,\"notarius_debug_directory\":null}"
|
|
representative_log="$test_tmp/representative.log"
|
|
run_converge "$representative_log" -e "$representative_config"
|
|
"$ansible_playbook" -i "$inventory" "$verify_config"
|
|
representative_repeat_log="$test_tmp/representative-repeat.log"
|
|
run_converge "$representative_repeat_log" -e "$representative_config"
|
|
require_clean_recap "$representative_repeat_log"
|