-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tests): test for deleted namespace (#8693)
this test ensures that we don't miss out on bumping the max namespace ID after a restore if before backup the max namespace had been deleted.
- Loading branch information
1 parent
7609ee4
commit 968080c
Showing
3 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
systest/backup/advanced-scenarios/deleted-namespace/backup_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
e2eCommon "github.com/dgraph-io/dgraph/graphql/e2e/common" | ||
utilsCommon "github.com/dgraph-io/dgraph/systest/backup/common" | ||
"github.com/dgraph-io/dgraph/testutil" | ||
"github.com/dgraph-io/dgraph/x" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
const ( | ||
accessJwtHeader = "X-Dgraph-AccessToken" | ||
restoreLocation = "/data/backups/" | ||
backupDst = "/data/backups/" | ||
) | ||
|
||
func TestDeletedNamespaceID(t *testing.T) { | ||
jwtTokenAlpha1Np0, headerAlpha1Np0 := utilsCommon.GetJwtTokenAndHeader(t, "alpha1", 0) | ||
jwtTokenAlpha2Np0, headerAlpha2Np0 := utilsCommon.GetJwtTokenAndHeader(t, "alpha2", 0) | ||
ns1 := e2eCommon.CreateNamespaces(t, headerAlpha1Np0, "alpha1", 4) | ||
jwtTokenAlpha1Np1, headerAlpha1Np1 := utilsCommon.GetJwtTokenAndHeader(t, "alpha1", 1) | ||
utilsCommon.AddItemSchema(t, headerAlpha1Np1, "alpha1") | ||
utilsCommon.AddItem(t, 11, 20, jwtTokenAlpha1Np1, "alpha1") | ||
jwtTokenAlpha1Np2, headerAlpha1Np2 := utilsCommon.GetJwtTokenAndHeader(t, "alpha1", 2) | ||
utilsCommon.AddItemSchema(t, headerAlpha1Np2, "alpha1") | ||
utilsCommon.AddItem(t, 21, 30, jwtTokenAlpha1Np2, "alpha1") | ||
jwtTokenAlpha1Np3, headerAlpha1Np3 := utilsCommon.GetJwtTokenAndHeader(t, "alpha1", 3) | ||
utilsCommon.AddItemSchema(t, headerAlpha1Np3, "alpha1") | ||
utilsCommon.AddItem(t, 31, 40, jwtTokenAlpha1Np3, "alpha1") | ||
jwtTokenAlpha1Np4, headerAlpha1Np4 := utilsCommon.GetJwtTokenAndHeader(t, "alpha1", 4) | ||
utilsCommon.AddItemSchema(t, headerAlpha1Np4, "alpha1") | ||
utilsCommon.AddItem(t, 41, 50, jwtTokenAlpha1Np4, "alpha1") | ||
e2eCommon.DeleteNamespace(t, ns1[2], headerAlpha1Np0, "alpha1") | ||
utilsCommon.TakeBackup(t, jwtTokenAlpha1Np0, backupDst, "alpha1") | ||
utilsCommon.RunRestore(t, jwtTokenAlpha2Np0, restoreLocation, "alpha2") | ||
dg1 := testutil.DgClientWithLogin(t, "groot", "password", x.GalaxyNamespace) | ||
testutil.WaitForRestore(t, dg1, testutil.ContainerAddr("alpha2", 8080)) | ||
lastAddedNamespaceId := e2eCommon.CreateNamespace(t, headerAlpha2Np0, "alpha2") | ||
require.Equal(t, lastAddedNamespaceId > ns1[3], true) | ||
require.Greater(t, lastAddedNamespaceId, ns1[3]) | ||
jwtTokenAlpha2Np1, _ := utilsCommon.GetJwtTokenAndHeader(t, "alpha2", 1) | ||
utilsCommon.CheckItemExists(t, 15, jwtTokenAlpha2Np1, "alpha2") | ||
jwtTokenAlpha2Np2, _ := utilsCommon.GetJwtTokenAndHeader(t, "alpha2", 2) | ||
utilsCommon.CheckItemExists(t, 35, jwtTokenAlpha2Np2, "alpha2") | ||
jwtTokenAlpha2Np3, _ := utilsCommon.GetJwtTokenAndHeader(t, "alpha2", 4) | ||
utilsCommon.CheckItemExists(t, 35, jwtTokenAlpha2Np3, "alpha2") | ||
nsl := e2eCommon.ListNamespaces(t, jwtTokenAlpha2Np0, headerAlpha2Np0, "alpha2") | ||
for _, ns := range nsl { | ||
require.NotEqual(t, ns, ns1[2]) | ||
} | ||
require.Contains(t, nsl, lastAddedNamespaceId) | ||
|
||
} |
86 changes: 86 additions & 0 deletions
86
systest/backup/advanced-scenarios/deleted-namespace/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Auto-generated with: [./compose -a 3 -z 1 -r 1 -w --port_offset=0 --expose_ports=false --alpha_volume=./data/backups:/data/backups/ --zero_volume=./data/backups:/data/backups/ --mem= --names=false -O ../systest/backup/multi-tenancy/docker-compose.yml --acl] | ||
# | ||
version: "3.5" | ||
services: | ||
alpha1: | ||
image: dgraph/dgraph:local | ||
working_dir: /data/alpha1 | ||
depends_on: | ||
- zero1 | ||
labels: | ||
cluster: test | ||
ports: | ||
- 8080 | ||
- 9080 | ||
volumes: | ||
- type: bind | ||
source: $GOPATH/bin | ||
target: /gobin | ||
read_only: true | ||
- type: bind | ||
source: ../../../acl/restore/acl-secret | ||
target: /secret/hmac | ||
read_only: true | ||
- data-volume:/data/backups/ | ||
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 | ||
labels: | ||
cluster: test | ||
ports: | ||
- 5080 | ||
- 6080 | ||
volumes: | ||
- type: bind | ||
source: $GOPATH/bin | ||
target: /gobin | ||
read_only: true | ||
- data-volume:/data/backups/ | ||
command: /gobin/dgraph ${COVERAGE_OUTPUT} zero --raft "idx=1;" --my=zero1:5080 --logtostderr -v=2 --bindall | ||
|
||
alpha2: | ||
image: dgraph/dgraph:local | ||
working_dir: /data/alpha2 | ||
depends_on: | ||
- zero2 | ||
labels: | ||
cluster: test | ||
ports: | ||
- 8080 | ||
- 9080 | ||
volumes: | ||
- type: bind | ||
source: $GOPATH/bin | ||
target: /gobin | ||
read_only: true | ||
- type: bind | ||
source: ../../../acl/restore/acl-secret | ||
target: /secret/hmac | ||
read_only: true | ||
- data-volume:/data/backups/ | ||
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 | ||
labels: | ||
cluster: test | ||
ports: | ||
- 5080 | ||
- 6080 | ||
volumes: | ||
- type: bind | ||
source: $GOPATH/bin | ||
target: /gobin | ||
read_only: true | ||
- data-volume:/data/backups/ | ||
command: /gobin/dgraph ${COVERAGE_OUTPUT} zero --raft "idx=1;" --my=zero2:5080 --logtostderr -v=2 --bindall | ||
volumes: | ||
data-volume: | ||
|