split run.sh to make run.sh be more clear. (#485)
split run.sh Signed-off-by: yxxhero <aiopsclub@163.com> Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
		
							parent
							
								
									6dcde20d7a
								
							
						
					
					
						commit
						82004b53f9
					
				|  | @ -85,167 +85,11 @@ $kubectl create namespace ${test_ns} || fail "Could not create namespace ${test_ | ||||||
| 
 | 
 | ||||||
| # TEST CASES---------------------------------------------------------------------------------------------------------- | # TEST CASES---------------------------------------------------------------------------------------------------------- | ||||||
| 
 | 
 | ||||||
| test_start "happypath - simple rollout of httpbin chart" | . ${dir}/test-cases/happypath.sh | ||||||
| 
 | . ${dir}/test-cases/regression.sh | ||||||
| info "Diffing ${dir}/happypath.yaml" | . ${dir}/test-cases/secretssops.sh | ||||||
| bash -c "${helmfile} -f ${dir}/happypath.yaml diff --detailed-exitcode; code="'$?'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile diff" | . ${dir}/test-cases/yaml-overwrite.sh | ||||||
| 
 | . ${dir}/test-cases/chart-needs.sh | ||||||
| info "Diffing ${dir}/happypath.yaml without color" |  | ||||||
| bash -c "${helmfile} -f ${dir}/happypath.yaml --no-color diff --detailed-exitcode; code="'$?'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile diff" |  | ||||||
| 
 |  | ||||||
| info "Diffing ${dir}/happypath.yaml with limited context" |  | ||||||
| bash -c "${helmfile} -f ${dir}/happypath.yaml diff --context 3 --detailed-exitcode; code="'$?'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile diff" |  | ||||||
| 
 |  | ||||||
| info "Diffing ${dir}/happypath.yaml with altered output" |  | ||||||
| bash -c "${helmfile} -f ${dir}/happypath.yaml diff --output simple --detailed-exitcode; code="'$?'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile diff" |  | ||||||
| 
 |  | ||||||
| info "Templating ${dir}/happypath.yaml" |  | ||||||
| rm -rf ${dir}/tmp |  | ||||||
| ${helmfile} -f ${dir}/happypath.yaml --debug template --output-dir tmp |  | ||||||
| code=$? |  | ||||||
| [ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile template: ${code}" |  | ||||||
| for output in $(ls -d ${dir}/tmp/*); do |  | ||||||
|     # e.g. test/integration/tmp/happypath-877c0dd4-helmx/helmx |  | ||||||
|     for release_dir in $(ls -d ${output}/*); do |  | ||||||
|         release_name=$(basename ${release_dir}) |  | ||||||
|         golden_dir=${dir}/templates-golden/v${helm_major_version}/${release_name} |  | ||||||
|         info "Comparing template output ${release_dir}/templates with ${golden_dir}" |  | ||||||
|         ./diff-yamls ${golden_dir} ${release_dir}/templates || fail "unexpected diff in template result for ${release_name}" |  | ||||||
|     done |  | ||||||
| done |  | ||||||
| 
 |  | ||||||
| info "Applying ${dir}/happypath.yaml" |  | ||||||
| bash -c "${helmfile} -f ${dir}/happypath.yaml apply --detailed-exitcode; code="'$?'"; echo Code: "'$code'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile apply" |  | ||||||
| 
 |  | ||||||
| info "Syncing ${dir}/happypath.yaml" |  | ||||||
| ${helmfile} -f ${dir}/happypath.yaml sync |  | ||||||
| wait_deploy_ready httpbin-httpbin |  | ||||||
| retry 5 "curl --fail $(minikube service --url --namespace=${test_ns} httpbin-httpbin)/status/200" |  | ||||||
| [ ${retry_result} -eq 0 ] || fail "httpbin failed to return 200 OK" |  | ||||||
| 
 |  | ||||||
| info "Applying ${dir}/happypath.yaml" |  | ||||||
| ${helmfile} -f ${dir}/happypath.yaml apply --detailed-exitcode |  | ||||||
| code=$? |  | ||||||
| [ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile apply: want 0, got ${code}" |  | ||||||
| 
 |  | ||||||
| info "Locking dependencies" |  | ||||||
| ${helmfile} -f ${dir}/happypath.yaml deps |  | ||||||
| code=$? |  | ||||||
| [ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile deps: ${code}" |  | ||||||
| 
 |  | ||||||
| info "Applying ${dir}/happypath.yaml with locked dependencies" |  | ||||||
| ${helmfile} -f ${dir}/happypath.yaml apply |  | ||||||
| code=$? |  | ||||||
| [ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile apply: ${code}" |  | ||||||
| ${helm} list --namespace=${test_ns} || fail "unable to list releases" |  | ||||||
| 
 |  | ||||||
| info "Deleting release" |  | ||||||
| ${helmfile} -f ${dir}/happypath.yaml delete |  | ||||||
| ${helm} status --namespace=${test_ns} httpbin &> /dev/null && fail "release should not exist anymore after a delete" |  | ||||||
| 
 |  | ||||||
| info "Ensuring \"helmfile delete\" doesn't fail when no releases installed" |  | ||||||
| ${helmfile} -f ${dir}/happypath.yaml delete || fail "\"helmfile delete\" shouldn't fail when there are no installed releases" |  | ||||||
| 
 |  | ||||||
| info "Ensuring \"helmfile template\" output does contain only YAML docs" |  | ||||||
| (${helmfile} -f ${dir}/happypath.yaml template | kubectl apply -f -) || fail "\"helmfile template | kubectl apply -f -\" shouldn't fail" |  | ||||||
| 
 |  | ||||||
| test_pass "happypath" |  | ||||||
| 
 |  | ||||||
| test_start "regression tests" |  | ||||||
| 
 |  | ||||||
| if [[ helm_major_version -eq 3 ]]; then |  | ||||||
|   info "https://github.com/roboll/helmfile/issues/1857" |  | ||||||
|   (${helmfile} -f ${dir}/issue.1857.yaml --state-values-set grafanaEnabled=true template | grep grafana 1>/dev/null) || fail "\"helmfile template\" shouldn't include grafana" |  | ||||||
|   ! (${helmfile} -f ${dir}/issue.1857.yaml --state-values-set grafanaEnabled=false template | grep grafana) || fail "\"helmfile template\" shouldn't include grafana" |  | ||||||
| 
 |  | ||||||
|   info "https://github.com/roboll/helmfile/issues/1867" |  | ||||||
|   (${helmfile} -f ${dir}/issue.1867.yaml template 1>/dev/null) || fail "\"helmfile template\" shouldn't fail" |  | ||||||
| 
 |  | ||||||
|   info "https://github.com/roboll/helmfile/issues/2118" |  | ||||||
|   (${helmfile} -f ${dir}/issue.2118.yaml template 1>/dev/null) || fail "\"helmfile template\" shouldn't fail" |  | ||||||
| else |  | ||||||
|   info "There are no regression tests for helm 2 because all the target charts have dropped helm 2 support." |  | ||||||
| fi |  | ||||||
| 
 |  | ||||||
| test_pass "regression tests" |  | ||||||
| 
 |  | ||||||
| if [[ helm_major_version -eq 3 ]]; then |  | ||||||
|   export VAULT_ADDR=http://127.0.0.1:8200 |  | ||||||
|   export VAULT_TOKEN=toor |  | ||||||
|   sops="sops --hc-vault-transit $VAULT_ADDR/v1/sops/keys/key" |  | ||||||
|   mkdir -p ${dir}/tmp |  | ||||||
| 
 |  | ||||||
|   info "Encrypt secrets" |  | ||||||
|   ${sops} -e ${dir}/env-1.secrets.yaml > ${dir}/tmp/env-1.secrets.sops.yaml || fail "${sops} failed at ${dir}/env-1.secrets.yaml" |  | ||||||
|   ${sops} -e ${dir}/env-2.secrets.yaml > ${dir}/tmp/env-2.secrets.sops.yaml || fail "${sops} failed at ${dir}/env-2.secrets.yaml" |  | ||||||
| 
 |  | ||||||
|   test_start "secretssops.1 - should fail without secrets plugin" |  | ||||||
| 
 |  | ||||||
|   info "Ensure helm-secrets is not installed" |  | ||||||
|   ${helm} plugin rm secrets || true |  | ||||||
| 
 |  | ||||||
|   info "Ensure helmfile fails when no helm-secrets is installed" |  | ||||||
|   unset code |  | ||||||
|   ${helmfile} -f ${dir}/secretssops.yaml -e direct build || code="$?"; code="${code:-0}" |  | ||||||
|   echo Code: "${code}" |  | ||||||
|   [ "${code}" -ne 0 ] || fail "\"helmfile build\" should fail without secrets plugin" |  | ||||||
| 
 |  | ||||||
|   test_pass "secretssops.1" |  | ||||||
| 
 |  | ||||||
|   test_start "secretssops.2 - should succeed with secrets plugin" |  | ||||||
| 
 |  | ||||||
|   info "Ensure helm-secrets is installed" |  | ||||||
|   ${helm} plugin install https://github.com/jkroepke/helm-secrets --version v${HELM_SECRETS_VERSION} |  | ||||||
| 
 |  | ||||||
|   info "Ensure helmfile succeed when helm-secrets is installed" |  | ||||||
|   ${helmfile} -f ${dir}/secretssops.yaml -e direct build || fail "\"helmfile build\" shouldn't fail" |  | ||||||
| 
 |  | ||||||
|   test_pass "secretssops.2" |  | ||||||
| 
 |  | ||||||
|   test_start "secretssops.3 - should order secrets correctly" |  | ||||||
| 
 |  | ||||||
|   tmp=$(mktemp -d) |  | ||||||
|   direct=${tmp}/direct.build.yaml |  | ||||||
|   reverse=${tmp}/reverse.build.yaml |  | ||||||
|   secrets_golden_dir=${dir}/secrets-golden |  | ||||||
| 
 |  | ||||||
|   info "Building secrets output" |  | ||||||
| 
 |  | ||||||
|   info "Comparing build/direct output ${direct} with ${secrets_golden_dir}" |  | ||||||
|   for i in $(seq 10); do |  | ||||||
|       info "Comparing build/direct #$i" |  | ||||||
|       ${helmfile} -f ${dir}/secretssops.yaml -e direct template --skip-deps > ${direct} || fail "\"helmfile template\" shouldn't fail" |  | ||||||
|       ./yamldiff ${secrets_golden_dir}/direct.build.yaml ${direct} || fail "\"helmfile template\" should be consistent" |  | ||||||
|       echo code=$? |  | ||||||
|   done |  | ||||||
| 
 |  | ||||||
|   info "Comparing build/reverse output ${direct} with ${secrets_golden_dir}" |  | ||||||
|   for i in $(seq 10); do |  | ||||||
|       info "Comparing build/reverse #$i" |  | ||||||
|       ${helmfile} -f ${dir}/secretssops.yaml -e reverse template --skip-deps > ${reverse} || fail "\"helmfile template\" shouldn't fail" |  | ||||||
|       ./yamldiff ${secrets_golden_dir}/reverse.build.yaml ${reverse} || fail "\"helmfile template\" should be consistent" |  | ||||||
|       echo code=$? |  | ||||||
|   done |  | ||||||
| 
 |  | ||||||
|   test_pass "secretssops.3" |  | ||||||
| 
 |  | ||||||
|   yaml_feature_golden_dir=${dir}/yaml-features-golden |  | ||||||
|   yaml_overwrite_reverse=${tmp}/yaml.override.build.yaml |  | ||||||
| 
 |  | ||||||
|   test_start "yaml overwrite feature" |  | ||||||
|   info "Comparing yaml overwrite feature output ${yaml_overwrite_reverse} with ${yaml_feature_golden_dir}/overwritten.yaml" |  | ||||||
|   for i in $(seq 10); do |  | ||||||
|       info "Comparing build/yaml-overwrite #$i" |  | ||||||
|       ${helmfile} -f ${dir}/issue.657.yaml template --skip-deps > ${yaml_overwrite_reverse} || fail "\"helmfile template\" shouldn't fail" |  | ||||||
|       ./yamldiff ${yaml_feature_golden_dir}/overwritten.yaml ${yaml_overwrite_reverse} || fail "\"helmfile template\" should be consistent" |  | ||||||
|       echo code=$? |  | ||||||
|   done |  | ||||||
|   test_pass "yaml overwrite feature" |  | ||||||
| 
 |  | ||||||
|   # chart preprocessing with needs |  | ||||||
|   . ${dir}/test-cases/chart-needs.sh |  | ||||||
| 
 |  | ||||||
| fi |  | ||||||
| 
 | 
 | ||||||
| # ALL DONE ----------------------------------------------------------------------------------------------------------- | # ALL DONE ----------------------------------------------------------------------------------------------------------- | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,55 +1,58 @@ | ||||||
| chart_needs_golden_dir=${dir}/chart-needs-golden | if [[ helm_major_version -eq 3 ]]; then | ||||||
| chart_needs_template_reverse=${tmp}/chart.needs.template.log |   chart_needs_tmp=$(mktemp -d) | ||||||
| chart_needs_lint_reverse=${tmp}/chart.needs.lint.log |   chart_needs_golden_dir=${dir}/chart-needs-golden | ||||||
| chart_needs_diff_reverse=${tmp}/chart.needs.diff.log |   chart_needs_template_reverse=${chart_needs_tmp}/chart.needs.template.log | ||||||
|  |   chart_needs_lint_reverse=${chart_needs_tmp}/chart.needs.lint.log | ||||||
|  |   chart_needs_diff_reverse=${chart_needs_tmp}/chart.needs.diff.log | ||||||
| 
 | 
 | ||||||
| test_start "chart prepare when helmfile template with needs" |   test_start "chart prepare when helmfile template with needs" | ||||||
| 
 | 
 | ||||||
| info "https://github.com/helmfile/helmfile/issues/455" |   info "https://github.com/helmfile/helmfile/issues/455" | ||||||
| 
 | 
 | ||||||
| for i in $(seq 10); do |   for i in $(seq 10); do | ||||||
|     info "Comparing template/chart-needs #$i" |       info "Comparing template/chart-needs #$i" | ||||||
|     ${helmfile} -f ${dir}/issue.455/helmfile.yaml template --include-needs > ${chart_needs_template_reverse} || fail "\"helmfile template\" shouldn't fail" |       ${helmfile} -f ${dir}/issue.455/helmfile.yaml template --include-needs > ${chart_needs_template_reverse} || fail "\"helmfile template\" shouldn't fail" | ||||||
|     ./yamldiff ${chart_needs_golden_dir}/template ${chart_needs_template_reverse} || fail "\"helmfile template\" should be consistent" |       ./yamldiff ${chart_needs_golden_dir}/template ${chart_needs_template_reverse} || fail "\"helmfile template\" should be consistent" | ||||||
|     echo code=$? |       echo code=$? | ||||||
| done |   done | ||||||
| 
 | 
 | ||||||
| for i in $(seq 10); do |   for i in $(seq 10); do | ||||||
|     info "Comparing lint/chart-needs #$i" |       info "Comparing lint/chart-needs #$i" | ||||||
|     ${helmfile_no_extra_flags} -f ${dir}/issue.455/helmfile.yaml lint --include-needs | grep -v Linting > ${chart_needs_lint_reverse} || fail "\"helmfile lint\" shouldn't fail" |       ${helmfile_no_extra_flags} -f ${dir}/issue.455/helmfile.yaml lint --include-needs | grep -v Linting > ${chart_needs_lint_reverse} || fail "\"helmfile lint\" shouldn't fail" | ||||||
|     diff -u ${chart_needs_golden_dir}/lint ${chart_needs_lint_reverse} || fail "\"helmfile lint\" should be consistent" |       diff -u ${chart_needs_golden_dir}/lint ${chart_needs_lint_reverse} || fail "\"helmfile lint\" should be consistent" | ||||||
|     echo code=$? |       echo code=$? | ||||||
| done |   done | ||||||
| 
 | 
 | ||||||
| for i in $(seq 10); do |   for i in $(seq 10); do | ||||||
|     info "Comparing diff/chart-needs #$i" |       info "Comparing diff/chart-needs #$i" | ||||||
|     ${helmfile_no_extra_flags} -f ${dir}/issue.455/helmfile.yaml diff --include-needs | grep -Ev "Comparing release=azuredisk-csi-storageclass, chart=/tmp/[0-9a-zA-Z]+/azuredisk-csi-storageclass" | grep -v "$test_ns" > ${chart_needs_diff_reverse} || fail "\"helmfile diff\" shouldn't fail" |       ${helmfile_no_extra_flags} -f ${dir}/issue.455/helmfile.yaml diff --include-needs | grep -Ev "Comparing release=azuredisk-csi-storageclass, chart=/tmp/[0-9a-zA-Z]+/azuredisk-csi-storageclass" | grep -v "$test_ns" > ${chart_needs_diff_reverse} || fail "\"helmfile diff\" shouldn't fail" | ||||||
|     diff -u ${chart_needs_golden_dir}/diff ${chart_needs_diff_reverse} || fail "\"helmfile diff\" should be consistent" |       diff -u ${chart_needs_golden_dir}/diff ${chart_needs_diff_reverse} || fail "\"helmfile diff\" should be consistent" | ||||||
|     echo code=$? |       echo code=$? | ||||||
| done |   done | ||||||
| 
 | 
 | ||||||
| info "Applying ${dir}/issue.455/helmfile.yaml" |   info "Applying ${dir}/issue.455/helmfile.yaml" | ||||||
| ${helmfile} -f ${dir}/issue.455/helmfile.yaml  apply --include-needs |   ${helmfile} -f ${dir}/issue.455/helmfile.yaml  apply --include-needs | ||||||
| code=$? |   code=$? | ||||||
| [ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile apply: want 0, got ${code}" |   [ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile apply: want 0, got ${code}" | ||||||
| 
 | 
 | ||||||
| ${kubectl} get storageclass managed-csi -o yaml | grep -q "provisioner: disk.csi.azure.com" || fail "storageclass managed-csi should be created when applying helmfile.yaml" |   ${kubectl} get storageclass managed-csi -o yaml | grep -q "provisioner: disk.csi.azure.com" || fail "storageclass managed-csi should be created when applying helmfile.yaml" | ||||||
| 
 | 
 | ||||||
| info "Destroying ${dir}/issue.455/helmfile.yaml" |   info "Destroying ${dir}/issue.455/helmfile.yaml" | ||||||
| ${helmfile} -f ${dir}/issue.455/helmfile.yaml destroy |   ${helmfile} -f ${dir}/issue.455/helmfile.yaml destroy | ||||||
| code=$? |   code=$? | ||||||
| [ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile destroy: want 0, got ${code}" |   [ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile destroy: want 0, got ${code}" | ||||||
| 
 | 
 | ||||||
| info "Syncing ${dir}/issue.455/helmfile.yaml" |   info "Syncing ${dir}/issue.455/helmfile.yaml" | ||||||
| ${helmfile} -f ${dir}/issue.455/helmfile.yaml  sync --include-needs |   ${helmfile} -f ${dir}/issue.455/helmfile.yaml  sync --include-needs | ||||||
| code=$? |   code=$? | ||||||
| [ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile apply: want 0, got ${code}" |   [ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile apply: want 0, got ${code}" | ||||||
| 
 | 
 | ||||||
| ${kubectl} get storageclass managed-csi -o yaml | grep -q "provisioner: disk.csi.azure.com" || fail "storageclass managed-csi should be created when syncing helmfile.yaml" |   ${kubectl} get storageclass managed-csi -o yaml | grep -q "provisioner: disk.csi.azure.com" || fail "storageclass managed-csi should be created when syncing helmfile.yaml" | ||||||
| 
 | 
 | ||||||
| info "Destroying ${dir}/issue.455/helmfile.yaml" |   info "Destroying ${dir}/issue.455/helmfile.yaml" | ||||||
| ${helmfile} -f ${dir}/issue.455/helmfile.yaml destroy |   ${helmfile} -f ${dir}/issue.455/helmfile.yaml destroy | ||||||
| code=$? |   code=$? | ||||||
| [ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile destroy: want 0, got ${code}" |   [ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile destroy: want 0, got ${code}" | ||||||
| 
 | 
 | ||||||
| test_pass "chart prepare when helmfile template with needs" |   test_pass "chart prepare when helmfile template with needs" | ||||||
|  | fi | ||||||
|  | @ -0,0 +1,65 @@ | ||||||
|  | test_start "happypath - simple rollout of httpbin chart" | ||||||
|  | 
 | ||||||
|  | info "Diffing ${dir}/happypath.yaml" | ||||||
|  | bash -c "${helmfile} -f ${dir}/happypath.yaml diff --detailed-exitcode; code="'$?'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile diff" | ||||||
|  | 
 | ||||||
|  | info "Diffing ${dir}/happypath.yaml without color" | ||||||
|  | bash -c "${helmfile} -f ${dir}/happypath.yaml --no-color diff --detailed-exitcode; code="'$?'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile diff" | ||||||
|  | 
 | ||||||
|  | info "Diffing ${dir}/happypath.yaml with limited context" | ||||||
|  | bash -c "${helmfile} -f ${dir}/happypath.yaml diff --context 3 --detailed-exitcode; code="'$?'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile diff" | ||||||
|  | 
 | ||||||
|  | info "Diffing ${dir}/happypath.yaml with altered output" | ||||||
|  | bash -c "${helmfile} -f ${dir}/happypath.yaml diff --output simple --detailed-exitcode; code="'$?'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile diff" | ||||||
|  | 
 | ||||||
|  | info "Templating ${dir}/happypath.yaml" | ||||||
|  | rm -rf ${dir}/tmp | ||||||
|  | ${helmfile} -f ${dir}/happypath.yaml --debug template --output-dir tmp | ||||||
|  | code=$? | ||||||
|  | [ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile template: ${code}" | ||||||
|  | for output in $(ls -d ${dir}/tmp/*); do | ||||||
|  |     # e.g. test/integration/tmp/happypath-877c0dd4-helmx/helmx | ||||||
|  |     for release_dir in $(ls -d ${output}/*); do | ||||||
|  |         release_name=$(basename ${release_dir}) | ||||||
|  |         golden_dir=${dir}/templates-golden/v${helm_major_version}/${release_name} | ||||||
|  |         info "Comparing template output ${release_dir}/templates with ${golden_dir}" | ||||||
|  |         ./diff-yamls ${golden_dir} ${release_dir}/templates || fail "unexpected diff in template result for ${release_name}" | ||||||
|  |     done | ||||||
|  | done | ||||||
|  | 
 | ||||||
|  | info "Applying ${dir}/happypath.yaml" | ||||||
|  | bash -c "${helmfile} -f ${dir}/happypath.yaml apply --detailed-exitcode; code="'$?'"; echo Code: "'$code'"; [ "'${code}'" -eq 2 ]" || fail "unexpected exit code returned by helmfile apply" | ||||||
|  | 
 | ||||||
|  | info "Syncing ${dir}/happypath.yaml" | ||||||
|  | ${helmfile} -f ${dir}/happypath.yaml sync | ||||||
|  | wait_deploy_ready httpbin-httpbin | ||||||
|  | retry 5 "curl --fail $(minikube service --url --namespace=${test_ns} httpbin-httpbin)/status/200" | ||||||
|  | [ ${retry_result} -eq 0 ] || fail "httpbin failed to return 200 OK" | ||||||
|  | 
 | ||||||
|  | info "Applying ${dir}/happypath.yaml" | ||||||
|  | ${helmfile} -f ${dir}/happypath.yaml apply --detailed-exitcode | ||||||
|  | code=$? | ||||||
|  | [ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile apply: want 0, got ${code}" | ||||||
|  | 
 | ||||||
|  | info "Locking dependencies" | ||||||
|  | ${helmfile} -f ${dir}/happypath.yaml deps | ||||||
|  | code=$? | ||||||
|  | [ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile deps: ${code}" | ||||||
|  | 
 | ||||||
|  | info "Applying ${dir}/happypath.yaml with locked dependencies" | ||||||
|  | ${helmfile} -f ${dir}/happypath.yaml apply | ||||||
|  | code=$? | ||||||
|  | [ ${code} -eq 0 ] || fail "unexpected exit code returned by helmfile apply: ${code}" | ||||||
|  | ${helm} list --namespace=${test_ns} || fail "unable to list releases" | ||||||
|  | 
 | ||||||
|  | info "Deleting release" | ||||||
|  | ${helmfile} -f ${dir}/happypath.yaml delete | ||||||
|  | ${helm} status --namespace=${test_ns} httpbin &> /dev/null && fail "release should not exist anymore after a delete" | ||||||
|  | 
 | ||||||
|  | info "Ensuring \"helmfile delete\" doesn't fail when no releases installed" | ||||||
|  | ${helmfile} -f ${dir}/happypath.yaml delete || fail "\"helmfile delete\" shouldn't fail when there are no installed releases" | ||||||
|  | 
 | ||||||
|  | info "Ensuring \"helmfile template\" output does contain only YAML docs" | ||||||
|  | (${helmfile} -f ${dir}/happypath.yaml template | kubectl apply -f -) || fail "\"helmfile template | kubectl apply -f -\" shouldn't fail" | ||||||
|  | 
 | ||||||
|  | test_pass "happypath" | ||||||
|  | @ -0,0 +1,18 @@ | ||||||
|  | 
 | ||||||
|  | test_start "regression tests" | ||||||
|  | 
 | ||||||
|  | if [[ helm_major_version -eq 3 ]]; then | ||||||
|  |   info "https://github.com/roboll/helmfile/issues/1857" | ||||||
|  |   (${helmfile} -f ${dir}/issue.1857.yaml --state-values-set grafanaEnabled=true template | grep grafana 1>/dev/null) || fail "\"helmfile template\" shouldn't include grafana" | ||||||
|  |   ! (${helmfile} -f ${dir}/issue.1857.yaml --state-values-set grafanaEnabled=false template | grep grafana) || fail "\"helmfile template\" shouldn't include grafana" | ||||||
|  | 
 | ||||||
|  |   info "https://github.com/roboll/helmfile/issues/1867" | ||||||
|  |   (${helmfile} -f ${dir}/issue.1867.yaml template 1>/dev/null) || fail "\"helmfile template\" shouldn't fail" | ||||||
|  | 
 | ||||||
|  |   info "https://github.com/roboll/helmfile/issues/2118" | ||||||
|  |   (${helmfile} -f ${dir}/issue.2118.yaml template 1>/dev/null) || fail "\"helmfile template\" shouldn't fail" | ||||||
|  | else | ||||||
|  |   info "There are no regression tests for helm 2 because all the target charts have dropped helm 2 support." | ||||||
|  | fi | ||||||
|  | 
 | ||||||
|  | test_pass "regression tests" | ||||||
|  | @ -0,0 +1,60 @@ | ||||||
|  | if [[ helm_major_version -eq 3 ]]; then | ||||||
|  |   export VAULT_ADDR=http://127.0.0.1:8200 | ||||||
|  |   export VAULT_TOKEN=toor | ||||||
|  |   sops="sops --hc-vault-transit $VAULT_ADDR/v1/sops/keys/key" | ||||||
|  |   mkdir -p ${dir}/tmp | ||||||
|  | 
 | ||||||
|  |   info "Encrypt secrets" | ||||||
|  |   ${sops} -e ${dir}/env-1.secrets.yaml > ${dir}/tmp/env-1.secrets.sops.yaml || fail "${sops} failed at ${dir}/env-1.secrets.yaml" | ||||||
|  |   ${sops} -e ${dir}/env-2.secrets.yaml > ${dir}/tmp/env-2.secrets.sops.yaml || fail "${sops} failed at ${dir}/env-2.secrets.yaml" | ||||||
|  | 
 | ||||||
|  |   test_start "secretssops.1 - should fail without secrets plugin" | ||||||
|  | 
 | ||||||
|  |   info "Ensure helm-secrets is not installed" | ||||||
|  |   ${helm} plugin rm secrets || true | ||||||
|  | 
 | ||||||
|  |   info "Ensure helmfile fails when no helm-secrets is installed" | ||||||
|  |   unset code | ||||||
|  |   ${helmfile} -f ${dir}/secretssops.yaml -e direct build || code="$?"; code="${code:-0}" | ||||||
|  |   echo Code: "${code}" | ||||||
|  |   [ "${code}" -ne 0 ] || fail "\"helmfile build\" should fail without secrets plugin" | ||||||
|  | 
 | ||||||
|  |   test_pass "secretssops.1" | ||||||
|  | 
 | ||||||
|  |   test_start "secretssops.2 - should succeed with secrets plugin" | ||||||
|  | 
 | ||||||
|  |   info "Ensure helm-secrets is installed" | ||||||
|  |   ${helm} plugin install https://github.com/jkroepke/helm-secrets --version v${HELM_SECRETS_VERSION} | ||||||
|  | 
 | ||||||
|  |   info "Ensure helmfile succeed when helm-secrets is installed" | ||||||
|  |   ${helmfile} -f ${dir}/secretssops.yaml -e direct build || fail "\"helmfile build\" shouldn't fail" | ||||||
|  | 
 | ||||||
|  |   test_pass "secretssops.2" | ||||||
|  | 
 | ||||||
|  |   test_start "secretssops.3 - should order secrets correctly" | ||||||
|  | 
 | ||||||
|  |   secretssops_tmp=$(mktemp -d) | ||||||
|  |   direct=${secretssops_tmp}/direct.build.yaml | ||||||
|  |   reverse=${secretssops_tmp}/reverse.build.yaml | ||||||
|  |   secrets_golden_dir=${dir}/secrets-golden | ||||||
|  | 
 | ||||||
|  |   info "Building secrets output" | ||||||
|  | 
 | ||||||
|  |   info "Comparing build/direct output ${direct} with ${secrets_golden_dir}" | ||||||
|  |   for i in $(seq 10); do | ||||||
|  |       info "Comparing build/direct #$i" | ||||||
|  |       ${helmfile} -f ${dir}/secretssops.yaml -e direct template --skip-deps > ${direct} || fail "\"helmfile template\" shouldn't fail" | ||||||
|  |       ./yamldiff ${secrets_golden_dir}/direct.build.yaml ${direct} || fail "\"helmfile template\" should be consistent" | ||||||
|  |       echo code=$? | ||||||
|  |   done | ||||||
|  | 
 | ||||||
|  |   info "Comparing build/reverse output ${direct} with ${secrets_golden_dir}" | ||||||
|  |   for i in $(seq 10); do | ||||||
|  |       info "Comparing build/reverse #$i" | ||||||
|  |       ${helmfile} -f ${dir}/secretssops.yaml -e reverse template --skip-deps > ${reverse} || fail "\"helmfile template\" shouldn't fail" | ||||||
|  |       ./yamldiff ${secrets_golden_dir}/reverse.build.yaml ${reverse} || fail "\"helmfile template\" should be consistent" | ||||||
|  |       echo code=$? | ||||||
|  |   done | ||||||
|  | 
 | ||||||
|  |   test_pass "secretssops.3" | ||||||
|  | fi | ||||||
|  | @ -0,0 +1,15 @@ | ||||||
|  | if [[ helm_major_version -eq 3 ]]; then | ||||||
|  |   yaml_overwrite_tmp=$(mktemp -d) | ||||||
|  |   yaml_feature_golden_dir=${dir}/yaml-features-golden | ||||||
|  |   yaml_overwrite_reverse=${yaml_overwrite_tmp}/yaml.override.build.yaml | ||||||
|  | 
 | ||||||
|  |   test_start "yaml overwrite feature" | ||||||
|  |   info "Comparing yaml overwrite feature output ${yaml_overwrite_reverse} with ${yaml_feature_golden_dir}/overwritten.yaml" | ||||||
|  |   for i in $(seq 10); do | ||||||
|  |       info "Comparing build/yaml-overwrite #$i" | ||||||
|  |       ${helmfile} -f ${dir}/issue.657.yaml template --skip-deps > ${yaml_overwrite_reverse} || fail "\"helmfile template\" shouldn't fail" | ||||||
|  |       ./yamldiff ${yaml_feature_golden_dir}/overwritten.yaml ${yaml_overwrite_reverse} || fail "\"helmfile template\" should be consistent" | ||||||
|  |       echo code=$? | ||||||
|  |   done | ||||||
|  |   test_pass "yaml overwrite feature" | ||||||
|  | fi | ||||||
		Loading…
	
		Reference in New Issue