Skip to content

Commit 6f99b9c

Browse files
CLOUDP-314966: Use cloud-qa at mongodbgov for gov tests (#2350)
Use cloud-qa at mongodbgov for gov tests
1 parent cc6fa65 commit 6f99b9c

File tree

4 files changed

+216
-0
lines changed

4 files changed

+216
-0
lines changed

.github/workflows/tests-selectable.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: Tests-selectable
22

33
# This workflow is for running tests based on PR labels
4+
# NOTE:
5+
# The label filter app is used to select tests based on GitHub PR labels
6+
# Tests in the ./int directory are considered an integration test and executed in a separate job
7+
# Tests in the ./e2e directory are considered an end-to-end test and executed in a separate job
8+
# Tests in the ./e2e directory are considered a GOV test ONLY IF their labels contain "atlas-gov" and executed in a separate job
49

510
on:
611
pull_request:
@@ -23,6 +28,7 @@ jobs:
2328
outputs:
2429
int_matrix: ${{ steps.set-matrix.outputs.int_matrix }}
2530
e2e_matrix: ${{ steps.set-matrix.outputs.e2e_matrix }}
31+
e2e_gov_matrix: ${{ steps.set-matrix.outputs.e2e_gov_matrix }}
2632
steps:
2733
- name: Checkout Code
2834
uses: actions/checkout@v4
@@ -82,9 +88,11 @@ jobs:
8288
./bin/ginkgo-labels > result.json
8389
echo "Int tests to execute $(cat result.json | jq -c .int)"
8490
echo "E2E tests to execute $(cat result.json | jq -c .e2e)"
91+
echo "E2E GOV tests to execute $(cat result.json | jq -c .e2e_gov)"
8592
8693
echo "int_matrix=$(cat result.json | jq -c .int)" >> $GITHUB_OUTPUT
8794
echo "e2e_matrix=$(cat result.json | jq -c .e2e)" >> $GITHUB_OUTPUT
95+
echo "e2e_gov_matrix=$(cat result.json | jq -c .e2e_gov)" >> $GITHUB_OUTPUT
8896
8997
compute:
9098
needs: detect-tests
@@ -342,4 +350,75 @@ jobs:
342350
GCP_SA_CRED: ${{ secrets.GCP_SA_CRED }}
343351
DATADOG_KEY: ${{ secrets.DATADOG_KEY }}
344352
PAGER_DUTY_SERVICE_KEY: ${{ secrets.PAGER_DUTY_SERVICE_KEY }}
353+
run: |
354+
echo "Using ENV: ${{ steps.select-env.outputs.ENV }}"
355+
devbox run -- ./scripts/launch-ci-e2e.sh
356+
357+
- name: Upload operator logs
358+
if: ${{ failure() }}
359+
uses: actions/upload-artifact@v4
360+
with:
361+
name: logs
362+
path: output/**
363+
364+
run-e2e-gov-tests:
365+
needs: detect-tests
366+
environment: gov-test
367+
if: ${{ needs.detect-tests.outputs.e2e_gov_matrix != '[]' && fromJSON(needs.detect-tests.outputs.e2e_gov_matrix) != '[]' }}
368+
strategy:
369+
fail-fast: false
370+
matrix:
371+
test: ${{ fromJSON(needs.detect-tests.outputs.e2e_gov_matrix) }}
372+
runs-on: ubuntu-latest
373+
name: "e2e gov: ${{ matrix.test }}"
374+
steps:
375+
- name: Get repo files from cache
376+
id: get-repo-files-from-cache
377+
uses: actions/cache@v4
378+
with:
379+
path: ./*
380+
key: ${{ github.sha }}
381+
382+
- name: Checkout if cache repo files missed
383+
if: steps.get-repo-files-from-cache.outputs.cache-hit != 'true'
384+
uses: actions/checkout@v4
385+
with:
386+
ref: ${{github.event.pull_request.head.sha}}
387+
submodules: true
388+
fetch-depth: 0
389+
390+
- name: Create k8s Kind Cluster
391+
if: ${{ !env.ACT }}
392+
uses: helm/[email protected]
393+
with:
394+
version: v0.26.0
395+
config: test/helper/e2e/config/kind.yaml
396+
cluster_name: "atlas-gov-e2e-test"
397+
wait: 180s
398+
399+
- name: Install devbox
400+
uses: jetify-com/[email protected]
401+
with:
402+
enable-cache: 'true'
403+
404+
- name: Install CRDs
405+
run: devbox run -- 'make install'
406+
407+
- name: Run e2e test
408+
env:
409+
MCLI_PUBLIC_API_KEY: ${{ secrets.ATLAS_GOV_PUBLIC_KEY }}
410+
MCLI_PRIVATE_API_KEY: ${{ secrets.ATLAS_GOV_PRIVATE_KEY }}
411+
MCLI_ORG_ID: ${{ secrets.ATLAS_GOV_ORG_ID}}
412+
MCLI_OPS_MANAGER_URL: "https://cloud-qa.mongodbgov.com/"
413+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
414+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
415+
AWS_ACCOUNT_ARN_LIST: ${{ secrets.AWS_ACCOUNT_ARN_LIST }}
416+
PAGER_DUTY_SERVICE_KEY: ${{ secrets.PAGER_DUTY_SERVICE_KEY }}
417+
TEST_NAME: "${{ matrix.test }}"
345418
run: devbox run -- ./scripts/launch-ci-e2e.sh
419+
- name: Upload operator logs
420+
if: ${{ failure() }}
421+
uses: actions/upload-artifact@v4
422+
with:
423+
name: logs
424+
path: output/**
3.12 MB
Binary file not shown.

tools/compute-test-labels/main.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,26 @@ func MatchWildcards(labels []string, testLabels []string, testType string) []str
5858
return result
5959
}
6060

61+
func FilterLabelsDoNotContain(labels []string, substr string) []string {
62+
filtered := make([]string, 0, len(labels))
63+
for _, label := range labels {
64+
if !strings.Contains(label, substr) {
65+
filtered = append(filtered, label)
66+
}
67+
}
68+
return filtered
69+
}
70+
71+
func FilterLabelsContain(labels []string, substr string) []string {
72+
filtered := make([]string, 0, len(labels))
73+
for _, label := range labels {
74+
if strings.Contains(label, substr) {
75+
filtered = append(filtered, label)
76+
}
77+
}
78+
return filtered
79+
}
80+
6181
func main() {
6282
envPRLabels := os.Getenv("PR_LABELS")
6383
envIntLabels := os.Getenv("INT_LABELS")
@@ -83,17 +103,24 @@ func main() {
83103

84104
matchedIntTests := MatchWildcards(labels, intLabels, "int")
85105
matchedE2ETests := MatchWildcards(labels, e2eLabels, "e2e")
106+
// These have to be executed in their own environment )
107+
matchedE2EGovTests := FilterLabelsContain(matchedE2ETests, "atlas-gov")
108+
109+
matchedE2ETests = FilterLabelsDoNotContain(matchedE2ETests, "atlas-gov")
86110

87111
matchedIntTestsJSON, _ := json.Marshal(matchedIntTests)
88112
matchedE2ETestsJSON, _ := json.Marshal(matchedE2ETests)
113+
matchedE2EGovTestsJSON, _ := json.Marshal(matchedE2EGovTests)
89114

90115
if envUseJSON != "" {
91116
res := map[string]any{}
92117
res["int"] = matchedIntTests
93118
res["e2e"] = matchedE2ETests
119+
res["e2e_gov"] = matchedE2EGovTests
94120
fmt.Println(jsonDump(res))
95121
return
96122
}
97123
fmt.Printf("Matched Integration Tests: %s\n", matchedIntTestsJSON)
98124
fmt.Printf("Matched E2E Tests: %s\n", matchedE2ETestsJSON)
125+
fmt.Printf("Matched E2E GOV Tests: %s\n", matchedE2EGovTestsJSON)
99126
}

tools/compute-test-labels/main_test.go

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,116 @@ import (
1818
"testing"
1919
)
2020

21+
func TestFilterLabelsContain(t *testing.T) {
22+
tests := []struct {
23+
name string
24+
labels []string
25+
substr string
26+
expectedResult []string
27+
}{
28+
{
29+
name: "Single match",
30+
labels: []string{"atlas-gov", "atlas", "cloud"},
31+
substr: "gov",
32+
expectedResult: []string{"atlas-gov"},
33+
},
34+
{
35+
name: "Multiple matches",
36+
labels: []string{"atlas-gov", "atlas-gov-cloud", "cloud"},
37+
substr: "gov",
38+
expectedResult: []string{"atlas-gov", "atlas-gov-cloud"},
39+
},
40+
{
41+
name: "No matches",
42+
labels: []string{"atlas", "cloud"},
43+
substr: "gov",
44+
expectedResult: []string{},
45+
},
46+
{
47+
name: "Empty labels",
48+
labels: []string{},
49+
substr: "gov",
50+
expectedResult: []string{},
51+
},
52+
}
53+
54+
for _, tt := range tests {
55+
t.Run(tt.name, func(t *testing.T) {
56+
result := FilterLabelsContain(tt.labels, tt.substr)
57+
if len(result) != len(tt.expectedResult) {
58+
t.Errorf("Test %s failed: expected %v, got %v", tt.name, tt.expectedResult, result)
59+
}
60+
for _, label := range tt.expectedResult {
61+
found := false
62+
for _, res := range result {
63+
if res == label {
64+
found = true
65+
break
66+
}
67+
}
68+
if !found {
69+
t.Errorf("Test %s failed: expected %v to be in the result", tt.name, label)
70+
}
71+
}
72+
})
73+
}
74+
}
75+
76+
func TestFilterLabelsDoNotContain(t *testing.T) {
77+
tests := []struct {
78+
name string
79+
labels []string
80+
substr string
81+
expectedResult []string
82+
}{
83+
{
84+
name: "Single exclusion",
85+
labels: []string{"atlas-gov", "atlas", "cloud"},
86+
substr: "gov",
87+
expectedResult: []string{"atlas", "cloud"},
88+
},
89+
{
90+
name: "Multiple exclusions",
91+
labels: []string{"atlas-gov", "atlas-gov-cloud", "cloud"},
92+
substr: "gov",
93+
expectedResult: []string{"cloud"},
94+
},
95+
{
96+
name: "No exclusions",
97+
labels: []string{"atlas", "cloud"},
98+
substr: "gov",
99+
expectedResult: []string{"atlas", "cloud"},
100+
},
101+
{
102+
name: "Empty labels",
103+
labels: []string{},
104+
substr: "gov",
105+
expectedResult: []string{},
106+
},
107+
}
108+
109+
for _, tt := range tests {
110+
t.Run(tt.name, func(t *testing.T) {
111+
result := FilterLabelsDoNotContain(tt.labels, tt.substr)
112+
if len(result) != len(tt.expectedResult) {
113+
t.Errorf("Test %s failed: expected %v, got %v", tt.name, tt.expectedResult, result)
114+
}
115+
for _, label := range tt.expectedResult {
116+
found := false
117+
for _, res := range result {
118+
if res == label {
119+
found = true
120+
break
121+
}
122+
}
123+
if !found {
124+
t.Errorf("Test %s failed: expected %v to be in the result", tt.name, label)
125+
}
126+
}
127+
})
128+
}
129+
}
130+
21131
func TestMatchWildcards(t *testing.T) {
22132
tests := []struct {
23133
name string

0 commit comments

Comments
 (0)