diff --git a/.github/workflows/ci-dgraph-upgrade-tests.yml b/.github/workflows/ci-dgraph-upgrade-tests.yml new file mode 100644 index 00000000000..7912f8f5d88 --- /dev/null +++ b/.github/workflows/ci-dgraph-upgrade-tests.yml @@ -0,0 +1,52 @@ +name: ci-dgraph-upgrade-and-integration-tests +on: + push: + branches: + - main + - 'release/**' + pull_request: + types: + - opened + - reopened + - synchronize + - ready_for_review + branches: + - main + - 'release/**' + schedule: + - cron: "0 */2 * * *" # every 2hrs +jobs: + dgraph-upgrade-and-integration-tests: + if: github.event.pull_request.draft == false + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - name: Get Go Version + run: | + #!/bin/bash + GOVERSION=$({ [ -f .go-version ] && cat .go-version; }) + echo "GOVERSION=$GOVERSION" >> $GITHUB_ENV + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: ${{ env.GOVERSION }} + - name: Make Linux Build and Docker Image + run: make docker-image + - name: Clean Up Environment + run: | + #!/bin/bash + # clean cache + go clean -testcache + - name: Run Upgrade and Integration Tests + run: | + #!/bin/bash + # go env settings + export GOPATH=~/go + # move the binary + cp dgraph/dgraph ~/go/bin/dgraph + # run the tests + go test -v -failfast -tags=upgrade,integration2 ./... + # clean up docker containers after test execution + go clean -testcache + # sleep + sleep 5 diff --git a/dgraphtest/cluster.go b/dgraphtest/cluster.go index ab37ce360e8..165f94989fd 100644 --- a/dgraphtest/cluster.go +++ b/dgraphtest/cluster.go @@ -465,16 +465,16 @@ func (hc *HTTPClient) Restore(c Cluster, backupPath string, backupId string, incrFrom, backupNum int, encKey string) error { // incremental restore was introduced in commit 8b3712e93ed2435bea52d957f7b69976c6cfc55b - afterIncrRestore, err := isParent("8b3712e93ed2435bea52d957f7b69976c6cfc55b", c.GetVersion()) + beforeIncrRestore, err := isParent("8b3712e93ed2435bea52d957f7b69976c6cfc55b", c.GetVersion()) if err != nil { return errors.Wrapf(err, "error checking incremental restore support") } - if afterIncrRestore && incrFrom != 0 { + if beforeIncrRestore && incrFrom != 0 { return errors.New("incremental restore is not supported by the cluster") } var varPart, queryPart string - if afterIncrRestore { + if !beforeIncrRestore { varPart = "$incrFrom: Int, " queryPart = " incrementalFrom: $incrFrom," } @@ -488,7 +488,7 @@ func (hc *HTTPClient) Restore(c Cluster, backupPath string, }`, varPart, queryPart) vars := map[string]interface{}{"location": backupPath, "backupId": backupId, "backupNum": backupNum, "encKey": encKey} - if afterIncrRestore { + if !beforeIncrRestore { vars["incrFrom"] = incrFrom } diff --git a/dgraphtest/local_cluster.go b/dgraphtest/local_cluster.go index 45ca14002e9..63feff27961 100644 --- a/dgraphtest/local_cluster.go +++ b/dgraphtest/local_cluster.go @@ -447,7 +447,7 @@ func (c *LocalCluster) recreateContainers() error { } // Upgrades the cluster to the provided dgraph version -func (c *LocalCluster) Upgrade(hc *HTTPClient, version string, strategy UpgradeStrategy) error { +func (c *LocalCluster) Upgrade(version string, strategy UpgradeStrategy) error { if version == c.conf.version { return fmt.Errorf("cannot upgrade to the same version") } @@ -455,9 +455,17 @@ func (c *LocalCluster) Upgrade(hc *HTTPClient, version string, strategy UpgradeS log.Printf("[INFO] upgrading the cluster from [%v] to [%v] using [%v]", c.conf.version, version, strategy) switch strategy { case BackupRestore: + hc, err := c.HTTPClient() + if err != nil { + return err + } + if err := hc.LoginIntoNamespace(DefaultUser, DefaultPassword, 0); err != nil { + return err + } if err := hc.Backup(true, DefaultBackupDir); err != nil { return errors.Wrap(err, "error taking backup during upgrade") } + if err := c.Stop(); err != nil { return err } @@ -475,6 +483,14 @@ func (c *LocalCluster) Upgrade(hc *HTTPClient, version string, strategy UpgradeS if c.conf.encryption { encPath = encKeyMountPath } + + hc, err = c.HTTPClient() + if err != nil { + return errors.Wrapf(err, "error creating HTTP client after upgrade") + } + if err := hc.LoginIntoNamespace(DefaultUser, DefaultPassword, 0); err != nil { + return errors.Wrapf(err, "error during login after upgrade") + } if err := hc.Restore(c, DefaultBackupDir, "", 0, 1, encPath); err != nil { return errors.Wrap(err, "error doing restore during upgrade") } diff --git a/query/query0_test.go b/query/query0_test.go index 4762d4d2edf..62290192c6e 100644 --- a/query/query0_test.go +++ b/query/query0_test.go @@ -1425,6 +1425,9 @@ func TestQueryVarValOrderError(t *testing.T) { } func TestQueryVarEmptyRootOrderError(t *testing.T) { + // This bug was fixed in commit b256f9c6e6c68ae163eee3242518f77a6ab35fa0 + dgraphtest.ShouldSkipTest(t, "b256f9c6e6c68ae163eee3242518f77a6ab35fa0", dc.GetVersion()) + query := ` { q(func: eq(name, "DNEinDB")) { @@ -1440,6 +1443,9 @@ func TestQueryVarEmptyRootOrderError(t *testing.T) { } func TestQueryVarEmptyRootOrderChildQueryError(t *testing.T) { + // This bug was fixed in commit b256f9c6e6c68ae163eee3242518f77a6ab35fa0 + dgraphtest.ShouldSkipTest(t, "b256f9c6e6c68ae163eee3242518f77a6ab35fa0", dc.GetVersion()) + query := ` { var(func: eq(name, "DNEinDB")) { diff --git a/query/upgrade_test.go b/query/upgrade_test.go index 8ab5efa5518..49cfd344a94 100644 --- a/query/upgrade_test.go +++ b/query/upgrade_test.go @@ -19,6 +19,7 @@ package query import ( + "context" "testing" "time" @@ -27,36 +28,29 @@ import ( ) func TestMain(m *testing.M) { - conf := dgraphtest.NewClusterConfig().WithNumAlphas(3).WithNumZeros(3).WithReplicas(3). - WithACL(20 * time.Second).WithEncryption().WithVersion("0c9f60156") + conf := dgraphtest.NewClusterConfig().WithNumAlphas(1).WithNumZeros(1). + WithReplicas(1).WithACL(time.Hour).WithVersion("0c9f60156") c, err := dgraphtest.NewLocalCluster(conf) x.Panic(err) defer c.Cleanup() - require.NoError(t, c.Start()) + x.Panic(c.Start()) - // setup the global Cluster var - dc = c - - // setup client - dg, err := c.Client() - if err != nil { - panic(err) - } - client = dg + dg, cleanup, err := c.Client() + x.Panic(err) + defer cleanup() + x.Panic(dg.LoginIntoNamespace(context.Background(), dgraphtest.DefaultUser, dgraphtest.DefaultPassword, 0)) - // do mutations + client = dg.Dgraph + dc = c populateCluster() + x.Panic(c.Upgrade("v23.0.0-beta1", dgraphtest.BackupRestore)) - // upgrade - x.Panic(c.Upgrade("v23.0.0-beta1")) - - // setup the client again - dg, err = c.Client() - if err != nil { - panic(err) - } - client = dg + dg, cleanup, err = c.Client() + x.Panic(err) + defer cleanup() + x.Panic(dg.LoginIntoNamespace(context.Background(), dgraphtest.DefaultUser, dgraphtest.DefaultPassword, 0)) - // Run tests + client = dg.Dgraph + dc = c _ = m.Run() } diff --git a/systest/audit_encrypted/audit_test.go b/systest/audit_encrypted/audit_test.go index 97e268bb41d..6faff24dad0 100644 --- a/systest/audit_encrypted/audit_test.go +++ b/systest/audit_encrypted/audit_test.go @@ -1,3 +1,5 @@ +//go:build integration + /* * Copyright 2017-2023 Dgraph Labs, Inc. and Contributors *