-
Notifications
You must be signed in to change notification settings - Fork 73
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
ASC-393 Refactoring of proxy_test.go #803
Conversation
Skipping CI for Draft Pull Request. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: jkopriva The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: Josef Kopriva <[email protected]>
Signed-off-by: Josef Kopriva <[email protected]>
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.
contents looks good overall! I just left a few comments about the form
Signed-off-by: Josef Kopriva <[email protected]>
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.
Thanks, these are great changes! They look good overall. I've left a few comments about the code but I have some general questions/comment as well:
-
If I understand the changes correctly, it's mainly taking everything that was in proxy_test.go and splitting it into separate files and tests and making the tests run in parallel. So shouldn't we delete the proxy_test.go file as part of this PR?
-
I think we would need to move the test files from
test/e2e/proxy
totest/e2e/parallel/proxy
in order for them to run in parallel since only tests under thetest/e2e/parallel
dir are run in parallel. See https://github.com/codeready-toolchain/toolchain-e2e/blob/2d619cfee45849678d9691a1ce95e6f3b8386ffb/make/test.mk#L119C186-L119C186 -
Would it be better to rename the
testsupport/appstudio
package totestsupport/proxy
? I think those utilities have more to do with the proxy than appstudio.
Signed-off-by: Josef Kopriva <[email protected]>
Signed-off-by: Josef Kopriva <[email protected]>
Hey @jkopriva, thanks a lot for your PR. Test execution PR description
But I don't see any parallelization there yet, or am I missing something? |
Signed-off-by: Josef Kopriva <[email protected]>
Hi @rajivnathan, Thank you for review! |
@MatousJobanek Hi, thank you for comments. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
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.
overall looks good - If I understand the changes correctly, it's just about moving the tests and functions around and separating them.
I'm slightly missing the point of introducing a new package and moving the tests there and I'm also missing your plans for introducing parallelization. Could you please add a topic to the next sync call so we can discuss it?
@@ -122,7 +122,7 @@ e2e-run-parallel: | |||
.PHONY: e2e-run | |||
e2e-run: | |||
@echo "Running e2e tests..." | |||
$(MAKE) execute-tests MEMBER_NS=${MEMBER_NS} MEMBER_NS_2=${MEMBER_NS_2} HOST_NS=${HOST_NS} REGISTRATION_SERVICE_NS=${REGISTRATION_SERVICE_NS} TESTS_TO_EXECUTE="./test/e2e ./test/metrics" | |||
$(MAKE) execute-tests MEMBER_NS=${MEMBER_NS} MEMBER_NS_2=${MEMBER_NS_2} HOST_NS=${HOST_NS} REGISTRATION_SERVICE_NS=${REGISTRATION_SERVICE_NS} TESTS_TO_EXECUTE="./test/e2e ./test/e2e/proxy ./test/metrics" |
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 could do this instead, right?
$(MAKE) execute-tests MEMBER_NS=${MEMBER_NS} MEMBER_NS_2=${MEMBER_NS_2} HOST_NS=${HOST_NS} REGISTRATION_SERVICE_NS=${REGISTRATION_SERVICE_NS} TESTS_TO_EXECUTE="./test/e2e ./test/e2e/proxy ./test/metrics" | |
$(MAKE) execute-tests MEMBER_NS=${MEMBER_NS} MEMBER_NS_2=${MEMBER_NS_2} HOST_NS=${HOST_NS} REGISTRATION_SERVICE_NS=${REGISTRATION_SERVICE_NS} TESTS_TO_EXECUTE="./test/e2e/... ./test/metrics" |
but is there really a benefit of moving it to a separate package?
func SetAppstudioConfig(t *testing.T, hostAwait *wait.HostAwaitility, memberAwait *wait.MemberAwaitility) { | ||
// member cluster configured to skip user creation to mimic appstudio configuration where user & identity resources are not created | ||
memberConfigurationWithSkipUserCreation := testconfig.ModifyMemberOperatorConfigObj(memberAwait.GetMemberOperatorConfig(t), testconfig.SkipUserCreation(true)) | ||
// configure default space tier to appstudio | ||
hostAwait.UpdateToolchainConfig(t, testconfig.Tiers().DefaultUserTier("deactivate30").DefaultSpaceTier("appstudio"), testconfig.Members().Default(memberConfigurationWithSkipUserCreation.Spec)) | ||
} |
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.
could you please shed more light on how you want to introduce the parallelization of the tests when you change the global configuration?
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 will be deleted in future - here it is just to avoid duplicated code.
// and the same group as the actual one. The CRD is created as part of the test setup | ||
// and since the CRD name & group name matches, then RBAC allow us to execute create/read | ||
// operations on that resource using the user permissions. | ||
func TestProxyFlow(t *testing.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.
related to the other comment, I don't see how we could get closer to sending many requests to proxy in a parallel way. There are many sub-tests that will be executed in sequential order.
I hoped that we could have something closer to what we do in migration tests. see
toolchain-e2e/test/migration/setup_runner.go
Lines 38 to 59 in 713b901
func (r *SetupMigrationRunner) Run(t *testing.T) { | |
var wg sync.WaitGroup | |
toRun := []func(t *testing.T){ | |
r.prepareAppStudioProvisionedSpace, | |
r.prepareSecondMemberProvisionedSpace, | |
r.prepareProvisionedUser, | |
r.prepareSecondMemberProvisionedUser, | |
r.prepareDeactivatedUser, | |
r.prepareBannedUser, | |
r.prepareAppStudioProvisionedUser} | |
for _, funcToRun := range toRun { | |
wg.Add(1) | |
go func(run func(t *testing.T)) { | |
defer wg.Done() | |
run(t) | |
}(funcToRun) | |
} | |
wg.Wait() | |
} |
toolchain-e2e/test/migration/verify/verify_migration_test.go
Lines 68 to 106 in 713b901
func runVerifyFunctions(t *testing.T, awaitilities wait.Awaitilities) { | |
// check MUR migrations and get Signups for the users provisioned in the setup part | |
t.Log("checking MUR Migrations") | |
provisionedSignup := checkMURMigratedAndGetSignup(t, awaitilities.Host(), migration.ProvisionedUser) | |
secondMemberProvisionedSignup := checkMURMigratedAndGetSignup(t, awaitilities.Host(), migration.SecondMemberProvisionedUser) | |
appstudioProvisionedSignup := checkMURMigratedAndGetSignup(t, awaitilities.Host(), migration.AppStudioProvisionedUser) | |
// note: listing banned/deactivated UserSignups should be done as part of setup because the tests are run in parallel and there can be multiple banned/deactivated UserSignups at that point which could lead to test flakiness | |
deactivatedSignup := listAndGetSignupWithState(t, awaitilities.Host(), toolchainv1alpha1.UserSignupStateLabelValueDeactivated) | |
bannedSignup := listAndGetSignupWithState(t, awaitilities.Host(), toolchainv1alpha1.UserSignupStateLabelValueBanned) | |
var wg sync.WaitGroup | |
// prepare all functions to verify the state of the Signups and Spaces | |
toRun := []func(){ | |
// Spaces | |
func() { verifyAppStudioProvisionedSpace(t, awaitilities) }, | |
func() { verifySecondMemberProvisionedSpace(t, awaitilities) }, | |
// UserSignups | |
func() { verifyProvisionedSignup(t, awaitilities, provisionedSignup) }, | |
func() { verifySecondMemberProvisionedSignup(t, awaitilities, secondMemberProvisionedSignup) }, | |
func() { verifyAppStudioProvisionedSignup(t, awaitilities, appstudioProvisionedSignup) }, | |
func() { verifyDeactivatedSignup(t, awaitilities, deactivatedSignup) }, | |
func() { verifyBannedSignup(t, awaitilities, bannedSignup) }, | |
} | |
// when & then - run all functions in parallel | |
for _, funcToRun := range toRun { | |
wg.Add(1) | |
go func(run func()) { | |
defer wg.Done() | |
run() | |
}(funcToRun) | |
} | |
wg.Wait() | |
cleanup.ExecuteAllCleanTasks(t) | |
} |
A very very quick example of what it could look like:
...
usersToBeTested := createUsersForParallelTests("user1"..."user10")
usersToBeTested["user1"].ShareSpaceWith(t, hostAwait, users["user2"])
usersToBeTested["user4"].ShareSpaceWith(t, hostAwait, users["user2"])
usersToBeTested["user10"].ShareSpaceWith(t, hostAwait, users["user5"])
...
for _, user := range usersToBeTested {
// provision users
user.provision()
user.shareWithOtherUsers()
user.verify().assessToWorkspaces() // space lister verification
for _, action := actionsToBeTested { // CRUD, watch, websockets operations, etc...
go func() {
user.verify().action(action).inAllWorkspaces()
}()
}
}
...
the actions to be tested are the whole stories like
action 1:
- create CM
- list CMs
- delete CM
action2
- watch secrets
- create secret
- modify it
- delete it
action3
- create pod
- see the logs
- delete pod
etc...
All these things could be easily hidden behind a nice fluent API and set of functions. You can technically reuse most of the functions that are already there - eg the one for running websockets.
Is this still your plan and this PR is only a preparation for it?
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.
Thank you for this comment. I am working on running tests in parallel in similar way, as you pointed out and this PR is more about preparation for next PR(s) with parallelization.
Let's close this PR for now. |
This PR about refactoring proxy_test.go file and splitting it in more files to make tests readable.
Parallelization of proxy tests will be part of next PRs.