Skip to content

Commit 44bde0f

Browse files
authored
feat: Complete FlexCluster implementation (#1425)
1 parent 1ca3274 commit 44bde0f

29 files changed

+1212
-306
lines changed

.github/workflows/contract-testing.yaml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
cluster-outage-simulation: ${{ steps.filter.outputs.cluster-outage-simulation }}
2020
federated-database-instance: ${{ steps.filter.outputs.federated-database-instance }}
2121
federated-query-limit: ${{ steps.filter.outputs.federated-query-limit }}
22+
flex-cluster: ${{ steps.filter.outputs.flex-cluster }}
2223
online-archive: ${{ steps.filter.outputs.online-archive }}
2324
organization: ${{ steps.filter.outputs.organization }}
2425
private-endpoint-aws: ${{ steps.filter.outputs.private-endpoint-aws }}
@@ -53,6 +54,8 @@ jobs:
5354
- 'cfn-resources/federated-database-instance/**'
5455
federated-query-limit:
5556
- 'cfn-resources/federated-query-limit/**'
57+
flex-cluster:
58+
- 'cfn-resources/flex-cluster/**'
5659
online-archive:
5760
- 'cfn-resources/online-archive/**'
5861
organization:
@@ -401,6 +404,48 @@ jobs:
401404
402405
make run-contract-testing
403406
make delete-test-resources
407+
408+
flex-cluster:
409+
needs: change-detection
410+
if: ${{ needs.change-detection.outputs.flex-cluster == 'true' }}
411+
runs-on: ubuntu-latest
412+
steps:
413+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
414+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
415+
with:
416+
go-version-file: 'cfn-resources/go.mod'
417+
- name: setup Atlas CLI
418+
uses: mongodb/atlas-github-action@15663d068c40a8582d881560961fce9d45e0df9a
419+
- uses: aws-actions/setup-sam@f664fad9e12492edfc187a31f575537dfbb0ff63
420+
with:
421+
use-installer: true
422+
- uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a
423+
with:
424+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_TEST_ENV }}
425+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_TEST_ENV }}
426+
aws-region: eu-west-1
427+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
428+
with:
429+
python-version: '3.9'
430+
cache: 'pip' # caching pip dependencies
431+
- run: pip install cloudformation-cli cloudformation-cli-go-plugin
432+
- name: Run the Contract test
433+
shell: bash
434+
env:
435+
MONGODB_ATLAS_PUBLIC_API_KEY: ${{ secrets.CLOUD_DEV_PUBLIC_KEY }}
436+
MONGODB_ATLAS_PRIVATE_API_KEY: ${{ secrets.CLOUD_DEV_PRIVATE_KEY }}
437+
MONGODB_ATLAS_ORG_ID: ${{ secrets.CLOUD_DEV_ORG_ID }}
438+
MONGODB_ATLAS_OPS_MANAGER_URL: ${{ vars.MONGODB_ATLAS_BASE_URL }}
439+
MONGODB_ATLAS_PROFILE: cfn-cloud-dev-github-action
440+
run: |
441+
pushd cfn-resources/flex-cluster
442+
make create-test-resources
443+
444+
cat inputs/inputs_1_create.json
445+
cat inputs/inputs_1_update.json
446+
447+
make run-contract-testing
448+
make delete-test-resources
404449
online-archive:
405450
needs: change-detection
406451
if: ${{ needs.change-detection.outputs.online-archive == 'true' }}
@@ -853,4 +898,4 @@ jobs:
853898
make create-test-resources
854899
cat inputs/inputs_1_create.json
855900
make run-contract-testing
856-
make delete-test-resources
901+
make delete-test-resources

.github/workflows/e2e-testing.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
repository-projects: read
1313
outputs:
1414
cluster: ${{ steps.filter.outputs.cluster }}
15+
flex-cluster: ${{ steps.filter.outputs.flex-cluster }}
1516
project: ${{ steps.filter.outputs.project }}
1617
search-deployment: ${{ steps.filter.outputs.search-deployment }}
1718
steps:
@@ -24,6 +25,9 @@ jobs:
2425
cluster:
2526
- 'cfn-resources/cluster/**'
2627
- 'cfn-resources/test/e2e/cluster/**'
28+
flex-cluster:
29+
- 'cfn-resources/flex-cluster/**'
30+
- 'cfn-resources/test/e2e/flex-cluster/**'
2731
project:
2832
- 'cfn-resources/project/**'
2933
- 'cfn-resources/test/e2e/project/**'
@@ -60,6 +64,39 @@ jobs:
6064
run: |
6165
cd cfn-resources/test/e2e/cluster
6266
go test -timeout 90m -v cluster_test.go
67+
68+
69+
flex-cluster:
70+
needs: change-detection
71+
if: ${{ needs.change-detection.outputs.flex-cluster == 'true' }}
72+
runs-on: ubuntu-latest
73+
steps:
74+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
75+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
76+
with:
77+
python-version: '3.9'
78+
cache: 'pip'
79+
- run: pip install cloudformation-cli-go-plugin
80+
- uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5
81+
with:
82+
go-version-file: 'cfn-resources/go.mod'
83+
- uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a
84+
with:
85+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_TEST_ENV }}
86+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_TEST_ENV }}
87+
aws-region: eu-west-1
88+
- name: Run E2E test
89+
shell: bash
90+
env:
91+
MONGODB_ATLAS_PUBLIC_KEY: ${{ secrets.CLOUD_DEV_PUBLIC_KEY }}
92+
MONGODB_ATLAS_PRIVATE_KEY: ${{ secrets.CLOUD_DEV_PRIVATE_KEY }}
93+
MONGODB_ATLAS_ORG_ID: ${{ secrets.CLOUD_DEV_ORG_ID }}
94+
MONGODB_ATLAS_BASE_URL: https://cloud-dev.mongodb.com/
95+
MONGODB_ATLAS_SECRET_PROFILE: cfn-cloud-dev-github-action
96+
run: |
97+
cd cfn-resources/test/e2e/flex-cluster
98+
go test -timeout 60m -v flexcluster_test.go
99+
63100
project:
64101
needs: change-detection
65102
if: ${{ needs.change-detection.outputs.project == 'true' }}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"typeName": "MongoDB::Atlas::FlexCluster",
3-
"language": "go",
4-
"runtime": "provided.al2",
5-
"entrypoint": "bootstrap",
6-
"testEntrypoint": "bootstrap",
7-
"settings": {
8-
"import_path": "github.com/mongodb/mongodbatlas-cloudformation-resources/flex-cluster",
9-
"protocolVersion": "2.0.0",
10-
"pluginVersion": "2.0.4"
11-
}
2+
"typeName": "MongoDB::Atlas::FlexCluster",
3+
"language": "go",
4+
"runtime": "provided.al2",
5+
"entrypoint": "bootstrap",
6+
"testEntrypoint": "bootstrap",
7+
"settings": {
8+
"import_path": "github.com/mongodb/mongodbatlas-cloudformation-resources/flex-cluster",
9+
"protocolVersion": "2.0.0",
10+
"pluginVersion": "2.0.4"
11+
}
1212
}

cfn-resources/flex-cluster/Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,20 @@ clean:
1919
rm -rf bin
2020

2121
submit: clean build # submit to private registry must use release build not debug build
22+
@echo "==> Submitting to private registry for testing"
2223
cfn submit --set-default --region us-east-1
24+
25+
create-test-resources:
26+
@echo "==> Creating test files and resources for contract testing"
27+
./test/contract-testing/cfn-test-create.sh
28+
29+
delete-test-resources:
30+
@echo "==> Delete test resources used for contract testing"
31+
./test/contract-testing/cfn-test-delete.sh
32+
33+
run-contract-testing:
34+
@echo "==> Run contract testing"
35+
make build
36+
sam local start-lambda &
37+
cfn test --function-name TestEntrypoint --verbose
38+

cfn-resources/flex-cluster/cmd/resource/model.go

Lines changed: 39 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)