-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(test): Integration tests for advanced backup/restore scenarios #8643
Conversation
b777af2
to
78de1d8
Compare
78de1d8
to
25f1b3f
Compare
25f1b3f
to
856507b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much better, just two more comments:
- can we use shared volume instead of .gitkeep files
- can we refactor code from other backup test and use the functions that you have added?
) | ||
|
||
func TestDeletedNamespaceID(t *testing.T) { | ||
defer utilsCommon.DirCleanup(t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we only doing cleanup? Where do we create the dir that we are cleaning up here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
backupTemp folder gets created when the code takes a backup(backupdest is /data/backups/backupTemp).
Now the test is using shared volume and I have removed the DirCleanup() call from the test.
d8a3adc
to
9db7a5c
Compare
graphql/e2e/common/common.go
Outdated
func CreateNamespace(t *testing.T, headers http.Header) uint64 { | ||
type CreateNamespaceParams struct { | ||
CustomGraphAdminURLs string | ||
NamespaceQuant int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NamespaceQuant -> just Count
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
_ = e2eCommon.CreateNamespace(t, headerAlpha1, e2eCommon.CreateNamespaceParams{CustomGraphAdminURLs: "", NamespaceQuant: 20}) | ||
utilsCommon.AddSchema(t, headerAlpha1, "alpha1") | ||
e2eCommon.AssertGetGQLSchema(t, testutil.ContainerAddr("alpha1", 8080), headerAlpha1) | ||
utilsCommon.AddData(t, 1, 10, jwtTokenAlpha1, "alpha1") | ||
utilsCommon.CheckDataExists(t, 10, jwtTokenAlpha1, "alpha1") | ||
_ = e2eCommon.CreateNamespace(t, headerAlpha1, e2eCommon.CreateNamespaceParams{CustomGraphAdminURLs: "", NamespaceQuant: 20}) | ||
utilsCommon.AddData(t, 11, 20, jwtTokenAlpha1, "alpha1") | ||
utilsCommon.CheckDataExists(t, 20, jwtTokenAlpha1, "alpha1") | ||
_ = e2eCommon.CreateNamespace(t, headerAlpha1, e2eCommon.CreateNamespaceParams{CustomGraphAdminURLs: "", NamespaceQuant: 20}) | ||
utilsCommon.AddData(t, 21, 30, jwtTokenAlpha1, "alpha1") | ||
utilsCommon.CheckDataExists(t, 30, jwtTokenAlpha1, "alpha1") | ||
_ = e2eCommon.CreateNamespace(t, headerAlpha1, e2eCommon.CreateNamespaceParams{CustomGraphAdminURLs: "", NamespaceQuant: 20}) | ||
utilsCommon.AddData(t, 31, 40, jwtTokenAlpha1, "alpha1") | ||
utilsCommon.CheckDataExists(t, 40, jwtTokenAlpha1, "alpha1") | ||
_ = e2eCommon.CreateNamespace(t, headerAlpha1, e2eCommon.CreateNamespaceParams{CustomGraphAdminURLs: "", NamespaceQuant: 20}) | ||
utilsCommon.AddData(t, 41, 50, jwtTokenAlpha1, "alpha1") | ||
utilsCommon.CheckDataExists(t, 50, jwtTokenAlpha1, "alpha1") | ||
_ = e2eCommon.CreateNamespace(t, headerAlpha1, e2eCommon.CreateNamespaceParams{CustomGraphAdminURLs: "", NamespaceQuant: 20}) | ||
utilsCommon.AddData(t, 51, 60, jwtTokenAlpha1, "alpha1") | ||
utilsCommon.CheckDataExists(t, 60, jwtTokenAlpha1, "alpha1") | ||
_ = e2eCommon.CreateNamespace(t, headerAlpha1, e2eCommon.CreateNamespaceParams{CustomGraphAdminURLs: "", NamespaceQuant: 30}) | ||
utilsCommon.AddData(t, 61, 70, jwtTokenAlpha1, "alpha1") | ||
utilsCommon.CheckDataExists(t, 70, jwtTokenAlpha1, "alpha1") | ||
utilsCommon.TakeBackup(t, jwtTokenAlpha1, backupDst, "alpha1") | ||
utilsCommon.RunRestore(t, jwtTokenAlpha2, restoreLocation, "alpha2") | ||
dg := testutil.DgClientWithLogin(t, "groot", "password", x.GalaxyNamespace) | ||
testutil.WaitForRestore(t, dg, testutil.ContainerAddr("alpha2", 8080)) | ||
e2eCommon.AssertGetGQLSchema(t, testutil.ContainerAddr("alpha2", 8080), headerAlpha2) | ||
utilsCommon.CheckDataExists(t, 70, jwtTokenAlpha2, "alpha2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need so many steps, what would more useful would be distributing data across different namespaces as well.
I'd structure it like this:
- Step 1, Create 50 namespaces, add data to namespace 0, take backup and restore and check if data is present. (in the restored backend)
- Step 2. Create another 50 namespaced, add data to namespace 51, take backup and restore and check if the data is present in 0 and 51
- Step 3 Create another 50 namespaces, add data to namespace 130,, take backup and restore and check if data is present in 0, 51 and 130.
With this we check iteratively adding data to new namespaces preserves data in older namespaces across restores. We also check the namespace increment is monotonic, that is after first restore we get the namespace 51 created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
Now the test has the following flow:-
Create 1-50 Namespaces
Add data to Namespace 0
Backup on Alpha1
Restore on Alpha2
Log into Namespace 0 on Alpha2
CheckDataExist
Create 51-100 Namespaces
Add data to 51 Namespace
Backup on Alpha1
Restore on Alpha 2
Log into Namespace 0 on Alpha2
CheckDataExist
Log into Namespace51 on Alpha2
CheckDataExist
Create 101-130 Namespaces
Add data to Namespace 130
Backup on Alpha1
Restore on Alpha 2
Log into Namespace 0 on Alpha2
CheckDataExist
Log into Namespace51 on Alpha2
CheckDataExist
Log into Namespace130 on Alpha2
CheckDataExist
9db7a5c
to
6619f68
Compare
headerAlpha1Np0.Set("Content-Type", "application/json") | ||
|
||
jwtTokenAlpha2Np0 := testutil.GrootHttpLoginNamespace("http://"+testutil.ContainerAddr("alpha2", 8080)+"/admin", 0).AccessJwt | ||
headerAlpha2Np0.Set(accessJwtHeader, jwtTokenAlpha2Np0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a lot of this code can be wrapped inside a function and can be re-used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
graphql/e2e/common/common.go
Outdated
@@ -70,6 +70,9 @@ var ( | |||
"indicating that the GraphQL layer didn't get the updated schema even after 10" + | |||
" retries. The most probable cause is the new GraphQL schema is same as the old" + | |||
" GraphQL schema." | |||
|
|||
customAdminURL string | |||
namespaceCount = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can define this inside the test/function itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
graphql/e2e/common/common.go
Outdated
@@ -329,7 +332,12 @@ func containsRetryableCreateNamespaceError(resp *GraphQLResponse) bool { | |||
return false | |||
} | |||
|
|||
func CreateNamespace(t *testing.T, headers http.Header) uint64 { | |||
type CreateNamespaceParams struct { | |||
CustomGraphAdminURLs string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can it be just GraphAdminURLs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
graphql/e2e/common/common.go
Outdated
|
||
func CreateNamespace(t *testing.T, headers http.Header, cnp ...CreateNamespaceParams) uint64 { | ||
var customAdminURL string | ||
var namespaceCount = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be
const namespaceCount = 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
graphql/e2e/common/common.go
Outdated
@@ -360,7 +379,7 @@ func CreateNamespace(t *testing.T, headers http.Header) uint64 { | |||
return resp.AddNamespace.NamespaceId | |||
} | |||
|
|||
func DeleteNamespace(t *testing.T, id uint64, header http.Header) { | |||
func DeleteNamespace(t *testing.T, id uint64, header http.Header, whichAlpha ...string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should change this function instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
The same fix is applied to CreateNamespace()
graphql/e2e/common/common.go
Outdated
Count int | ||
} | ||
|
||
func CreateNamespace(t *testing.T, headers http.Header, cnp ...CreateNamespaceParams) uint64 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to have two functions here CreateNamespace
and CreateNamespaces
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
20ac6d3
to
2a8a2d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few minor comments, otherwise looks good
graphql/e2e/common/common.go
Outdated
@@ -344,7 +353,8 @@ func CreateNamespace(t *testing.T, headers http.Header) uint64 { | |||
// keep retrying as long as we get a retryable error | |||
var gqlResponse *GraphQLResponse | |||
for { | |||
gqlResponse = createNamespace.ExecuteAsPost(t, GraphqlAdminURL) | |||
// gqlResponse = createNamespace.ExecuteAsPost(t, GraphqlAdminURL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
source: $GOPATH/bin | ||
target: /gobin | ||
read_only: true | ||
- data-volume:/data/backups/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you leave a space after colon just like we do everywhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reconfirmed online. Shared volumes are written like this.
systest/backup/common/utils.go
Outdated
@@ -91,6 +101,179 @@ func CopyToLocalFs(t *testing.T) { | |||
require.NoError(t, testutil.DockerCp(srcPath, copyBackupDir)) | |||
} | |||
|
|||
func AddSchema(t *testing.T, header http.Header, whichAlpha string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decided against changing the name as we discussed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
2a8a2d7
to
61a8d70
Compare
… out of range [0] with length 0'
1] Resolved review comments 2] Updated CreateNamespace() to accept whichAlpha string value on which it runs mutation 3] Added CreateNamespaces() to iterate CreateNamespace() function to create multiple namespaces. 4] Updated DeleteNamespace() to accept whichAlpha string value on which it runs mutation 5] Updated the CreateNamespace() & DeleteNamespace() function calls from multi_tenancy_test.go & 127-Namespace/backup_test.go
d06322b
61a8d70
to
d06322b
Compare
This PR contains Integration tests for:
1] Illegal namespace test (more than 127 namespaces).