Skip to content

Commit

Permalink
[BREAKING] chore(dgraph): remove restore tracker as its not necessary (
Browse files Browse the repository at this point in the history
…#7148)

* remove restore tracker as its not necessary

* fixing test cases with restore removal

* making t.go to shut gracefully. no log.fatal

* fixing merge issues

* fixing for oss

* fixing error return
  • Loading branch information
aman-bansal authored Dec 21, 2020
1 parent 96b1fa5 commit a572947
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 371 deletions.
4 changes: 0 additions & 4 deletions graphql/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ var (
"state": {resolve.IpWhitelistingMW4Query, resolve.LoggingMWQuery}, // dgraph checks Guardian auth for state
"config": commonAdminQueryMWs,
"listBackups": commonAdminQueryMWs,
"restoreStatus": commonAdminQueryMWs,
"getGQLSchema": commonAdminQueryMWs,
// for queries and mutations related to User/Group, dgraph handles Guardian auth,
// so no need to apply GuardianAuth Middleware
Expand Down Expand Up @@ -592,9 +591,6 @@ func newAdminResolverFactory() resolve.ResolverFactory {
WithQueryResolver("listBackups", func(q schema.Query) resolve.QueryResolver {
return resolve.QueryResolverFunc(resolveListBackups)
}).
WithQueryResolver("restoreStatus", func(q schema.Query) resolve.QueryResolver {
return resolve.QueryResolverFunc(resolveRestoreStatus)
}).
WithMutationResolver("updateGQLSchema", func(m schema.Mutation) resolve.MutationResolver {
return resolve.MutationResolverFunc(
func(ctx context.Context, m schema.Mutation) (*resolve.Resolved, bool) {
Expand Down
25 changes: 1 addition & 24 deletions graphql/admin/endpoints_ee.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,13 @@ const adminTypes = `
type RestorePayload {
"""
A short string indicating whether the restore operation was successfully scheduled.
The status of the operation can be queried using the restoreStatus endpoint.
"""
code: String
"""
Includes the error message if the operation failed.
"""
message: String
"""
The unique ID that can be used to query the status of the restore operation.
"""
restoreId: Int
}
input ListBackupsInput {
Expand Down Expand Up @@ -229,18 +223,6 @@ const adminTypes = `
"""
type: String
}
type RestoreStatus {
"""
The status of the restore operation. One of UNKNOWN, IN_PROGRESS, OK, or ERR.
"""
status: String!
"""
A list of error messages if the restore operation failed.
"""
errors: [String]
}
type LoginResponse {
Expand Down Expand Up @@ -497,9 +479,4 @@ const adminQueries = `
"""
Get the information about the backups at a given location.
"""
listBackups(input: ListBackupsInput!) : [Manifest]
"""
Get information about a restore operation.
"""
restoreStatus(restoreId: Int!) : RestoreStatus`
listBackups(input: ListBackupsInput!) : [Manifest]`
8 changes: 3 additions & 5 deletions graphql/admin/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ func resolveRestore(ctx context.Context, m schema.Mutation) (*resolve.Resolved,
VaultField: input.VaultField,
VaultFormat: input.VaultFormat,
}
restoreId, err := worker.ProcessRestoreRequest(context.Background(), &req)
err = worker.ProcessRestoreRequest(context.Background(), &req)
if err != nil {
worker.DeleteRestoreId(restoreId)
return &resolve.Resolved{
Data: map[string]interface{}{m.Name(): map[string]interface{}{
"code": "Failure",
Expand All @@ -80,9 +79,8 @@ func resolveRestore(ctx context.Context, m schema.Mutation) (*resolve.Resolved,

return &resolve.Resolved{
Data: map[string]interface{}{m.Name(): map[string]interface{}{
"code": "Success",
"message": "Restore operation started.",
"restoreId": restoreId,
"code": "Success",
"message": "Restore operation started.",
}},
Field: m,
}, true
Expand Down
99 changes: 0 additions & 99 deletions graphql/admin/restore_status.go

This file was deleted.

38 changes: 0 additions & 38 deletions graphql/admin/restore_status_test.go

This file was deleted.

15 changes: 6 additions & 9 deletions systest/backup/filesystem/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var (
}
)

func sendRestoreRequest(t *testing.T, location string) int {
func sendRestoreRequest(t *testing.T, location string) {
if location == "" {
location = "/data/backup"
}
Expand All @@ -63,7 +63,6 @@ func sendRestoreRequest(t *testing.T, location string) int {
restore(input: {location: $location}) {
code
message
restoreId
}
}`,
Variables: map[string]interface{}{
Expand All @@ -77,14 +76,12 @@ func sendRestoreRequest(t *testing.T, location string) int {
Restore struct {
Code string
Message string
RestoreId int
}
}

require.NoError(t, json.Unmarshal(resp.Data, &restoreResp))
require.Equal(t, restoreResp.Restore.Code, "Success")
require.Greater(t, restoreResp.Restore.RestoreId, 0)
return restoreResp.Restore.RestoreId
return
}

// This test takes a backup and then restores an old backup in a cluster incrementally.
Expand All @@ -104,8 +101,8 @@ func TestBackupOfOldRestore(t *testing.T) {

_ = runBackup(t, 3, 1)

restoreId := sendRestoreRequest(t, oldBackupDir)
testutil.WaitForRestore(t, restoreId, dg)
sendRestoreRequest(t, oldBackupDir)
testutil.WaitForRestore(t, dg)

resp, err := dg.NewTxn().Query(context.Background(), `{ authors(func: has(Author.name)) { count(uid) } }`)
require.NoError(t, err)
Expand All @@ -116,8 +113,8 @@ func TestBackupOfOldRestore(t *testing.T) {
// Clean the cluster and try restoring the backups created above.
testutil.DropAll(t, dg)
time.Sleep(2 * time.Second)
restoreId = sendRestoreRequest(t, alphaBackupDir)
testutil.WaitForRestore(t, restoreId, dg)
sendRestoreRequest(t, alphaBackupDir)
testutil.WaitForRestore(t, dg)

resp, err = dg.NewTxn().Query(context.Background(), `{ authors(func: has(Author.name)) { count(uid) } }`)
require.NoError(t, err)
Expand Down
28 changes: 12 additions & 16 deletions systest/online-restore/online_restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"github.com/dgraph-io/dgraph/testutil"
)

func sendRestoreRequest(t *testing.T, location, backupId string, backupNum int) int {
func sendRestoreRequest(t *testing.T, location, backupId string, backupNum int) {
if location == "" {
location = "/data/backup2"
}
Expand All @@ -49,7 +49,6 @@ func sendRestoreRequest(t *testing.T, location, backupId string, backupNum int)
encryptionKeyFile: "/data/keys/enc_key"}) {
code
message
restoreId
}
}`,
Variables: map[string]interface{}{
Expand All @@ -70,8 +69,7 @@ func sendRestoreRequest(t *testing.T, location, backupId string, backupNum int)
}
require.NoError(t, json.Unmarshal(resp.Data, &restoreResp))
require.Equal(t, restoreResp.Restore.Code, "Success")
require.Greater(t, restoreResp.Restore.RestoreId, 0)
return restoreResp.Restore.RestoreId
return
}

// disableDraining disables draining mode before each test for increased reliability.
Expand Down Expand Up @@ -179,8 +177,8 @@ func TestBasicRestore(t *testing.T) {
ctx := context.Background()
require.NoError(t, dg.Alter(ctx, &api.Operation{DropAll: true}))

restoreId := sendRestoreRequest(t, "", "youthful_rhodes3", 0)
testutil.WaitForRestore(t, restoreId, dg)
sendRestoreRequest(t, "", "youthful_rhodes3", 0)
testutil.WaitForRestore(t, dg)
runQueries(t, dg, false)
runMutations(t, dg)
}
Expand All @@ -196,8 +194,8 @@ func TestRestoreBackupNum(t *testing.T) {
require.NoError(t, dg.Alter(ctx, &api.Operation{DropAll: true}))
runQueries(t, dg, true)

restoreId := sendRestoreRequest(t, "", "youthful_rhodes3", 1)
testutil.WaitForRestore(t, restoreId, dg)
sendRestoreRequest(t, "", "youthful_rhodes3", 1)
testutil.WaitForRestore(t, dg)
runQueries(t, dg, true)
runMutations(t, dg)
}
Expand All @@ -219,7 +217,6 @@ func TestRestoreBackupNumInvalid(t *testing.T) {
encryptionKeyFile: "/data/keys/enc_key"}) {
code
message
restoreId
}
}`, "youthful_rhodes3", 1000)

Expand All @@ -243,7 +240,6 @@ func TestRestoreBackupNumInvalid(t *testing.T) {
encryptionKeyFile: "/data/keys/enc_key"}) {
code
message
restoreId
}
}`, "youthful_rhodes3", -1)

Expand Down Expand Up @@ -271,14 +267,14 @@ func TestMoveTablets(t *testing.T) {
ctx := context.Background()
require.NoError(t, dg.Alter(ctx, &api.Operation{DropAll: true}))

restoreId := sendRestoreRequest(t, "", "youthful_rhodes3", 0)
testutil.WaitForRestore(t, restoreId, dg)
sendRestoreRequest(t, "", "youthful_rhodes3", 0)
testutil.WaitForRestore(t, dg)
runQueries(t, dg, false)

// Send another restore request with a different backup. This backup has some of the
// same predicates as the previous one but they are stored in different groups.
restoreId = sendRestoreRequest(t, "", "blissful_hermann1", 0)
testutil.WaitForRestore(t, restoreId, dg)
sendRestoreRequest(t, "", "blissful_hermann1", 0)
testutil.WaitForRestore(t, dg)

resp, err := dg.NewTxn().Query(context.Background(), `{
q(func: has(name), orderasc: name) {
Expand Down Expand Up @@ -307,7 +303,6 @@ func TestInvalidBackupId(t *testing.T) {
encryptionKeyFile: "/data/keys/enc_key"}) {
code
message
restoreId
}
}`

Expand Down Expand Up @@ -571,7 +566,8 @@ func backupRestoreAndVerify(t *testing.T, dg *dgo.Dgraph, backupDir, queryToVeri
expectedResponse string, schemaVerificationOpts testutil.SchemaOptions) {
schemaVerificationOpts.ExcludeAclSchema = true
backup(t, backupDir)
testutil.WaitForRestore(t, sendRestoreRequest(t, backupDir, "", 0), dg)
sendRestoreRequest(t, backupDir, "", 0)
testutil.WaitForRestore(t, dg)
testutil.VerifyQueryResponse(t, dg, queryToVerify, expectedResponse)
testutil.VerifySchema(t, dg, schemaVerificationOpts)
}
Loading

0 comments on commit a572947

Please sign in to comment.