|
| 1 | +// Copyright Envoy Gateway Authors |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | +// The full text of the Apache license is available in the LICENSE file at |
| 4 | +// the root of the repo. |
| 5 | + |
| 6 | +//go:build e2e |
| 7 | +// +build e2e |
| 8 | + |
| 9 | +package mergegateways |
| 10 | + |
| 11 | +import ( |
| 12 | + "flag" |
| 13 | + "testing" |
| 14 | + |
| 15 | + "github.com/stretchr/testify/require" |
| 16 | + "sigs.k8s.io/controller-runtime/pkg/client" |
| 17 | + "sigs.k8s.io/controller-runtime/pkg/client/config" |
| 18 | + gwapiv1 "sigs.k8s.io/gateway-api/apis/v1" |
| 19 | + gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2" |
| 20 | + "sigs.k8s.io/gateway-api/conformance/utils/flags" |
| 21 | + "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" |
| 22 | + "sigs.k8s.io/gateway-api/conformance/utils/suite" |
| 23 | + |
| 24 | + egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" |
| 25 | + "github.com/envoyproxy/gateway/test/e2e" |
| 26 | + "github.com/envoyproxy/gateway/test/e2e/tests" |
| 27 | +) |
| 28 | + |
| 29 | +func TestMergeGateways(t *testing.T) { |
| 30 | + flag.Parse() |
| 31 | + |
| 32 | + cfg, err := config.GetConfig() |
| 33 | + require.NoError(t, err) |
| 34 | + |
| 35 | + c, err := client.New(cfg, client.Options{}) |
| 36 | + require.NoError(t, err) |
| 37 | + require.NoError(t, gwapiv1a2.AddToScheme(c.Scheme())) |
| 38 | + require.NoError(t, gwapiv1.AddToScheme(c.Scheme())) |
| 39 | + require.NoError(t, egv1a1.AddToScheme(c.Scheme())) |
| 40 | + |
| 41 | + if flags.RunTest != nil && *flags.RunTest != "" { |
| 42 | + t.Logf("Running E2E test %s with %s GatewayClass\n cleanup: %t\n debug: %t", |
| 43 | + *flags.RunTest, *flags.GatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug) |
| 44 | + } else { |
| 45 | + t.Logf("Running E2E tests with %s GatewayClass\n cleanup: %t\n debug: %t", |
| 46 | + *flags.GatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug) |
| 47 | + } |
| 48 | + |
| 49 | + cSuite := suite.New(suite.Options{ |
| 50 | + Client: c, |
| 51 | + GatewayClassName: *flags.GatewayClassName, |
| 52 | + Debug: *flags.ShowDebug, |
| 53 | + CleanupBaseResources: *flags.CleanupBaseResources, |
| 54 | + RunTest: *flags.RunTest, |
| 55 | + }) |
| 56 | + |
| 57 | + // Setting up the necessary arguments for the suite instead of calling Suite.Setup method again, |
| 58 | + // since this test suite reuse the base resources of previous test suite. |
| 59 | + cSuite.Applier.FS = e2e.Manifests |
| 60 | + cSuite.Applier.GatewayClass = *flags.GatewayClassName |
| 61 | + cSuite.ControllerName = kubernetes.GWCMustHaveAcceptedConditionTrue(t, |
| 62 | + cSuite.Client, cSuite.TimeoutConfig, cSuite.GatewayClassName) |
| 63 | + |
| 64 | + t.Logf("Running %d MergeGateways tests", len(tests.MergeGatewaysTests)) |
| 65 | + cSuite.Run(t, tests.MergeGatewaysTests) |
| 66 | +} |
0 commit comments