Test Audita configuration rendering
This commit is contained in:
@@ -86,8 +86,10 @@ The integration driver installs pinned collection dependencies, runs syntax
|
|||||||
checking and ansible-lint, verifies the default release, file ownership and
|
checking and ansible-lint, verifies the default release, file ownership and
|
||||||
modes, executable behavior, and native configuration validation. It covers
|
modes, executable behavior, and native configuration validation. It covers
|
||||||
missing-binary and checkout rebuilds, caller-supplied Go with dependency
|
missing-binary and checkout rebuilds, caller-supplied Go with dependency
|
||||||
management disabled, metadata repair without rebuilding, configuration-only
|
management disabled, metadata repair without rebuilding, representative
|
||||||
convergence, and platform failures before isolated application state exists.
|
field-specific configuration rendering, explicitly selected falsey values,
|
||||||
|
restoration to the minimal default configuration, and platform failures before
|
||||||
|
isolated application state exists.
|
||||||
On a fresh host, default convergence may also install Git through APT, refresh
|
On a fresh host, default convergence may also install Git through APT, refresh
|
||||||
the APT cache, and install the Go Snap. Application state is limited to
|
the APT cache, and install the Go Snap. Application state is limited to
|
||||||
`/usr/local/src/audita`, `/usr/local/bin/audita`, and
|
`/usr/local/src/audita`, `/usr/local/bin/audita`, and
|
||||||
|
|||||||
@@ -12,6 +12,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="$repository_root/tests/verify.yml"
|
verify="$repository_root/tests/verify.yml"
|
||||||
|
verify_config="$repository_root/tests/verify-config.yml"
|
||||||
unsupported="$repository_root/tests/unsupported.yml"
|
unsupported="$repository_root/tests/unsupported.yml"
|
||||||
ansible_playbook="$workspace_venv/bin/ansible-playbook"
|
ansible_playbook="$workspace_venv/bin/ansible-playbook"
|
||||||
default_commit=a84941d68168a1ed9ea7423b6477ae8218be73f9
|
default_commit=a84941d68168a1ed9ea7423b6477ae8218be73f9
|
||||||
@@ -47,6 +48,13 @@ verify_release() {
|
|||||||
"$verify"
|
"$verify"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
verify_rendered_config() {
|
||||||
|
expected_config=$1
|
||||||
|
"$ansible_playbook" -i "$inventory" \
|
||||||
|
-e "{\"audita_expected_config\": $expected_config}" \
|
||||||
|
"$verify_config"
|
||||||
|
}
|
||||||
|
|
||||||
validate_config() {
|
validate_config() {
|
||||||
[[ "$("$binary_path" config validate --config "$config_path")" == 'config is valid' ]]
|
[[ "$("$binary_path" config validate --config "$config_path")" == 'config is valid' ]]
|
||||||
}
|
}
|
||||||
@@ -56,7 +64,7 @@ cd "$repository_root"
|
|||||||
-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" "$verify" "$unsupported"
|
"$workspace_venv/bin/ansible-lint" "$converge" "$verify" "$verify_config" "$unsupported"
|
||||||
|
|
||||||
baseline_log="$test_tmp/baseline.log"
|
baseline_log="$test_tmp/baseline.log"
|
||||||
run_converge "$baseline_log"
|
run_converge "$baseline_log"
|
||||||
@@ -106,6 +114,41 @@ metadata_repeat_log="$test_tmp/metadata-repeat.log"
|
|||||||
run_converge "$metadata_repeat_log"
|
run_converge "$metadata_repeat_log"
|
||||||
require_clean_recap "$metadata_repeat_log"
|
require_clean_recap "$metadata_repeat_log"
|
||||||
|
|
||||||
|
representative_config='{"audita_pipeline_modules": ["glossary"], "audita_output_schema": "bare-segments", "audita_llm_proposal_base_url": "https://openrouter.ai/api/v1", "audita_llm_proposal_model": "openrouter/google/gemma-4-31b-it", "audita_llm_proposal_timeout": "10s", "audita_llm_proposal_max_retries": 1, "audita_llm_validation_base_url": "https://openrouter.ai/api/v1", "audita_llm_validation_model": "openrouter/google/gemma-4-31b-it", "audita_llm_validation_timeout": 10, "audita_llm_validation_max_retries": 1, "audita_concurrency_total_llm": 2, "audita_concurrency_proposal_llm": 1, "audita_concurrency_validation_llm": 1, "audita_chunking_target_sections": 2, "audita_chunking_max_section_tokens": 8192, "audita_chunking_min_section_tokens": 2048, "audita_normalization_max_segment_gap": "4s", "audita_normalization_ellipsis_gap": 3.5, "audita_normalization_max_segment_duration": 60, "audita_normalization_max_segment_tokens": 2048, "audita_thresholds_glossary": 0.8, "audita_thresholds_homophones": 0.8, "audita_thresholds_spoken_word": 0.8, "audita_thresholds_grammar": 0.8, "audita_context_description": "Focused integration coverage", "audita_diagnostics_work_dir": "/tmp/audita-integration", "audita_diagnostics_retention": "never"}'
|
||||||
|
representative_expected='{"version": 1, "pipeline": {"modules": ["glossary"]}, "output": {"schema": "bare-segments"}, "llm": {"proposal": {"base_url": "https://openrouter.ai/api/v1", "model": "openrouter/google/gemma-4-31b-it", "timeout": "10s", "max_retries": 1}, "validation": {"base_url": "https://openrouter.ai/api/v1", "model": "openrouter/google/gemma-4-31b-it", "timeout": 10, "max_retries": 1}}, "concurrency": {"total_llm": 2, "proposal_llm": 1, "validation_llm": 1}, "chunking": {"target_sections": 2, "max_section_tokens": 8192, "min_section_tokens": 2048}, "normalization": {"max_segment_gap": "4s", "ellipsis_gap": 3.5, "max_segment_duration": 60, "max_segment_tokens": 2048}, "thresholds": {"glossary": 0.8, "homophones": 0.8, "spoken_word": 0.8, "grammar": 0.8}, "context": {"description": "Focused integration coverage"}, "diagnostics": {"work_dir": "/tmp/audita-integration", "retention": "never"}}'
|
||||||
|
representative_log="$test_tmp/representative-config.log"
|
||||||
|
run_converge "$representative_log" -e "$representative_config"
|
||||||
|
require_changed_recap "$representative_log"
|
||||||
|
grep -A1 -E 'TASK .*Build Audita' "$representative_log" | grep -q '^skipping:'
|
||||||
|
grep -A1 -E 'TASK .*Write Audita configuration' "$representative_log" | grep -q '^changed:'
|
||||||
|
verify_rendered_config "$representative_expected"
|
||||||
|
validate_config
|
||||||
|
representative_repeat_log="$test_tmp/representative-config-repeat.log"
|
||||||
|
run_converge "$representative_repeat_log" -e "$representative_config"
|
||||||
|
require_clean_recap "$representative_repeat_log"
|
||||||
|
|
||||||
|
falsey_config='{"audita_pipeline_modules": [], "audita_context_description": ""}'
|
||||||
|
falsey_expected='{"version": 1, "pipeline": {"modules": []}, "context": {"description": ""}}'
|
||||||
|
falsey_log="$test_tmp/falsey-config.log"
|
||||||
|
run_converge "$falsey_log" -e "$falsey_config"
|
||||||
|
require_changed_recap "$falsey_log"
|
||||||
|
grep -A1 -E 'TASK .*Build Audita' "$falsey_log" | grep -q '^skipping:'
|
||||||
|
grep -A1 -E 'TASK .*Write Audita configuration' "$falsey_log" | grep -q '^changed:'
|
||||||
|
verify_rendered_config "$falsey_expected"
|
||||||
|
falsey_repeat_log="$test_tmp/falsey-config-repeat.log"
|
||||||
|
run_converge "$falsey_repeat_log" -e "$falsey_config"
|
||||||
|
require_clean_recap "$falsey_repeat_log"
|
||||||
|
|
||||||
|
default_config_log="$test_tmp/default-config.log"
|
||||||
|
run_converge "$default_config_log"
|
||||||
|
require_changed_recap "$default_config_log"
|
||||||
|
grep -A1 -E 'TASK .*Build Audita' "$default_config_log" | grep -q '^skipping:'
|
||||||
|
grep -A1 -E 'TASK .*Write Audita configuration' "$default_config_log" | grep -q '^changed:'
|
||||||
|
verify_release "$default_commit"
|
||||||
|
default_config_repeat_log="$test_tmp/default-config-repeat.log"
|
||||||
|
run_converge "$default_config_repeat_log"
|
||||||
|
require_clean_recap "$default_config_repeat_log"
|
||||||
|
|
||||||
alternate_release_log="$test_tmp/alternate-release.log"
|
alternate_release_log="$test_tmp/alternate-release.log"
|
||||||
run_converge "$alternate_release_log" -e "audita_version=$alternate_commit"
|
run_converge "$alternate_release_log" -e "audita_version=$alternate_commit"
|
||||||
require_changed_recap "$alternate_release_log"
|
require_changed_recap "$alternate_release_log"
|
||||||
|
|||||||
31
tests/verify-config.yml
Normal file
31
tests/verify-config.yml
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
---
|
||||||
|
- name: Verify rendered Audita configuration
|
||||||
|
hosts: localhost
|
||||||
|
gather_facts: false
|
||||||
|
tasks:
|
||||||
|
- name: Read rendered configuration
|
||||||
|
become: true
|
||||||
|
ansible.builtin.slurp:
|
||||||
|
src: /usr/local/etc/audita/config.yml
|
||||||
|
register: audita_rendered_config_file
|
||||||
|
|
||||||
|
- name: Check rendered configuration
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- '(audita_rendered_config_file.content | b64decode | from_yaml) == audita_expected_config'
|
||||||
|
|
||||||
|
- name: Validate rendered configuration
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv:
|
||||||
|
- /usr/local/bin/audita
|
||||||
|
- config
|
||||||
|
- validate
|
||||||
|
- --config
|
||||||
|
- /usr/local/etc/audita/config.yml
|
||||||
|
register: audita_rendered_config_validation
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Check rendered configuration validation output
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- audita_rendered_config_validation.stdout == "config is valid"
|
||||||
Reference in New Issue
Block a user