Skip to content

Commit

Permalink
fix: e2e failure due to count returned by APISIX
Browse files Browse the repository at this point in the history
Signed-off-by: Ling Samuel <lingsamuelgrace@gmail.com>
  • Loading branch information
lingsamuel committed Aug 19, 2021
1 parent d8854c3 commit ba56dc4
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions test/e2e/scaffold/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
"time"

"github.com/apache/apisix-ingress-controller/pkg/apisix"
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ba56dc4

Please sign in to comment.