From a1e94bfbcd11584ab88641fbbe2b58704f576f9d Mon Sep 17 00:00:00 2001 From: Ben Napolitan Date: Tue, 21 Jul 2020 17:08:24 -0400 Subject: [PATCH] Cover bottlerocket cluster test. (#1096) --- .circleci/config.yml | 2 +- scripts/lib/aws.sh | 5 +++++ scripts/run-integration-tests.sh | 35 ++++++++++++++++++++++++-------- testdata/bottlerocket.yaml | 23 +++++++++++++++++++++ 4 files changed, 55 insertions(+), 10 deletions(-) create mode 100644 testdata/bottlerocket.yaml diff --git a/.circleci/config.yml b/.circleci/config.yml index 313f810f6b..da8bb249ea 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -73,7 +73,7 @@ jobs: - run: name: Run the integration tests command: ./scripts/run-integration-tests.sh - no_output_timeout: 15m + no_output_timeout: 20m - save_cache: key: dependency-packages-store-{{ checksum "test/integration/go.mod" }} paths: diff --git a/scripts/lib/aws.sh b/scripts/lib/aws.sh index cb74a10925..29ce6066d3 100644 --- a/scripts/lib/aws.sh +++ b/scripts/lib/aws.sh @@ -26,3 +26,8 @@ ensure_aws_k8s_tester() { chmod +x $TESTER_PATH fi } + +ensure_eksctl() { + curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp + sudo mv -v /tmp/eksctl /usr/local/bin +} diff --git a/scripts/run-integration-tests.sh b/scripts/run-integration-tests.sh index 24254e2d6d..6ffc15cdba 100755 --- a/scripts/run-integration-tests.sh +++ b/scripts/run-integration-tests.sh @@ -21,6 +21,7 @@ ARCH=$(go env GOARCH) : "${BUILD:=true}" : "${RUN_CONFORMANCE:=false}" : "${RUN_KOPS_TEST:=false}" +: "${RUN_BOTTLEROCKET_TEST:=false}" __cluster_created=0 __cluster_deprovisioned=0 @@ -29,13 +30,15 @@ on_error() { # Make sure we destroy any cluster that was created if we hit run into an # error when attempting to run tests against the cluster if [[ $__cluster_created -eq 1 && $__cluster_deprovisioned -eq 0 && "$DEPROVISION" == true ]]; then + echo "Cluster was provisioned already. Deprovisioning it..." + __cluster_deprovisioned=1 if [[ $RUN_KOPS_TEST == true ]]; then - __cluster_deprovisioned=1 echo "Cluster was provisioned already. Deprovisioning it..." down-kops-cluster + elif [[ $RUN_BOTTLEROCKET_TEST == true ]]; then + eksctl delete cluster bottlerocket else # prevent double-deprovisioning with ctrl-c during deprovisioning... - __cluster_deprovisioned=1 echo "Cluster was provisioned already. Deprovisioning it..." down-test-cluster fi @@ -151,10 +154,18 @@ mkdir -p "$TEST_CLUSTER_DIR" mkdir -p "$TEST_CONFIG_DIR" START=$SECONDS -if [[ "$PROVISION" == true && "$RUN_KOPS_TEST" == true ]]; then - up-kops-cluster -elif [[ "$PROVISION" == true ]]; then - up-test-cluster +if [[ "$PROVISION" == true ]]; then + START=$SECONDS + if [[ "$RUN_BOTTLEROCKET_TEST" == true ]]; then + ensure_eksctl + eksctl create cluster --config-file ./testdata/bottlerocket.yaml + elif [[ "$RUN_KOPS_TEST" == true ]]; then + up-kops-cluster + else + up-test-cluster + fi + UP_CLUSTER_DURATION=$((SECONDS - START)) + echo "TIMELINE: Upping test cluster took $UP_CLUSTER_DURATION seconds." fi __cluster_created=1 @@ -170,11 +181,15 @@ sed -i'.bak' "s,:$MANIFEST_IMAGE_VERSION,:$TEST_IMAGE_VERSION," "$TEST_CONFIG_PA sed -i'.bak' "s,602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon-k8s-cni-init,$INIT_IMAGE_NAME," "$TEST_CONFIG_PATH" sed -i'.bak' "s,:$MANIFEST_IMAGE_VERSION,:$TEST_IMAGE_VERSION," "$TEST_CONFIG_PATH" -if [[ $RUN_KOPS_TEST != true ]]; then - export KUBECONFIG=$KUBECONFIG_PATH +if [[ $RUN_KOPS_TEST == true || $RUN_BOTTLEROCKET_TEST == true ]]; then + KUBECTL_PATH=kubectl + export KUBECONFIG=~/.kube/config else + export KUBECONFIG=$KUBECONFIG_PATH +fi + +if [[ $RUN_KOPS_TEST == true ]]; then run_kops_conformance - KUBECTL_PATH=kubectl fi ADDONS_CNI_IMAGE=$($KUBECTL_PATH describe daemonset aws-node -n kube-system | grep Image | cut -d ":" -f 2-3 | tr -d '[:space:]') @@ -239,6 +254,8 @@ if [[ "$DEPROVISION" == true ]]; then if [[ "$RUN_KOPS_TEST" == true ]]; then down-kops-cluster + elif [[ "$RUN_BOTTLEROCKET_TEST" == true ]]; then + eksctl delete cluster bottlerocket else down-test-cluster fi diff --git a/testdata/bottlerocket.yaml b/testdata/bottlerocket.yaml new file mode 100644 index 0000000000..ad7c08b2ff --- /dev/null +++ b/testdata/bottlerocket.yaml @@ -0,0 +1,23 @@ +--- +apiVersion: eksctl.io/v1alpha5 +kind: ClusterConfig + +metadata: + name: bottlerocket + region: us-west-2 + version: '1.15' + +nodeGroups: + - name: ng-bottlerocket + instanceType: m5.large + desiredCapacity: 4 + amiFamily: Bottlerocket + iam: + attachPolicyARNs: + - arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy + - arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy + - arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly + - arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore + bottlerocket: + settings: + motd: "Hello from eksctl!"