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

ISSUE-2428 refactor: improve test for EnvsClustersTenantsControllerService #2517

Merged
merged 35 commits into from
Jul 23, 2024

Conversation

luke-zhou
Copy link
Contributor

@luke-zhou luke-zhou commented Jun 25, 2024

Resolves: ISSUE-2428
#2428

What kind of change does this PR introduce?

  • Bug fix
  • New feature
  • Refactor
  • Docs update
  • CI update

What is the current behavior?

Test coverage of EnvsClustersTenantsControllerService class is only 30%

What is the new behavior?

Line coverage of EnvsClustersTenantsControllerService class is increased to 87%
image

Other information

Refactor some of the code in EnvsClustersTenantsControllerService class

Requirements (all must be checked before review)

  • The pull request title follows our guidelines
  • Tests for the changes have been added (if relevant)
  • The latest changes from the main branch have been pulled
  • pnpm lint has been run successfully

luke-zhou added 12 commits June 25, 2024 11:57
EnvsClustersTenantsControllerService
.deleteTenant .addTenantId

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.getUpdateEnvStatus .deleteEnvironment
.addNewCluster .getSyncEnvs

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.getEnvDetails

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.getClusters

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.getMyTenantInfo

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.getAllTenants

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.getEnvsForRequestTopicsCluster

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.updateTenant

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.deleteCluster

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.getClustersPaginated

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.getClustersPaginated

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService

Signed-off-by: Luke Zhou <[email protected]>
@luke-zhou luke-zhou marked this pull request as ready for review June 25, 2024 02:11
@aindriu-aiven
Copy link
Contributor

@luke-zhou Thanks a million for your contribution 🎉 , I am a little busy at the moment but I will try to start the review this evening or tomorrow morning.

Copy link
Contributor

@aindriu-aiven aindriu-aiven left a comment

Choose a reason for hiding this comment

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

Thank you @luke-zhou for this contribution.

I had some stylistic comments, but nothing else just yet.

I need to do some testing on the change but wanted to give you the head up on the mainly import related request.

Thanks you again for your contribution!

import io.aiven.klaw.model.enums.EntityType;
import io.aiven.klaw.model.enums.KafkaClustersType;
import io.aiven.klaw.model.enums.RequestStatus;
import io.aiven.klaw.model.enums.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check your IDE settings, we try to avoid using .* on imports, but a lot of them will try to automatically use .* after about 5 entries. We normally set them to 20 before using .*

There is a nice answer from stack overflow on how to set this on Intellij https://stackoverflow.com/a/3348855

import io.aiven.klaw.model.enums.RequestMode;
import io.aiven.klaw.model.enums.RequestOperationType;
import io.aiven.klaw.model.enums.RequestStatus;
import io.aiven.klaw.model.enums.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here on the imports. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

import io.aiven.klaw.model.enums.RequestMode;
import io.aiven.klaw.model.enums.RequestOperationType;
import io.aiven.klaw.model.enums.RequestStatus;
import io.aiven.klaw.model.enums.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Imports here too please

import io.aiven.klaw.model.enums.KafkaSupportedProtocol;
import io.aiven.klaw.model.enums.MetadataOperationType;
import io.aiven.klaw.model.enums.PermissionType;
import io.aiven.klaw.model.enums.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Imports here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -1103,12 +981,9 @@ public ClusterInfo getClusterInfoFromEnv(String envSelected, String clusterType)
ClusterInfo clusterInfo = new ClusterInfo();
log.debug("getEnvDetails {}", envSelected);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a pre existing log stmt but could you update it to include the method name "getClusterInfoFromEnv"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static io.aiven.klaw.error.KlawErrorMessages.*;
import static io.aiven.klaw.helpers.KwConstants.*;
import static org.assertj.core.api.Assertions.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

just imports here as well. Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@aindriu-aiven
Copy link
Contributor

Hey @luke-zhou I'm almost finished testing this PR I am sorry for the delay, I've set aside tomorrow to finish it off. Sorry again for the delay!

luke-zhou added 10 commits July 3, 2024 10:56
EnvsClustersTenantsControllerService
.deleteTenant .addTenantId

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.getUpdateEnvStatus .deleteEnvironment
.addNewCluster .getSyncEnvs

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.getEnvDetails

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.getClusters

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.getMyTenantInfo

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.getAllTenants

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.getEnvsForRequestTopicsCluster

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.updateTenant

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.deleteCluster

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService
.getClustersPaginated

Signed-off-by: Luke Zhou <[email protected]>
luke-zhou added 4 commits July 3, 2024 10:56
EnvsClustersTenantsControllerService
.getClustersPaginated

Signed-off-by: Luke Zhou <[email protected]>
EnvsClustersTenantsControllerService

Signed-off-by: Luke Zhou <[email protected]>
Copy link
Contributor

@aindriu-aiven aindriu-aiven left a comment

Choose a reason for hiding this comment

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

Hey @luke-zhou just finished testing the changes, they look great I even managed to find a pre-existing bug during testing 😓

Aside from Muralis nits I think this PR is good to merge.

Thank you so much for your contribution!

luke-zhou and others added 2 commits July 5, 2024 07:46
@luke-zhou
Copy link
Contributor Author

Thanks, committed suggestion @muralibasani

@aindriu-aiven
Copy link
Contributor

Thanks, committed suggestion @muralibasani

Hey @luke-zhou I just noticed the last commit I think needs to be signed, would you be able to sign off your last commit?
git commit --amend --signoff

@luke-zhou
Copy link
Contributor Author

Thanks, committed suggestion @muralibasani

Hey @luke-zhou I just noticed the last commit I think needs to be signed, would you be able to sign off your last commit? git commit --amend --signoff

Hi @aindriu-aiven I have signed the last commit, and pushed. However I am having issues to sign the following two commits, which i made directly on the PR page:
image

@aindriu-aiven
Copy link
Contributor

Thanks, committed suggestion @muralibasani

Hey @luke-zhou I just noticed the last commit I think needs to be signed, would you be able to sign off your last commit? git commit --amend --signoff

Hi @aindriu-aiven I have signed the last commit, and pushed. However I am having issues to sign the following two commits, which i made directly on the PR page: image

Ah I've seen this before let me check if there is a way to do this and I'll let you know asap. Thanks for checking for me!

@aindriu-aiven
Copy link
Contributor

Thanks, committed suggestion @muralibasani

Hey @luke-zhou I just noticed the last commit I think needs to be signed, would you be able to sign off your last commit? git commit --amend --signoff

Hi @aindriu-aiven I have signed the last commit, and pushed. However I am having issues to sign the following two commits, which i made directly on the PR page: image

Hey I had a chat with some colleagues in this space and apparently we can use
git rebase --signoff <your commit>

This will sign off all the commits you made until HEAD. If you don't mind giving that a go it should let us pass the DCO and merge the PR.

Thanks a million!

Copy link
Contributor

@muralibasani muralibasani left a comment

Choose a reason for hiding this comment

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

LGTM, thanks again for the PR.

@aindriu-aiven
Copy link
Contributor

Thanks, committed suggestion @muralibasani

Hey @luke-zhou I just noticed the last commit I think needs to be signed, would you be able to sign off your last commit? git commit --amend --signoff

Hi @aindriu-aiven I have signed the last commit, and pushed. However I am having issues to sign the following two commits, which i made directly on the PR page: image

Hey I had a chat with some colleagues in this space and apparently we can use git rebase --signoff <your commit>

This will sign off all the commits you made until HEAD. If you don't mind giving that a go it should let us pass the DCO and merge the PR.

Thanks a million!

Hey @luke-zhou just wanted to see if you think you would be able to give the above command a try to sign off those commits, if it doesn't work just let us know and we can see if we can work around it.

Thanks!

@muralibasani muralibasani merged commit b682c7c into Aiven-Open:main Jul 23, 2024
24 checks passed
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.

3 participants