lingsamuel commented on code in PR #1128:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/1128#discussion_r912776251


##########
test/e2e/scaffold/k8s.go:
##########
@@ -208,6 +208,12 @@ func (s *Scaffold) ensureNumApisixCRDsCreated(url string, 
desired int) error {
        return wait.Poll(3*time.Second, 35*time.Second, condFunc)
 }
 
+// EnsureNumIngressCreated waits until desired number of route are created in
+// APISIX cluster.
+func (s *Scaffold) EnsureNumIngressCreated(desired int) error {

Review Comment:
   The name of the method is misleading because Ingress and APISIX Route are 
not always one-to-one. The implementation is wrong.



##########
test/e2e/scaffold/scaffold.go:
##########
@@ -564,23 +562,29 @@ func (s *Scaffold) FormatNamespaceLabel(label string) 
string {
 
 var (
        versionRegex = regexp.MustCompile(`apiVersion: 
apisix.apache.org/v.*?\n`)
-       kindRegex    = regexp.MustCompile(`kind: .*?\n`)
+       kindRegex    = regexp.MustCompile(`kind: (.*?)\n`)
 )
 
 func (s *Scaffold) replaceApiVersion(yml, ver string) string {
        return versionRegex.ReplaceAllString(yml, "apiVersion: "+ver+"\n")
 }
 
 func (s *Scaffold) getKindValue(yml string) string {
-       kind := strings.Replace(kindRegex.FindString(yml), "\n", "", -1)
-       kindValue := strings.Replace(kind, "kind: ", "", -1)
-       return kindValue
+       subStr := kindRegex.FindStringSubmatch(yml)
+       if len(subStr) < 2 {
+               return ""
+       }
+       return subStr[1]
 }
 
 func (s *Scaffold) DisableNamespaceSelector() {
        s.opts.disableNamespaceSelector = true
 }
 
+func (s *Scaffold) DisableGatewayAPI() {

Review Comment:
   I think we should remove this option completely in E2E because supporting it 
is on our roadmap.



##########
test/e2e/suite-ingress/suite-ingress-resource/resourcepushing.go:
##########
@@ -136,9 +130,9 @@ spec:
 
                        // remove
                        assert.Nil(ginkgo.GinkgoT(), 
s.RemoveResourceByString(apisixRoute))
-                       // TODO When ingress controller can feedback the 
lifecycle of CRDs to the
-                       // status field, we can poll it rather than sleeping.
-                       time.Sleep(10 * time.Second)
+
+                       err = s.EnsureNumApisixUpstreamsCreated(0)
+                       assert.Nil(ginkgo.GinkgoT(), err, "Checking number of 
routes")
                        ups, err := s.ListApisixUpstreams()
                        assert.Nil(ginkgo.GinkgoT(), err, "list upstreams 
error")
                        assert.Len(ginkgo.GinkgoT(), ups, 0, "upstreams nodes 
not expect")

Review Comment:
   Do we still need to check this? `Ensure` may have already done this work. 
Others have the same problem.



##########
test/e2e/suite-ingress/suite-ingress-resource/resourcepushing.go:
##########
@@ -223,9 +214,11 @@ spec:
                        // assert.Nil(ginkgo.GinkgoT(), 
s.DeleteHTTPBINService())
                        // remove
                        assert.Nil(ginkgo.GinkgoT(), 
s.RemoveResourceByString(apisixRoute))
-                       // TODO When ingress controller can feedback the 
lifecycle of CRDs to the
-                       // status field, we can poll it rather than sleeping.
-                       time.Sleep(10 * time.Second)
+
+                       err = s.EnsureNumApisixUpstreamsCreated(0)

Review Comment:
   Ensure ApisixRoute?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to