Skip to content

Commit

Permalink
Fix ci-latest test to actually use ci latest
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Büringer buringerst@vmware.com
  • Loading branch information
sbueringer committed Jan 31, 2024
1 parent caa378c commit b7c4bc0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
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 {
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{
E2EConfig: testSpecificE2EConfig,
E2EConfig: e2eConfig,
ClusterctlConfigPath: clusterctlConfigPath,
BootstrapClusterProxy: bootstrapClusterProxy,
ArtifactFolder: artifactFolder,
Expand Down

0 comments on commit b7c4bc0

Please sign in to comment.