Skip to content

Commit

Permalink
[1.18] tests: Fix failing K8sGateway/Metrics test in enterprise (#10491)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjumani authored Dec 16, 2024
1 parent 041dba6 commit 38e1342
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 deletions.
5 changes: 5 additions & 0 deletions changelog/v1.18.1/fix-metrics-suite.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
changelog:
- type: NON_USER_FACING
issueLink: https://github.com/solo-io/solo-projects/issues/7405
description: Fixes the failing K8sGateway/Metrics in enterprise caused by using the wrong BaseTestingSuite constructor.

2 changes: 1 addition & 1 deletion test/kubernetes/e2e/features/helm/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type testingSuite struct {

func NewTestingSuite(ctx context.Context, testInst *e2e.TestInstallation) suite.TestingSuite {
return &testingSuite{
base.NewBaseTestingSuite(ctx, testInst, e2e.MustTestHelper(ctx, testInst), base.SimpleTestCase{}, helmTestCases),
base.NewBaseTestingSuiteWithUpgrades(ctx, testInst, e2e.MustTestHelper(ctx, testInst), base.SimpleTestCase{}, helmTestCases),
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/kubernetes/e2e/features/metrics/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type testingSuite struct {

func NewTestingSuite(ctx context.Context, testInst *e2e.TestInstallation) suite.TestingSuite {
return &testingSuite{
base.NewBaseTestingSuite(ctx, testInst, e2e.MustTestHelper(ctx, testInst), base.SimpleTestCase{}, testCases),
base.NewBaseTestingSuite(ctx, testInst, base.SimpleTestCase{}, testCases),
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/kubernetes/e2e/features/upgrade/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func NewTestingSuite(ctx context.Context, testInst *e2e.TestInstallation) suite.
testInst.Metadata.ReleasedVersion = releaseVersion

return &testingSuite{
base.NewBaseTestingSuite(ctx, testInst, testHelper, base.SimpleTestCase{}, nil),
base.NewBaseTestingSuiteWithUpgrades(ctx, testInst, testHelper, base.SimpleTestCase{}, nil),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type testingSuite struct {

func NewTestingSuite(ctx context.Context, testInst *e2e.TestInstallation) suite.TestingSuite {
return &testingSuite{
base.NewBaseTestingSuiteWithoutUpgrades(ctx, testInst, setupSuite, testCases),
base.NewBaseTestingSuite(ctx, testInst, setupSuite, testCases),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type testingSuite struct {

func NewTestingSuite(ctx context.Context, testInst *e2e.TestInstallation) suite.TestingSuite {
return &testingSuite{
base.NewBaseTestingSuite(ctx, testInst, e2e.MustTestHelper(ctx, testInst), base.SimpleTestCase{}, zeroDowntimeTestCases),
base.NewBaseTestingSuiteWithUpgrades(ctx, testInst, e2e.MustTestHelper(ctx, testInst), base.SimpleTestCase{}, zeroDowntimeTestCases),
}
}

Expand Down
15 changes: 8 additions & 7 deletions test/kubernetes/e2e/tests/base/base_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ type BaseTestingSuite struct {
Setup SimpleTestCase
}

// NewBaseTestingSuite returns a BaseTestingSuite that performs all the pre-requisites of upgrading helm installations,
// NewBaseTestingSuiteWithUpgrades returns a BaseTestingSuite that performs all the pre-requisites of upgrading helm installations,
// applying manifests and verifying resources exist before a suite and tests and the corresponding post-run cleanup.
// The pre-requisites for the suite are defined in the setup parameter and for each test in the individual testCase.
// Currently, tests that require upgrades (eg: to change settings) can not be run in Enterprise. To do so,
// the test must be written without upgrades and call the `NewBaseTestingSuiteWithoutUpgrades` constructor.
func NewBaseTestingSuite(ctx context.Context, testInst *e2e.TestInstallation, testHelper *helper.SoloTestHelper, setup SimpleTestCase, testCase map[string]*TestCase) *BaseTestingSuite {
// WARNING: Testing suites that call this method can not run in enterprise as they require upgrades (eg: to change settings).
// To use the BaseTestingSuite, the test must be written without upgrades and call the `NewBaseTestingSuite` constructor.
func NewBaseTestingSuiteWithUpgrades(ctx context.Context, testInst *e2e.TestInstallation, testHelper *helper.SoloTestHelper, setup SimpleTestCase, testCase map[string]*TestCase) *BaseTestingSuite {
namespace = testInst.Metadata.InstallNamespace
return &BaseTestingSuite{
Ctx: ctx,
Expand All @@ -66,9 +66,10 @@ func NewBaseTestingSuite(ctx context.Context, testInst *e2e.TestInstallation, te
}
}

// NewBaseTestingSuiteWithoutUpgrades returns a BaseTestingSuite without allowing upgrades and reverts before the suite and tests.
// This is useful when creating tests that need to run in Enterprise since the helm values change between OSS and Enterprise installations.
func NewBaseTestingSuiteWithoutUpgrades(ctx context.Context, testInst *e2e.TestInstallation, setup SimpleTestCase, testCase map[string]*TestCase) *BaseTestingSuite {
// NewBaseTestingSuite returns a BaseTestingSuite without allowing upgrades and reverts before the suite and tests.
// Testing suites that call this method can safely run in Enterprise since the helm values change between OSS and Enterprise installations.
// If tests require upgrades, call the `NewBaseTestingSuiteWithUpgrades` constructor, however those tests can not run in Enterprise.
func NewBaseTestingSuite(ctx context.Context, testInst *e2e.TestInstallation, setup SimpleTestCase, testCase map[string]*TestCase) *BaseTestingSuite {
namespace = testInst.Metadata.InstallNamespace
return &BaseTestingSuite{
Ctx: ctx,
Expand Down

0 comments on commit 38e1342

Please sign in to comment.