Skip to content

Commit

Permalink
Allow backup ID to be passed to restore endpoint. (dgraph-io#5208)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmr authored and dna2github committed Jul 18, 2020
1 parent f8b3d8d commit 517bb6c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
5 changes: 5 additions & 0 deletions graphql/admin/endpoints_ee.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ const adminTypes = `
"""
location: String!
"""
Backup ID of the backup series to restore. This ID is included in the manifest.json file.
"""
backupId: String!
"""
Access key credential for the destination.
"""
Expand Down
2 changes: 2 additions & 0 deletions graphql/admin/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type restoreResolver struct {

type restoreInput struct {
Location string
BackupId string
AccessKey string
SecretKey string
SessionToken string
Expand All @@ -52,6 +53,7 @@ func (rr *restoreResolver) Rewrite(

req := pb.RestoreRequest{
Location: input.Location,
BackupId: input.BackupId,
AccessKey: input.AccessKey,
SecretKey: input.SecretKey,
SessionToken: input.SessionToken,
Expand Down
26 changes: 25 additions & 1 deletion systest/online-restore/online_restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (

func sendRestoreRequest(t *testing.T) {
restoreRequest := `mutation restore() {
restore(input: {location: "/data/alpha1/backup"}) {
restore(input: {location: "/data/alpha1/backup", backupId: "compassionate_antonelli7"}) {
response {
code
message
Expand Down Expand Up @@ -135,3 +135,27 @@ func TestBasicRestore(t *testing.T) {
runQueries(t, dg)
runMutations(t, dg)
}

func TestInvalidBackupId(t *testing.T) {
restoreRequest := `mutation restore() {
restore(input: {location: "/data/alpha1/backup", backupId: "bad-backup-id"}) {
response {
code
message
}
}
}`

adminUrl := "http://localhost:8180/admin"
params := testutil.GraphQLParams{
Query: restoreRequest,
}
b, err := json.Marshal(params)
require.NoError(t, err)

resp, err := http.Post(adminUrl, "application/json", bytes.NewBuffer(b))
require.NoError(t, err)
buf, err := ioutil.ReadAll(resp.Body)
require.NoError(t, err)
require.Contains(t, string(buf), "failed to verify backup")
}

0 comments on commit 517bb6c

Please sign in to comment.