Skip to content

Commit aecf7c8

Browse files
Merge pull request #29993 from xueqzhan/revert-29782-staticEntryTest
Revert "CNF-17748: Add a comparing between static entry test"
2 parents a048b28 + 1ea68be commit aecf7c8

File tree

3 files changed

+30
-110
lines changed

3 files changed

+30
-110
lines changed

go.mod

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,6 @@ require (
9696
sigs.k8s.io/yaml v1.4.0
9797
)
9898

99-
require (
100-
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
101-
github.com/gocarina/gocsv v0.0.0-20231116093920-b87c2d0e983a // indirect
102-
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
103-
)
104-
10599
require (
106100
cel.dev/expr v0.18.0 // indirect
107101
git.sr.ht/~sbinet/gg v0.5.0 // indirect
@@ -163,6 +157,7 @@ require (
163157
github.com/emirpasic/gods v1.12.0 // indirect
164158
github.com/euank/go-kmsg-parser v2.0.0+incompatible // indirect
165159
github.com/evanphx/json-patch v5.9.0+incompatible // indirect
160+
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
166161
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
167162
github.com/fatih/camelcase v1.0.0 // indirect
168163
github.com/felixge/fgprof v0.9.4 // indirect
@@ -179,6 +174,7 @@ require (
179174
github.com/go-openapi/swag v0.23.0 // indirect
180175
github.com/go-pdf/fpdf v0.8.0 // indirect
181176
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
177+
github.com/gocarina/gocsv v0.0.0-20231116093920-b87c2d0e983a // indirect
182178
github.com/godbus/dbus/v5 v5.1.0 // indirect
183179
github.com/gogo/protobuf v1.3.2 // indirect
184180
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
@@ -295,6 +291,7 @@ require (
295291
golang.org/x/text v0.23.0 // indirect
296292
golang.org/x/time v0.7.0 // indirect
297293
golang.org/x/tools v0.26.0 // indirect
294+
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
298295
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
299296
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 // indirect
300297
google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61 // indirect

test/extended/networking/commatrix.go

Lines changed: 27 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -60,51 +60,15 @@ var staticOpenPortsToIgnore = []types.ComDetails{
6060
},
6161
}
6262

63-
// port used only interanly just on ci.
64-
var staticOpenPortsToIgnoreInStaticEntry = []types.ComDetails{
65-
{
66-
Direction: "Ingress",
67-
Protocol: "TCP",
68-
Port: 10250,
69-
NodeRole: "worker",
70-
Optional: false,
71-
},
72-
{
73-
Direction: "Ingress",
74-
Protocol: "TCP",
75-
Port: 10250,
76-
NodeRole: "master",
77-
Optional: false,
78-
},
79-
{
80-
Direction: "Ingress",
81-
Protocol: "TCP",
82-
Port: 6385,
83-
NodeRole: "master",
84-
Optional: false,
85-
},
86-
}
87-
88-
var (
89-
cs *client.ClientSet
90-
epExporter *endpointslices.EndpointSlicesExporter
91-
isSNO bool
92-
infraType configv1.PlatformType
93-
deployment types.Deployment
94-
utilsHelpers utils.UtilsInterface
95-
artifactsDir string
96-
commMatrixCreator *commatrixcreator.CommunicationMatrixCreator
97-
)
98-
9963
var _ = Describe("[sig-network][Feature:commatrix][apigroup:config.openshift.io][Serial]", func() {
100-
BeforeEach(func() {
64+
It("generated communication matrix should be equal to documented communication matrix", func() {
10165
kubeconfig := os.Getenv("KUBECONFIG")
10266
if kubeconfig == "" {
10367
Fail("KUBECONFIG not set")
10468
}
10569

10670
By("Creating output folder")
107-
artifactsDir = os.Getenv("ARTIFACT_DIR")
71+
artifactsDir := os.Getenv("ARTIFACT_DIR")
10872
if artifactsDir == "" {
10973
log.Println("env var ARTIFACT_DIR is not set, using default value")
11074
}
@@ -114,36 +78,14 @@ var _ = Describe("[sig-network][Feature:commatrix][apigroup:config.openshift.io]
11478
Expect(err).NotTo(HaveOccurred())
11579

11680
By("Creating the clients for the Generating step")
117-
cs, err = client.New()
81+
cs, err := client.New()
11882
Expect(err).NotTo(HaveOccurred())
11983

120-
utilsHelpers = utils.New(cs)
121-
epExporter, err = endpointslices.New(cs)
122-
Expect(err).NotTo(HaveOccurred())
123-
124-
By("Get cluster's deployment and infrastructure types")
125-
deployment = types.Standard
126-
isSNO, err = utilsHelpers.IsSNOCluster()
127-
Expect(err).NotTo(HaveOccurred())
128-
129-
if isSNO {
130-
deployment = types.SNO
131-
}
132-
133-
infraType, err = utilsHelpers.GetPlatformType()
134-
Expect(err).NotTo(HaveOccurred())
135-
136-
// if cluster's type is not supported by the commatrix app, skip tests
137-
if !slices.Contains(types.SupportedPlatforms, infraType) {
138-
Skip(fmt.Sprintf("unsupported platform type: %s. Supported platform types are: %v", infraType, types.SupportedPlatforms))
139-
}
84+
utilsHelpers := utils.New(cs)
14085

141-
By("Generating cluster's communication matrix creator")
142-
commMatrixCreator, err = commatrixcreator.New(epExporter, "", "", infraType, deployment)
143-
Expect(err).NotTo(HaveOccurred())
144-
})
86+
epExporter, err := endpointslices.New(cs)
87+
Expect(err).ToNot(HaveOccurred())
14588

146-
It("generated communication matrix should be equal to documented communication matrix", func() {
14789
By("Get cluster's version and check if it's suitable for test")
14890
clusterVersionStr, err := cluster.GetClusterVersion(cs)
14991
Expect(err).NotTo(HaveOccurred())
@@ -157,7 +99,26 @@ var _ = Describe("[sig-network][Feature:commatrix][apigroup:config.openshift.io]
15799
Skip(fmt.Sprintf("Cluster version is lower than the lowest version that has a documented communication matrix (%v)", minimalDocCommatrixVersionStr))
158100
}
159101

160-
By("Create endpoint matrix ")
102+
By("Get cluster's deployment and infrastructure types")
103+
deployment := types.Standard
104+
isSNO, err := utilsHelpers.IsSNOCluster()
105+
Expect(err).NotTo(HaveOccurred())
106+
if isSNO {
107+
deployment = types.SNO
108+
}
109+
110+
platformType, err := utilsHelpers.GetPlatformType()
111+
Expect(err).NotTo(HaveOccurred())
112+
113+
// if cluster's type is not supported by the commatrix app, skip tests
114+
if !slices.Contains(types.SupportedPlatforms, platformType) {
115+
Skip(fmt.Sprintf("unsupported platform type: %s. Supported platform types are: %v", platformType, types.SupportedPlatforms))
116+
}
117+
118+
By("Generating cluster's communication matrix")
119+
commMatrixCreator, err := commatrixcreator.New(epExporter, "", "", platformType, deployment)
120+
Expect(err).NotTo(HaveOccurred())
121+
161122
commatrix, err := commMatrixCreator.CreateEndpointMatrix()
162123
Expect(err).NotTo(HaveOccurred())
163124

@@ -169,7 +130,7 @@ var _ = Describe("[sig-network][Feature:commatrix][apigroup:config.openshift.io]
169130

170131
// clusters with unsupported platform types had skip the test, so we assume the platform type is supported
171132
var docType string
172-
switch infraType {
133+
switch platformType {
173134
case configv1.AWSPlatformType:
174135
docType = "aws"
175136
case configv1.BareMetalPlatformType:
@@ -253,40 +214,4 @@ var _ = Describe("[sig-network][Feature:commatrix][apigroup:config.openshift.io]
253214
Expect(err).ToNot(HaveOccurred())
254215
}
255216
})
256-
257-
It("Static entries should not overlap with those in the EndpointSlice; any shared entries must be removed", func() {
258-
By("Get EndpointSlice matrix")
259-
err := epExporter.LoadExposedEndpointSlicesInfo()
260-
Expect(err).NotTo(HaveOccurred())
261-
262-
epSliceComDetails, err := epExporter.ToComDetails()
263-
Expect(err).NotTo(HaveOccurred())
264-
265-
By("Get static entries list")
266-
staticEntries, err := commMatrixCreator.GetStaticEntries()
267-
Expect(err).NotTo(HaveOccurred())
268-
269-
staticEntriesMat := &types.ComMatrix{Matrix: staticEntries}
270-
epSliceComDetailsMat := &types.ComMatrix{Matrix: epSliceComDetails}
271-
272-
By("Write the matrix to files")
273-
err = staticEntriesMat.WriteMatrixToFileByType(utilsHelpers, "static-entry-matrix", types.FormatCSV, deployment, artifactsDir)
274-
Expect(err).ToNot(HaveOccurred())
275-
276-
err = epSliceComDetailsMat.WriteMatrixToFileByType(utilsHelpers, "expose-communication-matrix", types.FormatCSV, deployment, artifactsDir)
277-
Expect(err).ToNot(HaveOccurred())
278-
279-
By("Generating the Diff between the static entris and the expose communication matrix")
280-
endpointslicesDiffWithstaticEntrieMat := matrixdiff.Generate(epSliceComDetailsMat, staticEntriesMat)
281-
sharedEntries := endpointslicesDiffWithstaticEntrieMat.GetSharedEntries()
282-
283-
portsToIgnoreMat := &types.ComMatrix{Matrix: staticOpenPortsToIgnoreInStaticEntry}
284-
sharedEntriesDiffWithIgnoredPorts := matrixdiff.Generate(sharedEntries, portsToIgnoreMat)
285-
staticEntryNeedToRemove := sharedEntriesDiffWithIgnoredPorts.GetUniquePrimary()
286-
287-
if len(staticEntryNeedToRemove.Matrix) > 0 {
288-
err := fmt.Errorf("the following ports must be removed from the static entry file, as they already exist in an EndpointSlice:\n%s", staticEntryNeedToRemove)
289-
Expect(err).NotTo(HaveOccurred())
290-
}
291-
})
292217
})

test/extended/util/annotate/generated/zz_generated.annotations.go

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)