Skip to content

Conversation

@maastha
Copy link
Collaborator

@maastha maastha commented Jan 23, 2025

Description

Enables AWS encryption_at_rest acceptance tests to run in CI

Link to any related issue(s): CLOUDP-293831

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 have added appropriate changelog entries.
  • 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

Base automatically changed from CLOUDP-295878-ear-pe to CLOUDP-262752-ear-aws-kms-dev January 24, 2025 11:32
@maastha maastha changed the title ci: Enables AWS encryption_at_rest acceptance tests to run in CI chore: Enables AWS encryption_at_rest acceptance tests to run in CI Jan 24, 2025
@maastha maastha marked this pull request as ready for review January 24, 2025 16:24
@maastha maastha requested a review from a team as a code owner January 24, 2025 16:24

encryption:
needs: [ change-detection, get-provider-version ]
concurrency:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Each test run for encryption takes about ~8min to complete. Since the tests use shared resources, I want to prevent multiple simultaneous runs.
I'm thinking as a follow-up I can separate out AWS and Azure tests in separate jobs using ACCTEST_REGEX_RUN to reduce the test run time more.
Will wait to see if any other suggestions.

Copy link
Member

@lantoli lantoli Jan 24, 2025

Choose a reason for hiding this comment

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

I see tests are using resource.Test instead of resource.ParallelTest, so I understand it's in case this is running in multiple PRs / test suites.

The main issue I see, as cancel-in-progress=false, is that there can be some pile-up of jobs, and for example some PR checks are blocked until older ones finish, if some gets stucks, it can be a long time until they time out. This could also block Test Suite.

but we can go ahead and see if this happens

Copy link
Collaborator Author

@maastha maastha Jan 27, 2025

Choose a reason for hiding this comment

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

The main issue I see, as cancel-in-progress=false, is that there can be some pile-up of jobs, and for example some PR checks are blocked until older ones finish, if some gets stucks, it can be a long time until they time out.

Right. I don't think it should block the test suite given the cadence but yes PR checks could take longer. we can't use cancel-inprogress=true because that may leave resources in an inconsistent state.

but we can go ahead and see if this happens

yes sounds good.

AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
AWS_CUSTOMER_MASTER_KEY_ID: ${{ secrets.aws_customer_master_key_id }}
MONGODB_ATLAS_PROJECT_EAR_PE_AWS_ID: ${{ inputs.mongodb_atlas_project_ear_pe_aws_id }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

n00b question: what does PE stand for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Private Endpoint. Happy to rename if this isn't readable, lmk in case of any suggestions

os.Getenv("AWS_SECRET_ACCESS_KEY") == "" ||
os.Getenv("AWS_CUSTOMER_MASTER_KEY_ID") == "" ||
os.Getenv("MONGODB_ATLAS_PROJECT_EAR_PE_AWS_ID") == "" ||
os.Getenv("AWS_PRIVATE_ENDPOINT_REGION") == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

just checking is this change correct? what is the diff between the two EV?

Copy link
Collaborator Author

@maastha maastha Jan 27, 2025

Choose a reason for hiding this comment

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

yes. AWS_PRIVATE_ENDPOINT_REGION was added in a previous PR and currently is only in the CLOUDP-262752-ear-aws-kms-dev dev branch, not in master. I just decided to reuse another existing env AWS_REGION instead of adding this (AWS_PRIVATE_ENDPOINT_REGION ) new one

Config: testAccMongoDBAtlasEncryptionAtRestConfigAwsKmsWithRole(projectID, awsIAMRoleName, awsIAMRolePolicyName, awsKeyName, &awsKms),
Check: resource.ComposeAggregateTestCheckFunc(
acc.CheckEARExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "project_id", projectID),
Copy link
Member

Choose a reason for hiding this comment

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

being a TPF resource, consider checking only computed values

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

encryption:
needs: [ change-detection, get-provider-version ]
concurrency:
group: ${{ github.repository }}-global-ear-concurrency
Copy link
Collaborator

Choose a reason for hiding this comment

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

why the ${{ github.repository}}?

Copy link
Collaborator Author

@maastha maastha Jan 27, 2025

Choose a reason for hiding this comment

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

since these tests use same AWS and Azure resources (Atlas project, etc), we want all workflows across the repository to not run concurrently which could result in race conditions.

I have refactored the other TestMigEncryptionAtRest_withRole_basicAWS test though as per your comment. Hope that helps!

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am under the impression that group simply is a key, as long as it is the same, it will not run concurrently, this means:

  1. group: ${{ github.repository }}-global-ear-concurrency
  2. group: global-ear-concurrency

would be equivalent

projectID = os.Getenv("MONGODB_ATLAS_PROJECT_EAR_PE_AWS_ID") // to use RequirePrivateNetworking, Atlas Project is required to have FF enabled

awsKms = admin.AWSKMSConfiguration{
Enabled: conversion.Pointer(true),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as earlier PR 😅
Why we cannot refactor out the test case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

so the acc test case checks update of RequirePrivateNetworking which is a required test case. Since this attr doesn't exist in previous versions, I'd like to keep these test cases separate

@EspenAlbert
Copy link
Collaborator

Any reason why TestMigEncryptionAtRest_withRole_basicAWS is still skipped?

@maastha
Copy link
Collaborator Author

maastha commented Jan 24, 2025

Any reason why TestMigEncryptionAtRest_withRole_basicAWS is still skipped?

Responded in above comment. Let's try to leave comments on specific lines as these are hard to respond to/have a conversation :)

@maastha
Copy link
Collaborator Author

maastha commented Jan 27, 2025

Required env vars and secrets have been added to repo for dev and QA.
QA still doesn't have all required features deployed from MMS yet so some tests fail with FEATURE_UNSUPPORTED error at this point which is expected:
https://github.com/mongodb/terraform-provider-mongodbatlas/actions/runs/12990429495/job/36225611851

Added an item to ensure QA tests succeed once required changes are in prod and before merging this to master in this ticket: https://jira.mongodb.org/browse/CLOUDP-296239

Merging this PR to dev branch.

@maastha maastha merged commit fd0f885 into CLOUDP-262752-ear-aws-kms-dev Jan 27, 2025
93 of 94 checks passed
@maastha maastha deleted the CLOUDP-293831-ear-aws-ci-enable branch January 27, 2025 14:07
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