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

🌱 Fix ci-latest test to actually use ci latest #10080

Merged
merged 1 commit into from
Jan 31, 2024
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
9 changes: 9 additions & 0 deletions scripts/ci-e2e-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ k8s::prepareKindestImages() {
kind::prepareKindestImage "$resolveVersion"
fi

# If the test focuses on [K8s-Install-ci-latest], default KUBERNETES_VERSION_LATEST_CI
# to the value in the e2e config if it is not set.
# Note: We do this because we want to specify KUBERNETES_VERSION_LATEST_CI *only* in the e2e config.
if [[ $GINKGO_FOCUS == *"K8s-Install-ci-latest"* ]]; then
if [[ -z "${KUBERNETES_VERSION_LATEST_CI:-}" ]]; then
KUBERNETES_VERSION_LATEST_CI=$(grep KUBERNETES_VERSION_LATEST_CI < "$E2E_CONF_FILE" | awk -F'"' '{ print $2}')
echo "Defaulting KUBERNETES_VERSION_LATEST_CI to ${KUBERNETES_VERSION_LATEST_CI} to trigger image build (because env var is not set)"
fi
fi
if [ -n "${KUBERNETES_VERSION_LATEST_CI:-}" ]; then
k8s::resolveVersion "KUBERNETES_VERSION_LATEST_CI" "$KUBERNETES_VERSION_LATEST_CI"
export KUBERNETES_VERSION_LATEST_CI=$resolveVersion
Expand Down
18 changes: 9 additions & 9 deletions scripts/ci-e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ export PATH="${REPO_ROOT}/hack/tools/bin:${PATH}"
# Builds CAPI (and CAPD) images.
capi:buildDockerImages

# Configure e2e tests
export GINKGO_NODES=3
export GINKGO_NOCOLOR=true
export GINKGO_ARGS="${GINKGO_ARGS:-""}"
export E2E_CONF_FILE="${REPO_ROOT}/test/e2e/config/docker.yaml"
export ARTIFACTS="${ARTIFACTS:-${REPO_ROOT}/_artifacts}"
export SKIP_RESOURCE_CLEANUP=${SKIP_RESOURCE_CLEANUP:-"false"}
export USE_EXISTING_CLUSTER=false

# Prepare kindest/node images for all the required Kubernetes version; this implies
# 1. Kubernetes version labels (e.g. latest) to the corresponding version numbers.
# 2. Pre-pulling the corresponding kindest/node image if available; if not, building the image locally.
Expand All @@ -52,15 +61,6 @@ k8s::prepareKindestImages
# - cert-manager images
kind:prepullAdditionalImages

# Configure e2e tests
export GINKGO_NODES=3
export GINKGO_NOCOLOR=true
export GINKGO_ARGS="${GINKGO_ARGS:-""}"
export E2E_CONF_FILE="${REPO_ROOT}/test/e2e/config/docker.yaml"
export ARTIFACTS="${ARTIFACTS:-${REPO_ROOT}/_artifacts}"
export SKIP_RESOURCE_CLEANUP=${SKIP_RESOURCE_CLEANUP:-"false"}
export USE_EXISTING_CLUSTER=false

# Setup local output directory
ARTIFACTS_LOCAL="${ARTIFACTS}/localhost"
mkdir -p "${ARTIFACTS_LOCAL}"
Expand Down
18 changes: 10 additions & 8 deletions test/e2e/k8s_conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ limitations under the License.
package e2e

import (
"os"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/utils/ptr"
Expand All @@ -28,6 +30,7 @@ import (
)

var _ = Describe("When testing K8S conformance [Conformance] [K8s-Install]", func() {
// Note: This installs a cluster based on KUBERNETES_VERSION and runs conformance tests.
K8SConformanceSpec(ctx, func() K8SConformanceSpecInput {
return K8SConformanceSpecInput{
E2EConfig: e2eConfig,
Expand All @@ -40,17 +43,16 @@ var _ = Describe("When testing K8S conformance [Conformance] [K8s-Install]", fun
})

var _ = Describe("When testing K8S conformance with K8S latest ci [Conformance] [K8s-Install-ci-latest]", func() {
// Note: This installs a cluster based on KUBERNETES_VERSION_LATEST_CI and runs conformance tests.
// Note: We are resolving KUBERNETES_VERSION_LATEST_CI and then setting the resolved version as
// KUBERNETES_VERSION env var. This only works without side effects on other tests because we are
// running this test in its separate job.
K8SConformanceSpec(ctx, func() K8SConformanceSpecInput {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically I don't have to consider env vars when doing read/write of the version as we don't set KUBERNETES_VERSION_LATEST_CI via env var (just via e2e config). But I think it's better to also support the case where the env var is set

kubernetesVersion, err := kubernetesversions.ResolveVersion(ctx, e2eConfig.Variables["KUBERNETES_VERSION_LATEST_CI"])
kubernetesVersion, err := kubernetesversions.ResolveVersion(ctx, e2eConfig.GetVariable("KUBERNETES_VERSION_LATEST_CI"))
Expect(err).NotTo(HaveOccurred())

// Kubernetes version has to be set as KUBERNETES_VERSION because the conformance test
// expects it there.
testSpecificE2EConfig := e2eConfig.DeepCopy()
e2eConfig.Variables["KUBERNETES_VERSION"] = kubernetesVersion

Expect(os.Setenv("KUBERNETES_VERSION", kubernetesVersion)).To(Succeed())
return K8SConformanceSpecInput{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual mistake that lead to us using the wrong version was setting the variable in e2eConfig instead of in testSpecificE2EConfig 😂

E2EConfig: testSpecificE2EConfig,
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
Expand Down
Loading