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(tests): wait for license to be applied before trying to login #8744

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ services:
command: /gobin/dgraph ${COVERAGE_OUTPUT} alpha --my=alpha1:7080 --zero=zero1:5080
--logtostderr -v=2 --raft "idx=1; group=1;" --security "whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16;"
--acl "secret-file=/secret/hmac;"

zero1:
image: dgraph/dgraph:local
working_dir: /data/zero1
Expand Down Expand Up @@ -65,7 +65,7 @@ services:
command: /gobin/dgraph ${COVERAGE_OUTPUT} alpha --my=alpha2:7080 --zero=zero2:5080
--logtostderr -v=2 --raft "idx=1; group=1;" --security "whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16;"
--acl "secret-file=/secret/hmac;"

zero2:
image: dgraph/dgraph:local
working_dir: /data/zero2
Expand All @@ -83,4 +83,3 @@ services:
command: /gobin/dgraph ${COVERAGE_OUTPUT} zero --raft "idx=1;" --my=zero2:5080 --logtostderr -v=2 --bindall
volumes:
data-volume:

22 changes: 19 additions & 3 deletions testutil/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/docker/docker/api/types"
"github.com/docker/docker/client"
"github.com/golang/glog"
"github.com/pkg/errors"
"golang.org/x/net/context"

"github.com/dgraph-io/dgraph/x"
Expand Down Expand Up @@ -60,8 +61,17 @@ func (in ContainerInstance) BestEffortWaitForHealthy(privatePort uint16) error {
return nil
}
checkACL := func(body []byte) error {
const acl string = "\"acl\""
if bytes.Index(body, []byte(acl)) > 0 {
// Zero returns OK as response
if string(body) == "OK" {
return nil
}

const eef string = `"ee_features"`
const acl string = `"acl"`
if !bytes.Contains(body, []byte(eef)) {
return errors.New("EE features are not enabled yet")
}
if bytes.Contains(body, []byte(acl)) {
return in.bestEffortTryLogin()
}
return nil
Expand All @@ -75,7 +85,13 @@ func (in ContainerInstance) BestEffortWaitForHealthy(privatePort uint16) error {
_ = resp.Body.Close()
}
if err == nil && resp.StatusCode == http.StatusOK {
return checkACL(body)
if aerr := checkACL(body); aerr == nil {
return nil
} else {
fmt.Printf("waiting for login to work: %v\n", aerr)
time.Sleep(time.Second)
continue
}
}
fmt.Printf("Health for %s failed: %v. Response: %q. Retrying...\n", in, err, body)
time.Sleep(time.Second)
Expand Down