Skip to content

Commit 906d2e0

Browse files
committed
Refactor unit-tests
1 parent 709d41f commit 906d2e0

File tree

50 files changed

+167
-111
lines changed

Some content is hidden

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

50 files changed

+167
-111
lines changed

.evergreen-functions.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -659,32 +659,25 @@ functions:
659659
params:
660660
shell: bash
661661
working_dir: src/github.com/mongodb/mongodb-kubernetes
662-
script: |
663-
source .generated/context.export.env
664-
make test-race
665-
- command: gotest.parse_files
666-
params:
667-
files: [ "src/github.com/mongodb/mongodb-kubernetes/*.suite", "src/github.com/mongodb/mongodb-kubernetes/docker/mongodb-kubernetes-init-ops-manager/mmsconfiguration/*.suite" ]
662+
env:
663+
USE_RACE: "true"
664+
script: scripts/evergreen/unit-tests-golang.sh
668665

669666
test_python_unit:
670667
- command: shell.exec
671668
type: test
672669
params:
673670
shell: bash
674671
working_dir: src/github.com/mongodb/mongodb-kubernetes
675-
script: |
676-
source .generated/context.export.env
677-
make python-tests
672+
script: scripts/evergreen/unit-tests-python.sh
678673

679-
test_sboms:
674+
test_python_sbom:
680675
- command: shell.exec
681676
type: test
682677
params:
683678
shell: bash
684679
working_dir: src/github.com/mongodb/mongodb-kubernetes
685-
script: |
686-
source .generated/context.export.env
687-
make sbom-tests
680+
script: scripts/evergreen/unit-tests-sbom.sh
688681

689682
generate_perf_tests_tasks:
690683
- *switch_context

.evergreen.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ tasks:
268268
# See https://docs.devprod.prod.corp.mongodb.com/evergreen/Project-Configuration/Project-Configuration-Files#limiting-when-a-task-or-variant-will-run
269269
patchable: false
270270
commands:
271-
- func: "test_sboms"
271+
- func: "test_python_sbom"
272272

273273
- name: lint_repo
274274
tags: [ "unit_tests" ]
@@ -664,6 +664,11 @@ task_groups:
664664
- unit_tests_golang
665665
- unit_tests_python
666666
- sbom_tests
667+
teardown_task:
668+
- command: attach.xunit_results
669+
params:
670+
files: [ "src/github.com/mongodb/mongodb-kubernetes/*-result.xml" ]
671+
667672

668673
- name: gke_code_snippets_task_group
669674
<<: *setup_and_teardown_group_gke_code_snippets

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ bundle
6161
.DS_Store
6262
cover.out
6363
result.suite
64+
*result.xml
6465
# loadtesting binary
6566
production_notes/cmd/runtest/runtest
6667
production_notes/helm_charts/opsmanager/charts/

Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,19 +278,18 @@ endif
278278
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
279279

280280
golang-tests:
281-
scripts/evergreen/unit-tests.sh
281+
scripts/evergreen/unit-tests-golang.sh
282282

283283
golang-tests-race:
284-
USE_RACE=true scripts/evergreen/unit-tests.sh
284+
USE_RACE=true scripts/evergreen/unit-tests-golang.sh
285285

286286
sbom-tests:
287-
@ scripts/evergreen/run_python.sh -m pytest generate_ssdlc_report_test.py
287+
scripts/evergreen/unit-tests-sbom.sh
288288

289289
# e2e tests are also in python and we will need to ignore them as they are in the docker/mongodb-kubernetes-tests folder
290290
# additionally, we have one lib which we want to test which is in the =docker/mongodb-kubernetes-tests folder.
291291
python-tests:
292-
@ scripts/evergreen/run_python.sh -m pytest docker/mongodb-kubernetes-tests/kubeobject
293-
@ scripts/evergreen/run_python.sh -m pytest --ignore=docker/mongodb-kubernetes-tests
292+
scripts/evergreen/unit-tests-python.sh
294293

295294
generate-ssdlc-report:
296295
@ scripts/evergreen/run_python.sh generate_ssdlc_report.py

api/v1/mdb/sharded_cluster_validation_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ func TestNoIgnoredFieldUsed(t *testing.T) {
238238
Spec: corev1.PodSpec{},
239239
}},
240240
}
241+
242+
// when tests are executed with env set from current context, some kubeconfig validation tests might stop working
243+
t.Setenv(multicluster.KubeConfigPathEnv, "")
244+
241245
tests := []struct {
242246
name string
243247
isMultiCluster bool

docker/mongodb-kubernetes-init-ops-manager/Dockerfile.builder

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
#
44

55
FROM public.ecr.aws/docker/library/golang:1.24 as builder
6-
WORKDIR /go/src
7-
ADD . .
8-
RUN CGO_ENABLED=0 go build -a -buildvcs=false -o /data/scripts/mmsconfiguration ./mmsconfiguration
9-
RUN CGO_ENABLED=0 go build -a -buildvcs=false -o /data/scripts/backup-daemon-readiness-probe ./backupdaemon_readinessprobe/
106

11-
COPY scripts/docker-entry-point.sh /data/scripts/
12-
COPY scripts/backup-daemon-liveness-probe.sh /data/scripts/
7+
COPY . /go/src/github.com/mongodb/mongodb-kubernetes
8+
WORKDIR /go/src/github.com/mongodb/mongodb-kubernetes
9+
10+
RUN CGO_ENABLED=0 go build -a -buildvcs=false -o /data/scripts/mmsconfiguration docker/mongodb-kubernetes-init-ops-manager/mmsconfiguration
11+
RUN CGO_ENABLED=0 go build -a -buildvcs=false -o /data/scripts/backup-daemon-readiness-probe docker/mongodb-kubernetes-init-ops-manager/backupdaemon_readinessprobe/
12+
13+
COPY docker/mongodb-kubernetes-init-ops-manager/scripts/docker-entry-point.sh /data/scripts/
14+
COPY docker/mongodb-kubernetes-init-ops-manager/scripts/backup-daemon-liveness-probe.sh /data/scripts/
1315

1416
COPY LICENSE /data/licenses/mongodb-enterprise-ops-manager

docker/mongodb-kubernetes-init-ops-manager/go.mod

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

docker/mongodb-kubernetes-init-ops-manager/go.sum

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

go.mod

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,16 @@ require google.golang.org/protobuf v1.36.5 // indirect
4848

4949
require (
5050
github.com/beorn7/perks v1.0.1 // indirect
51+
github.com/bitfield/gotestdox v0.2.2 // indirect
5152
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
5253
github.com/cespare/xxhash/v2 v2.3.0 // indirect
5354
github.com/davecgh/go-spew v1.1.1 // indirect
55+
github.com/dnephin/pflag v1.0.7 // indirect
5456
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
5557
github.com/evanphx/json-patch v5.9.0+incompatible // indirect
5658
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
57-
github.com/fsnotify/fsnotify v1.7.0 // indirect
59+
github.com/fatih/color v1.18.0 // indirect
60+
github.com/fsnotify/fsnotify v1.8.0 // indirect
5861
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
5962
github.com/go-logr/stdr v1.2.2 // indirect
6063
github.com/go-openapi/jsonpointer v0.19.6 // indirect
@@ -67,6 +70,7 @@ require (
6770
github.com/google/gnostic-models v0.6.8 // indirect
6871
github.com/google/go-querystring v1.1.0 // indirect
6972
github.com/google/gofuzz v1.2.0 // indirect
73+
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
7074
github.com/gorilla/websocket v1.5.0 // indirect
7175
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
7276
github.com/hashicorp/errwrap v1.1.0 // indirect
@@ -81,6 +85,8 @@ require (
8185
github.com/json-iterator/go v1.1.12 // indirect
8286
github.com/klauspost/compress v1.18.0 // indirect
8387
github.com/mailru/easyjson v0.7.7 // indirect
88+
github.com/mattn/go-colorable v0.1.13 // indirect
89+
github.com/mattn/go-isatty v0.0.20 // indirect
8490
github.com/mitchellh/go-homedir v1.1.0 // indirect
8591
github.com/mitchellh/mapstructure v1.5.0 // indirect
8692
github.com/moby/spdystream v0.2.0 // indirect
@@ -112,21 +118,22 @@ require (
112118
go.uber.org/multierr v1.11.0 // indirect
113119
go.yaml.in/yaml/v2 v2.4.2 // indirect
114120
golang.org/x/mod v0.25.0 // indirect
115-
golang.org/x/net v0.40.0 // indirect
121+
golang.org/x/net v0.41.0 // indirect
116122
golang.org/x/oauth2 v0.29.0 // indirect
117123
golang.org/x/sync v0.15.0 // indirect
118124
golang.org/x/sys v0.33.0 // indirect
119125
golang.org/x/term v0.32.0 // indirect
120126
golang.org/x/text v0.26.0 // indirect
121127
golang.org/x/time v0.3.0 // indirect
122-
golang.org/x/tools v0.33.0 // indirect
128+
golang.org/x/tools v0.34.0 // indirect
123129
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
124130
google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e // indirect
125131
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
126132
google.golang.org/grpc v1.58.3 // indirect
127133
gopkg.in/inf.v0 v0.9.1 // indirect
128134
gopkg.in/yaml.v2 v2.4.0 // indirect
129135
gopkg.in/yaml.v3 v3.0.1 // indirect
136+
gotest.tools/gotestsum v1.12.3 // indirect
130137
k8s.io/apiextensions-apiserver v0.30.1 // indirect
131138
k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect
132139
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
@@ -135,3 +142,5 @@ require (
135142
)
136143

137144
go 1.24.0
145+
146+
tool gotest.tools/gotestsum

0 commit comments

Comments
 (0)