@@ -204,8 +204,7 @@ spec:
204204 port:
205205 number: 80
206206`
207-
208- It ("Test IngressClass Selection" , func () {
207+ BeforeEach (func () {
209208 By ("create GatewayProxy" )
210209 gatewayProxy := fmt .Sprintf (gatewayProxyYaml , s .Namespace (), s .Deployer .GetAdminEndpoint (), s .AdminKey ())
211210 err := s .CreateResourceFromStringWithNamespace (gatewayProxy , s .Namespace ())
@@ -217,34 +216,47 @@ spec:
217216 Expect (err ).NotTo (HaveOccurred (), "creating Default IngressClass" )
218217 time .Sleep (5 * time .Second )
219218
219+ })
220+
221+ It ("Service Endpoints Changed" , func () {
220222 By ("create Ingress without IngressClass" )
221- err = s .CreateResourceFromStringWithNamespace (fmt .Sprintf (defaultIngress , s .Namespace ()), s .Namespace ())
223+ err : = s .CreateResourceFromStringWithNamespace (fmt .Sprintf (defaultIngress , s .Namespace ()), s .Namespace ())
222224 Expect (err ).NotTo (HaveOccurred (), "creating Ingress without IngressClass" )
223225 time .Sleep (5 * time .Second )
224226
225227 By ("verify default ingress" )
226- s .NewAPISIXClient ().
227- GET ( "/get" ).
228- WithHost ( "default.example.com" ).
229- Expect ().
230- Status ( 200 )
231- })
228+ s .RequestAssert ( & scaffold. RequestAssert {
229+ Method : " GET" ,
230+ Path : "/get" ,
231+ Host : "default.example.com" ,
232+ Check : scaffold . WithExpectedStatus ( http . StatusOK ),
233+ })
232234
233- It ("Proxy External Service" , func () {
234- By ("create GatewayProxy" )
235- gatewayProxy := fmt .Sprintf (gatewayProxyYaml , s .Namespace (), s .Deployer .GetAdminEndpoint (), s .AdminKey ())
236- err := s .CreateResourceFromStringWithNamespace (gatewayProxy , s .Namespace ())
237- Expect (err ).NotTo (HaveOccurred (), "creating GatewayProxy" )
238- time .Sleep (5 * time .Second )
235+ err = s .ScaleHTTPBIN (0 )
236+ Expect (err ).NotTo (HaveOccurred (), "scaling httpbin to 0" )
239237
240- By ("create Default IngressClass" )
241- err = s .CreateResourceFromStringWithNamespace (fmt .Sprintf (defaultIngressClass , s .GetControllerName (), s .Namespace ()), s .Namespace ())
242- Expect (err ).NotTo (HaveOccurred (), "creating Default IngressClass" )
243- time .Sleep (5 * time .Second )
238+ s .RequestAssert (& scaffold.RequestAssert {
239+ Method : "GET" ,
240+ Path : "/get" ,
241+ Host : "default.example.com" ,
242+ Check : scaffold .WithExpectedStatus (http .StatusServiceUnavailable ),
243+ })
244+
245+ err = s .ScaleHTTPBIN (1 )
246+ Expect (err ).NotTo (HaveOccurred (), "scaling httpbin to 1" )
244247
248+ s .RequestAssert (& scaffold.RequestAssert {
249+ Method : "GET" ,
250+ Path : "/get" ,
251+ Host : "default.example.com" ,
252+ Check : scaffold .WithExpectedStatus (http .StatusOK ),
253+ })
254+ })
255+
256+ It ("Proxy External Service" , func () {
245257 By ("create Ingress" )
246258 ingressName := s .Namespace () + "-external"
247- err = s .CreateResourceFromStringWithNamespace (fmt .Sprintf (ingressWithExternalName , ingressName ), s .Namespace ())
259+ err : = s .CreateResourceFromStringWithNamespace (fmt .Sprintf (ingressWithExternalName , ingressName ), s .Namespace ())
248260 Expect (err ).NotTo (HaveOccurred (), "creating Ingress without IngressClass" )
249261
250262 By ("checking the external service response" )
@@ -259,20 +271,9 @@ spec:
259271 })
260272
261273 It ("Delete Ingress during restart" , func () {
262- By ("create GatewayProxy" )
263- gatewayProxy := fmt .Sprintf (gatewayProxyYaml , s .Namespace (), s .Deployer .GetAdminEndpoint (), s .AdminKey ())
264- err := s .CreateResourceFromStringWithNamespace (gatewayProxy , s .Namespace ())
265- Expect (err ).NotTo (HaveOccurred (), "creating GatewayProxy" )
266- time .Sleep (5 * time .Second )
267-
268- By ("create Default IngressClass" )
269- err = s .CreateResourceFromStringWithNamespace (fmt .Sprintf (defaultIngressClass , s .GetControllerName (), s .Namespace ()), s .Namespace ())
270- Expect (err ).NotTo (HaveOccurred (), "creating Default IngressClass" )
271- time .Sleep (5 * time .Second )
272-
273274 By ("create Ingress with ExternalName" )
274275 ingressName := s .Namespace () + "-external"
275- err = s .CreateResourceFromStringWithNamespace (fmt .Sprintf (ingressWithExternalName , ingressName ), s .Namespace ())
276+ err : = s .CreateResourceFromStringWithNamespace (fmt .Sprintf (ingressWithExternalName , ingressName ), s .Namespace ())
276277 Expect (err ).NotTo (HaveOccurred (), "creating Ingress without IngressClass" )
277278 time .Sleep (5 * time .Second )
278279
0 commit comments