Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use raw yq output, split e2e runner from deployment #235

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 1 addition & 43 deletions scripts/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,46 +54,4 @@ done
echo "--- Waiting for deployment"
sleep 120

# Run tests
echo "--- Running e2e tests"
failed="false"
for e2e_config in $(find ./e2e-fixtures -name 'e2e-expected.yaml')
do
example_dir=$(dirname $e2e_config)
for config_file in $(cat $e2e_config | yq -r '(. | keys)[]')
do
if [ -f "$example_dir/$config_file" ]
then
example_config="$example_dir/$config_file"
edge_fqdn=$(yq '.[0].value' $example_config)

echo "--- Testing '$example_config' with Edge '$edge_fqdn'"
for test_path in $(yq -r "(.\"$config_file\".paths | keys)[]" $e2e_config)
do
expected=$(yq -r ".\"$config_file\".paths[\"$test_path\"]" $e2e_config)
test_uri="https://${edge_fqdn}${test_path}"
result=$(curl -Is $test_uri | xargs -0)
status=$(printf "${result}" | strings | awk 'NR==1{$1=$1;print}')

printf "\tTesting '${test_uri}' expecting '${expected}': "
if [[ "$status" == "$expected" ]]
then
echo "Passed."
else
echo "FAILED!"
echo -en " Expected:\"${expected}\" received:\"${status}\" with:\n\n"
echo "${result}" | sed 's/^/\t/'
failed="true"
fi
done
fi
done
done

echo "--- Results"
if [[ "$failed" != "false" ]]
then
echo "!!! Tests Failed!"
exit 1
fi
echo "Tests Passed."
exec scripts/postflight.sh
50 changes: 50 additions & 0 deletions scripts/postflight.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash

set -eu -o pipefail

namespace='ngrok-ingress-controller'
kubectl config set-context --current --namespace=$namespace

# Run tests
echo "--- Running e2e tests"
failed="false"
for e2e_config in $(find ./e2e-fixtures -name 'e2e-expected.yaml')
do
example_dir=$(dirname $e2e_config)
for config_file in $(cat $e2e_config | yq -r '(. | keys)[]')
do
if [ -f "$example_dir/$config_file" ]
then
example_config="$example_dir/$config_file"
edge_fqdn=$(yq -r '.[0].value' $example_config)

echo "--- Testing '$example_config' with Edge '$edge_fqdn'"
for test_path in $(yq -r "(.\"$config_file\".paths | keys)[]" $e2e_config)
do
expected=$(yq -r ".\"$config_file\".paths[\"$test_path\"]" $e2e_config)
test_uri="https://${edge_fqdn}${test_path}"
result=$(curl -Is $test_uri | xargs -0)
status=$(printf "${result}" | strings | awk 'NR==1{$1=$1;print}')

printf "\tTesting '${test_uri}' expecting '${expected}': "
if [[ "$status" == "$expected" ]]
then
echo "Passed."
else
echo "FAILED!"
echo -en " Expected:\"${expected}\" received:\"${status}\" with:\n\n"
echo "${result}" | sed 's/^/\t/'
failed="true"
fi
done
fi
done
done

echo "--- Results"
if [[ "$failed" != "false" ]]
then
echo "!!! Tests Failed!"
exit 1
fi
echo "Tests Passed."