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: Fixes acceptance and migrations tests not running in CI #1907

Merged
merged 28 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
274 changes: 155 additions & 119 deletions .github/workflows/acceptance-tests-runner.yml

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ jobs:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_s3_bucket_federation: ${{ secrets.AWS_S3_BUCKET_FEDERATION }}
mongodb_atlas_ldap_hostname: ${{ secrets.MONGODB_ATLAS_LDAP_HOSTNAME }}
mongodb_atlas_ldap_username: ${{ secrets.MONGODB_ATLAS_LDAP_USERNAME }}
mongodb_atlas_ldap_password: ${{ secrets.MONGODB_ATLAS_LDAP_PASSWORD }}
mongodb_atlas_ldap_port: ${{ secrets.MONGODB_ATLAS_LDAP_PORT }}
with:
terraform_version: ${{ inputs.terraform_version || vars.TF_VERSION_LATEST }}
ref: ${{ inputs.ref }}
Expand All @@ -69,10 +73,10 @@ jobs:
azure_tenant_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.AZURE_TENANT_ID_QA || vars.AZURE_TENANT_ID }}
aws_secret_name: ${{ inputs.atlas_cloud_env == 'qa' && vars.AWS_SECRET_NAME_QA || vars.AWS_SECRET_NAME }}
mongodb_atlas_federation_settings_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_FEDERATION_SETTINGS_ID_QA || vars.MONGODB_ATLAS_FEDERATION_SETTINGS_ID }}
mongodb_atlas_federatied_okta_idp_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_FEDERATED_OKTA_IDP_ID_QA || vars.MONGODB_ATLAS_FEDERATED_OKTA_IDP_ID }}
mongodb_atlas_federatied_idp_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_FEDERATED_IDP_ID_QA || vars.MONGODB_ATLAS_FEDERATED_IDP_ID }}
mongodb_atlas_federatied_oidc_idp_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_FEDERATED_OIDC_IDP_ID_QA || vars.MONGODB_ATLAS_FEDERATED_OIDC_IDP_ID }}
mongodb_atlas_federatied_sso_url: ${{ vars.MONGODB_ATLAS_FEDERATED_SSO_URL }}
mongodb_atlas_federatied_issuer_uri: ${{ vars.MONGODB_ATLAS_FEDERATED_ISSUER_URI }}
mongodb_atlas_federatied_project_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_FEDERATED_PROJECT_ID_QA || vars.MONGODB_ATLAS_FEDERATED_PROJECT_ID }}
mongodb_atlas_federatied_org_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_FEDERATED_ORG_ID_QA || vars.MONGODB_ATLAS_FEDERATED_ORG_ID }}
mongodb_atlas_federated_okta_idp_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_FEDERATED_OKTA_IDP_ID_QA || vars.MONGODB_ATLAS_FEDERATED_OKTA_IDP_ID }}
mongodb_atlas_federated_idp_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_FEDERATED_IDP_ID_QA || vars.MONGODB_ATLAS_FEDERATED_IDP_ID }}
mongodb_atlas_federated_oidc_idp_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_FEDERATED_OIDC_IDP_ID_QA || vars.MONGODB_ATLAS_FEDERATED_OIDC_IDP_ID }}
mongodb_atlas_federated_sso_url: ${{ vars.MONGODB_ATLAS_FEDERATED_SSO_URL }}
mongodb_atlas_federated_issuer_uri: ${{ vars.MONGODB_ATLAS_FEDERATED_ISSUER_URI }}
mongodb_atlas_federated_project_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_FEDERATED_PROJECT_ID_QA || vars.MONGODB_ATLAS_FEDERATED_PROJECT_ID }}
mongodb_atlas_federated_org_id: ${{ inputs.atlas_cloud_env == 'qa' && vars.MONGODB_ATLAS_FEDERATED_ORG_ID_QA || vars.MONGODB_ATLAS_FEDERATED_ORG_ID }}
57 changes: 46 additions & 11 deletions .github/workflows/migration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ on:

env:
terraform_version: ${{ inputs.terraform_version || vars.TF_VERSION_LATEST }}
# CI: true # GH does this automatically
TF_ACC: 1
SKIP_TEST_EXTERNAL_CREDENTIALS: true
TF_LOG: ${{ vars.LOG_LEVEL }}
ACCTEST_TIMEOUT: ${{ vars.ACCTEST_TIMEOUT }}

Expand Down Expand Up @@ -59,12 +57,13 @@ jobs:
project: ${{ steps.filter.outputs.project == 'true' || env.mustTrigger == 'true' }}
config: ${{ steps.filter.outputs.config == 'true' || env.mustTrigger == 'true' }}
advanced_cluster: ${{ steps.filter.outputs.advanced_cluster == 'true' || env.mustTrigger == 'true' }}
backup_online_archive: ${{ steps.filter.outputs.backup_online_archive == 'true' || env.mustTrigger == 'true' }}
backup: ${{ steps.filter.outputs.backup == 'true' || env.mustTrigger == 'true' }}
stream: ${{ steps.filter.outputs.stream == 'true' || env.mustTrigger == 'true' }}
federation: ${{ steps.filter.outputs.federation == 'true' || env.mustTrigger == 'true' }}
federated: ${{ steps.filter.outputs.federated == 'true' || env.mustTrigger == 'true' }}
search_deployment: ${{ steps.filter.outputs.search_deployment == 'true' || env.mustTrigger == 'true' }}
generic: ${{ steps.filter.outputs.generic == 'true' || env.mustTrigger == 'true' }}
network: ${{ steps.filter.outputs.network == 'true' || env.mustTrigger == 'true' }}
encryption: ${{ steps.filter.outputs.encryption == 'true' || env.mustTrigger == 'true' }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd
Expand Down Expand Up @@ -92,15 +91,24 @@ jobs:
- 'internal/service/orginvitation/*.go'
- 'internal/service/organization/*.go'
- 'internal/service/thirdpartyintegration/*.go'
backup_online_archive:
backup:
- 'internal/service/onlinearchive/*.go'
- 'internal/service/cloudbackupschedule/*.go'
- 'internal/service/cloudbackupsnapshot/*.go'
- 'internal/service/cloudbackupsnapshotexportbucket/*.go'
- 'internal/service/cloudbackupsnapshotexportjob/*.go'
- 'internal/service/cloudbackupsnapshotrestorejob/*.go'
advanced_cluster:
- 'internal/service/advancedcluster/*.go'
stream:
- 'internal/service/streaminstance/*.go'
- 'internal/service/streamconnection/*.go'
federation:
federated:
- 'internal/service/federatedsettingsidentityprovider/*.go'
- 'internal/service/federateddatabaseinstance/*.go'
- 'internal/service/federatedsettingsorgconfig/*.go'
- 'internal/service/federatedsettingsorgrolemapping/*.go'
- 'internal/service/federatedquerylimit/*.go'
search_deployment:
- 'internal/service/searchdeployment/*.go'
generic:
Expand All @@ -114,6 +122,9 @@ jobs:
- 'internal/service/privatelinkendpoint/*.go'
- 'internal/service/privatelinkendpointservice/*.go'
- 'internal/service/privatelinkendpointservicedatafederationonlinearchive/*.go'
- 'internal/service/privatelinkendpointserverless/*.go'
encryption:
- 'internal/service/encryptionatrest/*.go'

project:
needs: [ change-detection, get-provider-version ]
Expand Down Expand Up @@ -180,9 +191,9 @@ jobs:
TEST_REGEX: "^TestAccMigrationConfig"
run: make testacc

backup_online_archive:
backup:
needs: [ change-detection, get-provider-version ]
if: ${{ needs.change-detection.outputs.backup_online_archive == 'true' || inputs.test_group == 'backup_online_archive' }}
if: ${{ needs.change-detection.outputs.backup == 'true' || inputs.test_group == 'backup' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -257,9 +268,9 @@ jobs:
TEST_REGEX: "^TestAccMigrationStream"
run: make testacc

federation:
federated:
needs: [ change-detection, get-provider-version ]
if: ${{ needs.change-detection.outputs.federation == 'true' || inputs.test_group == 'federation' }}
if: ${{ needs.change-detection.outputs.federated == 'true' || inputs.test_group == 'federated' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -283,7 +294,7 @@ jobs:
MONGODB_ATLAS_PUBLIC_KEY: ${{ secrets.MONGODB_ATLAS_PUBLIC_KEY_CLOUD_DEV }}
MONGODB_ATLAS_PRIVATE_KEY: ${{ secrets.MONGODB_ATLAS_PRIVATE_KEY_CLOUD_DEV }}
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
TEST_REGEX: "^TestAccMigrationFederatedDatabaseInstance"
TEST_REGEX: "^TestAccMigrationFederated"
run: make testacc

search_deployment:
Expand Down Expand Up @@ -371,3 +382,27 @@ jobs:
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
TEST_REGEX: "^TestAccMigrationNetwork"
run: make testacc
encryption:
needs: [ change-detection, get-provider-version ]
if: ${{ needs.change-detection.outputs.encryption == 'true' || inputs.test_group == 'encryption' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ env.terraform_version }}
terraform_wrapper: false
- name: Migration Tests
env:
MONGODB_ATLAS_PUBLIC_KEY: ${{ secrets.MONGODB_ATLAS_PUBLIC_KEY_CLOUD_DEV_NETWORK }}
MONGODB_ATLAS_PRIVATE_KEY: ${{ secrets.MONGODB_ATLAS_PRIVATE_KEY_CLOUD_DEV_NETWORK }}
MONGODB_ATLAS_ORG_ID: ${{ vars.MONGODB_ATLAS_ORG_ID_CLOUD_DEV_NETWORK }}
MONGODB_ATLAS_BASE_URL: ${{ vars.MONGODB_ATLAS_BASE_URL }}
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
TEST_REGEX: "^TestAccMigrationEncryption"
run: make testacc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/mongodb/terraform-provider-mongodbatlas/internal/service/advancedcluster"
)

func TestAccClusterRSAdvancedClusterMigrateState_empty_advancedConfig(t *testing.T) {
func TestAccMigrationAdvancedCluster_empty_advancedConfig(t *testing.T) {
v0State := map[string]any{
"project_id": "test-id",
"name": "test-cluster",
Expand Down Expand Up @@ -60,7 +60,7 @@ func TestAccClusterRSAdvancedClusterMigrateState_empty_advancedConfig(t *testing
}
}

func TestAccClusterRSAdvancedClusterV0StateUpgrade_ReplicationSpecs(t *testing.T) {
func TestAccMigrationAdvancedCluster_v0StateUpgrade_ReplicationSpecs(t *testing.T) {
v0State := map[string]any{
"project_id": "test-id",
"name": "test-cluster",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ func TestAccClusterAdvancedCluster_multicloudSharded(t *testing.T) {
}

func TestAccClusterAdvancedCluster_UnpausedToPaused(t *testing.T) {
acc.SkipTest(t)
var (
cluster matlas.AdvancedCluster
resourceName = "mongodbatlas_advanced_cluster.test"
Expand Down Expand Up @@ -297,7 +296,6 @@ func TestAccClusterAdvancedCluster_UnpausedToPaused(t *testing.T) {
}

func TestAccClusterAdvancedCluster_PausedToUnpaused(t *testing.T) {
acc.SkipTest(t)
var (
cluster matlas.AdvancedCluster
resourceName = "mongodbatlas_advanced_cluster.test"
Expand Down
12 changes: 8 additions & 4 deletions internal/service/atlasuser/data_source_atlas_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ import (
)

func TestAccConfigDSAtlasUser_ByUserID(t *testing.T) {
acc.SkipIfTFAccNotDefined(t)
if os.Getenv("TF_ACC") == "" { // needed while fetchUser is called from the test
t.Skip()
}
var (
dataSourceName = "data.mongodbatlas_atlas_user.test"
userID = os.Getenv("MONGODB_ATLAS_PROJECT_OWNER_ID")
user = fetchUser(t, userID)
)
resource.Test(t, resource.TestCase{ // does not run in parallel to avoid changes in fetched user during execution
PreCheck: func() { acc.PreCheckBasic(t); acc.PreCheckBasicOwnerID(t) },
PreCheck: func() { acc.PreCheckBasicOwnerID(t) },
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
Steps: []resource.TestStep{
{
Expand All @@ -35,14 +37,16 @@ func TestAccConfigDSAtlasUser_ByUserID(t *testing.T) {
}

func TestAccConfigDSAtlasUser_ByUsername(t *testing.T) {
acc.SkipIfTFAccNotDefined(t)
if os.Getenv("TF_ACC") == "" { // needed while fetchUserByUsername is called from the test
t.Skip()
}
var (
dataSourceName = "data.mongodbatlas_atlas_user.test"
username = os.Getenv("MONGODB_ATLAS_USERNAME")
user = fetchUserByUsername(t, username)
)
resource.Test(t, resource.TestCase{ // does not run in parallel to avoid changes in fetched user during execution
PreCheck: func() { acc.PreCheckBasic(t); acc.PreCheckAtlasUsername(t) },
PreCheck: func() { acc.PreCheckAtlasUsername(t) },
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
Steps: []resource.TestStep{
{
Expand Down
10 changes: 6 additions & 4 deletions internal/service/atlasuser/data_source_atlas_users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import (
)

func TestAccConfigDSAtlasUsers_ByOrgID(t *testing.T) {
acc.SkipIfTFAccNotDefined(t)
if os.Getenv("TF_ACC") == "" { // needed while fetchOrgUsers is called from the test
t.Skip()
}
var (
dataSourceName = "data.mongodbatlas_atlas_users.test"
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
Expand Down Expand Up @@ -46,7 +48,7 @@ func TestAccConfigDSAtlasUsers_ByProjectID(t *testing.T) {
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t); acc.PreCheckBasicOwnerID(t) },
PreCheck: func() { acc.PreCheckBasicOwnerID(t) },
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyProject,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -77,7 +79,7 @@ func TestAccConfigDSAtlasUsers_ByTeamID(t *testing.T) {
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t); acc.PreCheckAtlasUsername(t) },
PreCheck: func() { acc.PreCheckAtlasUsername(t) },
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyTeam,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -111,7 +113,7 @@ func TestAccConfigDSAtlasUsers_UsingPagination(t *testing.T) {
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t); acc.PreCheckAtlasUsername(t) },
PreCheck: func() { acc.PreCheckAtlasUsername(t) },
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyTeam,
Steps: []resource.TestStep{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func TestAccBackupRSCloudBackupSchedule_basic(t *testing.T) {
}

func TestAccBackupRSCloudBackupSchedule_export(t *testing.T) {
acc.SkipTestExtCred(t)
acc.SkipTestForCI(t)
var (
resourceName = "mongodbatlas_cloud_backup_schedule.schedule_test"
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func TestAccBackupDSCloudBackupSnapshotExportBucket_basic(t *testing.T) {
acc.SkipTestExtCred(t)
acc.SkipTestForCI(t)
var (
snapshotExportBackup matlas.CloudProviderSnapshotExportBucket
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func TestAccBackupDSCloudBackupSnapshotExportBuckets_basic(t *testing.T) {
acc.SkipTestExtCred(t)
acc.SkipTestForCI(t)
var (
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
bucketName = os.Getenv("AWS_S3_BUCKET")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func TestAccBackupRSBackupSnapshotExportBucket_basic(t *testing.T) {
acc.SkipTestExtCred(t)
acc.SkipTestForCI(t)
var (
snapshotExportBucket matlas.CloudProviderSnapshotExportBucket
resourceName = "mongodbatlas_cloud_backup_snapshot_export_bucket.test"
Expand All @@ -41,7 +41,7 @@ func TestAccBackupRSBackupSnapshotExportBucket_basic(t *testing.T) {
}

func TestAccBackupRSBackupSnapshotExportBucket_importBasic(t *testing.T) {
acc.SkipTestExtCred(t)
acc.SkipTestForCI(t)
var (
resourceName = "mongodbatlas_cloud_backup_snapshot_export_bucket.test"
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
Expand Down Expand Up @@ -82,7 +82,6 @@ func testAccCheckMongoDBAtlasBackupSnapshotExportBucketExists(resourceName strin
*snapshotExportBucket = *response
return nil
}

return fmt.Errorf("snapshot export bucket (%s) does not exist", ids["id"])
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func TestAccBackupDSCloudBackupSnapshotExportJob_basic(t *testing.T) {
acc.SkipTestExtCred(t)
acc.SkipTestForCI(t)
var (
snapshotExportJob matlas.CloudProviderSnapshotExportJob
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func TestAccBackupDSCloudBackupSnapshotExportJobs_basic(t *testing.T) {
acc.SkipTestExtCred(t)
acc.SkipTestForCI(t)
var (
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
bucketName = os.Getenv("AWS_S3_BUCKET")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func TestAccBackupRSBackupSnapshotExportJob_basic(t *testing.T) {
acc.SkipTestExtCred(t)
acc.SkipTestForCI(t)
var (
snapshotExportJob matlas.CloudProviderSnapshotExportJob
resourceName = "mongodbatlas_cloud_backup_snapshot_export_job.test"
Expand All @@ -41,7 +41,7 @@ func TestAccBackupRSBackupSnapshotExportJob_basic(t *testing.T) {
}

func TestAccBackupRSBackupSnapshotExportJob_importBasic(t *testing.T) {
acc.SkipTestExtCred(t)
acc.SkipTestForCI(t)
var (
resourceName = "mongodbatlas_cloud_backup_snapshot_export_job.test"
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

func TestAccConfigRSCloudProviderAccessAuthorizationAWS_basic(t *testing.T) {
acc.SkipTestExtCred(t)
acc.SkipTestForCI(t)
var (
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_ID")
policyName = acctest.RandomWithPrefix("tf-acc")
Expand Down
Loading
Loading