From 6190e7cee0b39da870101092001f3ee25bfc76a6 Mon Sep 17 00:00:00 2001 From: Aman Mangal Date: Fri, 10 Mar 2023 03:56:36 +0530 Subject: [PATCH] fix(tests): wait for license to be applied before trying to login once the zero cluster is up, it applies a trial license. Until the license is applied, health check for alpha returns that the cluster is an OSS cluster. This PR ensures that the t driver code now waits for the license to be proposed and applied in the cluster. Then, it waits for the login to succeed before running the tests if ACL is enabled. --- .../deleted-namespace/docker-compose.yml | 5 ++--- testutil/docker.go | 22 ++++++++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/systest/backup/advanced-scenarios/deleted-namespace/docker-compose.yml b/systest/backup/advanced-scenarios/deleted-namespace/docker-compose.yml index e531a06f55a..67e6656f8a4 100755 --- a/systest/backup/advanced-scenarios/deleted-namespace/docker-compose.yml +++ b/systest/backup/advanced-scenarios/deleted-namespace/docker-compose.yml @@ -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 @@ -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 @@ -83,4 +83,3 @@ services: command: /gobin/dgraph ${COVERAGE_OUTPUT} zero --raft "idx=1;" --my=zero2:5080 --logtostderr -v=2 --bindall volumes: data-volume: - \ No newline at end of file diff --git a/testutil/docker.go b/testutil/docker.go index b19d0ebfc6e..562c2eb53b3 100644 --- a/testutil/docker.go +++ b/testutil/docker.go @@ -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" @@ -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 @@ -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)