Skip to content

Commit

Permalink
Cover bottlerocket cluster test. (#1096)
Browse files Browse the repository at this point in the history
  • Loading branch information
bnapolitan authored Jul 21, 2020
1 parent 0da7491 commit a1e94bf
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions scripts/lib/aws.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
35 changes: 26 additions & 9 deletions scripts/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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:]')

Expand Down Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions testdata/bottlerocket.yaml
Original file line number Diff line number Diff line change
@@ -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!"

0 comments on commit a1e94bf

Please sign in to comment.