From c6ce507f0a44cfba50813065dab38a75bf06ecfe Mon Sep 17 00:00:00 2001 From: Yi Tao Date: Mon, 27 Nov 2023 16:56:03 +0800 Subject: [PATCH] skip upgrade tests if Kong version below 3.0 --- test/e2e/upgrade_test.go | 15 +++++++++++++++ test/e2e/utils_test.go | 3 +++ 2 files changed, 18 insertions(+) diff --git a/test/e2e/upgrade_test.go b/test/e2e/upgrade_test.go index d96d69441a..cab035c47c 100644 --- a/test/e2e/upgrade_test.go +++ b/test/e2e/upgrade_test.go @@ -7,6 +7,7 @@ import ( "fmt" "testing" + "github.com/kong/go-kong/kong" "github.com/kong/kubernetes-testing-framework/pkg/environments" "github.com/samber/lo" "github.com/stretchr/testify/require" @@ -84,6 +85,20 @@ func testManifestsUpgrade( t *testing.T, testParams manifestsUpgradeTestParams, ) { + // Skip the test if the version of the provides Kong image is too low + // that the version of target image is not be compatible with the already-running KIC. + if kongImageOverride != "" { + kongVersion, err := getKongVersionFromOverrideImageTag() + skipTestVersionRange := kong.MustNewRange("<" + upgradeTestMinimalKongVersion.String()) + // If we could not get version from kong image, assume they are latest. + // So we will run the upgrade tests. + if err == nil && skipTestVersionRange(kongVersion) { + t.Skipf("skip upgrade test because Kong version is %s, lower than %s", + kongVersion.String(), upgradeTestMinimalKongVersion.String(), + ) + } + } + httpClient := helpers.RetryableHTTPClient(helpers.DefaultHTTPClient()) oldManifest, err := httpClient.Get(testParams.fromManifestURL) require.NoError(t, err) diff --git a/test/e2e/utils_test.go b/test/e2e/utils_test.go index bd151700b5..33b64711a2 100644 --- a/test/e2e/utils_test.go +++ b/test/e2e/utils_test.go @@ -47,6 +47,9 @@ var ( gatewayDiscoveryMinimalVersion = semver.Version{Major: 2, Minor: 9} // 2.9.0 // adminAPIHTTP2MinimalKongVersion is the minimal version of Kong gateway version that supports `http2` on admin APIs. adminAPIHTTP2MinimalKongVersion = semver.Version{Major: 3, Minor: 0} // 3.0.0 + // upgradeTestMinimalKongVersion is the minimal version of Kong gateway version that enables `TestDeployAndUpgrade*` test cases. + // Since the source Kong version used in TestDeployAndUpgrade* is 3.3, we should enable the test for Kong 3.0.x and above. + upgradeTestMinimalKongVersion = semver.Version{Major: 3, Minor: 0} // 3.0.0 // statusReadyProbeMinimalKongVersion is the minimal version of kong gateway version that enables /status/ready probe. statusReadyProbeMinimalKongVersion = semver.Version{Major: 3, Minor: 3} // 3.3.0 )