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

tests: fix TestDeployAndUpgradeAllInOneDBLESS tests by using traditional router in upgrade tests #4997

Merged
merged 1 commit into from
Oct 27, 2023
Merged
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
24 changes: 20 additions & 4 deletions test/e2e/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
package e2e

import (
"bytes"
"context"
"fmt"
"os"
"testing"

"github.com/kong/kubernetes-testing-framework/pkg/environments"
Expand Down Expand Up @@ -72,15 +74,15 @@ func testManifestsUpgrade(
testParams manifestsUpgradeTestParams,
) {
httpClient := helpers.RetryableHTTPClient(helpers.DefaultHTTPClient())
oldManifest, err := httpClient.Get(testParams.fromManifestURL)
oldManifestResp, err := httpClient.Get(testParams.fromManifestURL)
require.NoError(t, err)
defer oldManifest.Body.Close()
defer oldManifestResp.Body.Close()

t.Log("configuring upgrade manifests test")
ctx, env := setupE2ETest(t)

t.Logf("deploying previous kong manifests: %s", testParams.fromManifestURL)
oldManifestPath := dumpToTempFile(t, oldManifest.Body)
oldManifestPath := dumpToTempFile(t, oldManifestResp.Body)
ManifestDeploy{
Path: oldManifestPath,
SkipTestPatches: true,
Expand All @@ -95,9 +97,23 @@ func testManifestsUpgrade(
hook(ctx, t, env)
}

// TODO: https://github.com/Kong/kubernetes-ingress-controller/issues/4973
// This router flavor substitution is a workaround for the fact that KIC doesn't
// support configuring Gateways of different router flavors at the same time.
// Since pre 3.0 the default router flavor was "traditional", use it here during
// the upgrade.
// When 4973 is fixed, this will go away as those new tests will use a different
// testing strategy.
// Using expressions router in earlier version (e.g. 2.12) was causing
// configuration translation errors.
newManifestB, err := os.ReadFile(testParams.toManifestPath)
require.NoError(t, err)
newManifestB = bytes.ReplaceAll(newManifestB, []byte("value: expressions"), []byte("value: traditional"))
newManifestPath := dumpToTempFile(t, bytes.NewReader(newManifestB))

t.Logf("deploying target version of kong manifests: %s", testParams.toManifestPath)
deployments := ManifestDeploy{
Path: testParams.toManifestPath,
Path: newManifestPath,
// Do not skip test patches - we want to verify that upgrade works with an image override in target manifest.
SkipTestPatches: false,
}.Run(ctx, t, env)
Expand Down
Loading