Skip to content

Commit

Permalink
OSSM-8252: Add pod locality controller fails to update pod test
Browse files Browse the repository at this point in the history
  • Loading branch information
unsortedhashsets committed Oct 17, 2024
1 parent 4623dc6 commit 3f12059
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions pkg/tests/ossm/bug_istiopods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package ossm

import (
"fmt"
"regexp"
"strings"
"testing"
"time"
Expand All @@ -25,7 +26,9 @@ 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/shell"
"github.com/maistra/maistra-test-tool/pkg/util/template"

. "github.com/maistra/maistra-test-tool/pkg/util/test"
)

Expand Down Expand Up @@ -56,6 +59,65 @@ func TestIstiodPodFailsAfterRestarts(t *testing.T) {
})
}

func TestControllerFailsToUpdatePod(t *testing.T) {
NewTest(t).Groups(Full, Disconnected, 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")

namespaces := util.GenerateStrings("test-", 100)

t.Cleanup(func() {
oc.DeleteNamespace(t, namespaces...)
oc.RecreateNamespace(t, meshNamespace)
})

DeployControlPlane(t)

t.LogStep("Add namespaces to the SMMR")
oc.ApplyString(t, meshNamespace, createSMMRManifest(namespaces...))

istioOperatorPodName := oc.GetResouceNameByLabel(t, "openshift-operators", "pod", "name=istio-operator")

// Initially assumed 1 iteration, however, as issue can be flaky it could be increased up to 5 iterations
count := 2
for i := 1; i < count; i++ {
t.LogStepf("Create/Recreate 100 Namespaces, attempt #%d", i)
oc.RecreateNamespace(t, namespaces...)

t.LogStepf("Check istio-operator logs for 'Error updating pod's labels', attempt #%d", i)
output := shell.Execute(t,
fmt.Sprintf("oc logs %s -n openshift-operators", istioOperatorPodName),
assert.OutputDoesNotContain(
"Error updating pod's labels",
"Found no updating pod's labels error",
"Expected to find no error updating pod's labels, but got",
))

t.LogStepf("Check istio-operator logs for 'error adding member-of label' errors, attempt #%d", i)
re := regexp.MustCompile(`error adding member-of label to namespace test-(\d+)`)
matches := re.FindStringSubmatch(output)
if len(matches) > 1 {
namespaceNumber := matches[1]
successMessage := fmt.Sprintf(`Added member-of label to namespace","ServiceMeshMember":"test-%s/default","namespace":"test-%s`, namespaceNumber, namespaceNumber)
if strings.Contains(output, successMessage) {
t.LogSuccessf("Found error and success message for namespace test-%s: %s", namespaceNumber, successMessage)
break
} else {
t.Log(output)
t.Fatalf("Was not found success message after error for namespace test-%s: %s", namespaceNumber, successMessage)
}
} else {
if count < 6 {
count++
t.Logf("Was not found any 'error adding member-of label' error, repeat (max 5), attempt #%d", i)
} else {
t.Logf("Was not found any 'error adding member-of label' error, stop test, attempt #%d", i)
}
}
}
})
}

func TestIstiodPodFailsWithValidationMessages(t *testing.T) {
NewTest(t).Groups(Full, Disconnected, ARM).Run(func(t TestHelper) {
t.Log("Verify that Istio pod is not failing when validationMessages was enabled")
Expand Down

0 comments on commit 3f12059

Please sign in to comment.