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

Update CNI canary integration test and cleanup for ginkgo v2 #2088

Merged
merged 6 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions scripts/lib/add-on.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# Helper script for performing operations on vpc-cni addons

VPC_CNI_ADDON_NAME="vpc-cni"

function load_addon_details() {
echo "loading $VPC_CNI_ADDON_NAME addon details"
DESCRIBE_ADDON_VERSIONS=$(aws eks describe-addon-versions $ENDPOINT_FLAG --addon-name $VPC_CNI_ADDON_NAME --kubernetes-version "$K8S_VERSION")
Expand Down
3 changes: 1 addition & 2 deletions scripts/lib/canary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Helper script used for running canary test for CNI IPv4 and IPv6

SECONDS=0
VPC_CNI_ADDON_NAME="vpc-cni"

echo "Running Canary tests for amazon-vpc-cni-k8s with the following variables
KUBE_CONFIG_PATH: $KUBE_CONFIG_PATH
Expand All @@ -22,7 +21,7 @@ else
echo "skipping making ginkgo test binaries"
fi

# Request timesout in China Regions with default proxy
# Request times out in China Regions with default proxy
if [[ $REGION == "cn-north-1" || $REGION == "cn-northwest-1" ]]; then
go env -w GOPROXY=https://goproxy.cn,direct
go env -w GOSUMDB=sum.golang.google.cn
Expand Down
31 changes: 11 additions & 20 deletions scripts/run-canary-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,24 @@ source "$SCRIPT_DIR"/lib/canary.sh
function run_ginkgo_test() {
local focus=$1
echo "Running ginkgo tests with focus: $focus"
(CGO_ENABLED=0 ginkgo $EXTRA_GINKGO_FLAGS --focus="$focus" -v --timeout 20m --failOnPending $GINKGO_TEST_BUILD/cni.test -- --cluster-kubeconfig="$KUBE_CONFIG_PATH" --cluster-name="$CLUSTER_NAME" --aws-region="$REGION" --aws-vpc-id="$VPC_ID" --ng-name-label-key="kubernetes.io/os" --ng-name-label-val="linux")
(CGO_ENABLED=0 ginkgo $EXTRA_GINKGO_FLAGS --focus="$focus" -v --timeout 10m --failOnPending $GINKGO_TEST_BUILD/ipamd.test -- --cluster-kubeconfig="$KUBE_CONFIG_PATH" --cluster-name="$CLUSTER_NAME" --aws-region="$REGION" --aws-vpc-id="$VPC_ID" --ng-name-label-key="kubernetes.io/os" --ng-name-label-val="linux")
(CGO_ENABLED=0 ginkgo $EXTRA_GINKGO_FLAGS --no-color --focus="$focus" -v --timeout 30m --fail-on-pending $GINKGO_TEST_BUILD/cni.test -- --cluster-kubeconfig="$KUBE_CONFIG_PATH" --cluster-name="$CLUSTER_NAME" --aws-region="$REGION" --aws-vpc-id="$VPC_ID" --ng-name-label-key="kubernetes.io/os" --ng-name-label-val="linux")
(CGO_ENABLED=0 ginkgo $EXTRA_GINKGO_FLAGS --no-color --focus="$focus" -v --timeout 30m --fail-on-pending $GINKGO_TEST_BUILD/ipamd.test -- --cluster-kubeconfig="$KUBE_CONFIG_PATH" --cluster-name="$CLUSTER_NAME" --aws-region="$REGION" --aws-vpc-id="$VPC_ID" --ng-name-label-key="kubernetes.io/os" --ng-name-label-val="linux")
}

load_cluster_details
load_addon_details

# TODO: v1.7.5 restarts continiously if IMDS goes out of sync, the issue is mitigated
# from v.1.8.0 onwards, once the default addon is updated to v1.8.0+ we should uncomment
# the following code. See: https://github.com/aws/amazon-vpc-cni-k8s/issues/1340

# Run more comprehensive test on the default addon version. CANARY focused tests
# tests basic functionlity plus test that could detect issues with dependencies
# cover basic functionlity plus test that could detect issues with dependencies
# early on.
#echo "Running Canary tests on the default addon version"
#install_add_on "$DEFAULT_ADDON_VERSION"
#run_ginkgo_test "CANARY"

# Run smoke test on the latest addon version. Smoke tests contains a subset of test
# used in Canary tests.
#echo "Running Smoke tests on the latest addon version"
#install_add_on "$LATEST_ADDON_VERSION"
#run_ginkgo_test "SMOKE"

# TODO: Remove the following code once the v1.8.0+ is made the default addon version
echo "Running Canary tests on the latest addon version"
install_add_on "$LATEST_ADDON_VERSION"
echo "Running Canary tests on the default addon version"
install_add_on "$DEFAULT_ADDON_VERSION"
run_ginkgo_test "CANARY"

# Run smoke test on the latest addon version. Smoke tests consist of a subset of tests
# from Canary suite.
echo "Running Smoke tests on the latest addon version"
install_add_on "$LATEST_ADDON_VERSION"
run_ginkgo_test "SMOKE"
jdn5126 marked this conversation as resolved.
Show resolved Hide resolved

echo "all tests ran successfully in $(($SECONDS / 60)) minutes and $(($SECONDS % 60)) seconds"
15 changes: 7 additions & 8 deletions scripts/run-cni-release-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# 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"
# CNI_METRICS_HELPER: cni metrics helper image tag, default "602401143452.dkr.ecr.us-west-2.amazonaws.com/cni-metrics-helper:v1.7.10"
# CNI_METRICS_HELPER: cni metrics helper image tag, default "602401143452.dkr.ecr.us-west-2.amazonaws.com/cni-metrics-helper:v1.11.4"
# CALICO_VERSION: calico version, default 3.22.0

set -e
Expand All @@ -27,20 +27,19 @@ function run_integration_test() {
TEST_RESULT=success
echo "Running cni integration tests"
START=$SECONDS
# skip tests for changes not released yet and are applicable in future releases only, for now skipping 1.11.3
cd $INTEGRATION_TEST_DIR/cni && CGO_ENABLED=0 ginkgo --skip="1.11.3" -v -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
cd $INTEGRATION_TEST_DIR/cni && CGO_ENABLED=0 ginkgo $EXTRA_GINKGO_FLAGS -v -timeout 60m --no-color --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"
START=$SECONDS
cd $INTEGRATION_TEST_DIR/ipamd && CGO_ENABLED=0 ginkgo --skip="1.11.3" -v -timeout 90m --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
cd $INTEGRATION_TEST_DIR/ipamd && CGO_ENABLED=0 ginkgo $EXTRA_GINKGO_FLAGS -v -timeout 90m --no-color --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."

: "${CNI_METRICS_HELPER:=602401143452.dkr.ecr.us-west-2.amazonaws.com/cni-metrics-helper:v1.7.10}"
: "${CNI_METRICS_HELPER:=602401143452.dkr.ecr.us-west-2.amazonaws.com/cni-metrics-helper:v1.11.4}"
REPO_NAME=$(echo $CNI_METRICS_HELPER | cut -d ":" -f 1)
TAG=$(echo $CNI_METRICS_HELPER | cut -d ":" -f 2)
echo "Running cni-metrics-helper image($CNI_METRICS_HELPER) tests"
START=$SECONDS
cd $INTEGRATION_TEST_DIR/metrics-helper && CGO_ENABLED=0 ginkgo --skip="1.11.3" -v -timeout 15m --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" --cni-metrics-helper-image-repo=$REPO_NAME --cni-metrics-helper-image-tag=$TAG || TEST_RESULT=fail
cd $INTEGRATION_TEST_DIR/metrics-helper && CGO_ENABLED=0 ginkgo $EXTRA_GINKGO_FLAGS -v -timeout 15m --no-color --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" --cni-metrics-helper-image-repo=$REPO_NAME --cni-metrics-helper-image-tag=$TAG || TEST_RESULT=fail
echo "cni-metrics-helper test took $((SECONDS - START)) seconds."
if [[ "$TEST_RESULT" == fail ]]; then
echo "Integration test failed."
Expand All @@ -55,7 +54,7 @@ function run_calico_tests(){
echo "Running calico tests, version $CALICO_VERSION"
START=$SECONDS
TEST_RESULT=success
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
ginkgo -v --no-color $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
Expand All @@ -72,4 +71,4 @@ load_cluster_details
START=$SECONDS
run_integration_test
run_calico_tests
echo "Completed running all tests in $((SECONDS - START)) seconds."
echo "Completed running all tests in $((SECONDS - START)) seconds."
10 changes: 5 additions & 5 deletions scripts/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ START=$SECONDS

focus="CANARY"
echo "Running ginkgo tests with focus: $focus"
(cd "$INTEGRATION_TEST_DIR/cni" && CGO_ENABLED=0 ginkgo --focus="$focus" -v --timeout 20m --failOnPending -- --cluster-kubeconfig="$KUBECONFIG" --cluster-name="$CLUSTER_NAME" --aws-region="$AWS_DEFAULT_REGION" --aws-vpc-id="$VPC_ID" --ng-name-label-key="kubernetes.io/os" --ng-name-label-val="linux")
(cd "$INTEGRATION_TEST_DIR/ipamd" && CGO_ENABLED=0 ginkgo --focus="$focus" -v --timeout 10m --failOnPending -- --cluster-kubeconfig="$KUBECONFIG" --cluster-name="$CLUSTER_NAME" --aws-region="$AWS_DEFAULT_REGION" --aws-vpc-id="$VPC_ID" --ng-name-label-key="kubernetes.io/os" --ng-name-label-val="linux")
(cd "$INTEGRATION_TEST_DIR/cni" && CGO_ENABLED=0 ginkgo --focus="$focus" -v --timeout 20m --no-color --fail-on-pending -- --cluster-kubeconfig="$KUBECONFIG" --cluster-name="$CLUSTER_NAME" --aws-region="$AWS_DEFAULT_REGION" --aws-vpc-id="$VPC_ID" --ng-name-label-key="kubernetes.io/os" --ng-name-label-val="linux")
(cd "$INTEGRATION_TEST_DIR/ipamd" && CGO_ENABLED=0 ginkgo --focus="$focus" -v --timeout 10m --no-color --fail-on-pending -- --cluster-kubeconfig="$KUBECONFIG" --cluster-name="$CLUSTER_NAME" --aws-region="$AWS_DEFAULT_REGION" --aws-vpc-id="$VPC_ID" --ng-name-label-key="kubernetes.io/os" --ng-name-label-val="linux")
TEST_PASS=$?
DEFAULT_INTEGRATION_DURATION=$((SECONDS - START))
echo "TIMELINE: Default CNI integration tests took $DEFAULT_INTEGRATION_DURATION seconds."
Expand Down Expand Up @@ -262,8 +262,8 @@ START=$SECONDS

focus="CANARY"
echo "Running ginkgo tests with focus: $focus"
(cd "$INTEGRATION_TEST_DIR/cni" && CGO_ENABLED=0 ginkgo --focus="$focus" -v --timeout 60m --fail-on-pending -- --cluster-kubeconfig="$KUBECONFIG" --cluster-name="$CLUSTER_NAME" --aws-region="$AWS_DEFAULT_REGION" --aws-vpc-id="$VPC_ID" --ng-name-label-key="kubernetes.io/os" --ng-name-label-val="linux")
(cd "$INTEGRATION_TEST_DIR/ipamd" && CGO_ENABLED=0 ginkgo --focus="$focus" -v --timeout 60m --fail-on-pending -- --cluster-kubeconfig="$KUBECONFIG" --cluster-name="$CLUSTER_NAME" --aws-region="$AWS_DEFAULT_REGION" --aws-vpc-id="$VPC_ID" --ng-name-label-key="kubernetes.io/os" --ng-name-label-val="linux")
(cd "$INTEGRATION_TEST_DIR/cni" && CGO_ENABLED=0 ginkgo --focus="$focus" -v --timeout 60m --no-color --fail-on-pending -- --cluster-kubeconfig="$KUBECONFIG" --cluster-name="$CLUSTER_NAME" --aws-region="$AWS_DEFAULT_REGION" --aws-vpc-id="$VPC_ID" --ng-name-label-key="kubernetes.io/os" --ng-name-label-val="linux")
(cd "$INTEGRATION_TEST_DIR/ipamd" && CGO_ENABLED=0 ginkgo --focus="$focus" -v --timeout 60m --no-color --fail-on-pending -- --cluster-kubeconfig="$KUBECONFIG" --cluster-name="$CLUSTER_NAME" --aws-region="$AWS_DEFAULT_REGION" --aws-vpc-id="$VPC_ID" --ng-name-label-key="kubernetes.io/os" --ng-name-label-val="linux")
TEST_PASS=$?
CURRENT_IMAGE_INTEGRATION_DURATION=$((SECONDS - START))
echo "TIMELINE: Current image integration tests took $CURRENT_IMAGE_INTEGRATION_DURATION seconds."
Expand Down Expand Up @@ -302,7 +302,7 @@ if [[ $TEST_PASS -eq 0 && "$RUN_CONFORMANCE" == true ]]; then
wget -qO- https://dl.k8s.io/v$K8S_VERSION/kubernetes-test-linux-amd64.tar.gz | tar -zxvf - --strip-components=3 -C ${TEST_BASE_DIR} kubernetes/test/bin/e2e.test

echo "Running e2e tests: "
${TEST_BASE_DIR}/e2e.test --ginkgo.focus="\[Serial\].*Conformance" --kubeconfig=$KUBECONFIG --ginkgo.failFast --ginkgo.flakeAttempts 2 \
${TEST_BASE_DIR}/e2e.test --ginkgo.focus="\[Serial\].*Conformance" --kubeconfig=$KUBECONFIG --ginkgo.failFast --ginkgo.noColor --ginkgo.flakeAttempts 2 \
--ginkgo.skip="(should support remote command execution over websockets)|(should support retrieving logs from the container over websockets)|\[Slow\]"

CONFORMANCE_DURATION=$((SECONDS - START))
Expand Down
10 changes: 3 additions & 7 deletions scripts/run-ipv6-canary-test.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
#!/bin/bash

# The script runs amazon-vpc-cni Canary tests on the default
# addon version and then runs smoke test on the latest addon version.
# The script runs amazon-vpc-cni IPv6 canary tests

set -e

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
GINKGO_TEST_BUILD="$SCRIPT_DIR/../test/build"

source "$SCRIPT_DIR"/lib/add-on.sh
source "$SCRIPT_DIR"/lib/cluster.sh
source "$SCRIPT_DIR"/lib/canary.sh

function run_ginkgo_test() {
jdn5126 marked this conversation as resolved.
Show resolved Hide resolved
local focus=$1
echo "Running ginkgo tests with focus: $focus"
(CGO_ENABLED=0 ginkgo $EXTRA_GINKGO_FLAGS --focus="$focus" -v --timeout 15m --failOnPending $GINKGO_TEST_BUILD/ipv6.test -- --cluster-kubeconfig="$KUBE_CONFIG_PATH" --cluster-name="$CLUSTER_NAME" --aws-region="$REGION" --aws-vpc-id="$VPC_ID" --ng-name-label-key="kubernetes.io/os" --ng-name-label-val="linux")
(CGO_ENABLED=0 ginkgo $EXTRA_GINKGO_FLAGS --focus="$focus" -v --timeout 15m --no-color --fail-on-pending $GINKGO_TEST_BUILD/ipv6.test -- --cluster-kubeconfig="$KUBE_CONFIG_PATH" --cluster-name="$CLUSTER_NAME" --aws-region="$REGION" --aws-vpc-id="$VPC_ID" --ng-name-label-key="kubernetes.io/os" --ng-name-label-val="linux")
}

load_cluster_details
load_addon_details

echo "Running IPv6 Canary tests on the latest addon version"
echo "Running IPv6 Canary tests"

install_add_on "$LATEST_ADDON_VERSION"
run_ginkgo_test "CANARY"

echo "all tests ran successfully in $(($SECONDS / 60)) minutes and $(($SECONDS % 60)) seconds"
4 changes: 2 additions & 2 deletions test/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ cd test/e2e/custom-networking

Run Ginkgo test suite
```bash
ginkgo -v --failOnPending -- \
ginkgo -v --fail-on-pending -- \
--cluster-kubeconfig=$KUBECONFIG \
--cluster-name=$CLUSTER_NAME \
--aws-region=$AWS_REGION \
--aws-vpc-id=$VPC_ID \
--eks-endpoint=$EKS_ENDPOINT
```
```
4 changes: 2 additions & 2 deletions test/integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The package contains automated integration tests suites for `amazon-vpc-cni-k8s`
The integration test requires
- At least 2 nodes in a node group.
- Nodes in the nodegroup shouldn't have existing pods.
- Ginkgo installed on your environment. To install `go install github.com/onsi/ginkgo/ginkgo@latest`
- Ginkgo installed on your environment. To install `go install github.com/onsi/ginkgo/v2/ginkgo@latest`
- Supports instance types having at least 3 ENIs and 16+ Secondary IPv4 Addresses across all ENIs.

#### Testing
Expand All @@ -28,7 +28,7 @@ cd test/integration/cni
```
Run Ginkgo test suite
```bash
ginkgo -v --failOnPending -- \
ginkgo -v --fail-on-pending -- \
--cluster-kubeconfig=$KUBECONFIG \
--cluster-name=$CLUSTER_NAME \
--aws-region=$AWS_REGION \
Expand Down
2 changes: 1 addition & 1 deletion test/integration/ipamd/eni_ip_leak_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
var primaryNode v1.Node
var numOfNodes int

var _ = Describe("[CANARY] ENI/IP Leak Test", func() {
var _ = Describe("[CANARY][SMOKE] ENI/IP Leak Test", func() {
Context("ENI/IP Released on Pod Deletion", func() {

It("Verify that on Pod Deletion, ENI/IP State is restored", func() {
Expand Down
3 changes: 1 addition & 2 deletions test/integration/ipamd/ipamd_event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ import (
const EKSCNIPolicyARN = "arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy"
const AwsNodeLabelKey = "k8s-app"

// Changes tested in this case is not released yet, adding future release version label to identify
var _ = Describe("[1.11.3] test aws-node pod event", func() {
var _ = Describe("test aws-node pod event", func() {

// Verifies aws-node pod events works as expected
Context("when iam role is missing VPC_CNI policy", func() {
Expand Down