diff --git a/pkg/tests/non-dependant/bug_multiple_smcp_test.go b/pkg/tests/non-dependant/bug_multiple_smcp_test.go index 17d5f1c3..15a632c1 100644 --- a/pkg/tests/non-dependant/bug_multiple_smcp_test.go +++ b/pkg/tests/non-dependant/bug_multiple_smcp_test.go @@ -31,7 +31,7 @@ import ( ) func TestSMCPMultiple(t *testing.T) { - NewTest(t).Id("T36").Groups(Full, ARM).Run(func(t TestHelper) { + NewTest(t).Id("T36").Groups(Full, ARM, Disconnected).Run(func(t TestHelper) { t.Log("This test verifies whether the operator only reconciles one SMCP when two exist in a namespace") t.Log("See https://issues.redhat.com/browse/OSSM-2419") diff --git a/pkg/tests/non-dependant/olm_webhooks_test.go b/pkg/tests/non-dependant/olm_webhooks_test.go index 64d729bb..6cc9d4d1 100644 --- a/pkg/tests/non-dependant/olm_webhooks_test.go +++ b/pkg/tests/non-dependant/olm_webhooks_test.go @@ -28,7 +28,7 @@ import ( ) func TestOlmWebhookCreation(t *testing.T) { - NewTest(t).Groups(Full, ARM).Run(func(t TestHelper) { + NewTest(t).Groups(Full, ARM, Disconnected).Run(func(t TestHelper) { t.Log("This test verifies that OLM creates all validating/mutating webhooks") t.Log("See https://issues.redhat.com/browse/OSSM-6762") if env.GetOperatorVersion().LessThan(version.OPERATOR_2_6_0) { diff --git a/pkg/tests/ossm/bug_istiopods_test.go b/pkg/tests/ossm/bug_istiopods_test.go index 51726016..6599f433 100644 --- a/pkg/tests/ossm/bug_istiopods_test.go +++ b/pkg/tests/ossm/bug_istiopods_test.go @@ -61,7 +61,7 @@ func TestIstiodPodFailsAfterRestarts(t *testing.T) { } func TestControllerFailsToUpdatePod(t *testing.T) { - NewTest(t).Groups(Full, Disconnected, ARM).Run(func(t TestHelper) { + NewTest(t).Groups(Full, ARM).Run(func(t TestHelper) { t.Log("Verify that the controller does not fails to update the pod when the member controller couldn't add the member-of label") t.Log("References: \n- https://issues.redhat.com/browse/OSSM-2169\n- https://issues.redhat.com/browse/OSSM-2420") diff --git a/pkg/tests/ossm/bug_rolebinding_test.go b/pkg/tests/ossm/bug_rolebinding_test.go index 071e62a0..3832ae6d 100644 --- a/pkg/tests/ossm/bug_rolebinding_test.go +++ b/pkg/tests/ossm/bug_rolebinding_test.go @@ -31,7 +31,7 @@ type namespaceResources struct { } func TestMissingRoleBinding(t *testing.T) { - NewTest(t).Groups(Full, ARM).Run(func(t TestHelper) { + NewTest(t).Groups(Full, ARM, Disconnected).Run(func(t TestHelper) { t.Log("Verify that role and role binding is detected with SMMR namespace with gateway") t.Log("Reference: https://issues.redhat.com/browse/OSSM-2143") diff --git a/pkg/tests/ossm/discovery_selectors_test.go b/pkg/tests/ossm/discovery_selectors_test.go index a10e0121..bf8c5b6f 100644 --- a/pkg/tests/ossm/discovery_selectors_test.go +++ b/pkg/tests/ossm/discovery_selectors_test.go @@ -29,7 +29,7 @@ import ( ) func TestDiscoverySelectors(t *testing.T) { - NewTest(t).Groups(Full, ARM).Run(func(t TestHelper) { + NewTest(t).Groups(Full, ARM, Disconnected).Run(func(t TestHelper) { t.Log("This test checks if discoverySelectors are being honored") t.Log("See https://issues.redhat.com/browse/OSSM-3802") t.Log("Test case is based on https://istio.io/latest/blog/2021/discovery-selectors/") diff --git a/pkg/tests/ossm/ior_test.go b/pkg/tests/ossm/ior_test.go index 897be75d..3a5d636c 100644 --- a/pkg/tests/ossm/ior_test.go +++ b/pkg/tests/ossm/ior_test.go @@ -20,6 +20,7 @@ import ( "sort" "strings" "testing" + "time" "gopkg.in/yaml.v2" @@ -32,8 +33,9 @@ import ( "github.com/maistra/maistra-test-tool/pkg/util/pod" "github.com/maistra/maistra-test-tool/pkg/util/retry" "github.com/maistra/maistra-test-tool/pkg/util/shell" - "github.com/maistra/maistra-test-tool/pkg/util/test" "github.com/maistra/maistra-test-tool/pkg/util/version" + + . "github.com/maistra/maistra-test-tool/pkg/util/test" ) type RouteMetadata struct { @@ -54,7 +56,7 @@ const ( // TestIOR tests IOR error regarding routes recreated: https://issues.redhat.com/browse/OSSM-1974. IOR will be deprecated on 2.4 and willl be removed on 3.0 func TestIOR(t *testing.T) { - test.NewTest(t).Groups(test.Full, test.ARM).Run(func(t test.TestHelper) { + NewTest(t).Groups(Full, ARM, Disconnected).Run(func(t TestHelper) { t.Log("This test verifies the behavior of IOR.") meshNamespace := env.GetDefaultMeshNamespace() @@ -67,19 +69,19 @@ func TestIOR(t *testing.T) { host := "www.test.ocp" gatewayName := "gw" - createSimpleGateway := func(t test.TestHelper) { + createSimpleGateway := func(t TestHelper) { t.Logf("Creating Gateway for %s host", host) oc.ApplyString(t, "", generateGateway(gatewayName, meshNamespace, host)) } - deleteSimpleGateway := func(t test.TestHelper) { + deleteSimpleGateway := func(t TestHelper) { t.Logf("Deleting Gateway for %s host", host) oc.DeleteFromString(t, "", generateGateway(gatewayName, meshNamespace, host)) } - checkSimpleGateway := func(t test.TestHelper) { + checkSimpleGateway := func(t TestHelper) { t.Logf("Checking whether a Route is generated for %s", host) - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { routes := getRoutes(t, meshNamespace) if len(routes) != 1 { t.Fatalf("Expect a single route set for %s host, but got %s instead", host, len(routes)) @@ -98,7 +100,7 @@ func TestIOR(t *testing.T) { DeployControlPlane(t) - t.NewSubTest("check IOR off by default from v2.5").Run(func(t test.TestHelper) { + t.NewSubTest("check IOR off by default from v2.5").Run(func(t TestHelper) { if env.GetSMCPVersion().LessThan(version.SMCP_2_5) { t.Skip("Skipping until 2.5") } else { @@ -110,7 +112,7 @@ func TestIOR(t *testing.T) { } }) - t.NewSubTest("check IOR basic functionalities").Run(func(t test.TestHelper) { + t.NewSubTest("check IOR basic functionalities").Run(func(t TestHelper) { t.Cleanup(func() { if env.GetSMCPVersion().GreaterThanOrEqual(version.SMCP_2_5) { removeIORCustomSetting(t, meshNamespace, meshName) @@ -128,7 +130,7 @@ func TestIOR(t *testing.T) { checkSimpleGateway(t) }) - t.NewSubTest("check routes aren't deleted during v2.3 to v2.4 upgrade").Run(func(t test.TestHelper) { + t.NewSubTest("check routes aren't deleted during v2.3 to v2.4 upgrade").Run(func(t TestHelper) { if env.GetSMCPVersion().LessThan(version.SMCP_2_4) { t.Skip("This test only applies for v2.3 to v2.4 upgrade") } @@ -169,7 +171,7 @@ func TestIOR(t *testing.T) { } }) - t.NewSubTest("check IOR does not delete routes after deleting Istio pod").Run(func(t test.TestHelper) { + t.NewSubTest("check IOR does not delete routes after deleting Istio pod").Run(func(t TestHelper) { total := 3 nsNames := []string{} gateways := []string{} @@ -210,7 +212,7 @@ func TestIOR(t *testing.T) { oc.ApplyString(t, meshNamespace, AppendDefaultSMMR(nsNames...)) oc.WaitSMMRReady(t, meshNamespace) - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { routes := getRoutes(t, meshNamespace) if len(routes) != total { t.Fatalf("Expect to find %d Routes but found %d instead", total, len(routes)) @@ -240,7 +242,7 @@ func TestIOR(t *testing.T) { }) before := buildManagedRouteYamlDocument(t, meshNamespace) - detectRouteChanges := func(t test.TestHelper) { + detectRouteChanges := func(t TestHelper) { after := buildManagedRouteYamlDocument(t, meshNamespace) if err := util.Compare( []byte(before), @@ -267,7 +269,7 @@ func TestIOR(t *testing.T) { detectRouteChanges(t) }) - t.NewSubTest("Check argocd.argoproj.io labels from Gateways to Routes except argocd.argoproj.io/instance").Run(func(t test.TestHelper) { + t.NewSubTest("Check argocd.argoproj.io labels from Gateways to Routes except argocd.argoproj.io/instance").Run(func(t TestHelper) { if env.GetArch() == "arm64" && env.GetSMCPVersion().LessThan(version.SMCP_2_5) { t.Skip("2.4 is not supported in arm, from 2.5 GA in arm") } @@ -297,17 +299,17 @@ metadata: `) t.LogStep("Check the argocd.argoproj.io/secret label was copied to the Route") - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { if oc.ResourceByLabelExists(t, "istio-system", "route", "argocd.argoproj.io/secret-type=cluster") { t.LogSuccess("argocd.argoproj.io/secret-type=cluster label was copied to the Route") } else { - t.Fatalf("argocd.argoproj.io/secret-type=cluster label was not copied to the Route") + t.Errorf("argocd.argoproj.io/secret-type=cluster label was not copied to the Route") } }) t.LogStep("Check the argocd.argoproj.io/instance label was not copied to the Route") if oc.ResourceByLabelExists(t, "istio-system", "route", "argocd.argoproj.io/instance=app") { - t.Fatalf("argocd.argoproj.io/instance=app label was copied to the Route") + t.Errorf("argocd.argoproj.io/instance=app label was copied to the Route") } else { t.LogSuccess("argocd.argoproj.io/instance=app label was not copied to the Route") } @@ -319,7 +321,7 @@ metadata: checkAnnotationCopiedToRoute(t, meshNamespace, "argocd.argoproj.io/instance", "app", gatewayName) }) - t.NewSubTest("Check Headless service in istio namespace does not break IOR").Run(func(t test.TestHelper) { + t.NewSubTest("Check Headless service in istio namespace does not break IOR").Run(func(t TestHelper) { if env.GetSMCPVersion().LessThan(version.SMCP_2_5) { t.Skip("Issue fixed from SMCP 2.5") } @@ -351,21 +353,22 @@ spec: testAttempts := 5 t.LogStepf("Try to delete istiod pod and check the bookinfo route few times (%d)", testAttempts) for i := 0; i < testAttempts; i++ { - shell.Execute(t, - fmt.Sprintf(` -oc delete pod -l app=istiod -n %[1]s; -oc rollout status deployment -l app=istiod -n %[1]s; -sleep 5; -oc get route -l maistra.io/gateway-name=bookinfo-gateway -n %[1]s -o jsonpath='{.items[].spec.to.name}'`, meshNamespace), - assert.OutputContains("istio-ingressgateway", - fmt.Sprintf("%d: Headless service in istio namespace did not broke IOR", i+1), - fmt.Sprintf("%d: Headless service in istio namespace broke IOR", i+1))) + oc.DeletePod(t, pod.MatchingSelector("app=istiod", meshNamespace)) + oc.WaitPodReady(t, pod.MatchingSelector("app=istiod", meshNamespace)) + retry.UntilSuccessWithOptions(t, retry.Options().MaxAttempts(10).DelayBetweenAttempts(2*time.Second), func(t TestHelper) { + shell.Execute(t, + fmt.Sprintf(`oc get route -n %s -l 'maistra.io/gateway-name=bookinfo-gateway' -o jsonpath='{.items[*].spec.to.name}'`, meshNamespace), + assert.OutputContains( + "istio-ingressgateway", + fmt.Sprintf("%d: Headless service in istio namespace did not broke IOR", i+1), + fmt.Sprintf("%d: Headless service in istio namespace broke IOR", i+1))) + }) } }) }) } -func addAdditionalIngressGateway(t test.TestHelper, meshName, meshNamespace, gatewayName string) { +func addAdditionalIngressGateway(t TestHelper, meshName, meshNamespace, gatewayName string) { oc.Patch(t, meshNamespace, "smcp", meshName, "merge", fmt.Sprintf(` @@ -382,7 +385,7 @@ func addAdditionalIngressGateway(t test.TestHelper, meshName, meshNamespace, gat oc.WaitSMCPReady(t, meshNamespace, meshName) } -func getRoutes(t test.TestHelper, ns string) []Route { +func getRoutes(t TestHelper, ns string) []Route { res := shell.Executef(t, "oc -n %s get --selector 'maistra.io/generated-by=ior' --output 'jsonpath={.items}' route", ns) var routes []Route err := json.Unmarshal([]byte(res), &routes) @@ -393,11 +396,11 @@ func getRoutes(t test.TestHelper, ns string) []Route { return routes } -func getRouteNames(t test.TestHelper, ns string) []string { +func getRouteNames(t TestHelper, ns string) []string { return oc.GetAllResoucesNamesByLabel(t, ns, "route", "maistra.io/generated-by=ior") } -func buildManagedRouteYamlDocument(t test.TestHelper, ns string) string { +func buildManagedRouteYamlDocument(t TestHelper, ns string) string { names := getRouteNames(t, ns) sort.Strings(names) @@ -422,12 +425,12 @@ func buildManagedRouteYamlDocument(t test.TestHelper, ns string) string { return doc } -func setupDefaultSMCP(t test.TestHelper, ns string) { +func setupDefaultSMCP(t TestHelper, ns string) { InstallSMCP(t, ns) oc.WaitSMCPReady(t, ns, env.GetDefaultSMCPName()) } -func setupV23SMCP(t test.TestHelper, ns, name string) { +func setupV23SMCP(t TestHelper, ns, name string) { InstallSMCPVersion(t, ns, version.SMCP_2_3) oc.WaitSMCPReady(t, ns, name) @@ -435,27 +438,27 @@ func setupV23SMCP(t test.TestHelper, ns, name string) { oc.WaitSMMRReady(t, ns) } -func updateToV24SMCP(t test.TestHelper, ns, name string) { +func updateToV24SMCP(t TestHelper, ns, name string) { oc.Patch(t, ns, "smcp", name, "json", `[{"op": "add", "path": "/spec/version", "value": "v2.4"}]`) oc.WaitSMCPReady(t, ns, name) } -func getIORSetting(t test.TestHelper, ns, name string) string { +func getIORSetting(t TestHelper, ns, name string) string { return shell.Executef(t, `oc -n %s get smcp/%s -o jsonpath='{.status.appliedValues.istio.gateways.istio-ingressgateway.ior_enabled}'`, ns, name) } -func enableIOR(t test.TestHelper, ns, name string) { +func enableIOR(t TestHelper, ns, name string) { oc.Patch(t, ns, "smcp", name, "json", `[{"op": "add", "path": "/spec/gateways", "value": {"openshiftRoute": {"enabled": true}}}]`, ) } -func removeIORCustomSetting(t test.TestHelper, ns, name string) { +func removeIORCustomSetting(t TestHelper, ns, name string) { oc.Patch(t, ns, "smcp", name, "json", `[{"op": "remove", "path": "/spec/gateways"}]`, @@ -484,8 +487,8 @@ spec: ) } -func checkAnnotationCopiedToRoute(t test.TestHelper, meshNamespace, annotationKey, annotationValue, expectedOutput string) { - retry.UntilSuccess(t, func(t test.TestHelper) { +func checkAnnotationCopiedToRoute(t TestHelper, meshNamespace, annotationKey, annotationValue, expectedOutput string) { + retry.UntilSuccess(t, func(t TestHelper) { shell.Execute(t, fmt.Sprintf(`oc get route -n %s -o json | jq -r '.items[] | select(.metadata.annotations["%s"] == "%s") | .metadata.name'`, meshNamespace, annotationKey, annotationValue), assert.OutputContains(expectedOutput, diff --git a/pkg/tests/ossm/prometheus_scoped_scraping_test.go b/pkg/tests/ossm/prometheus_scoped_scraping_test.go index e771ac86..aebcdc32 100644 --- a/pkg/tests/ossm/prometheus_scoped_scraping_test.go +++ b/pkg/tests/ossm/prometheus_scoped_scraping_test.go @@ -31,14 +31,15 @@ import ( "github.com/maistra/maistra-test-tool/pkg/util/pod" "github.com/maistra/maistra-test-tool/pkg/util/retry" "github.com/maistra/maistra-test-tool/pkg/util/shell" - "github.com/maistra/maistra-test-tool/pkg/util/test" "github.com/maistra/maistra-test-tool/pkg/util/version" + + . "github.com/maistra/maistra-test-tool/pkg/util/test" ) var prometheusPodSelector oc.PodLocatorFunc = pod.MatchingSelector("app=prometheus,maistra-control-plane="+meshNamespace, meshNamespace) func TestOperatorCanUpdatePrometheusConfigMap(t *testing.T) { - test.NewTest(t).Groups(test.Full, test.ARM).Run(func(t test.TestHelper) { + NewTest(t).Groups(Full, ARM, Disconnected).Run(func(t TestHelper) { t.Log("This test checks if the operator can update Prometheus ConfigMap when the SMMR is updated") if env.GetSMCPVersion().LessThan(version.SMCP_2_4) { @@ -53,7 +54,7 @@ func TestOperatorCanUpdatePrometheusConfigMap(t *testing.T) { checkPermissionError(t) - t.NewSubTest("when the default SMMR with no member").Run(func(t test.TestHelper) { + t.NewSubTest("when the default SMMR with no member").Run(func(t TestHelper) { t.Cleanup(func() { restoreDefaultSMMR(t) }) @@ -66,7 +67,7 @@ func TestOperatorCanUpdatePrometheusConfigMap(t *testing.T) { checkPermissionError(t) }) - t.NewSubTest("when creating a SMMR").Run(func(t test.TestHelper) { + t.NewSubTest("when creating a SMMR").Run(func(t TestHelper) { ns := generateNamespace() t.Cleanup(func() { @@ -82,7 +83,7 @@ func TestOperatorCanUpdatePrometheusConfigMap(t *testing.T) { testPrometheusConfigWithAsserts(t, assertConfigMapContainsNamespace(ns)) }) - t.NewSubTest("when adding a new namespace into existing SMMR").Run(func(t test.TestHelper) { + t.NewSubTest("when adding a new namespace into existing SMMR").Run(func(t TestHelper) { ns := generateNamespace() anotherNs := generateNamespace() @@ -103,7 +104,7 @@ func TestOperatorCanUpdatePrometheusConfigMap(t *testing.T) { testPrometheusConfigWithAsserts(t, assertConfigMapContainsNamespace(ns), assertConfigMapContainsNamespace(anotherNs)) }) - t.NewSubTest("when removing a namespace from existing SMMR").Run(func(t test.TestHelper) { + t.NewSubTest("when removing a namespace from existing SMMR").Run(func(t TestHelper) { ns := generateNamespace() anotherNs := generateNamespace() @@ -123,7 +124,7 @@ func TestOperatorCanUpdatePrometheusConfigMap(t *testing.T) { testPrometheusConfigWithAsserts(t, assertConfigMapContainsNamespace(ns), assertConfigMapDoesNotContainNamespace(anotherNs)) }) - t.NewSubTest("when the default SMMR with nonexistent namespace").Run(func(t test.TestHelper) { + t.NewSubTest("when the default SMMR with nonexistent namespace").Run(func(t TestHelper) { t.Cleanup(func() { restoreDefaultSMMR(t) }) @@ -141,7 +142,7 @@ func TestOperatorCanUpdatePrometheusConfigMap(t *testing.T) { checkPermissionError(t) }) - t.NewSubTest("query istio_request_total").Run(func(t test.TestHelper) { + t.NewSubTest("query istio_request_total").Run(func(t TestHelper) { t.Log("This test checks if Prometheus is scraping data from mesh member application when SMCP is MultiTenant mode") t.Cleanup(func() { oc.RecreateNamespace(t, ns.Bookinfo) @@ -153,7 +154,7 @@ func TestOperatorCanUpdatePrometheusConfigMap(t *testing.T) { testBookinfoAppReportIstioRequestsTotal(t) }) - t.NewSubTest("when removing SMMR").Run(func(t test.TestHelper) { + t.NewSubTest("when removing SMMR").Run(func(t TestHelper) { t.Cleanup(func() { restoreDefaultSMMR(t) }) @@ -171,15 +172,11 @@ func TestOperatorCanUpdatePrometheusConfigMap(t *testing.T) { checkConfigurationReloadingTriggered(t, start) checkPermissionError(t) }) - - t.NewSubTest("[TODO] test under cluster scoped").Run(func(t test.TestHelper) { - t.Skip() - }) }) } func TestPrometheusScrapingAppDataWithClusterWideSmcp(t *testing.T) { - test.NewTest(t).Groups(test.Full, test.ARM).Run(func(t test.TestHelper) { + NewTest(t).Groups(Full, ARM, Disconnected).Run(func(t TestHelper) { t.Log("This test checks if Prometheus is scraping data from mesh member application when SMCP is ClusterWide mode") t.Log("Related issue: https://issues.redhat.com/browse/OSSM-8205") @@ -203,7 +200,7 @@ func TestPrometheusScrapingAppDataWithClusterWideSmcp(t *testing.T) { }) } -func testBookinfoAppReportIstioRequestsTotal(t test.TestHelper) { +func testBookinfoAppReportIstioRequestsTotal(t TestHelper) { t.LogStep("Test that the `istio_requests_total` metric exist for bookinfo") generateBookinfoTraffic(t) checkIstioRequestsTotalInPrometheus(t, "productpage") @@ -212,7 +209,7 @@ func testBookinfoAppReportIstioRequestsTotal(t test.TestHelper) { checkIstioRequestsTotalInPrometheus(t, "ratings") } -func checkPermissionError(t test.TestHelper) { +func checkPermissionError(t TestHelper) { t.LogStep("Check the Prometheus log to see if there is any permission error") oc.Logs(t, prometheusPodSelector, @@ -225,11 +222,11 @@ func checkPermissionError(t test.TestHelper) { ) } -func checkConfigurationReloadingTriggered(t test.TestHelper, start time.Time) { +func checkConfigurationReloadingTriggered(t TestHelper, start time.Time) { // By default, any changes in the `ConfigMap`, the kubelet will sync them to the mapped volume on one minute interval. t.Log("Wait one minute on the kubelet to update the volume to reflect the changes") time.Sleep(1 * time.Minute) - retry.UntilSuccessWithOptions(t, retry.Options().DelayBetweenAttempts(5*time.Second).MaxAttempts(25), func(t test.TestHelper) { + retry.UntilSuccessWithOptions(t, retry.Options().DelayBetweenAttempts(5*time.Second).MaxAttempts(25), func(t TestHelper) { oc.LogsSince(t, start, prometheusPodSelector, "config-reloader", @@ -241,20 +238,20 @@ func checkConfigurationReloadingTriggered(t test.TestHelper, start time.Time) { }) } -func testPrometheusConfigWithAsserts(t test.TestHelper, asserts ...common.CheckFunc) { - retry.UntilSuccess(t, func(t test.TestHelper) { +func testPrometheusConfigWithAsserts(t TestHelper, asserts ...common.CheckFunc) { + retry.UntilSuccess(t, func(t TestHelper) { shell.Execute(t, fmt.Sprintf("oc -n %s get configmap prometheus -o jsonpath='{.data.prometheus\\.yml}'", meshNamespace), asserts...) }) } -func restoreDefaultSMMR(t test.TestHelper) { +func restoreDefaultSMMR(t TestHelper) { oc.ApplyString(t, meshNamespace, smmr) oc.WaitSMMRReady(t, meshNamespace) } -func updateDefaultSMMRWithNamespace(t test.TestHelper, names ...string) { +func updateDefaultSMMRWithNamespace(t TestHelper, names ...string) { s := buildSMMR(names...) t.LogStepf("Update SMMR %s", s) @@ -297,7 +294,7 @@ func generateNamespace() string { return fmt.Sprintf("namespace-%d", rand.Int()) } -func generateBookinfoTraffic(t test.TestHelper) { +func generateBookinfoTraffic(t TestHelper) { count := 10 t.LogStepf("Generate %d requests to product page", count) productPageURL := app.BookinfoProductPageURL(t, meshNamespace) @@ -306,11 +303,11 @@ func generateBookinfoTraffic(t test.TestHelper) { } } -func checkIstioRequestsTotalInPrometheus(t test.TestHelper, app string) { +func checkIstioRequestsTotalInPrometheus(t TestHelper, app string) { query := "istio_requests_total" expectedOutput := fmt.Sprintf(`"app":"%s"`, app) t.LogStep(`Check if the "istio_request_total metric is in Prometheus"`) - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { oc.Exec(t, prometheusPodSelector, "prometheus-proxy", @@ -323,9 +320,9 @@ func checkIstioRequestsTotalInPrometheus(t test.TestHelper, app string) { }) } -func waitUntilPrometheusTargetReady(t test.TestHelper, app string) { +func waitUntilPrometheusTargetReady(t TestHelper, app string) { t.LogStep(`Wait till targets are available in Prometheus"`) - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { oc.Exec(t, prometheusPodSelector, "prometheus-proxy", diff --git a/pkg/tests/ossm/route_prevent_additional_ingress_test.go b/pkg/tests/ossm/route_prevent_additional_ingress_test.go index d775de0a..3d827df4 100644 --- a/pkg/tests/ossm/route_prevent_additional_ingress_test.go +++ b/pkg/tests/ossm/route_prevent_additional_ingress_test.go @@ -23,12 +23,13 @@ import ( "github.com/maistra/maistra-test-tool/pkg/util/oc" "github.com/maistra/maistra-test-tool/pkg/util/retry" "github.com/maistra/maistra-test-tool/pkg/util/shell" - . "github.com/maistra/maistra-test-tool/pkg/util/test" "github.com/maistra/maistra-test-tool/pkg/util/version" + + . "github.com/maistra/maistra-test-tool/pkg/util/test" ) func TestRoutePreventAdditionalIngress(t *testing.T) { - NewTest(t).Id("T48").Groups(Full, ARM).MaxVersion(version.SMCP_2_5).Run(func(t TestHelper) { + NewTest(t).Id("T48").Groups(Full, ARM, Disconnected).MaxVersion(version.SMCP_2_5).Run(func(t TestHelper) { meshValues := map[string]interface{}{ "Version": env.GetSMCPVersion().String(), diff --git a/pkg/tests/tasks/injection/native_sidecars_test.go b/pkg/tests/tasks/injection/native_sidecars_test.go index ebc1d4c7..01bacd87 100644 --- a/pkg/tests/tasks/injection/native_sidecars_test.go +++ b/pkg/tests/tasks/injection/native_sidecars_test.go @@ -32,7 +32,7 @@ import ( ) func TestNativeSidecars(t *testing.T) { - NewTest(t).Groups(Full, InterOp, ARM).Run(func(t TestHelper) { + NewTest(t).Groups(Full, InterOp, ARM, Disconnected).Run(func(t TestHelper) { if version.ParseVersion(oc.GetOCPVersion(t)).LessThan(version.OCP_4_16) || env.GetSMCPVersion().LessThan(version.SMCP_2_6) { t.Skip("Native sidecars are only supported in OpenShift 4.16+ and OSSM 2.6+") } diff --git a/pkg/tests/tasks/injection/tproxy_test.go b/pkg/tests/tasks/injection/tproxy_test.go index 7033efa1..32eb2ba2 100644 --- a/pkg/tests/tasks/injection/tproxy_test.go +++ b/pkg/tests/tasks/injection/tproxy_test.go @@ -34,7 +34,7 @@ import ( ) func TestTproxy(t *testing.T) { - NewTest(t).Groups(Full, InterOp, ARM).Run(func(t TestHelper) { + NewTest(t).Groups(Full, InterOp, ARM, Disconnected).Run(func(t TestHelper) { if env.GetSMCPVersion().LessThan(version.SMCP_2_5) { t.Skip("TPROXY is only supported in 2.5.3 and newer versions") } diff --git a/pkg/tests/tasks/observability/federated_openshift_monitoring_test.go b/pkg/tests/tasks/observability/federated_openshift_monitoring_test.go index 25739b38..f851fd2d 100644 --- a/pkg/tests/tasks/observability/federated_openshift_monitoring_test.go +++ b/pkg/tests/tasks/observability/federated_openshift_monitoring_test.go @@ -29,13 +29,14 @@ import ( "github.com/maistra/maistra-test-tool/pkg/util/oc" "github.com/maistra/maistra-test-tool/pkg/util/prometheus" "github.com/maistra/maistra-test-tool/pkg/util/retry" - "github.com/maistra/maistra-test-tool/pkg/util/test" + + . "github.com/maistra/maistra-test-tool/pkg/util/test" ) // TestFederatedOpenShiftMonitoring requires OpenShift Monitoring stack to be enabled. // See the comment on TestOpenShiftMonitoring for help setting up on crc func TestFederatedOpenShiftMonitoring(t *testing.T) { - test.NewTest(t).Id("federated-openshift-monitoring-integration").Groups(test.Full, test.ARM).Run(func(t test.TestHelper) { + NewTest(t).Id("federated-openshift-monitoring-integration").Groups(Full, ARM, Disconnected).Run(func(t TestHelper) { meshValues := map[string]interface{}{ "Name": smcpName, "Version": env.GetSMCPVersion().String(), @@ -67,7 +68,7 @@ func TestFederatedOpenShiftMonitoring(t *testing.T) { oc.ApplyString(t, meshNamespace, federatedMonitor) t.LogStep("Wait until istio targets appear in the Prometheus") - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { resp := prometheus.ThanosTargets(t, monitoringNs) if !strings.Contains(resp, "serviceMonitor/istio-system/istio-federation") { t.Error("Istio Prometheus target serviceMonitor/istio-system/istio-federation are not ready") @@ -77,12 +78,12 @@ func TestFederatedOpenShiftMonitoring(t *testing.T) { t.LogStep("Generate some ingress traffic") oc.ApplyFile(t, ns.Foo, "https://raw.githubusercontent.com/maistra/istio/maistra-2.6/samples/httpbin/httpbin-gateway.yaml") httpbinURL := fmt.Sprintf("http://%s/headers", istio.GetIngressGatewayHost(t, meshNamespace)) - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { curl.Request(t, httpbinURL, nil, assert.ResponseStatus(http.StatusOK)) }) t.LogStep("Check istiod metrics") - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { resp := prometheus.ThanosQuery(t, monitoringNs, `pilot_info{mesh_id="unique-mesh-id"}`) if len(resp.Data.Result) == 0 { t.Errorf("No data points received from Prometheus API. Response status: %s", resp.Status) @@ -90,7 +91,7 @@ func TestFederatedOpenShiftMonitoring(t *testing.T) { }) t.LogStep("Check httpbin metrics") - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { resp := prometheus.ThanosQuery(t, monitoringNs, `istio_requests_total{mesh_id="unique-mesh-id"}`) if len(resp.Data.Result) == 0 { t.Errorf("No data points received from Prometheus API. Response status: %s", resp.Status) diff --git a/pkg/tests/tasks/observability/openshift_monitoring_test.go b/pkg/tests/tasks/observability/openshift_monitoring_test.go index 57fbe919..c44e8fb3 100644 --- a/pkg/tests/tasks/observability/openshift_monitoring_test.go +++ b/pkg/tests/tasks/observability/openshift_monitoring_test.go @@ -30,8 +30,9 @@ import ( "github.com/maistra/maistra-test-tool/pkg/util/pod" "github.com/maistra/maistra-test-tool/pkg/util/retry" "github.com/maistra/maistra-test-tool/pkg/util/shell" - "github.com/maistra/maistra-test-tool/pkg/util/test" "github.com/maistra/maistra-test-tool/pkg/util/version" + + . "github.com/maistra/maistra-test-tool/pkg/util/test" ) const ( @@ -45,7 +46,7 @@ const ( // crc config set memory 20480 // crc config set cpus 8 func TestOpenShiftMonitoring(t *testing.T) { - test.NewTest(t).Id("openshift-monitoring-integration").Groups(test.Full, test.ARM).Run(func(t test.TestHelper) { + NewTest(t).Id("openshift-monitoring-integration").Groups(Full, ARM, Disconnected).Run(func(t TestHelper) { smcpVer := env.GetSMCPVersion() if smcpVer.LessThan(version.SMCP_2_4) { t.Skip("integration with OpenShift Monitoring stack is not supported in OSSM older than v2.4.0") @@ -81,7 +82,7 @@ func TestOpenShiftMonitoring(t *testing.T) { t.LogStep("Grant cluster-monitoring-view to Kiali") oc.ApplyTemplate(t, meshNamespace, kialiClusterMonitoringView, kialiValues) - t.NewSubTest("SMCP manageNetworkPolicy false").Run(func(t test.TestHelper) { + t.NewSubTest("SMCP manageNetworkPolicy false").Run(func(t TestHelper) { t.Cleanup(func() { oc.DeleteFromString(t, meshNamespace, istiodMonitor) oc.DeleteFromString(t, ns.Foo, istioProxyMonitor) @@ -120,7 +121,7 @@ func TestOpenShiftMonitoring(t *testing.T) { generateTrafficAndcheckMetrics(t, kialiToken) }) - t.NewSubTest("SMCP manageNetworkPolicy true").Run(func(t test.TestHelper) { + t.NewSubTest("SMCP manageNetworkPolicy true").Run(func(t TestHelper) { t.Cleanup(func() { oc.DeleteFromString(t, meshNamespace, istiodMonitor) oc.DeleteFromString(t, ns.Foo, istioProxyMonitor) @@ -167,12 +168,12 @@ func TestOpenShiftMonitoring(t *testing.T) { }) } -func waitKialiAndVerifyIsReconciled(t test.TestHelper) { +func waitKialiAndVerifyIsReconciled(t TestHelper) { t.LogStep("Wait until Kiali is ready") oc.WaitCondition(t, meshNamespace, "Kiali", kialiName, "Successful") t.LogStep("Verify that Kiali was reconciled by Istio Operator") - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { accessibleNamespaces := shell.Executef(t, "oc get kiali %s -n %s -o jsonpath='{.spec.deployment.accessible_namespaces}'", kialiName, meshNamespace) if accessibleNamespaces != fmt.Sprintf(`["%s"]`, ns.Foo) { t.Errorf(`unexpected accessible namespaces: got '%s', expected: '["%s"]'`, accessibleNamespaces, ns.Foo) @@ -196,13 +197,13 @@ func waitKialiAndVerifyIsReconciled(t test.TestHelper) { }) } -func generateTrafficAndcheckMetrics(t test.TestHelper, thanosToken string) { +func generateTrafficAndcheckMetrics(t TestHelper, thanosToken string) { t.LogStep("Generate some ingress traffic") oc.ApplyFile(t, ns.Foo, "https://raw.githubusercontent.com/maistra/istio/maistra-2.6/samples/httpbin/httpbin-gateway.yaml") httpbinURL := fmt.Sprintf("http://%s/headers", istio.GetIngressGatewayHost(t, meshNamespace)) for i := 0; i < 5; i++ { - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { curl.Request(t, httpbinURL, nil, assert.ResponseStatus(http.StatusOK)) }) } @@ -214,8 +215,8 @@ func generateTrafficAndcheckMetrics(t test.TestHelper, thanosToken string) { checkMetricExists(t, ns.Foo, "istio_requests_total", thanosToken) } -func checkMetricExists(t test.TestHelper, ns, metricName, token string) { - retry.UntilSuccess(t, func(t test.TestHelper) { +func checkMetricExists(t TestHelper, ns, metricName, token string) { + retry.UntilSuccess(t, func(t TestHelper) { oc.Exec(t, pod.MatchingSelectorFirst("app.kubernetes.io/instance=thanos-querier", monitoringNs), "thanos-query", @@ -228,13 +229,13 @@ func checkMetricExists(t test.TestHelper, ns, metricName, token string) { }) } -func waitUntilAllPrometheusTargetReady(t test.TestHelper, token string) { +func waitUntilAllPrometheusTargetReady(t TestHelper, token string) { waitUntilPrometheusTargetReady(t, "serviceMonitor", meshNamespace, "istiod-monitor", token) waitUntilPrometheusTargetReady(t, "podMonitor", ns.Foo, "istio-proxies-monitor", token) } -func waitUntilPrometheusTargetReady(t test.TestHelper, monitorType string, ns string, targetName string, token string) { - retry.UntilSuccess(t, func(t test.TestHelper) { +func waitUntilPrometheusTargetReady(t TestHelper, monitorType string, ns string, targetName string, token string) { + retry.UntilSuccess(t, func(t TestHelper) { oc.Exec(t, pod.MatchingSelectorFirst("app.kubernetes.io/instance=thanos-querier", monitoringNs), "thanos-query", @@ -258,9 +259,9 @@ func prometheusActiveTargetQuery(token string) string { `curl -X GET -kG "https://localhost:9091/api/v1/targets?state=active" --data-urlencode "query=up" -H "Authorization: Bearer %s"`, token) } -func fetchKialiToken(t test.TestHelper) string { +func fetchKialiToken(t TestHelper) string { var kialiToken string - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { kialiToken = shell.Executef(t, "oc exec -n %s $(oc get pods -n %s -l app=kiali -o jsonpath='{.items[].metadata.name}') "+ "-- cat /var/run/secrets/kubernetes.io/serviceaccount/token", meshNamespace, meshNamespace) if strings.Contains(kialiToken, "Error") { diff --git a/pkg/tests/tasks/security/authentication/mtls_migration_test.go b/pkg/tests/tasks/security/authentication/mtls_migration_test.go index 297faf09..91993873 100644 --- a/pkg/tests/tasks/security/authentication/mtls_migration_test.go +++ b/pkg/tests/tasks/security/authentication/mtls_migration_test.go @@ -24,11 +24,12 @@ import ( "github.com/maistra/maistra-test-tool/pkg/util/ns" "github.com/maistra/maistra-test-tool/pkg/util/oc" "github.com/maistra/maistra-test-tool/pkg/util/retry" - "github.com/maistra/maistra-test-tool/pkg/util/test" + + . "github.com/maistra/maistra-test-tool/pkg/util/test" ) func TestMTlsMigration(t *testing.T) { - test.NewTest(t).Id("T19").Groups(test.Full, test.InterOp, test.ARM).Run(func(t test.TestHelper) { + NewTest(t).Id("T19").Groups(Full, InterOp, ARM, Disconnected).Run(func(t TestHelper) { meshNamespace := env.GetDefaultMeshNamespace() t.Cleanup(func() { @@ -49,7 +50,7 @@ func TestMTlsMigration(t *testing.T) { toNamespaces := []string{ns.Foo, ns.Bar} t.LogStep("Check connectivity from namespaces foo, bar, and legacy to namespace foo and bar") - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { for _, from := range fromNamespaces { for _, to := range toNamespaces { app.AssertSleepPodRequestSuccess(t, from, fmt.Sprintf("http://httpbin.%s:8000/ip", to)) @@ -57,12 +58,12 @@ func TestMTlsMigration(t *testing.T) { } }) - t.NewSubTest("mTLS enabled in foo").Run(func(t test.TestHelper) { + t.NewSubTest("mTLS enabled in foo").Run(func(t TestHelper) { t.LogStep("Apply strict mTLS in namespace foo") oc.ApplyString(t, "foo", PeerAuthenticationMTLSStrict) t.LogStep("Check connectivity from namespaces foo, bar, and legacy to namespace foo and bar (expect failure only from legacy to foo)") - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { for _, from := range fromNamespaces { for _, to := range toNamespaces { url := fmt.Sprintf("http://httpbin.%s:8000/ip", to) @@ -76,7 +77,7 @@ func TestMTlsMigration(t *testing.T) { }) }) - t.NewSubTest("mTLS enabled globally").Run(func(t test.TestHelper) { + t.NewSubTest("mTLS enabled globally").Run(func(t TestHelper) { t.LogStep("Apply strict mTLS for the entire mesh") oc.ApplyString(t, meshNamespace, PeerAuthenticationMTLSStrict) t.Cleanup(func() { @@ -84,7 +85,7 @@ func TestMTlsMigration(t *testing.T) { }) t.LogStep("Check connectivity from namespaces foo, bar, and legacy to namespace foo and bar (expect failure from legacy)") - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { for _, from := range fromNamespaces { for _, to := range toNamespaces { url := fmt.Sprintf("http://httpbin.%s:8000/ip", to) diff --git a/pkg/tests/tasks/security/authorization/deny_test.go b/pkg/tests/tasks/security/authorization/deny_test.go index c3c1f431..60937d59 100644 --- a/pkg/tests/tasks/security/authorization/deny_test.go +++ b/pkg/tests/tasks/security/authorization/deny_test.go @@ -20,11 +20,12 @@ import ( "github.com/maistra/maistra-test-tool/pkg/app" "github.com/maistra/maistra-test-tool/pkg/tests/ossm" "github.com/maistra/maistra-test-tool/pkg/util/oc" - "github.com/maistra/maistra-test-tool/pkg/util/test" + + . "github.com/maistra/maistra-test-tool/pkg/util/test" ) func TestAuthorizationDenyAllow(t *testing.T) { - test.NewTest(t).Id("T23").Groups(test.Full, test.InterOp, test.ARM).Run(func(t test.TestHelper) { + NewTest(t).Id("T23").Groups(Full, InterOp, ARM, Disconnected).Run(func(t TestHelper) { ns := "foo" curlOptsAdmin := app.CurlOpts{Headers: []string{"x-token: admin"}} curlOptsGuest := app.CurlOpts{Headers: []string{"x-token: guest"}} @@ -42,7 +43,7 @@ func TestAuthorizationDenyAllow(t *testing.T) { t.LogStep("Check if httpbin returns 200 OK when no authorization policies are in place") app.AssertSleepPodRequestSuccess(t, ns, "http://httpbin:8000/ip") - t.NewSubTest("explicitly deny request").Run(func(t test.TestHelper) { + t.NewSubTest("explicitly deny request").Run(func(t TestHelper) { t.Cleanup(func() { oc.DeleteFromString(t, ns, DenyGETPolicy) }) @@ -56,7 +57,7 @@ func TestAuthorizationDenyAllow(t *testing.T) { app.AssertSleepPodRequestSuccess(t, ns, "http://httpbin:8000/post", app.CurlOpts{Method: "POST"}) }) - t.NewSubTest("deny request header").Run(func(t test.TestHelper) { + t.NewSubTest("deny request header").Run(func(t TestHelper) { t.Cleanup(func() { oc.DeleteFromString(t, ns, DenyHeaderNotAdminPolicy) }) @@ -70,7 +71,7 @@ func TestAuthorizationDenyAllow(t *testing.T) { app.AssertSleepPodRequestForbidden(t, ns, "http://httpbin:8000/get", curlOptsGuest) }) - t.NewSubTest("allow request path").Run(func(t test.TestHelper) { + t.NewSubTest("allow request path").Run(func(t TestHelper) { t.Cleanup(func() { oc.DeleteFromString(t, ns, DenyHeaderNotAdminPolicy) oc.DeleteFromString(t, ns, AllowPathIPPolicy) diff --git a/pkg/tests/tasks/security/authorization/ext_auth_test.go b/pkg/tests/tasks/security/authorization/ext_auth_test.go index e8b34a25..2b5ecce9 100644 --- a/pkg/tests/tasks/security/authorization/ext_auth_test.go +++ b/pkg/tests/tasks/security/authorization/ext_auth_test.go @@ -217,7 +217,7 @@ spec: } func TestEnvoyExtAuthzRequestPayloadTooLarge(t *testing.T) { - NewTest(t).Groups(Full, Disconnected, ARM).Run(func(t TestHelper) { + NewTest(t).Groups(Full, ARM).Run(func(t TestHelper) { t.Log("Verify that Istio proxy doesn't fail with 'Request payload too large' error") t.Log("Reference: https://issues.redhat.com/browse/OSSM-5850") diff --git a/pkg/tests/tasks/security/authorization/http_test.go b/pkg/tests/tasks/security/authorization/http_test.go index 2ae7615c..dcd7be9c 100644 --- a/pkg/tests/tasks/security/authorization/http_test.go +++ b/pkg/tests/tasks/security/authorization/http_test.go @@ -23,12 +23,13 @@ import ( "github.com/maistra/maistra-test-tool/pkg/util/curl" "github.com/maistra/maistra-test-tool/pkg/util/oc" "github.com/maistra/maistra-test-tool/pkg/util/retry" - "github.com/maistra/maistra-test-tool/pkg/util/test" + + . "github.com/maistra/maistra-test-tool/pkg/util/test" ) // TestAuthorizationHTTPTraffic validates authorization policies for HTTP traffic. func TestAuthorizationHTTPTraffic(t *testing.T) { - test.NewTest(t).Id("T20").Groups(test.Full, test.ARM, test.InterOp).Run(func(t test.TestHelper) { + NewTest(t).Id("T20").Groups(Full, ARM, InterOp, Disconnected).Run(func(t TestHelper) { ns := "bookinfo" t.Cleanup(func() { oc.Patch(t, @@ -56,7 +57,7 @@ func TestAuthorizationHTTPTraffic(t *testing.T) { productPageURL := app.BookinfoProductPageURL(t, meshNamespace) - t.NewSubTest("deny all http traffic to bookinfo").Run(func(t test.TestHelper) { + t.NewSubTest("deny all http traffic to bookinfo").Run(func(t TestHelper) { t.Cleanup(func() { oc.DeleteFromString(t, ns, DenyAllPolicy) }) @@ -64,7 +65,7 @@ func TestAuthorizationHTTPTraffic(t *testing.T) { oc.ApplyString(t, ns, DenyAllPolicy) t.LogStep("Verify that GET request is denied") - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { curl.Request(t, productPageURL, nil, @@ -73,7 +74,7 @@ func TestAuthorizationHTTPTraffic(t *testing.T) { }) }) - t.NewSubTest("only allow HTTP GET request to the productpage workload").Run(func(t test.TestHelper) { + t.NewSubTest("only allow HTTP GET request to the productpage workload").Run(func(t TestHelper) { t.Cleanup(func() { oc.DeleteFromString(t, ns, ProductpageGETPolicy) oc.DeleteFromString(t, ns, DenyAllPolicy) @@ -83,7 +84,7 @@ func TestAuthorizationHTTPTraffic(t *testing.T) { oc.ApplyString(t, ns, ProductpageGETPolicy) t.LogStep("Verify that GET request to the productpage is allowed and fetching other services is denied") - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { curl.Request(t, productPageURL, nil, @@ -93,7 +94,7 @@ func TestAuthorizationHTTPTraffic(t *testing.T) { }) }) - t.NewSubTest("allow HTTP GET requests to all bookinfo workloads").Run(func(t test.TestHelper) { + t.NewSubTest("allow HTTP GET requests to all bookinfo workloads").Run(func(t TestHelper) { t.Cleanup(func() { oc.DeleteFromString(t, ns, RatingsGETPolicy) oc.DeleteFromString(t, ns, ReviewsGETPolicy) @@ -109,7 +110,7 @@ func TestAuthorizationHTTPTraffic(t *testing.T) { oc.ApplyString(t, ns, RatingsGETPolicy) t.LogStep("Verify that GET requests are allowed to all bookinfo workloads") - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { curl.Request(t, productPageURL, nil, diff --git a/pkg/tests/tasks/security/authorization/trust_domain_test.go b/pkg/tests/tasks/security/authorization/trust_domain_test.go index 084d30be..455fb20c 100644 --- a/pkg/tests/tasks/security/authorization/trust_domain_test.go +++ b/pkg/tests/tasks/security/authorization/trust_domain_test.go @@ -27,7 +27,7 @@ import ( ) func TestTrustDomainMigration(t *testing.T) { - NewTest(t).Id("T24").Groups(Full, InterOp, ARM).Run(func(t TestHelper) { + NewTest(t).Id("T24").Groups(Full, InterOp, ARM, Disconnected).Run(func(t TestHelper) { foo := "foo" bar := "bar" httpbinUrl := "http://httpbin.foo:8000/ip" diff --git a/pkg/tests/tasks/security/certificate/external_ca_test.go b/pkg/tests/tasks/security/certificate/external_ca_test.go index 3a507306..877600ba 100644 --- a/pkg/tests/tasks/security/certificate/external_ca_test.go +++ b/pkg/tests/tasks/security/certificate/external_ca_test.go @@ -27,11 +27,12 @@ import ( "github.com/maistra/maistra-test-tool/pkg/util/oc" "github.com/maistra/maistra-test-tool/pkg/util/pod" "github.com/maistra/maistra-test-tool/pkg/util/retry" - "github.com/maistra/maistra-test-tool/pkg/util/test" + + . "github.com/maistra/maistra-test-tool/pkg/util/test" ) func TestExternalCertificate(t *testing.T) { - test.NewTest(t).Id("T17").Groups(test.Full, test.ARM, test.InterOp).Run(func(t test.TestHelper) { + NewTest(t).Id("T17").Groups(Full, ARM, InterOp, Disconnected).Run(func(t TestHelper) { const ns = "bookinfo" t.Cleanup(func() { @@ -65,7 +66,7 @@ func TestExternalCertificate(t *testing.T) { app.InstallAndWaitReady(t, app.BookinfoWithMTLS(ns)) t.LogStep("Wait for response from productpage app") - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { curl.Request(t, app.BookinfoProductPageURL(t, meshNamespace), nil, assert.ResponseStatus(200)) @@ -74,7 +75,7 @@ func TestExternalCertificate(t *testing.T) { t.LogStep("Retrieve certificates from bookinfo details service") var returnedCerts []*x509.Certificate - retry.UntilSuccess(t, func(t test.TestHelper) { + retry.UntilSuccess(t, func(t TestHelper) { opensslOutput := oc.Exec(t, pod.MatchingSelector("app=productpage", ns), "istio-proxy", `openssl s_client -showcerts -connect details:9080 || true`) // the "|| true" is needed until oc.Exec can ignore return codes @@ -93,7 +94,7 @@ func TestExternalCertificate(t *testing.T) { }) } -func verifyContainsCerts(t test.TestHelper, actualCerts, expectedCerts []*x509.Certificate, successMsg, failureMsg string) { +func verifyContainsCerts(t TestHelper, actualCerts, expectedCerts []*x509.Certificate, successMsg, failureMsg string) { t.T().Helper() // Make a copy of expectedCerts because we will clobber it @@ -118,7 +119,7 @@ func verifyContainsCerts(t test.TestHelper, actualCerts, expectedCerts []*x509.C t.Error(failureMsg) } -func verifyCertificate(t test.TestHelper, cert *x509.Certificate, rootCerts, intermediateCerts []*x509.Certificate, successMsg, failureMsg string) { +func verifyCertificate(t TestHelper, cert *x509.Certificate, rootCerts, intermediateCerts []*x509.Certificate, successMsg, failureMsg string) { t.T().Helper() rootCertPool := x509.NewCertPool() for _, c := range rootCerts { @@ -149,7 +150,7 @@ func verifyCertificate(t test.TestHelper, cert *x509.Certificate, rootCerts, int } } -func readPemCertificatesFromFile(t test.TestHelper, path string) []*x509.Certificate { +func readPemCertificatesFromFile(t TestHelper, path string) []*x509.Certificate { t.T().Helper() bytes, err := os.ReadFile(path) if err != nil { @@ -158,13 +159,13 @@ func readPemCertificatesFromFile(t test.TestHelper, path string) []*x509.Certifi return readPemCertificates(t, bytes) } -func readPemCertificatesFromText(t test.TestHelper, text string) []*x509.Certificate { +func readPemCertificatesFromText(t TestHelper, text string) []*x509.Certificate { t.T().Helper() return readPemCertificates(t, []byte(text)) } -func readPemCertificates(t test.TestHelper, pemData []byte) []*x509.Certificate { +func readPemCertificates(t TestHelper, pemData []byte) []*x509.Certificate { t.T().Helper() var certificates []*x509.Certificate for { diff --git a/pkg/tests/tasks/traffic/egress/access_external_services_test.go b/pkg/tests/tasks/traffic/egress/access_external_services_test.go index 7bacf583..5991e00a 100644 --- a/pkg/tests/tasks/traffic/egress/access_external_services_test.go +++ b/pkg/tests/tasks/traffic/egress/access_external_services_test.go @@ -26,11 +26,12 @@ import ( "github.com/maistra/maistra-test-tool/pkg/util/ns" "github.com/maistra/maistra-test-tool/pkg/util/oc" "github.com/maistra/maistra-test-tool/pkg/util/pod" - "github.com/maistra/maistra-test-tool/pkg/util/test" + + . "github.com/maistra/maistra-test-tool/pkg/util/test" ) func TestAccessExternalServices(t *testing.T) { - test.NewTest(t).Id("T11").Groups(test.Full, test.InterOp, test.ARM).Run(func(t test.TestHelper) { + NewTest(t).Id("T11").Groups(Full, InterOp, ARM, Disconnected).Run(func(t TestHelper) { smcpName := env.GetDefaultSMCPName() t.Cleanup(func() { app.Uninstall(t, app.Sleep(ns.Bookinfo)) @@ -80,7 +81,7 @@ func TestAccessExternalServices(t *testing.T) { t.LogStep("Make request to external httpbin from sleep again, and expect it denied") app.AssertSleepPodRequestFailure(t, ns.Bookinfo, httpbinHeadersUrl) - t.NewSubTest("allow request to external httpbin after applying ServiceEntry").Run(func(t test.TestHelper) { + t.NewSubTest("allow request to external httpbin after applying ServiceEntry").Run(func(t TestHelper) { t.Cleanup(func() { oc.DeleteFromString(t, ns.Bookinfo, httpbinServiceEntry) }) diff --git a/pkg/tests/tasks/traffic/fault_injection_test.go b/pkg/tests/tasks/traffic/fault_injection_test.go index 500be82e..25687674 100644 --- a/pkg/tests/tasks/traffic/fault_injection_test.go +++ b/pkg/tests/tasks/traffic/fault_injection_test.go @@ -40,7 +40,7 @@ var ( ) func TestFaultInjection(t *testing.T) { - NewTest(t).Id("T2").Groups(Full, InterOp, ARM).Run(func(t TestHelper) { + NewTest(t).Id("T2").Groups(Full, InterOp, ARM, Disconnected).Run(func(t TestHelper) { t.Cleanup(func() { oc.RecreateNamespace(t, ns.Bookinfo) diff --git a/pkg/tests/tasks/traffic/ingress/gatewayapi_test.go b/pkg/tests/tasks/traffic/ingress/gatewayapi_test.go index c3e30814..f6ff5325 100644 --- a/pkg/tests/tasks/traffic/ingress/gatewayapi_test.go +++ b/pkg/tests/tasks/traffic/ingress/gatewayapi_test.go @@ -39,7 +39,7 @@ type EnvVar struct { } func TestGatewayApi(t *testing.T) { - NewTest(t).Id("T41").Groups(Full, InterOp, ARM).Run(func(t TestHelper) { + NewTest(t).Id("T41").Groups(Full, InterOp, ARM, Disconnected).Run(func(t TestHelper) { if env.GetSMCPVersion().LessThan(version.SMCP_2_3) { t.Skip("TestGatewayApi was added in v2.3") } diff --git a/pkg/tests/tasks/traffic/ingress/ingress_gateways_test.go b/pkg/tests/tasks/traffic/ingress/ingress_gateways_test.go index 06cc8234..d651b758 100644 --- a/pkg/tests/tasks/traffic/ingress/ingress_gateways_test.go +++ b/pkg/tests/tasks/traffic/ingress/ingress_gateways_test.go @@ -34,7 +34,7 @@ import ( ) func TestIngressGateways(t *testing.T) { - NewTest(t).Id("T8").Groups(Full, InterOp, ARM).Run(func(t TestHelper) { + NewTest(t).Id("T8").Groups(Full, InterOp, ARM, Disconnected).Run(func(t TestHelper) { t.Cleanup(func() { oc.RecreateNamespace(t, ns.Bookinfo) diff --git a/pkg/tests/tasks/traffic/request_routing_test.go b/pkg/tests/tasks/traffic/request_routing_test.go index f01be2d3..0904e271 100644 --- a/pkg/tests/tasks/traffic/request_routing_test.go +++ b/pkg/tests/tasks/traffic/request_routing_test.go @@ -30,7 +30,7 @@ import ( ) func TestRequestRouting(t *testing.T) { - NewTest(t).Id("T1").Groups(Smoke, Full, InterOp, ARM).Run(func(t TestHelper) { + NewTest(t).Id("T1").Groups(Smoke, Full, InterOp, ARM, Disconnected).Run(func(t TestHelper) { t.Cleanup(func() { oc.RecreateNamespace(t, ns.Bookinfo) diff --git a/pkg/tests/tasks/traffic/request_timeouts_test.go b/pkg/tests/tasks/traffic/request_timeouts_test.go index 42d13e3f..19603754 100644 --- a/pkg/tests/tasks/traffic/request_timeouts_test.go +++ b/pkg/tests/tasks/traffic/request_timeouts_test.go @@ -35,7 +35,7 @@ import ( var reviewTimeout string func TestRequestTimeouts(t *testing.T) { - NewTest(t).Id("T5").Groups(Full, InterOp, ARM).Run(func(t TestHelper) { + NewTest(t).Id("T5").Groups(Full, InterOp, ARM, Disconnected).Run(func(t TestHelper) { t.Cleanup(func() { oc.RecreateNamespace(t, ns.Bookinfo) diff --git a/pkg/tests/tasks/traffic/traffic_mirroring_test.go b/pkg/tests/tasks/traffic/traffic_mirroring_test.go index 5340492a..f65b80d2 100644 --- a/pkg/tests/tasks/traffic/traffic_mirroring_test.go +++ b/pkg/tests/tasks/traffic/traffic_mirroring_test.go @@ -29,7 +29,7 @@ import ( ) func TestMirroring(t *testing.T) { - NewTest(t).Id("T7").Groups(Full, InterOp, ARM).Run(func(t TestHelper) { + NewTest(t).Id("T7").Groups(Full, InterOp, ARM, Disconnected).Run(func(t TestHelper) { t.Cleanup(func() { oc.RecreateNamespace(t, ns.Bookinfo) diff --git a/pkg/tests/tasks/traffic/traffic_shifting_test.go b/pkg/tests/tasks/traffic/traffic_shifting_test.go index 44c4323e..1b5ba2b8 100644 --- a/pkg/tests/tasks/traffic/traffic_shifting_test.go +++ b/pkg/tests/tasks/traffic/traffic_shifting_test.go @@ -35,7 +35,7 @@ import ( ) func TestTrafficShifting(t *testing.T) { - NewTest(t).Id("T3").Groups(Full, InterOp, ARM).Run(func(t TestHelper) { + NewTest(t).Id("T3").Groups(Full, InterOp, ARM, Disconnected).Run(func(t TestHelper) { t.Cleanup(func() { oc.RecreateNamespace(t, ns.Bookinfo)