Skip to content
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

Refactored kestest integration tests #368

Merged
merged 2 commits into from
May 18, 2023
Merged

Conversation

shtripat
Copy link
Contributor

@shtripat shtripat commented May 17, 2023

This PR adds a cleanup method to make sure each test works in its entirety and there are no left outs.
Also all tests use the same common functions for scenarios like create, import, generate, encrypt and decrypt etc.

Different kind of tests can be executed using go test -v -run="<test>" command.
e.g. go test -v -run="TestGatewayMem" or go test -v -fs.path=./keys -run="TestGatewayFS"

@shtripat shtripat requested a review from aead May 17, 2023 07:16
@shtripat shtripat force-pushed the refactor-kestest branch from e24921d to 3ff71e0 Compare May 17, 2023 07:34
Copy link
Member

@aead aead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor tweaks. Also consider a descriptive commit message as suggested by the contributing doc.
Ref: https://github.com/minio/kes/blob/master/CONTRIBUTING.md#commit-message

@@ -633,3 +626,28 @@ func mustDecodeB64(s string) []byte {
}
return b
}

func clean(ctx context.Context, client *kes.Client, pattern string, t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can omit the pattern here and use the match all pattern * in ListKeys.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can omit the pattern here and use the match all pattern * in ListKeys.

Ok, makes sense. Will do the changes.

Signed-off-by: Shubhendu Ram Tripathi <[email protected]>
@shtripat shtripat force-pushed the refactor-kestest branch from 343ea85 to 2e4fa01 Compare May 17, 2023 10:35
@shtripat shtripat requested a review from aead May 17, 2023 10:50
defer iter.Close()

names := []string{}
keysInfo, err := iter.Values(-1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iter.Values(-1) already collects all KeyInfo objects into one slice. You don't need to clone this slice again.
You can simply remove:

for _, keyInfo := range keysInfo {
	names = append(names, keyInfo.Name)
}

An just do one for loop:

for _, info := range keyInfos {
		if err = client.DeleteKey(ctx, info.Name); err != nil {
			t.Errorf("Cleanup: failed to delete '%s': %v", name, err)
		}
	}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: Shubhendu Ram Tripathi <[email protected]>
@shtripat shtripat force-pushed the refactor-kestest branch from 2e4fa01 to 6d6b57b Compare May 17, 2023 15:19
@shtripat shtripat requested a review from aead May 18, 2023 06:34
@aead aead merged commit 1ba5d33 into minio:master May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants