Skip to content

Commit b30e560

Browse files
authored
chore: move e2e tests into code_health (#3828)
1 parent 38a29de commit b30e560

File tree

127 files changed

+1799
-1922
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+1799
-1922
lines changed

.github/workflows/code-health.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,3 +360,28 @@ jobs:
360360
platforms: linux/amd64,linux/arm64
361361
tags: mongodb/atlas:test
362362
file: Dockerfile
363+
e2e-tests:
364+
runs-on: ubuntu-latest
365+
strategy:
366+
fail-fast: false
367+
steps:
368+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
369+
with:
370+
config: ${{ vars.PERMISSIONS_CONFIG }}
371+
- name: Checkout repository
372+
uses: actions/checkout@v4
373+
with:
374+
fetch-depth: 0
375+
- name: Install Go
376+
uses: actions/setup-go@v5
377+
with:
378+
go-version-file: 'go.mod'
379+
- run: go install gotest.tools/gotestsum@latest
380+
- run: make e2e-test-snapshots
381+
env:
382+
TEST_CMD: gotestsum --junitfile e2e-tests.xml --format standard-verbose --
383+
- name: Test Summary
384+
if: always()
385+
uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86
386+
with:
387+
paths: e2e-tests.xml

.github/workflows/e2e-tests.yml

Lines changed: 0 additions & 85 deletions
This file was deleted.

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,6 @@ linters:
199199
- linters:
200200
- gocyclo
201201
path: e2e
202-
- linters:
203-
- mnd
204-
path: internal/test/fixture
205202
paths:
206203
- third_party$
207204
- builtin$

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ ATLAS_INSTALL_PATH="${GOPATH}/bin/$(ATLAS_BINARY_NAME)"
1919

2020
LOCALDEV_IMAGE?=docker.io/mongodb/mongodb-atlas-local
2121
LINKER_FLAGS=-s -w -X github.com/mongodb/mongodb-atlas-cli/atlascli/internal/version.GitCommit=${GIT_SHA} -X github.com/mongodb/mongodb-atlas-cli/atlascli/internal/version.Version=${ATLAS_VERSION} -X github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/deployments/options.LocalDevImage=${LOCALDEV_IMAGE}
22-
ATLAS_E2E_BINARY?=../../bin/${ATLAS_BINARY_NAME}
22+
ATLAS_E2E_BINARY?=$(abspath bin/${ATLAS_BINARY_NAME})
23+
export SNAPSHOTS_DIR?=$(abspath test/e2e/testdata/.snapshots)
2324

2425
DEBUG_FLAGS=all=-N -l
2526

@@ -163,6 +164,10 @@ e2e-test: build-debug ## Run E2E tests
163164
@echo "==> Running E2E tests..."
164165
$(TEST_CMD) -v -p 1 -parallel $(E2E_PARALLEL) -v -timeout $(E2E_TIMEOUT) -tags="$(E2E_TAGS)" ./test/e2e... $(E2E_EXTRA_ARGS)
165166

167+
.PHONY: e2e-test-snapshots
168+
e2e-test-snapshots: build-debug ## Run E2E tests
169+
UPDATE_SNAPSHOTS=false E2E_SKIP_CLEANUP=true DO_NOT_TRACK=1 $(TEST_CMD) -v -timeout $(E2E_TIMEOUT) -tags="e2eSnap" ./test/e2e... $(E2E_EXTRA_ARGS)
170+
166171
.PHONY: unit-test
167172
unit-test: build-debug ## Run unit-tests
168173
@echo "==> Running unit tests..."
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
//go:build e2e || (atlas && generic)
14+
//go:build e2e || e2eSnap || (atlas && generic)
1515

16-
package e2e
16+
package accesslists
1717

1818
import (
1919
"encoding/json"
@@ -29,6 +29,10 @@ import (
2929
atlasv2 "go.mongodb.org/atlas-sdk/v20250312001/admin"
3030
)
3131

32+
const (
33+
accessListEntity = "accessList"
34+
)
35+
3236
func TestAccessList(t *testing.T) {
3337
g := internal.NewAtlasE2ETestGenerator(t, internal.WithSnapshot())
3438
g.GenerateProject("accessList")
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
//go:build e2e || (atlas && logs)
14+
//go:build e2e || e2eSnap || (atlas && logs)
1515

16-
package e2e
16+
package accesslogs
1717

1818
import (
1919
"encoding/json"
@@ -26,6 +26,10 @@ import (
2626
atlasv2 "go.mongodb.org/atlas-sdk/v20250312001/admin"
2727
)
2828

29+
const (
30+
accessLogsEntity = "accessLogs"
31+
)
32+
2933
func TestAccessLogs(t *testing.T) {
3034
g := internal.NewAtlasE2ETestGenerator(t, internal.WithSnapshot())
3135
req := require.New(t)
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
//go:build e2e || (atlas && generic)
14+
//go:build e2e || e2eSnap || (atlas && generic)
1515

16-
package e2e
16+
package accessroles
1717

1818
import (
1919
"encoding/json"
@@ -27,6 +27,12 @@ import (
2727
atlasv2 "go.mongodb.org/atlas-sdk/v20250312001/admin"
2828
)
2929

30+
const (
31+
awsEntity = "aws"
32+
cloudProvidersEntity = "cloudProviders"
33+
accessRolesEntity = "accessRoles"
34+
)
35+
3036
const aws = "AWS"
3137

3238
func TestAccessRoles(t *testing.T) {
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14-
//go:build e2e || (atlas && generic)
14+
//go:build e2e || e2eSnap || (atlas && generic)
1515

16-
package e2e
16+
package alerts
1717

1818
import (
1919
"encoding/json"
@@ -28,6 +28,10 @@ import (
2828
atlasv2 "go.mongodb.org/atlas-sdk/v20250312001/admin"
2929
)
3030

31+
const (
32+
alertsEntity = "alerts"
33+
)
34+
3135
const (
3236
closed = "CLOSED"
3337
)

test/e2e/alert_settings_test.go renamed to test/e2e/alertsettings/alert_settings_test.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
//go:build e2e || (atlas && generic)
15+
//go:build e2e || e2eSnap || (atlas && generic)
1616

17-
package e2e
17+
package alertsettings
1818

1919
import (
2020
"encoding/json"
@@ -30,6 +30,17 @@ import (
3030
"go.mongodb.org/atlas-sdk/v20250312001/admin"
3131
)
3232

33+
const (
34+
alertsEntity = "alerts"
35+
settingsEntity = "settings"
36+
37+
// AlertConfig constants.
38+
group = "GROUP"
39+
eventTypeName = "NO_PRIMARY"
40+
intervalMin = 5
41+
delayMin = 0
42+
)
43+
3344
func TestAlertConfig(t *testing.T) {
3445
g := internal.NewAtlasE2ETestGenerator(t, internal.WithSnapshot())
3546
var alertID string

test/e2e/atlas_org_api_key_access_list_test.go renamed to test/e2e/atlasorgapikeyaccesslist/atlas_org_api_key_access_list_test.go

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
//go:build e2e || (iam && atlas)
15+
//go:build e2e || e2eSnap || (iam && atlas)
1616

17-
package e2e
17+
package atlasorgapikeyaccesslist
1818

1919
import (
2020
"encoding/json"
@@ -30,6 +30,12 @@ import (
3030
atlasv2 "go.mongodb.org/atlas-sdk/v20250312001/admin"
3131
)
3232

33+
const (
34+
orgEntity = "org"
35+
apiKeysEntity = "apikeys"
36+
apiKeyAccessListEntity = "accessLists"
37+
)
38+
3339
var errNoAPIKey = errors.New("the apiKey ID is empty")
3440

3541
func TestAtlasOrgAPIKeyAccessList(t *testing.T) {
@@ -41,7 +47,7 @@ func TestAtlasOrgAPIKeyAccessList(t *testing.T) {
4147
require.NoError(t, e)
4248

4349
t.Cleanup(func() {
44-
require.NoError(t, deleteOrgAPIKey(apiKeyID))
50+
require.NoError(t, internal.DeleteOrgAPIKey(apiKeyID))
4551
})
4652

4753
n := g.MemoryRand("rand", 255)
@@ -159,18 +165,3 @@ func createOrgAPIKey() (string, error) {
159165

160166
return "", errNoAPIKey
161167
}
162-
163-
func deleteOrgAPIKey(id string) error {
164-
cliPath, err := internal.AtlasCLIBin()
165-
if err != nil {
166-
return err
167-
}
168-
cmd := exec.Command(cliPath,
169-
orgEntity,
170-
apiKeysEntity,
171-
"rm",
172-
id,
173-
"--force")
174-
cmd.Env = os.Environ()
175-
return cmd.Run()
176-
}

0 commit comments

Comments
 (0)