@@ -1369,6 +1369,117 @@ spec:
13691369 })
13701370 })
13711371 })
1372+
1373+ Context ("Test ApisixRoute with ApisixUpstream: retries" , func () {
1374+ const apisixRouteSpec = `
1375+ apiVersion: apisix.apache.org/v2
1376+ kind: ApisixRoute
1377+ metadata:
1378+ name: default
1379+ namespace: %s
1380+ spec:
1381+ ingressClassName: %s
1382+ http:
1383+ - name: rule0
1384+ match:
1385+ hosts:
1386+ - httpbin
1387+ paths:
1388+ - /*
1389+ backends:
1390+ - serviceName: httpbin-service-e2e-test
1391+ servicePort: 80
1392+
1393+ `
1394+ const apisixUpstreamSpec = `
1395+ apiVersion: apisix.apache.org/v2
1396+ kind: ApisixUpstream
1397+ metadata:
1398+ name: httpbin-service-e2e-test
1399+ namespace: %s
1400+ spec:
1401+ ingressClassName: %s
1402+ retries: 3
1403+ `
1404+ It ("create ApisixRoute and upstream with retries" , func () {
1405+ By ("apply apisixupstream" )
1406+ applier .MustApplyAPIv2 (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin-service-e2e-test" },
1407+ new (apiv2.ApisixUpstream ), fmt .Sprintf (apisixUpstreamSpec , s .Namespace (), s .Namespace ()))
1408+ By ("apply apisixroute" )
1409+ applier .MustApplyAPIv2 (types.NamespacedName {Namespace : s .Namespace (), Name : "default" },
1410+ new (apiv2.ApisixRoute ), fmt .Sprintf (apisixRouteSpec , s .Namespace (), s .Namespace ()))
1411+ Eventually (func () bool {
1412+ services , err := s .DefaultDataplaneResource ().Service ().List (context .Background ())
1413+ if err != nil {
1414+ return false
1415+ }
1416+ if len (services ) != 1 {
1417+ return false
1418+ }
1419+ if services [0 ].Upstream == nil {
1420+ return false
1421+ }
1422+ return * services [0 ].Upstream .Retries == 3
1423+ }).WithTimeout (30 * time .Second ).ProbeEvery (5 * time .Second ).Should (BeTrue ())
1424+ })
1425+ })
1426+
1427+ Context ("Test ApisixRoute with ApisixUpstream: timeout" , func () {
1428+ const apisixRouteSpec = `
1429+ apiVersion: apisix.apache.org/v2
1430+ kind: ApisixRoute
1431+ metadata:
1432+ name: default
1433+ namespace: %s
1434+ spec:
1435+ ingressClassName: %s
1436+ http:
1437+ - name: rule0
1438+ match:
1439+ hosts:
1440+ - httpbin
1441+ paths:
1442+ - /*
1443+ backends:
1444+ - serviceName: httpbin-service-e2e-test
1445+ servicePort: 80
1446+
1447+ `
1448+ const apisixUpstreamSpec = `
1449+ apiVersion: apisix.apache.org/v2
1450+ kind: ApisixUpstream
1451+ metadata:
1452+ name: httpbin-service-e2e-test
1453+ namespace: %s
1454+ spec:
1455+ ingressClassName: %s
1456+ timeout:
1457+ read: 10s
1458+ send: 10s
1459+ `
1460+ It ("create ApisixRoute and upstream with retries" , func () {
1461+ By ("apply apisixupstream" )
1462+ applier .MustApplyAPIv2 (types.NamespacedName {Namespace : s .Namespace (), Name : "httpbin-service-e2e-test" },
1463+ new (apiv2.ApisixUpstream ), fmt .Sprintf (apisixUpstreamSpec , s .Namespace (), s .Namespace ()))
1464+ By ("apply apisixroute" )
1465+ applier .MustApplyAPIv2 (types.NamespacedName {Namespace : s .Namespace (), Name : "default" },
1466+ new (apiv2.ApisixRoute ), fmt .Sprintf (apisixRouteSpec , s .Namespace (), s .Namespace ()))
1467+ Eventually (func () bool {
1468+ services , err := s .DefaultDataplaneResource ().Service ().List (context .Background ())
1469+ if err != nil {
1470+ return false
1471+ }
1472+ if len (services ) != 1 {
1473+ return false
1474+ }
1475+ if services [0 ].Upstream == nil {
1476+ return false
1477+ }
1478+ return services [0 ].Upstream .Timeout .Read == 10 && services [0 ].Upstream .Timeout .Send == 10
1479+ }).WithTimeout (30 * time .Second ).ProbeEvery (5 * time .Second ).Should (BeTrue ())
1480+ })
1481+ })
1482+
13721483 Context ("Test tls secret processed from ApisixUpstream" , func () {
13731484 var Cert = strings .TrimSpace (framework .TestServerCert )
13741485 var Key = strings .TrimSpace (framework .TestServerKey )
0 commit comments