@@ -21,8 +21,8 @@ import (
2121 "testing"
2222
2323 "github.com/stretchr/testify/assert"
24+ "github.com/stretchr/testify/require"
2425 v1 "k8s.io/api/core/v1"
25- "k8s.io/kubernetes/test/e2e/framework"
2626 "sigs.k8s.io/controller-runtime/pkg/client"
2727
2828 "sigs.k8s.io/network-policy-api/apis/v1alpha1"
@@ -55,15 +55,15 @@ var AdminNetworkPolicyEgressSCTP = suite.ConformanceTest{
5555 Namespace : "network-policy-conformance-gryffindor" ,
5656 Name : "harry-potter-0" ,
5757 }, serverPod )
58- framework . ExpectNoError ( err , "unable to fetch the server pod" )
58+ require . NoErrorf ( t , err , "unable to fetch the server pod" )
5959 // luna-lovegood-0 is our client pod in ravenclaw namespace
6060 // ensure egress is ALLOWED to gryffindor from ravenclaw
6161 // egressRule at index0 will take precedence over egressRule at index1; thus ALLOW takes precedence over DENY since rules are ordered
62- success := kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
62+ success := kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
6363 serverPod .Status .PodIP , int32 (9003 ), s .TimeoutConfig .RequestTimeout , true )
6464 assert .Equal (t , true , success )
6565 // luna-lovegood-1 is our client pod in ravenclaw namespace
66- success = kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
66+ success = kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
6767 serverPod .Status .PodIP , int32 (9005 ), s .TimeoutConfig .RequestTimeout , true )
6868 assert .Equal (t , true , success )
6969 })
@@ -78,15 +78,15 @@ var AdminNetworkPolicyEgressSCTP = suite.ConformanceTest{
7878 Namespace : "network-policy-conformance-hufflepuff" ,
7979 Name : "cedric-diggory-1" ,
8080 }, serverPod )
81- framework . ExpectNoError ( err , "unable to fetch the server pod" )
81+ require . NoErrorf ( t , err , "unable to fetch the server pod" )
8282 // luna-lovegood-0 is our client pod in ravenclaw namespace
8383 // ensure egress is ALLOWED to hufflepuff from ravenclaw at port 9003; egressRule at index5 should take effect
84- success := kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
84+ success := kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
8585 serverPod .Status .PodIP , int32 (9003 ), s .TimeoutConfig .RequestTimeout , true )
8686 assert .Equal (t , true , success )
8787 // luna-lovegood-1 is our client pod in ravenclaw namespace
8888 // ensure egress is DENIED to hufflepuff from ravenclaw for rest of the traffic; egressRule at index6 should take effect
89- success = kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
89+ success = kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
9090 serverPod .Status .PodIP , int32 (9005 ), s .TimeoutConfig .RequestTimeout , false )
9191 assert .Equal (t , true , success )
9292 })
@@ -101,26 +101,26 @@ var AdminNetworkPolicyEgressSCTP = suite.ConformanceTest{
101101 Namespace : "network-policy-conformance-gryffindor" ,
102102 Name : "harry-potter-1" ,
103103 }, serverPod )
104- framework . ExpectNoError ( err , "unable to fetch the server pod" )
104+ require . NoErrorf ( t , err , "unable to fetch the server pod" )
105105 anp := & v1alpha1.AdminNetworkPolicy {}
106106 err = s .Client .Get (ctx , client.ObjectKey {
107107 Name : "egress-sctp" ,
108108 }, anp )
109- framework . ExpectNoError ( err , "unable to fetch the admin network policy" )
109+ require . NoErrorf ( t , err , "unable to fetch the admin network policy" )
110110 // swap rules at index0 and index1
111111 allowRule := anp .DeepCopy ().Spec .Egress [0 ]
112112 anp .Spec .Egress [0 ] = anp .DeepCopy ().Spec .Egress [1 ]
113113 anp .Spec .Egress [1 ] = allowRule
114114 err = s .Client .Update (ctx , anp )
115- framework . ExpectNoError ( err , "unable to update the admin network policy" )
115+ require . NoErrorf ( t , err , "unable to update the admin network policy" )
116116 // luna-lovegood-0 is our client pod in gryffindor namespace
117117 // ensure egress is DENIED to gryffindor from ravenclaw
118118 // egressRule at index0 will take precedence over egressRule at index1; thus DENY takes precedence over ALLOW since rules are ordered
119- success := kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
119+ success := kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
120120 serverPod .Status .PodIP , int32 (9003 ), s .TimeoutConfig .RequestTimeout , false )
121121 assert .Equal (t , true , success )
122122 // luna-lovegood-1 is our client pod in ravenclaw namespace
123- success = kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
123+ success = kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
124124 serverPod .Status .PodIP , int32 (9005 ), s .TimeoutConfig .RequestTimeout , false )
125125 assert .Equal (t , true , success )
126126 })
@@ -135,15 +135,15 @@ var AdminNetworkPolicyEgressSCTP = suite.ConformanceTest{
135135 Namespace : "network-policy-conformance-slytherin" ,
136136 Name : "draco-malfoy-0" ,
137137 }, serverPod )
138- framework . ExpectNoError ( err , "unable to fetch the server pod" )
138+ require . NoErrorf ( t , err , "unable to fetch the server pod" )
139139 // luna-lovegood-0 is our client pod in ravenclaw namespace
140140 // ensure egress to slytherin is DENIED from ravenclaw at port 9003; egressRule at index3 should take effect
141- success := kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
141+ success := kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
142142 serverPod .Status .PodIP , int32 (9003 ), s .TimeoutConfig .RequestTimeout , false )
143143 assert .Equal (t , true , success )
144144 // luna-lovegood-1 is our client pod in ravenclaw namespace
145145 // ensure egress to slytherin is ALLOWED from ravenclaw for rest of the traffic; matches no rules hence allowed
146- success = kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
146+ success = kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
147147 serverPod .Status .PodIP , int32 (9005 ), s .TimeoutConfig .RequestTimeout , true )
148148 assert .Equal (t , true , success )
149149 })
@@ -158,26 +158,26 @@ var AdminNetworkPolicyEgressSCTP = suite.ConformanceTest{
158158 Namespace : "network-policy-conformance-gryffindor" ,
159159 Name : "harry-potter-1" ,
160160 }, serverPod )
161- framework . ExpectNoError ( err , "unable to fetch the server pod" )
161+ require . NoErrorf ( t , err , "unable to fetch the server pod" )
162162 anp := & v1alpha1.AdminNetworkPolicy {}
163163 err = s .Client .Get (ctx , client.ObjectKey {
164164 Name : "egress-sctp" ,
165165 }, anp )
166- framework . ExpectNoError ( err , "unable to fetch the admin network policy" )
166+ require . NoErrorf ( t , err , "unable to fetch the admin network policy" )
167167 // swap rules at index0 and index2
168168 denyRule := anp .DeepCopy ().Spec .Egress [0 ]
169169 anp .Spec .Egress [0 ] = anp .DeepCopy ().Spec .Egress [2 ]
170170 anp .Spec .Egress [2 ] = denyRule
171171 err = s .Client .Update (ctx , anp )
172- framework . ExpectNoError ( err , "unable to update the admin network policy" )
172+ require . NoErrorf ( t , err , "unable to update the admin network policy" )
173173 // luna-lovegood-0 is our client pod in ravenclaw namespace
174174 // ensure egress is PASSED from gryffindor to ravenclaw
175175 // egressRule at index0 will take precedence over egressRule at index1&index2; thus PASS takes precedence over ALLOW/DENY since rules are ordered
176- success := kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
176+ success := kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
177177 serverPod .Status .PodIP , int32 (9003 ), s .TimeoutConfig .RequestTimeout , true )
178178 assert .Equal (t , true , success )
179179 // luna-lovegood-1 is our client pod in ravenclaw namespace
180- success = kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
180+ success = kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
181181 serverPod .Status .PodIP , int32 (9005 ), s .TimeoutConfig .RequestTimeout , true )
182182 assert .Equal (t , true , success )
183183 })
@@ -192,26 +192,26 @@ var AdminNetworkPolicyEgressSCTP = suite.ConformanceTest{
192192 Namespace : "network-policy-conformance-slytherin" ,
193193 Name : "draco-malfoy-0" ,
194194 }, serverPod )
195- framework . ExpectNoError ( err , "unable to fetch the server pod" )
195+ require . NoErrorf ( t , err , "unable to fetch the server pod" )
196196 anp := & v1alpha1.AdminNetworkPolicy {}
197197 err = s .Client .Get (ctx , client.ObjectKey {
198198 Name : "egress-sctp" ,
199199 }, anp )
200- framework . ExpectNoError ( err , "unable to fetch the admin network policy" )
200+ require . NoErrorf ( t , err , "unable to fetch the admin network policy" )
201201 // swap rules at index3 and index4
202202 denyRule := anp .DeepCopy ().Spec .Egress [3 ]
203203 anp .Spec .Egress [3 ] = anp .DeepCopy ().Spec .Egress [4 ]
204204 anp .Spec .Egress [4 ] = denyRule
205205 err = s .Client .Update (ctx , anp )
206- framework . ExpectNoError ( err , "unable to update the admin network policy" )
206+ require . NoErrorf ( t , err , "unable to update the admin network policy" )
207207 // luna-lovegood-0 is our client pod in ravenclaw namespace
208208 // ensure egress to slytherin is PASSED from ravenclaw at port 9003; egressRule at index3 should take effect
209- success := kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
209+ success := kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-0" , "sctp" ,
210210 serverPod .Status .PodIP , int32 (9003 ), s .TimeoutConfig .RequestTimeout , true )
211211 assert .Equal (t , true , success )
212212 // luna-lovegood-1 is our client pod in ravenclaw namespace
213213 // ensure egress to slytherin is ALLOWED from ravenclaw for rest of the traffic; matches no rules hence allowed
214- success = kubernetes .PokeServer (t , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
214+ success = kubernetes .PokeServer (t , s . ClientSet , & s . KubeConfig , "network-policy-conformance-ravenclaw" , "luna-lovegood-1" , "sctp" ,
215215 serverPod .Status .PodIP , int32 (9005 ), s .TimeoutConfig .RequestTimeout , true )
216216 assert .Equal (t , true , success )
217217 })
0 commit comments