Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: e2e failure due to count returned by APISIX #640

Merged
merged 1 commit into from
Sep 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
gxthrj marked this conversation as resolved.
Show resolved Hide resolved
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