Skip to content

Commit e7cc7ec

Browse files
committed
Refactor unit-tests
1 parent 637923f commit e7cc7ec

File tree

50 files changed

+157
-80
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

+157
-80
lines changed

.evergreen-functions.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -682,32 +682,25 @@ functions:
682682
params:
683683
shell: bash
684684
working_dir: src/github.com/mongodb/mongodb-kubernetes
685-
script: |
686-
source .generated/context.export.env
687-
make test-race
688-
- command: gotest.parse_files
689-
params:
690-
files: [ "src/github.com/mongodb/mongodb-kubernetes/*.suite", "src/github.com/mongodb/mongodb-kubernetes/docker/mongodb-kubernetes-init-ops-manager/mmsconfiguration/*.suite" ]
685+
env:
686+
USE_RACE: "true"
687+
script: scripts/evergreen/unit-tests-golang.sh
691688

692689
test_python_unit:
693690
- command: shell.exec
694691
type: test
695692
params:
696693
shell: bash
697694
working_dir: src/github.com/mongodb/mongodb-kubernetes
698-
script: |
699-
source .generated/context.export.env
700-
make python-tests
695+
script: scripts/evergreen/unit-tests-python.sh
701696

702-
test_sboms:
697+
test_python_sbom:
703698
- command: shell.exec
704699
type: test
705700
params:
706701
shell: bash
707702
working_dir: src/github.com/mongodb/mongodb-kubernetes
708-
script: |
709-
source .generated/context.export.env
710-
make sbom-tests
703+
script: scripts/evergreen/unit-tests-sbom.sh
711704

712705
generate_perf_tests_tasks:
713706
- *switch_context

.evergreen.yml

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

280280
- name: lint_repo
281281
tags: [ "unit_tests" ]
@@ -623,6 +623,11 @@ task_groups:
623623
- unit_tests_golang
624624
- unit_tests_python
625625
- sbom_tests
626+
teardown_task:
627+
- command: attach.xunit_results
628+
params:
629+
files: [ "src/github.com/mongodb/mongodb-kubernetes/*-result.xml" ]
630+
626631

627632
- name: gke_code_snippets_task_group
628633
<<: *setup_and_teardown_group_gke_code_snippets

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ bundle
5656
.DS_Store
5757
cover.out
5858
result.suite
59+
*result.xml
5960
# loadtesting binary
6061
production_notes/cmd/runtest/runtest
6162
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/dev/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/dev/run_python.sh -m pytest docker/mongodb-kubernetes-tests/kubeobject
293-
@ scripts/dev/run_python.sh -m pytest --ignore=docker/mongodb-kubernetes-tests
292+
scripts/evergreen/unit-tests-python.sh
294293

295294
generate-ssdlc-report:
296295
@ scripts/dev/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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,17 @@ require google.golang.org/protobuf v1.36.6 // 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/cenkalti/backoff/v5 v5.0.2 // indirect
5354
github.com/cespare/xxhash/v2 v2.3.0 // indirect
5455
github.com/davecgh/go-spew v1.1.1 // indirect
56+
github.com/dnephin/pflag v1.0.7 // indirect
5557
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
5658
github.com/evanphx/json-patch v5.9.0+incompatible // indirect
5759
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
58-
github.com/fsnotify/fsnotify v1.7.0 // indirect
60+
github.com/fatih/color v1.18.0 // indirect
61+
github.com/fsnotify/fsnotify v1.8.0 // indirect
5962
github.com/go-jose/go-jose/v4 v4.0.5 // indirect
6063
github.com/go-logr/stdr v1.2.2 // indirect
6164
github.com/go-openapi/jsonpointer v0.19.6 // indirect
@@ -68,6 +71,7 @@ require (
6871
github.com/google/gnostic-models v0.6.8 // indirect
6972
github.com/google/go-querystring v1.1.0 // indirect
7073
github.com/google/gofuzz v1.2.0 // indirect
74+
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
7175
github.com/gorilla/websocket v1.5.0 // indirect
7276
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1 // indirect
7377
github.com/hashicorp/errwrap v1.1.0 // indirect
@@ -82,6 +86,8 @@ require (
8286
github.com/json-iterator/go v1.1.12 // indirect
8387
github.com/klauspost/compress v1.18.0 // indirect
8488
github.com/mailru/easyjson v0.7.7 // indirect
89+
github.com/mattn/go-colorable v0.1.13 // indirect
90+
github.com/mattn/go-isatty v0.0.20 // indirect
8591
github.com/mitchellh/go-homedir v1.1.0 // indirect
8692
github.com/mitchellh/mapstructure v1.5.0 // indirect
8793
github.com/moby/spdystream v0.2.0 // indirect
@@ -129,6 +135,7 @@ require (
129135
gopkg.in/inf.v0 v0.9.1 // indirect
130136
gopkg.in/yaml.v2 v2.4.0 // indirect
131137
gopkg.in/yaml.v3 v3.0.1 // indirect
138+
gotest.tools/gotestsum v1.12.3 // indirect
132139
k8s.io/apiextensions-apiserver v0.30.1 // indirect
133140
k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect
134141
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
@@ -137,3 +144,5 @@ require (
137144
)
138145

139146
go 1.24.0
147+
148+
tool gotest.tools/gotestsum

go.sum

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkY
44
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
55
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
66
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
7+
github.com/bitfield/gotestdox v0.2.2 h1:x6RcPAbBbErKLnapz1QeAlf3ospg8efBsedU93CDsnE=
8+
github.com/bitfield/gotestdox v0.2.2/go.mod h1:D+gwtS0urjBrzguAkTM2wodsTQYFHdpx8eqRJ3N+9pY=
79
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
810
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
911
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
@@ -17,21 +19,23 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
1719
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1820
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1921
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
22+
github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk=
23+
github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE=
2024
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
2125
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
2226
github.com/evanphx/json-patch v5.9.0+incompatible h1:fBXyNpNMuTTDdquAq/uisOr2lShz4oaXpDTX2bLe7ls=
2327
github.com/evanphx/json-patch v5.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
2428
github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg=
2529
github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ=
2630
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
27-
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
28-
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
31+
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
32+
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
2933
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
3034
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
3135
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
3236
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
33-
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
34-
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
37+
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
38+
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
3539
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
3640
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
3741
github.com/go-jose/go-jose/v4 v4.0.5 h1:M6T8+mKZl/+fNNuFHvGIzDz7BTLQPIounk/b9dw3AaE=
@@ -85,6 +89,8 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
8589
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
8690
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=
8791
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
92+
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
93+
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
8894
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
8995
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
9096
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
@@ -146,6 +152,7 @@ github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaO
146152
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
147153
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
148154
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
155+
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
149156
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
150157
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
151158
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
@@ -325,6 +332,8 @@ golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7w
325332
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
326333
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
327334
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
335+
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
336+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
328337
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
329338
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
330339
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
@@ -393,6 +402,10 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
393402
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
394403
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
395404
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
405+
gotest.tools/gotestsum v1.12.3 h1:jFwenGJ0RnPkuKh2VzAYl1mDOJgbhobBDeL2W1iEycs=
406+
gotest.tools/gotestsum v1.12.3/go.mod h1:Y1+e0Iig4xIRtdmYbEV7K7H6spnjc1fX4BOuUhWw2Wk=
407+
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
408+
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=
396409
k8s.io/api v0.30.10 h1:2YvzRF/BELgCvxbQqFKaan5hnj2+y7JOuqu2WpVk3gg=
397410
k8s.io/api v0.30.10/go.mod h1:Hyz3ZuK7jVLJBUFvwzDSGwxHuDdsrGs5RzF16wfHIn4=
398411
k8s.io/apiextensions-apiserver v0.30.1 h1:4fAJZ9985BmpJG6PkoxVRpXv9vmPUOVzl614xarePws=

0 commit comments

Comments
 (0)