Remove mentions of uninstall tests and other repos from prepare-for-integration-tests.sh

This commit is contained in:
Ryan Richard 2020-09-10 17:36:22 -07:00
parent e6cb2f8220
commit 4fe609a043

View File

@ -2,16 +2,13 @@
# This script can be used to prepare a kind cluster and deploy the app. # This script can be used to prepare a kind cluster and deploy the app.
# You can call this script again to redeploy the app. # You can call this script again to redeploy the app.
# It will also output instructions on how to run the integration or uninstall tests. # It will also output instructions on how to run the integration.
# TODO: get rid of references to ci repo
# TODO: fix uninstall test setup
# TODO: add flag to let user provide registry/tag for their image
# \- (this can be used by kind integration tests from kind-load-and-docker-run-any-script.sh)
# TODO: add flag to setup current-context for integration tests
set -euo pipefail set -euo pipefail
#
# Helper functions
#
function log_note() { function log_note() {
GREEN='\033[0;32m' GREEN='\033[0;32m'
NC='\033[0m' NC='\033[0m'
@ -42,9 +39,11 @@ function log_error() {
fi fi
} }
#
# Handle argument parsing and help message
#
help=no help=no
skip_build=no skip_build=no
prepare_for_uninstall_test=no
PARAMS="" PARAMS=""
while (("$#")); do while (("$#")); do
@ -57,10 +56,6 @@ while (("$#")); do
skip_build=yes skip_build=yes
shift shift
;; ;;
-u | --prepare-uninstall)
prepare_for_uninstall_test=yes
shift
;;
-*) -*)
log_error "Unsupported flag $1" >&2 log_error "Unsupported flag $1" >&2
exit 1 exit 1
@ -76,19 +71,21 @@ eval set -- "$PARAMS"
if [[ "$help" == "yes" ]]; then if [[ "$help" == "yes" ]]; then
me="$(basename "${BASH_SOURCE[0]}")" me="$(basename "${BASH_SOURCE[0]}")"
echo "Usage:" echo "Usage:"
echo " $me [flags] [path/to/pinniped] [path/to/pinniped-ci]" echo " $me [flags] [path/to/pinniped]"
echo echo
echo " path/to/pinniped default: \$PWD ($PWD)" echo " path/to/pinniped default: \$PWD ($PWD)"
echo echo
echo "Flags:" echo "Flags:"
echo " -h, --help: print this usage" echo " -h, --help: print this usage"
echo " -s, --skip-build: reuse the most recently built image of the app instead of building" echo " -s, --skip-build: reuse the most recently built image of the app instead of building"
echo " -u, --prepare-uninstall: delete the kind cluster and prepare to run the install+uninstall test"
exit 1 exit 1
fi fi
pinniped_path="${1-$PWD}" pinniped_path="${1-$PWD}"
#
# Check for dependencies
#
if ! command -v kind >/dev/null; then if ! command -v kind >/dev/null; then
log_error "Please install kind. e.g. 'brew install kind' for MacOS" log_error "Please install kind. e.g. 'brew install kind' for MacOS"
exit 1 exit 1
@ -116,11 +113,9 @@ if [[ ! -f Dockerfile || ! -d deploy ]]; then
exit 1 exit 1
fi fi
if [[ "$prepare_for_uninstall_test" == "yes" ]]; then #
log_note "Deleting running kind clusters to prepare a clean slate for the install+uninstall test..." # Setup kind and build the app
kind delete cluster #
fi
log_note "Checking for running kind clusters..." log_note "Checking for running kind clusters..."
if ! kind get clusters | grep -q -e '^kind$'; then if ! kind get clusters | grep -q -e '^kind$'; then
log_note "Creating a kind cluster..." log_note "Creating a kind cluster..."
@ -163,24 +158,6 @@ fi
log_note "Loading the app's container image into the kind cluster..." log_note "Loading the app's container image into the kind cluster..."
kind load docker-image "$registry_repo_tag" kind load docker-image "$registry_repo_tag"
if [[ "$prepare_for_uninstall_test" == "yes" ]]; then
cat <<EOF >/tmp/uninstall-test-env
# The following env vars should be set before running $pinniped_ci_path/pipelines/shared-tasks/run-uninstall-test/run-uninstall-test.sh
export IMAGE_REPO="$registry_repo"
export IMAGE_TAG="$tag"
export PINNIPED_DISCOVERY_URL="$discovery_url"
EOF
log_note "Done!"
log_note
log_note "Ready to run the uninstall test."
log_note " cd $pinniped_path"
log_note ' source /tmp/uninstall-test-env'
log_note " $pinniped_ci_path/pipelines/shared-tasks/run-uninstall-test/run-uninstall-test.sh"
log_note
log_note "When you're finished, use 'kind delete cluster' to tear down the cluster."
else
manifest=/tmp/manifest.yaml manifest=/tmp/manifest.yaml
# #
@ -213,8 +190,8 @@ else
--from-literal=groups="$test_groups" \ --from-literal=groups="$test_groups" \
--from-literal=passwordHash="$(htpasswd -nbBC 10 x "$test_password" | sed -e "s/^x://")" \ --from-literal=passwordHash="$(htpasswd -nbBC 10 x "$test_password" | sed -e "s/^x://")" \
--dry-run=client \ --dry-run=client \
--output yaml \ --output yaml |
| kubectl apply -f - kubectl apply -f -
app_name="pinniped" app_name="pinniped"
namespace="integration" namespace="integration"
@ -242,6 +219,9 @@ else
popd >/dev/null popd >/dev/null
#
# Create the environment file
#
kind_capabilities_file="$pinniped_path/test/cluster_capabilities/kind.yaml" kind_capabilities_file="$pinniped_path/test/cluster_capabilities/kind.yaml"
pinniped_cluster_capability_file_content=$(cat "$kind_capabilities_file") pinniped_cluster_capability_file_content=$(cat "$kind_capabilities_file")
@ -260,6 +240,9 @@ PINNIPED_CLUSTER_CAPABILITY_YAML_EOF
export PINNIPED_CLUSTER_CAPABILITY_YAML export PINNIPED_CLUSTER_CAPABILITY_YAML
EOF EOF
#
# Print instructions for next steps
#
goland_vars=$(grep -v '^#' /tmp/integration-test-env | grep -E '^export .+=' | sed 's/export //g' | tr '\n' ';') goland_vars=$(grep -v '^#' /tmp/integration-test-env | grep -E '^export .+=' | sed 's/export //g' | tr '\n' ';')
log_note "Done!" log_note "Done!"
@ -278,4 +261,3 @@ EOF
log_note "When you're finished, use 'kind delete cluster' to tear down the cluster." log_note "When you're finished, use 'kind delete cluster' to tear down the cluster."
log_note log_note
log_note "To delete the deployments, run 'kapp delete -a local-user-authenticator -y && kapp delete -a pinniped -y'." log_note "To delete the deployments, run 'kapp delete -a local-user-authenticator -y && kapp delete -a pinniped -y'."
fi