Files
helmfile/test/integration/test-cases/v1-subhelmfile-multi-bases-with-array-values.sh
T
yxxhero bbf925f154 test: add integration test for issue #1880 transformers with file:// deps (#2673)
* test: add integration test for issue #1880 transformers with file:// deps

Add an integration test reproducing the exact scenario from issue #1880:
a local chart with a relative file:// dependency (file://../library) used
together with kustomize transformers.

Before the fix (rewriteChartDependencies in PR #2334), chartify copied
the chart to a temp directory, breaking the relative file:// path and
causing helm dependency up to fail with:
  Error: directory /tmp/chartify.../monitoring/library not found

Also fix test artifact leak in issue923_test.go where OCI chart downloads
wrote to CWD because OutputDirTemplate lacked {{ .OutputDir }}.

Closes #1880

Signed-off-by: yxxhero <aiopsclub@163.com>

* fix(test): guard exit-code captures against set -e in integration tests

Under set -e (enabled in run.sh), a failing command exits the shell
before 'var=$?' can execute, defeating diagnostic cat+fail blocks and
breaking helm diff tests that expect exit code 2.

Replaced 'cmd; var=$?' with 'var=0; cmd || var=$?' across 12 test
files (29 sites), matching the pattern already used in oci-parallel-pull.sh.

Signed-off-by: yxxhero <aiopsclub@163.com>

---------

Signed-off-by: yxxhero <aiopsclub@163.com>
2026-06-29 08:49:51 +08:00

30 lines
1.9 KiB
Bash

v1_subhelmfile_multi_bases_with_array_values_input_dir="${cases_dir}/v1-subhelmfile-multi-bases-with-array-values/input"
v1_subhelmfile_multi_bases_with_array_values_output_dir="${cases_dir}/v1-subhelmfile-multi-bases-with-array-values/output"
yaml_overwrite_tmp=$(mktemp -d)
yaml_overwrite_reverse=${yaml_overwrite_tmp}/helmfile_template_result
v1_subhelmfile_multi_bases_with_array_values_output_file=${v1_subhelmfile_multi_bases_with_array_values_output_dir}/result
if [[ $EXTRA_HELMFILE_FLAGS == *--enable-live-output* ]]; then
v1_subhelmfile_multi_bases_with_array_values_output_file=${v1_subhelmfile_multi_bases_with_array_values_output_dir}/result-live
fi
test_start "v1 subhelmfile multi bases with array values"
info "Comparing v1 subhelmfile multi bases with array values output ${yaml_overwrite_reverse} with ${v1_subhelmfile_multi_bases_with_array_values_output_file}"
for i in $(seq 10); do
info "Comparing build/v1-subhelmfile-multi-bases-with-array-values #$i"
# Remove incubator repo to ensure consistent output (repo addition message)
${helm} repo remove incubator 2>/dev/null || true
exit_code=0
${helmfile} -f ${v1_subhelmfile_multi_bases_with_array_values_input_dir}/helmfile.yaml.gotmpl template -e dev &> ${yaml_overwrite_reverse} || exit_code=$?
if [ $exit_code -ne 0 ]; then
info "ERROR: helmfile template command failed with exit code $exit_code"
info "ERROR: Output from failed command:"
cat ${yaml_overwrite_reverse}
fail "\"helmfile template\" shouldn't fail"
fi
diff -u ${v1_subhelmfile_multi_bases_with_array_values_output_file} ${yaml_overwrite_reverse} || fail "\"helmfile template\" should be consistent"
done
# Clean up: remove incubator repo to avoid conflicts with subsequent tests
${helm} repo remove incubator 2>/dev/null || true
test_pass "v1 subhelmfile multi bases with array values"