Skip to content

Commit 26e777f

Browse files
committed
updates
1 parent 5f293de commit 26e777f

File tree

3 files changed

+71
-5
lines changed

3 files changed

+71
-5
lines changed

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ export PATH := $(abspath $(TOOLS_BIN_DIR)):$(PATH)
7777
#
7878
# Ginkgo configuration.
7979
#
80+
GINKGO_FOCUS ?=
81+
GINKGO_SKIP ?=
8082
GINKGO_LABEL_FILTER ?=
8183
GINKGO_NODES ?= 1
8284
GINKGO_TIMEOUT ?= 2h
@@ -87,6 +89,11 @@ SKIP_RESOURCE_CLEANUP ?= false
8789
USE_EXISTING_CLUSTER ?= false
8890
GINKGO_NOCOLOR ?= false
8991

92+
# to set multiple ginkgo skip flags, if any
93+
ifneq ($(strip $(GINKGO_SKIP)),)
94+
_SKIP_ARGS := $(foreach arg,$(strip $(GINKGO_SKIP)),-skip="$(arg)")
95+
endif
96+
9097
# Helper function to get dependency version from go.mod
9198
get_go_version = $(shell go list -m $1 | awk '{print $$2}')
9299

@@ -972,8 +979,8 @@ test-test-extension-junit: $(SETUP_ENVTEST) $(GOTESTSUM) ## Run unit and integra
972979
.PHONY: test-e2e
973980
test-e2e: $(GINKGO) generate-e2e-templates ## Run the end-to-end tests
974981
$(GINKGO) -v --trace -poll-progress-after=$(GINKGO_POLL_PROGRESS_AFTER) \
975-
-poll-progress-interval=$(GINKGO_POLL_PROGRESS_INTERVAL) --tags=e2e --label-filter="$(GINKGO_LABEL_FILTER)" \
976-
--nodes=$(GINKGO_NODES) --timeout=$(GINKGO_TIMEOUT) --no-color=$(GINKGO_NOCOLOR) \
982+
-poll-progress-interval=$(GINKGO_POLL_PROGRESS_INTERVAL) --tags=e2e --focus="$(GINKGO_FOCUS)" --label-filter="$(GINKGO_LABEL_FILTER)" \
983+
$(_SKIP_ARGS) --nodes=$(GINKGO_NODES) --timeout=$(GINKGO_TIMEOUT) --no-color=$(GINKGO_NOCOLOR) \
977984
--output-dir="$(ARTIFACTS)" --junit-report="junit.e2e_suite.1.xml" $(GINKGO_ARGS) $(ROOT_DIR)/$(TEST_DIR)/e2e -- \
978985
-e2e.artifacts-folder="$(ARTIFACTS)" \
979986
-e2e.config="$(E2E_CONF_FILE)" \

scripts/ci-e2e-lib.sh

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ capi:buildDockerImages () {
3939
# depending on what is set in GINKGO_LABEL_FILTER.
4040
# Note: We do this to ensure that the kindest/node image gets built if it does
4141
# not already exist, e.g. for pre-releases, but only if necessary.
42-
k8s::prepareKindestImagesVariables() {
42+
k8s::prepareKindestImagesVariablesGingkoFilters() {
4343
# Always default KUBERNETES_VERSION_MANAGEMENT because we always create a management cluster out of it.
4444
if [[ -z "${KUBERNETES_VERSION_MANAGEMENT:-}" ]]; then
4545
KUBERNETES_VERSION_MANAGEMENT=$(grep KUBERNETES_VERSION_MANAGEMENT: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
@@ -65,7 +65,7 @@ k8s::prepareKindestImagesVariables() {
6565

6666
# Tests not focusing on anything and skipping [Conformance] run a clusterctl upgrade test
6767
# on the latest kubernetes version as management cluster.
68-
if [[ ${GINKGO_LABEL_FILTER:-} == "" ]] && [[ ${GINKGO_LABEL_FILTER} == *"!Conformance"* ]]; then
68+
if [[ ${GINKGO_LABEL_FILTER} =~ ^!Conformance$ ]]; then
6969
# Note: We do this because we want to specify KUBERNETES_VERSION_LATEST_CI *only* in the e2e config.
7070
if [[ -z "${KUBERNETES_VERSION_LATEST_CI:-}" ]]; then
7171
KUBERNETES_VERSION_LATEST_CI=$(grep KUBERNETES_VERSION_LATEST_CI: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
@@ -88,6 +88,60 @@ k8s::prepareKindestImagesVariables() {
8888
fi
8989
}
9090

91+
# k8s::prepareKindestImagesVariables defaults the environment variables KUBERNETES_VERSION_MANAGEMENT, KUBERNETES_VERSION,
92+
# KUBERNETES_VERSION_UPGRADE_TO, KUBERNETES_VERSION_UPGRADE_FROM and KUBERNETES_VERSION_LATEST_CI
93+
# depending on what is set in GINKGO_FOCUS.
94+
# Note: We do this to ensure that the kindest/node image gets built if it does
95+
# not already exist, e.g. for pre-releases, but only if necessary.
96+
k8s::prepareKindestImagesVariables() {
97+
# Always default KUBERNETES_VERSION_MANAGEMENT because we always create a management cluster out of it.
98+
if [[ -z "${KUBERNETES_VERSION_MANAGEMENT:-}" ]]; then
99+
KUBERNETES_VERSION_MANAGEMENT=$(grep KUBERNETES_VERSION_MANAGEMENT: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
100+
echo "Defaulting KUBERNETES_VERSION_MANAGEMENT to ${KUBERNETES_VERSION_MANAGEMENT} to trigger image build (because env var is not set)"
101+
fi
102+
103+
if [[ ${GINKGO_FOCUS:-} == *"K8s-Install-ci-latest"* ]]; then
104+
# If the test focuses on [K8s-Install-ci-latest], only default KUBERNETES_VERSION_LATEST_CI
105+
# to the value in the e2e config and only if it is not set.
106+
# Note: We do this because we want to specify KUBERNETES_VERSION_LATEST_CI *only* in the e2e config.
107+
if [[ -z "${KUBERNETES_VERSION_LATEST_CI:-}" ]]; then
108+
KUBERNETES_VERSION_LATEST_CI=$(grep KUBERNETES_VERSION_LATEST_CI: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
109+
echo "Defaulting KUBERNETES_VERSION_LATEST_CI to ${KUBERNETES_VERSION_LATEST_CI} to trigger image build (because env var is not set)"
110+
fi
111+
elif [[ ${GINKGO_FOCUS:-} != *"K8s-Upgrade"* ]]; then
112+
# In any other case which is not [K8s-Upgrade], default KUBERNETES_VERSION if it is not set to make sure
113+
# the corresponding kindest/node image exists.
114+
if [[ -z "${KUBERNETES_VERSION:-}" ]]; then
115+
KUBERNETES_VERSION=$(grep KUBERNETES_VERSION: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
116+
echo "Defaulting KUBERNETES_VERSION to ${KUBERNETES_VERSION} to trigger image build (because env var is not set)"
117+
fi
118+
fi
119+
120+
# Tests not focusing on anything and skipping [Conformance] run a clusterctl upgrade test
121+
# on the latest kubernetes version as management cluster.
122+
if [[ ${GINKGO_FOCUS:-} == "" ]] && [[ ${GINKGO_SKIP} == *"Conformance"* ]]; then
123+
# Note: We do this because we want to specify KUBERNETES_VERSION_LATEST_CI *only* in the e2e config.
124+
if [[ -z "${KUBERNETES_VERSION_LATEST_CI:-}" ]]; then
125+
KUBERNETES_VERSION_LATEST_CI=$(grep KUBERNETES_VERSION_LATEST_CI: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
126+
echo "Defaulting KUBERNETES_VERSION_LATEST_CI to ${KUBERNETES_VERSION_LATEST_CI} to trigger image build (because env var is not set)"
127+
fi
128+
fi
129+
130+
# Tests not focusing on [PR-Blocking], [K8s-Install] or [K8s-Install-ci-latest],
131+
# also run upgrade tests so default KUBERNETES_VERSION_UPGRADE_TO and KUBERNETES_VERSION_UPGRADE_FROM
132+
# to the value in the e2e config if they are not set.
133+
if [[ ${GINKGO_FOCUS:-} != *"PR-Blocking"* ]] && [[ ${GINKGO_FOCUS:-} != *"K8s-Install"* ]]; then
134+
if [[ -z "${KUBERNETES_VERSION_UPGRADE_TO:-}" ]]; then
135+
KUBERNETES_VERSION_UPGRADE_TO=$(grep KUBERNETES_VERSION_UPGRADE_TO: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
136+
echo "Defaulting KUBERNETES_VERSION_UPGRADE_TO to ${KUBERNETES_VERSION_UPGRADE_TO} to trigger image build (because env var is not set)"
137+
fi
138+
if [[ -z "${KUBERNETES_VERSION_UPGRADE_FROM:-}" ]]; then
139+
KUBERNETES_VERSION_UPGRADE_FROM=$(grep KUBERNETES_VERSION_UPGRADE_FROM: < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
140+
echo "Defaulting KUBERNETES_VERSION_UPGRADE_FROM to ${KUBERNETES_VERSION_UPGRADE_FROM} to trigger image build (because env var is not set)"
141+
fi
142+
fi
143+
}
144+
91145
# k8s::prepareKindestImages checks all the e2e test variables representing a Kubernetes version,
92146
# and makes sure a corresponding kindest/node image is available locally.
93147
k8s::prepareKindestImages() {

scripts/ci-e2e.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ export USE_EXISTING_CLUSTER=false
5353
# - KUBERNETES_VERSION_UPGRADE_FROM
5454
# - KUBERNETES_VERSION_LATEST_CI
5555
# - KUBERNETES_VERSION_MANAGEMENT
56-
k8s::prepareKindestImagesVariables
56+
if [[ -n "${GINKGO_LABEL_FILTER}" ]]; then
57+
echo "Preparing kindest/node images for Ginkgo label filter: ${GINKGO_LABEL_FILTER}"
58+
k8s::prepareKindestImagesVariablesGingkoFilters
59+
else
60+
k8s::prepareKindestImagesVariables
61+
fi
5762
k8s::prepareKindestImages
5863

5964
# pre-pull all the images that will be used in the e2e, thus making the actual test run

0 commit comments

Comments
 (0)