From 25058376b2897067669e8f8cae46a7932cdc8701 Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Tue, 14 Apr 2020 15:56:55 -0700 Subject: [PATCH 1/2] Allow backup ID to be passed to restore endpoint. --- graphql/admin/endpoints_ee.go | 5 ++++ graphql/admin/restore.go | 2 ++ systest/online-restore/online_restore_test.go | 24 +++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/graphql/admin/endpoints_ee.go b/graphql/admin/endpoints_ee.go index e1392ae4329..210c0501b0a 100644 --- a/graphql/admin/endpoints_ee.go +++ b/graphql/admin/endpoints_ee.go @@ -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. """ diff --git a/graphql/admin/restore.go b/graphql/admin/restore.go index 3153e5480b0..8895a0380f5 100644 --- a/graphql/admin/restore.go +++ b/graphql/admin/restore.go @@ -35,6 +35,7 @@ type restoreResolver struct { type restoreInput struct { Location string + BackupId string AccessKey string SecretKey string SessionToken string @@ -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, diff --git a/systest/online-restore/online_restore_test.go b/systest/online-restore/online_restore_test.go index 8d6f0d57e12..5aa544f4f86 100644 --- a/systest/online-restore/online_restore_test.go +++ b/systest/online-restore/online_restore_test.go @@ -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") +} From 713d7c57952181e53d485dac7055faeb66601adb Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Wed, 15 Apr 2020 13:29:54 -0700 Subject: [PATCH 2/2] Use backupId in test. --- systest/online-restore/online_restore_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systest/online-restore/online_restore_test.go b/systest/online-restore/online_restore_test.go index 5aa544f4f86..bac29320ed9 100644 --- a/systest/online-restore/online_restore_test.go +++ b/systest/online-restore/online_restore_test.go @@ -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