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

chore: Enables mongodbatlas_push_based_log_export tests in CI and adds unit tests #2196

Merged
merged 8 commits into from
Apr 25, 2024

Conversation

maastha
Copy link
Collaborator

@maastha maastha commented Apr 23, 2024

Description

Enables mongodbatlas_push_based_log_export tests in CI and adds unit tests

Link to any related issue(s): https://jira.mongodb.org/browse/CLOUDP-240975

Type of change:

  • Bug fix (non-breaking change which fixes an issue). Please, add the "bug" label to the PR.
  • New feature (non-breaking change which adds functionality). Please, add the "enhancement" label to the PR. A migration guide must be created or updated if the new feature will go in a major version.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR. A migration guide must be created or updated.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contributing guides
  • I have checked that this change does not generate any credentials and that they are NOT accidentally logged anywhere.
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code
  • If changes include deprecations or removals, I defined an isolated PR with a relevant title as it will be used in the auto-generated changelog.
  • If changes include removal or addition of 3rd party GitHub actions, I updated our internal document. Reach out to the APIx Integration slack channel to get access to the internal document.

Further comments

@maastha maastha marked this pull request as ready for review April 24, 2024 12:16
@maastha maastha requested a review from a team as a code owner April 24, 2024 12:16
@lantoli
Copy link
Member

lantoli commented Apr 24, 2024

tests are passing but showing "400 (request "CANNOT_ASSUME_ROLE") Atlas cannot assume the specified role" warning, don't know if it's important

func TestNewTFPushBasedLogExport(t *testing.T) {
currentTime := time.Now()

testCases := []sdkToTFModelTestCase{
Copy link
Member

Choose a reason for hiding this comment

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

{
name: "Valid TF state",
input: &pushbasedlogexport.TFPushBasedLogExportRSModel{
BucketName: types.StringValue(testBucketName),
Copy link
Member

Choose a reason for hiding this comment

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

to simplify test we might want to have in testBucketName the value of types.StringValue(testBucketName) so we can have just: BucketName: testBucketName,

same for all

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't see a lot of value in doing that, we're not only using types.StringValue(testBucketName) but also admin.PtrString() and the strings as is

assumeRoleFailedState = "ASSUME_ROLE_FAILED"
unknown = ""
sc500 = conversion.IntPtr(500)
currentTime = time.Now()
Copy link
Member

Choose a reason for hiding this comment

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

i think it's ok here but sometimes using the current (real) time can lead to flaky tests

Copy link
Collaborator Author

@maastha maastha Apr 25, 2024

Choose a reason for hiding this comment

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

let me know if you have any suggestions? I can update that if needed

@@ -45,3 +46,7 @@ func RandomEmail() string {
func RandomLDAPName() string {
return fmt.Sprintf("CN=%s-%[email protected],OU=users,DC=example,DC=com", prefixName, acctest.RandString(10))
}

func RandomS3BucketName() string {
Copy link
Member

Choose a reason for hiding this comment

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

nice!

Copy link
Member

@AgustinBettati AgustinBettati left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +122 to +131
expectedCreateReq: &admin.CreatePushBasedLogExportProjectRequest{
BucketName: testBucketName,
IamRoleId: testIAMRoleID,
PrefixPath: prefixPathEmpty,
},
expectedUpdateReq: &admin.PushBasedLogExportProject{
BucketName: admin.PtrString(testBucketName),
IamRoleId: admin.PtrString(testIAMRoleID),
PrefixPath: admin.PtrString(prefixPathEmpty),
},
Copy link
Member

Choose a reason for hiding this comment

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

nice having both request models asserted under the same test

@maastha
Copy link
Collaborator Author

maastha commented Apr 25, 2024

tests are passing but showing "400 (request "CANNOT_ASSUME_ROLE") Atlas cannot assume the specified role" warning, don't know if it's important

yes this is expected with the cloud provider access resource API. The resource then does retries to get a successful response.

@maastha maastha merged commit 5359976 into master Apr 25, 2024
32 checks passed
@maastha maastha deleted the CLOUDP-240975-push-logs-tests branch April 25, 2024 08:48
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.

5 participants