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

test: Modifies stream_connection and stream_instance tests to use shared cluster and project #2096

Merged
merged 3 commits into from
Apr 2, 2024

Conversation

AgustinBettati
Copy link
Member

@AgustinBettati AgustinBettati commented Mar 28, 2024

Description

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

  • Modifies stream connection acceptance/migration tests to share a single cluster, no risk in multiple stream connections referencing a same cluster.
  • Modifies stream connection and stream instance acceptance/migration tests to share a single project, no risk as a each test creates a new stream instance within the project.

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.
  • Breaking change (fix or feature that would cause existing functionality to not work as expected). Please, add the "breaking change" label to the PR.
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the contribution guidelines
  • 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

Comment on lines -12 to -16
resource "mongodbatlas_project" "test" {
org_id = %[1]q
name = %[2]q
}

Copy link
Member Author

Choose a reason for hiding this comment

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

projects are not longer present as part of the terraform config

Comment on lines -219 to +216
func clusterStreamConnectionConfig(projectIDStr, instanceName, clusterNameStr, clusterTerraformStr string) string {
return clusterTerraformStr + fmt.Sprintf(`

func clusterStreamConnectionConfig(projectID, instanceName, clusterName string) string {
return fmt.Sprintf(`
Copy link
Member Author

Choose a reason for hiding this comment

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

cluster definition is no longer part of the terraform config

@AgustinBettati AgustinBettati changed the title test: Used shared cluster for execution of stream connections tests test: Used shared cluster and project for execution of stream_connection and stream_instance tests Mar 28, 2024
@AgustinBettati AgustinBettati marked this pull request as ready for review March 28, 2024 10:29
@AgustinBettati AgustinBettati requested a review from a team as a code owner March 28, 2024 10:29
Config: streamInstancesDataSourceConfig(orgID, projectName, instanceName, region, cloudProvider),
Check: streamInstancesAttributeChecks(dataSourceName, nil, nil, 1),
Config: streamInstancesDataSourceConfig(projectID, instanceName, region, cloudProvider),
Check: streamInstancesAttributeChecks(dataSourceName, nil, nil, acc.IntGreatThan(0)), // at least on instance is present in the project
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we change this and check something that uniquely identifies the instance?

Copy link
Member Author

@AgustinBettati AgustinBettati Mar 28, 2024

Choose a reason for hiding this comment

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

good idea, apart from checking result is larger than 0 added a TestCheckTypeSetElemNestedAttrs to verify it contains an element with the stream instance name that was created in the test.

@@ -44,40 +41,40 @@ func TestAccStreamDSStreamInstances_withPageConfig(t *testing.T) {
CheckDestroy: acc.CheckDestroyStreamInstance,
Steps: []resource.TestStep{
{
Config: streamInstancesWithPageAttrDataSourceConfig(orgID, projectName, instanceName, region, cloudProvider),
Check: streamInstancesAttributeChecks(dataSourceName, admin.PtrInt(2), admin.PtrInt(1), 0),
Config: streamInstancesWithPageAttrDataSourceConfig(projectID, instanceName, region, cloudProvider, 1000),
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we give that 1000 a variable name?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, extracted

Config: streamInstancesWithPageAttrDataSourceConfig(orgID, projectName, instanceName, region, cloudProvider),
Check: streamInstancesAttributeChecks(dataSourceName, admin.PtrInt(2), admin.PtrInt(1), 0),
Config: streamInstancesWithPageAttrDataSourceConfig(projectID, instanceName, region, cloudProvider, 1000),
Check: streamInstancesAttributeChecks(dataSourceName, admin.PtrInt(1000), admin.PtrInt(1), acc.IntLowerThan(1)), // expecting no results
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not leaving 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

mess up from my end, leaving the check with 0 is just fine.

@AgustinBettati AgustinBettati force-pushed the CLOUDP-239134-stream-connection branch from 9b77917 to b59a73c Compare March 28, 2024 14:24
@AgustinBettati AgustinBettati changed the title test: Used shared cluster and project for execution of stream_connection and stream_instance tests test: Modifies stream_connection and stream_instance tests to use shared cluster and project Mar 28, 2024
Copy link
Collaborator

@EspenAlbert EspenAlbert left a comment

Choose a reason for hiding this comment

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

LGTM. Probably out of scope to refactor the datasource tests to be part of the resource tests?

@AgustinBettati
Copy link
Member Author

AgustinBettati commented Apr 2, 2024

Probably out of scope to refactor the datasource tests to be part of the resource tests?

will followup with a new PR for this change 👍

@AgustinBettati AgustinBettati merged commit 7453c79 into master Apr 2, 2024
48 checks passed
@AgustinBettati AgustinBettati deleted the CLOUDP-239134-stream-connection branch April 2, 2024 08:20
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.

4 participants