Skip to content

Commit

Permalink
add cni release test script
Browse files Browse the repository at this point in the history
  • Loading branch information
sushrk committed Apr 15, 2022
1 parent fd8bcf0 commit dad4a91
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions scripts/run-cni-release-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash

# script to run integration and calico tests tests(no cluster creation & deletion/installing addons)
# use case: run script after CNI images are updated to the image to be verified (see update-cni-images.sh)

# CLUSTER_NAME: name of the cluster to run the test
# VPC_ID: cluster VPC ID
# REGION: default us-west-2
# KUBE_CONFIG_PATH: path to the kubeconfig file, default ~/.kube/config
# NG_LABEL_KEY: nodegroup label key, default "kubernetes.io/os"
# NG_LABEL_VAL: nodegroup label val, default "linux"

# CALICO_VERSION: calico version, default 3.22.0

set -e

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
TEST_DIR="$SCRIPT_DIR/../test"
INTEGRATION_TEST_DIR="$TEST_DIR/integration-new"
CALICO_TEST_DIR="$TEST_DIR/e2e/calico"

source "$SCRIPT_DIR"/lib/cluster.sh
source "$SCRIPT_DIR"/lib/integration.sh

function run_integration_test() {
START=$SECONDS
: "${NG_LABEL_KEY:=kubernetes.io/os}"
: "${NG_LABEL_VAL:=linux}"
TEST_RESULT=success
echo "Running cni integration tests"
CGO_ENABLED=0 ginkgo -v $INTEGRATION_TEST_DIR/cni --timeout 60m --fail-on-pending -- --cluster-kubeconfig="$KUBE_CONFIG_PATH" --cluster-name="$CLUSTER_NAME" --aws-region="$REGION" --aws-vpc-id="$VPC_ID" --ng-name-label-key="$NG_LABEL_KEY" --ng-name-label-val="$NG_LABEL_VAL" || TEST_RESULT=fail
echo "cni test took $((SECONDS - START)) seconds."
echo "Running ipamd integration tests"
CGO_ENABLED=0 ginkgo -v $INTEGRATION_TEST_DIR/ipamd --timeout 120m --fail-on-pending -- --cluster-kubeconfig="$KUBE_CONFIG_PATH" --cluster-name="$CLUSTER_NAME" --aws-region="$REGION" --aws-vpc-id="$VPC_ID" --ng-name-label-key="$NG_LABEL_KEY" --ng-name-label-val="$NG_LABEL_VAL" || TEST_RESULT=fail
echo "ipamd test took $((SECONDS - START)) seconds."
if [[ "$TEST_RESULT" == fail ]]; then
echo "Integration test failed."
exit 1
fi
echo "Integration tests completed successfully!"
}

function run_calico_tests(){
: "${CALICO_VERSION:=3.22.0}"
echo "Running calico tests, version $CALICO_VERSION"
START=$SECONDS
TEST_RESULT=success
# get version from run-integration-tests.sh
ginkgo -v $CALICO_TEST_DIR -- --cluster-kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID --calico-version=$CALICO_VERSION || TEST_RESULT=fail
if [[ "$TEST_RESULT" == fail ]]; then
echo "Calico tests failed."
exit 1
fi
echo "Calico tests completed successfully!"
}

if [[ -n "${ENDPOINT}" ]]; then
ENDPOINT_FLAG="--endpoint $ENDPOINT"
fi

echo "Running release tests on cluster: $CLUSTER_NAME in region: $REGION"
load_cluster_details
START=$SECONDS
cd $TEST_DIR
run_integration_test
run_calico_tests
echo "Completed running all tests in $((SECONDS - START)) seconds."

0 comments on commit dad4a91

Please sign in to comment.