From 00e1cb42f6ee68077901910a6d9d874410937a15 Mon Sep 17 00:00:00 2001 From: Matej Kralik Date: Thu, 15 Aug 2024 15:09:37 +0200 Subject: [PATCH] Remove oc replace (#728) --- pkg/tests/ossm/bug_istiopods_test.go | 2 +- pkg/tests/ossm/discovery_selectors_test.go | 2 +- pkg/tests/ossm/setup.go | 2 +- pkg/tests/ossm/tempo_tracing_test.go | 6 +++--- pkg/util/oc/oc.go | 10 ---------- pkg/util/oc/oc_struct.go | 19 ------------------- 6 files changed, 6 insertions(+), 35 deletions(-) diff --git a/pkg/tests/ossm/bug_istiopods_test.go b/pkg/tests/ossm/bug_istiopods_test.go index ca360f3f..b85ffe8d 100644 --- a/pkg/tests/ossm/bug_istiopods_test.go +++ b/pkg/tests/ossm/bug_istiopods_test.go @@ -61,7 +61,7 @@ func TestIstiodPodFailsWithValidationMessages(t *testing.T) { t.Log("Verify that Istio pod is not failing when validationMessages was enabled") oc.RecreateNamespace(t, meshNamespace) - oc.ReplaceOrApplyString(t, meshNamespace, template.Run(t, validationMessagesSMCP, DefaultSMCP())) + oc.ApplyString(t, meshNamespace, template.Run(t, validationMessagesSMCP, DefaultSMCP())) t.Cleanup(func() { oc.RecreateNamespace(t, meshNamespace) }) diff --git a/pkg/tests/ossm/discovery_selectors_test.go b/pkg/tests/ossm/discovery_selectors_test.go index 344c86c6..5992e349 100644 --- a/pkg/tests/ossm/discovery_selectors_test.go +++ b/pkg/tests/ossm/discovery_selectors_test.go @@ -41,7 +41,7 @@ func TestDiscoverySelectors(t *testing.T) { t.LogStep("Apply cluster-wide SMCP and standard SMMR") oc.RecreateNamespace(t, meshNamespace) oc.ApplyString(t, meshNamespace, smmr) - oc.ReplaceOrApplyString(t, meshNamespace, template.Run(t, clusterWideSMCP, DefaultSMCP())) + oc.ApplyString(t, meshNamespace, template.Run(t, clusterWideSMCP, DefaultSMCP())) oc.WaitSMCPReady(t, meshNamespace, DefaultSMCP().Name) oc.WaitSMMRReady(t, meshNamespace) diff --git a/pkg/tests/ossm/setup.go b/pkg/tests/ossm/setup.go index f5d1cb5b..d0948208 100644 --- a/pkg/tests/ossm/setup.go +++ b/pkg/tests/ossm/setup.go @@ -111,7 +111,7 @@ func InstallSMCPVersion(t test.TestHelper, ns string, ver version.Version) { } func InstallSMCPCustom(t test.TestHelper, ns string, smcp SMCP) { - oc.ReplaceOrApplyString(t, ns, getSMCPManifestCustom(t, smcp)) + oc.ApplyString(t, ns, getSMCPManifestCustom(t, smcp)) } func DeleteSMCPVersion(t test.TestHelper, ns string, ver version.Version) { diff --git a/pkg/tests/ossm/tempo_tracing_test.go b/pkg/tests/ossm/tempo_tracing_test.go index e0fc2590..e33577a6 100644 --- a/pkg/tests/ossm/tempo_tracing_test.go +++ b/pkg/tests/ossm/tempo_tracing_test.go @@ -60,7 +60,7 @@ func TestTempoTracing(t *testing.T) { oc.RecreateNamespace(t, meshNamespace) t.LogStep("Install SMCP with otel extensionProviders") - oc.ReplaceOrApplyString(t, meshNamespace, template.Run(t, externalTracingSMCP, meshValues)) + oc.ApplyString(t, meshNamespace, template.Run(t, externalTracingSMCP, meshValues)) oc.WaitSMCPReady(t, meshNamespace, smcpName) oc.ApplyString(t, meshNamespace, GetSMMRTemplate()) oc.WaitSMMRReady(t, meshNamespace) @@ -69,14 +69,14 @@ func TestTempoTracing(t *testing.T) { app.InstallAndWaitReady(t, app.Bookinfo(ns.Bookinfo)) t.LogStep("Create open telemetry collector in bookinfo namespace") - oc.ReplaceOrApplyString(t, ns.Bookinfo, template.Run(t, otel, map[string]interface{}{"TracingNamespace": tempo.GetTracingNamespace()})) + oc.ApplyString(t, ns.Bookinfo, template.Run(t, otel, map[string]interface{}{"TracingNamespace": tempo.GetTracingNamespace()})) retry.UntilSuccess(t, func(t test.TestHelper) { t.T().Helper() oc.WaitPodReady(t, pod.MatchingSelector("app.kubernetes.io/component=opentelemetry-collector", ns.Bookinfo)) }) t.LogStep("Create telemetry cr in SMCP namespace") - oc.ReplaceOrApplyString(t, meshNamespace, template.Run(t, telemetry, nil)) + oc.ApplyString(t, meshNamespace, template.Run(t, telemetry, nil)) t.LogStep("Generate request to product page") curl.Request(t, app.BookinfoProductPageURL(t, meshNamespace), nil) diff --git a/pkg/util/oc/oc.go b/pkg/util/oc/oc.go index 2dc14f8a..5699d210 100644 --- a/pkg/util/oc/oc.go +++ b/pkg/util/oc/oc.go @@ -25,21 +25,11 @@ func GetOCPVersion(t test.TestHelper) string { return DefaultOC.GetOCPVersion(t) } -func ReplaceOrApplyString(t test.TestHelper, ns string, yaml string) { - t.T().Helper() - DefaultOC.ReplaceOrApplyString(t, ns, yaml) -} - func ApplyTemplate(t test.TestHelper, ns string, template string, input interface{}) { t.T().Helper() DefaultOC.ApplyTemplateString(t, ns, template, input) } -func ReplaceOrApplyTemplate(t test.TestHelper, ns string, template string, input interface{}) { - t.T().Helper() - DefaultOC.ReplaceOrApplyTemplate(t, ns, template, input) -} - func DeleteFromTemplate(t test.TestHelper, ns string, yaml string, data interface{}) { t.T().Helper() DefaultOC.DeleteFromTemplate(t, ns, yaml, data) diff --git a/pkg/util/oc/oc_struct.go b/pkg/util/oc/oc_struct.go index 1fbe2139..73bf88f0 100644 --- a/pkg/util/oc/oc_struct.go +++ b/pkg/util/oc/oc_struct.go @@ -64,25 +64,6 @@ func (o OC) GetOCPVersion(t test.TestHelper) string { return "" } -func (o OC) ReplaceOrApplyString(t test.TestHelper, ns string, yaml string) { - t.T().Helper() - o.withKubeconfig(t, func() { - t.T().Helper() - output := shell.ExecuteWithInput(t, fmt.Sprintf("oc %s replace -f - || echo 'error captured'", nsFlag(ns)), yaml) - if strings.Contains(output, "NotFound") { - shell.ExecuteWithInput(t, fmt.Sprintf("oc %s apply -f -", nsFlag(ns)), yaml) - } - }) -} - -func (o OC) ReplaceOrApplyTemplate(t test.TestHelper, ns string, tmpl string, input interface{}) { - t.T().Helper() - o.withKubeconfig(t, func() { - t.T().Helper() - o.ReplaceOrApplyString(t, ns, template.Run(t, tmpl, input)) - }) -} - func (o OC) DeleteFromTemplate(t test.TestHelper, ns string, tmpl string, input interface{}) { t.T().Helper() o.DeleteFromString(t, ns, template.Run(t, tmpl, input))