Skip to content

Commit

Permalink
tests(upgrade): add upgrade tests in query package
Browse files Browse the repository at this point in the history
  • Loading branch information
mangalaman93 committed Mar 18, 2023
1 parent da4061a commit 4cb2d10
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 19 deletions.
12 changes: 6 additions & 6 deletions query/cloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@
package query

import (
"os"
"testing"

"github.com/dgraph-io/dgraph/dgraphtest"
"github.com/dgraph-io/dgraph/x"
)

func TestMain(m *testing.M) {
c, err := dgraphtest.NewDCloudCluster()
if err != nil {
panic(err)
}
x.Panic(err)
defer c.Cleanup()

client = c.Client()
client, err = c.Client()
x.Panic(err)

dc = c
populateCluster()
os.Exit(m.Run())
_ = m.Run()
}
4 changes: 2 additions & 2 deletions query/common_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build integration || cloud
//go:build integration || cloud || upgrade

/*
* Copyright 2017-2023 Dgraph Labs, Inc. and Contributors
Expand Down Expand Up @@ -352,7 +352,7 @@ func populateCluster() {
panic(err)
}

if err := dc.AssignUids(21000); err != nil {
if err := dc.AssignUids(65536); err != nil {
panic(err)
}
setSchema(testSchema)
Expand Down
5 changes: 2 additions & 3 deletions query/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package query

import (
"os"
"testing"

"github.com/dgraph-io/dgraph/dgraphtest"
Expand All @@ -32,8 +31,8 @@ func TestMain(m *testing.M) {

var err error
client, err = testutil.DgraphClientWithGroot(testutil.SockAddr)
x.CheckfNoTrace(err)
x.Check(err)

populateCluster()
os.Exit(m.Run())
_ = m.Run()
}
2 changes: 1 addition & 1 deletion query/mutation_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build integration || cloud
//go:build integration || cloud || upgrade

/*
* Copyright 2016-2023 Dgraph Labs, Inc. and Contributors
Expand Down
2 changes: 1 addition & 1 deletion query/query0_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build integration || cloud
//go:build integration || cloud || upgrade

/*
* Copyright 2023 Dgraph Labs, Inc. and Contributors
Expand Down
2 changes: 1 addition & 1 deletion query/query1_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build integration || cloud
//go:build integration || cloud || upgrade

/*
* Copyright 2023 Dgraph Labs, Inc. and Contributors
Expand Down
2 changes: 1 addition & 1 deletion query/query2_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build integration || cloud
//go:build integration || cloud || upgrade

/*
* Copyright 2023 Dgraph Labs, Inc. and Contributors
Expand Down
2 changes: 1 addition & 1 deletion query/query3_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build integration || cloud
//go:build integration || cloud || upgrade

/*
* Copyright 2023 Dgraph Labs, Inc. and Contributors
Expand Down
2 changes: 1 addition & 1 deletion query/query4_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build integration || cloud
//go:build integration || cloud || upgrade

/*
* Copyright 2023 Dgraph Labs, Inc. and Contributors
Expand Down
2 changes: 1 addition & 1 deletion query/query_facets_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build integration || cloud
//go:build integration || cloud || upgrade

/*
* Copyright 2017-2023 Dgraph Labs, Inc. and Contributors
Expand Down
2 changes: 1 addition & 1 deletion query/rdf_result_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build integration || cloud
//go:build integration || cloud || upgrade

/*
* Copyright 2023 Dgraph Labs, Inc. and Contributors
Expand Down
62 changes: 62 additions & 0 deletions query/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//go:build upgrade

/*
* Copyright 2023 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package query

import (
"testing"
"time"

"github.com/dgraph-io/dgraph/dgraphtest"
"github.com/dgraph-io/dgraph/x"
)

func TestMain(m *testing.M) {
conf := dgraphtest.NewClusterConfig().WithNumAlphas(3).WithNumZeros(3).WithReplicas(3).
WithACL(20 * time.Second).WithEncryption().WithVersion("8b3712e")
c, err := dgraphtest.NewLocalCluster(conf)
x.Panic(err)
defer c.Cleanup()
c.Start()

// setup the global Cluster var
dc = c

// setup client
dg, err := c.Client()
if err != nil {
panic(err)
}
client = dg

// do mutations
populateCluster()

// upgrade
x.Panic(c.Upgrade("68427a7", dgraphtest.BackupRestore))

// setup the client again
dg, err = c.Client()
if err != nil {
panic(err)
}
client = dg

// Run tests
_ = m.Run()
}

0 comments on commit 4cb2d10

Please sign in to comment.