Skip to content

Commit 20f00e6

Browse files
authored
updated service mesh (#291)
* updated service mesh * updated best practice to be 5.2 * updated name of the function to be findIstioNamespace
1 parent ae27d1d commit 20f00e6

File tree

5 files changed

+31
-23
lines changed

5 files changed

+31
-23
lines changed

CATALOG.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -592,18 +592,18 @@ Description|http://test-network-function.com/testcases/platform-alteration/ocp-l
592592
Result Type|normative
593593
Suggested Remediation|Please update your cluster to a version that is generally available.
594594
Best Practice Reference|https://connect.redhat.com/sites/default/files/2022-05/Cloud%20Native%20Network%20Function%20Requirements%201-3.pdf Section x.x
595-
#### service-mesh
595+
#### service-mesh-usage
596596

597597
Property|Description
598598
---|---
599-
Test Case Name|service-mesh
600-
Test Case Label|platform-alteration-service-mesh
601-
Unique ID|http://test-network-function.com/testcases/platform-alteration/service-mesh
599+
Test Case Name|service-mesh-usage
600+
Test Case Label|platform-alteration-service-mesh-usage
601+
Unique ID|http://test-network-function.com/testcases/platform-alteration/service-mesh-usage
602602
Version|v1.0.0
603-
Description|http://test-network-function.com/testcases/platform-alteration/service-mesh verifies if service mesh is exist.
603+
Description|http://test-network-function.com/testcases/platform-alteration/service-mesh-usage verifies whether, if available, service mesh is actually being used by the CNF pods
604604
Result Type|normative
605-
Suggested Remediation|
606-
Best Practice Reference|https://connect.redhat.com/sites/default/files/2022-05/Cloud%20Native%20Network%20Function%20Requirements%201-3.pdf Section 6.2
605+
Suggested Remediation|Make sure all the CNF pods are using service mesh if the cluster provides it.
606+
Best Practice Reference|https://connect.redhat.com/sites/default/files/2022-05/Cloud%20Native%20Network%20Function%20Requirements%201-3.pdf Section 5.2
607607
#### sysctl-config
608608

609609
Property|Description

cnf-certification-test/identifiers/identifiers.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ var (
272272
}
273273
// TestServiceMesh checks if service mesh is exist.
274274
TestServiceMeshIdentifier = claim.Identifier{
275-
Url: formTestURL(common.PlatformAlterationTestKey, "service-mesh"),
275+
Url: formTestURL(common.PlatformAlterationTestKey, "service-mesh-usage"),
276276
Version: versionOne,
277277
}
278278
// TestOCPLifecycleIdentifier ensures the OCP version of the cluster is within the valid lifecycle status
@@ -773,9 +773,9 @@ the changes for you.`,
773773
Identifier: TestServiceMeshIdentifier,
774774
Type: normativeResult,
775775
Description: formDescription(TestServiceMeshIdentifier,
776-
`verifies if service mesh is exist.`),
777-
Remediation: ``,
778-
BestPracticeReference: bestPracticeDocV1dot3URL + " Section 6.2",
776+
`verifies whether, if available, service mesh is actually being used by the CNF pods`),
777+
Remediation: `Make sure all the CNF pods are using service mesh if the cluster provides it.`,
778+
BestPracticeReference: bestPracticeDocV1dot3URL + " Section 5.2",
779779
},
780780
TestScalingIdentifier: {
781781
Identifier: TestScalingIdentifier,

cnf-certification-test/platform/suite.go

+15-8
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import (
4343
)
4444

4545
const (
46-
istio = "istio-proxy"
46+
istioContainerName = "istio-proxy"
4747
)
4848

4949
//
@@ -121,7 +121,7 @@ var _ = ginkgo.Describe(common.PlatformAlterationTestKey, func() {
121121

122122
testID = identifiers.XformToGinkgoItIdentifier(identifiers.TestServiceMeshIdentifier)
123123
ginkgo.It(testID, ginkgo.Label(testID), func() {
124-
testhelper.SkipIfEmptyAny(ginkgo.Skip, env.DebugPods)
124+
testhelper.SkipIfEmptyAny(ginkgo.Skip, env.Pods)
125125
TestServiceMesh(&env)
126126
})
127127

@@ -137,21 +137,28 @@ func TestServiceMesh(env *provider.TestEnvironment) {
137137
// check if istio is installed
138138
if !env.IstioServiceMesh {
139139
tnf.ClaimFilePrintf("Istio is not installed")
140-
return
140+
ginkgo.Skip("No service mesh detected.")
141141
}
142142
tnf.ClaimFilePrintf("Istio is installed")
143143

144144
var badPods []string
145145
for _, put := range env.Pods {
146+
istioProxyFound := false
146147
for _, cut := range put.Containers {
147-
if cut.Status.Name == istio {
148-
tnf.ClaimFilePrintf("For pods %s ,ns %s have service mesh", cut.Podname, cut.Namespace)
149-
} else {
150-
badPods = append(badPods, "pod "+cut.Podname+" ,ns "+cut.Namespace+" do not have service mesh")
148+
if cut.Status.Name == istioContainerName {
149+
tnf.ClaimFilePrintf("Istio proxy container found on %s", put)
150+
istioProxyFound = true
151+
break
151152
}
152153
}
154+
if !istioProxyFound {
155+
badPods = append(badPods, put.String())
156+
}
157+
}
158+
if n := len(badPods); n > 0 {
159+
tnf.ClaimFilePrintf("Pods not using service mesh: %v", badPods)
160+
ginkgo.Fail(fmt.Sprintf("Found %d pods that do not use service mesh.", n))
153161
}
154-
logrus.Println("bad pods ", badPods)
155162
}
156163

157164
// testContainersFsDiff test that all CUT didn't install new packages are starting

pkg/autodiscover/autodiscover.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func DoAutoDiscover() DiscoveredTestData {
117117
if err != nil {
118118
logrus.Fatalln("Cannot get the K8s version")
119119
}
120-
data.Istio = findnamespace(oc.K8sClient.CoreV1())
120+
data.Istio = findIstioNamespace(oc.K8sClient.CoreV1())
121121

122122
// Find the status of the OCP version (pre-ga, end-of-life, maintenance, or generally available)
123123
data.OCPStatus = compatibility.DetermineOCPStatus(openshiftVersion, time.Now())

pkg/autodiscover/autodiscover_operators.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,17 @@ import (
3131
)
3232

3333
const (
34-
istio = "istio-system"
34+
istioNamespace = "istio-system"
3535
)
3636

37-
func findnamespace(oc corev1client.CoreV1Interface) bool {
37+
func findIstioNamespace(oc corev1client.CoreV1Interface) bool {
3838
nsList, err := oc.Namespaces().List(context.TODO(), metav1.ListOptions{})
3939
if err != nil {
4040
logrus.Errorln("Error when listing", "err: ", err)
41+
return false
4142
}
4243
for index := range nsList.Items {
43-
if nsList.Items[index].ObjectMeta.Name == istio {
44+
if nsList.Items[index].ObjectMeta.Name == istioNamespace {
4445
return true
4546
}
4647
}

0 commit comments

Comments
 (0)