@@ -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-
9963var _ = 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})
0 commit comments