Skip to content

Commit

Permalink
chore: Moves tests from advancedclustertpf to advancedcluster and ada…
Browse files Browse the repository at this point in the history
…pts to old config (#2945)

* refactor: Moves TestAccMockableAdvancedCluster_basicTenant to SDKv2

* test(unit): use IsTfLogDebug and support logging config in both REPLAY & CAPTURE

* refactor: move TPF resource_tests to sdkv2

* refactor: move testdata for TestAccMockableAdvancedCluster_replicasetAdvConfigUpdate.yaml

* refactor: move testdata for TestAccMockableAdvancedCluster_shardedBasic.yaml

* refactor: move testdata for TestAccMockableAdvancedCluster_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel.yaml

* chore: log also query string in request matching and add QueryVars to mockConfig

* chore: Support testmact in makefile and use it in github action

* feat: add timeouts attribute support in advanced cluster schema conversion

* refactor: consolidate data source definitions in advanced cluster tests

* feat: add support for HTTP mock capture in testmact-capture target

* refactor: move testdata for TestAccMockableAdvancedCluster_tenantUpgrade.yaml

* refactor: move testdata for TestAccMockableAdvancedCluster_symmetricShardedOldSchema.yaml

* test: ensure timeouts.create attribute is only checked on resource

* fix: enforce explicit setting of ACCTEST_PACKAGES for testmact targets

* chore: regenerate test files

* chore: Add ORG_ID env var when using replay

* fix: update minimum_enabled_tls_protocol to TLS1.2 and refactor timeout check in advanced cluster tests

* test: Add more checks to new acceptance tests

* fix: update advanced cluster test data sources to include new schema

* chore: regen replicasetAdvConfigUpdate test

* fix: update acceptance tests configuration to use correct package path and add regex for test selection

* test: Refactor tests to use consistent TF config for data sources

* fix: update advanced cluster test to correct timeout attribute and refactor update for TestAccMockableAdvancedCluster_replicasetAdvConfigUpdate

* refactor: remove test cases functions for new tests

* chore: use new schema for testmact if it is not set

* chore: regenerate mock data

* refactor: rename test function and make update compatible with SDKv2

* chore: fix wrongly merged file
  • Loading branch information
EspenAlbert authored Jan 9, 2025
1 parent 468aef4 commit 939244f
Show file tree
Hide file tree
Showing 41 changed files with 1,381 additions and 1,291 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/acceptance-tests-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,8 @@ jobs:
- name: Mocked Acceptance Tests
env:
ACCTEST_REGEX_RUN: '^TestAccMockable'
ACCTEST_PACKAGES: ./internal/service/advancedclustertpf
MONGODB_ATLAS_PROJECT_ID: '111111111111111111111111' # 24 chars used for skipping acc.ProjectIDExecution(t) in mocked tests
HTTP_MOCKER_REPLAY: 'true'
run: make testacc
ACCTEST_PACKAGES: ./internal/service/advancedcluster
run: make testmact
- name: Acceptance Tests
env:
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
Expand Down
29 changes: 28 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ else
ACCTEST_PACKAGES := "./..."
endif

ACCTEST_REGEX_RUN?=^TestAcc
ACCTEST_TIMEOUT?=300m
PARALLEL_GO_TEST?=50

Expand Down Expand Up @@ -41,9 +40,37 @@ install: fmtcheck
test: fmtcheck
go test ./... -timeout=30s -parallel=4 -race

.PHONY: testmact
testmact:
@$(eval VERSION=macct)
@$(eval ACCTEST_REGEX_RUN?=^TestAccMockable)
@$(eval export HTTP_MOCKER_REPLAY?=true)
@$(eval export HTTP_MOCKER_CAPTURE?=false)
@$(eval export MONGODB_ATLAS_ORG_ID?=111111111111111111111111)
@$(eval export MONGODB_ATLAS_PROJECT_ID?=111111111111111111111111)
@$(eval export MONGODB_ATLAS_ADVANCED_CLUSTER_V2_SCHEMA?=true)
@if [ "$(ACCTEST_PACKAGES)" = "./..." ]; then \
echo "Error: ACCTEST_PACKAGES must be explicitly set for testmact target, './...' is not allowed"; \
exit 1; \
fi
TF_ACC=1 go test $(ACCTEST_PACKAGES) -run '$(ACCTEST_REGEX_RUN)' -v -parallel $(PARALLEL_GO_TEST) $(TESTARGS) -timeout $(ACCTEST_TIMEOUT) -ldflags="$(LINKER_FLAGS)"

.PHONY: testmact-capture
testmact-capture:
@$(eval VERSION=macct)
@$(eval export ACCTEST_REGEX_RUN?=^TestAccMockable)
@$(eval export HTTP_MOCKER_REPLAY?=false)
@$(eval export HTTP_MOCKER_CAPTURE?=true)
@if [ "$(ACCTEST_PACKAGES)" = "./..." ]; then \
echo "Error: ACCTEST_PACKAGES must be explicitly set for testmact-capture target, './...' is not allowed"; \
exit 1; \
fi
TF_ACC=1 go test $(ACCTEST_PACKAGES) -run '$(ACCTEST_REGEX_RUN)' -v -parallel $(PARALLEL_GO_TEST) $(TESTARGS) -timeout $(ACCTEST_TIMEOUT) -ldflags="$(LINKER_FLAGS)"

.PHONY: testacc
testacc: fmtcheck
@$(eval VERSION=acc)
@$(eval ACCTEST_REGEX_RUN?=^TestAcc)
TF_ACC=1 go test $(ACCTEST_PACKAGES) -run '$(ACCTEST_REGEX_RUN)' -v -parallel $(PARALLEL_GO_TEST) $(TESTARGS) -timeout $(ACCTEST_TIMEOUT) -ldflags="$(LINKER_FLAGS)"

.PHONY: testaccgov
Expand Down
Loading

0 comments on commit 939244f

Please sign in to comment.