Add focused Scriptorium integration coverage
This commit is contained in:
15
README.md
15
README.md
@@ -64,12 +64,15 @@ service.
|
|||||||
|
|
||||||
## Validation
|
## Validation
|
||||||
|
|
||||||
The repository-local integration suite installs its pinned collection, runs
|
The repository-local integration suite installs its pinned collection and runs
|
||||||
syntax checking and production-profile lint, and applies the default role. It
|
syntax checking and production-profile lint. It applies the default role, uses
|
||||||
uses an offline native profile inspection with the managed configuration, then
|
an offline native profile inspection with the managed configuration, and then
|
||||||
requires clean repeated convergence. It mutates only the managed source,
|
requires clean repeated convergence. It also combines missing-binary recovery
|
||||||
binary, configuration, and a private temporary directory, then restores the
|
with a caller-supplied Go executable while dependency management is disabled,
|
||||||
default deployment during cleanup.
|
and covers one representative configuration with null omission, intentional
|
||||||
|
zero and false values, backend pass-through, and offline native inspection. It
|
||||||
|
mutates only the managed source, binary, configuration, and a private temporary
|
||||||
|
directory, then restores the default deployment during cleanup.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
tests/integration
|
tests/integration
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export ANSIBLE_ROLES_PATH="$(dirname "$repository_root")"
|
|||||||
|
|
||||||
inventory="$repository_root/tests/inventory"
|
inventory="$repository_root/tests/inventory"
|
||||||
converge="$repository_root/tests/converge.yml"
|
converge="$repository_root/tests/converge.yml"
|
||||||
|
verify_config="$repository_root/tests/verify-config.yml"
|
||||||
ansible_playbook="$workspace_venv/bin/ansible-playbook"
|
ansible_playbook="$workspace_venv/bin/ansible-playbook"
|
||||||
binary_path=/usr/local/bin/scriptorium
|
binary_path=/usr/local/bin/scriptorium
|
||||||
config_path=/usr/local/etc/scriptorium/config.yml
|
config_path=/usr/local/etc/scriptorium/config.yml
|
||||||
@@ -31,7 +32,8 @@ require_clean_recap() {
|
|||||||
|
|
||||||
run_converge() {
|
run_converge() {
|
||||||
output_file=$1
|
output_file=$1
|
||||||
"$ansible_playbook" -i "$inventory" "$converge" | tee "$output_file"
|
shift
|
||||||
|
"$ansible_playbook" -i "$inventory" "$@" "$converge" | tee "$output_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir -p "$profile_dir"
|
mkdir -p "$profile_dir"
|
||||||
@@ -39,13 +41,17 @@ printf '%s\n' \
|
|||||||
'id: endpoint-profile' \
|
'id: endpoint-profile' \
|
||||||
'endpoint: http://127.0.0.1:8000/v1' \
|
'endpoint: http://127.0.0.1:8000/v1' \
|
||||||
'model: offline-fixture' > "$profile_dir/endpoint-profile.yml"
|
'model: offline-fixture' > "$profile_dir/endpoint-profile.yml"
|
||||||
|
printf '%s\n' \
|
||||||
|
'id: backend-profile' \
|
||||||
|
'backend: fixture-backend' \
|
||||||
|
'model: offline-fixture' > "$profile_dir/backend-profile.yml"
|
||||||
|
|
||||||
cd "$repository_root"
|
cd "$repository_root"
|
||||||
"$workspace_venv/bin/ansible-galaxy" collection install \
|
"$workspace_venv/bin/ansible-galaxy" collection install \
|
||||||
-r collections/requirements.yml \
|
-r collections/requirements.yml \
|
||||||
-p "$ANSIBLE_COLLECTIONS_PATH"
|
-p "$ANSIBLE_COLLECTIONS_PATH"
|
||||||
"$ansible_playbook" -i "$inventory" --syntax-check "$converge"
|
"$ansible_playbook" -i "$inventory" --syntax-check "$converge"
|
||||||
"$workspace_venv/bin/ansible-lint" "$converge"
|
"$workspace_venv/bin/ansible-lint" "$converge" "$verify_config"
|
||||||
|
|
||||||
baseline_log="$test_tmp/baseline.log"
|
baseline_log="$test_tmp/baseline.log"
|
||||||
run_converge "$baseline_log"
|
run_converge "$baseline_log"
|
||||||
@@ -54,3 +60,40 @@ run_converge "$baseline_log"
|
|||||||
baseline_repeat_log="$test_tmp/baseline-repeat.log"
|
baseline_repeat_log="$test_tmp/baseline-repeat.log"
|
||||||
run_converge "$baseline_repeat_log"
|
run_converge "$baseline_repeat_log"
|
||||||
require_clean_recap "$baseline_repeat_log"
|
require_clean_recap "$baseline_repeat_log"
|
||||||
|
|
||||||
|
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 '{"scriptorium_manage_build_dependencies": false}' \
|
||||||
|
-e "scriptorium_go_binary=$custom_go_binary"
|
||||||
|
grep -q . "$custom_go_invocations"
|
||||||
|
"$binary_path" inspect profile --config "$config_path" \
|
||||||
|
--profile-dir "$profile_dir" --profile endpoint-profile
|
||||||
|
recovery_repeat_log="$test_tmp/recovery-repeat.log"
|
||||||
|
run_converge "$recovery_repeat_log" \
|
||||||
|
-e '{"scriptorium_manage_build_dependencies": false}' \
|
||||||
|
-e "scriptorium_go_binary=$custom_go_binary"
|
||||||
|
require_clean_recap "$recovery_repeat_log"
|
||||||
|
|
||||||
|
representative_log="$test_tmp/representative.log"
|
||||||
|
run_converge "$representative_log" \
|
||||||
|
-e "scriptorium_profile_dir=$profile_dir" \
|
||||||
|
-e 'scriptorium_server_addr=127.0.0.1:18080' \
|
||||||
|
-e '{"scriptorium_server_max_request_bytes": 0, "scriptorium_server_artifact_root": null, "scriptorium_schema_dir": null, "scriptorium_defaults_render_format": "json", "scriptorium_backends": {"fixture-backend": {"endpoint": "http://127.0.0.1:8000/v1", "concurrency_limit": 1, "queue_capacity": 0, "extra_params": {"stream": false}}}}'
|
||||||
|
"$binary_path" inspect profile --config "$config_path" --profile backend-profile
|
||||||
|
"$ansible_playbook" -i "$inventory" \
|
||||||
|
-e "scriptorium_test_profile_dir=$profile_dir" "$verify_config"
|
||||||
|
representative_repeat_log="$test_tmp/representative-repeat.log"
|
||||||
|
run_converge "$representative_repeat_log" \
|
||||||
|
-e "scriptorium_profile_dir=$profile_dir" \
|
||||||
|
-e 'scriptorium_server_addr=127.0.0.1:18080' \
|
||||||
|
-e '{"scriptorium_server_max_request_bytes": 0, "scriptorium_server_artifact_root": null, "scriptorium_schema_dir": null, "scriptorium_defaults_render_format": "json", "scriptorium_backends": {"fixture-backend": {"endpoint": "http://127.0.0.1:8000/v1", "concurrency_limit": 1, "queue_capacity": 0, "extra_params": {"stream": false}}}}'
|
||||||
|
require_clean_recap "$representative_repeat_log"
|
||||||
|
|||||||
31
tests/verify-config.yml
Normal file
31
tests/verify-config.yml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
- name: Verify representative Scriptorium configuration
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: false
|
||||||
|
vars:
|
||||||
|
scriptorium_config_path: /usr/local/etc/scriptorium/config.yml
|
||||||
|
tasks:
|
||||||
|
- name: Read the managed configuration
|
||||||
|
ansible.builtin.slurp:
|
||||||
|
src: "{{ scriptorium_config_path }}"
|
||||||
|
register: scriptorium_config_file
|
||||||
|
|
||||||
|
- name: Parse the managed configuration
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
scriptorium_config: "{{ scriptorium_config_file.content | b64decode | from_yaml }}"
|
||||||
|
|
||||||
|
- name: Verify representative configuration mappings
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- scriptorium_config.profile_dir == scriptorium_test_profile_dir
|
||||||
|
- scriptorium_config.server.addr == "127.0.0.1:18080"
|
||||||
|
- scriptorium_config.server.max_request_bytes == 0
|
||||||
|
- "'artifact_root' not in scriptorium_config.server"
|
||||||
|
- "'max_artifact_bytes' not in scriptorium_config.server"
|
||||||
|
- "'prompt_dir' not in scriptorium_config"
|
||||||
|
- "'schema_dir' not in scriptorium_config"
|
||||||
|
- scriptorium_config.defaults.render_format == "json"
|
||||||
|
- scriptorium_config.backends["fixture-backend"].endpoint == "http://127.0.0.1:8000/v1"
|
||||||
|
- scriptorium_config.backends["fixture-backend"].concurrency_limit == 1
|
||||||
|
- scriptorium_config.backends["fixture-backend"].queue_capacity == 0
|
||||||
|
- scriptorium_config.backends["fixture-backend"].extra_params.stream == false
|
||||||
Reference in New Issue
Block a user