Skip to content

Commit

Permalink
Remove oc replace (#728)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkralik3 authored Aug 15, 2024
1 parent 01c9d0a commit 00e1cb4
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 35 deletions.
2 changes: 1 addition & 1 deletion pkg/tests/ossm/bug_istiopods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/tests/ossm/discovery_selectors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion pkg/tests/ossm/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions pkg/tests/ossm/tempo_tracing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
10 changes: 0 additions & 10 deletions pkg/util/oc/oc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 0 additions & 19 deletions pkg/util/oc/oc_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 00e1cb4

Please sign in to comment.