You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by kv...@apache.org on 2021/09/01 03:55:17 UTC

[apisix-ingress-controller] branch master updated: fix: e2e failure due to count returned by APISIX (#640)

This is an automated email from the ASF dual-hosted git repository.

kvn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git


The following commit(s) were added to refs/heads/master by this push:
     new 270a176  fix: e2e failure due to count returned by APISIX (#640)
270a176 is described below

commit 270a176a39d34e1d0b213c9d190368919612db9c
Author: Sarasa Kisaragi <li...@gmail.com>
AuthorDate: Wed Sep 1 11:55:12 2021 +0800

    fix: e2e failure due to count returned by APISIX (#640)
    
    Signed-off-by: Ling Samuel <li...@gmail.com>
---
 test/e2e/scaffold/k8s.go | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/test/e2e/scaffold/k8s.go b/test/e2e/scaffold/k8s.go
index 4d9519b..2c6b3fd 100644
--- a/test/e2e/scaffold/k8s.go
+++ b/test/e2e/scaffold/k8s.go
@@ -20,6 +20,8 @@ import (
 	"io/ioutil"
 	"net/http"
 	"net/url"
+	"strconv"
+	"strings"
 	"time"
 
 	"github.com/apache/apisix-ingress-controller/pkg/apisix"
@@ -33,7 +35,26 @@ import (
 )
 
 type counter struct {
-	Count apisix.IntOrString `json:"count"`
+	Count intOrDescOneString `json:"count"`
+}
+
+// intOrDescOneString will decrease 1 if incoming value is string formatted number
+type intOrDescOneString struct {
+	Value int `json:"value"`
+}
+
+func (ios *intOrDescOneString) UnmarshalJSON(p []byte) error {
+	delta := 0
+	if strings.HasPrefix(string(p), `"`) {
+		delta = -1
+	}
+	result := strings.Trim(string(p), `"`)
+	count, err := strconv.Atoi(result)
+	if err != nil {
+		return err
+	}
+	ios.Value = count + delta
+	return nil
 }
 
 // ApisixRoute is the ApisixRoute CRD definition.
@@ -163,7 +184,7 @@ func (s *Scaffold) ensureNumApisixCRDsCreated(url string, desired int) error {
 		if err != nil {
 			return false, err
 		}
-		count := c.Count.IntValue
+		count := c.Count.Value
 		if count != desired {
 			ginkgo.GinkgoT().Logf("mismatched number of items, expected %d but found %d", desired, count)
 			return false, nil