Skip to content

Commit fd24b19

Browse files
committed
Refactor unit-tests
1 parent 7a058aa commit fd24b19

File tree

51 files changed

+135
-73
lines changed

Some content is hidden

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

51 files changed

+135
-73
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
vendor/
99
pkg/client/
1010
docker/mongodb-kubernetes-tests
11-
scripts/
11+
# scripts/
1212
samples/
1313
.multi_cluster_local_test_files/
1414

.evergreen-functions.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -615,12 +615,9 @@ functions:
615615
params:
616616
shell: bash
617617
working_dir: src/github.com/mongodb/mongodb-kubernetes
618-
script: |
619-
source .generated/context.export.env
620-
make test-race
621-
- command: gotest.parse_files
622-
params:
623-
files: [ "src/github.com/mongodb/mongodb-kubernetes/*.suite", "src/github.com/mongodb/mongodb-kubernetes/docker/mongodb-kubernetes-init-ops-manager/mmsconfiguration/*.suite" ]
618+
env:
619+
USE_RACE: "true"
620+
script: scripts/evergreen/unit-tests-golang.sh
624621

625622
test_helm_unit:
626623
- command: shell.exec
@@ -638,19 +635,15 @@ functions:
638635
params:
639636
shell: bash
640637
working_dir: src/github.com/mongodb/mongodb-kubernetes
641-
script: |
642-
source .generated/context.export.env
643-
make python-tests
638+
script: scripts/evergreen/unit-tests-python.sh
644639

645-
test_sboms:
640+
test_python_sbom:
646641
- command: shell.exec
647642
type: test
648643
params:
649644
shell: bash
650645
working_dir: src/github.com/mongodb/mongodb-kubernetes
651-
script: |
652-
source .generated/context.export.env
653-
make sbom-tests
646+
script: scripts/evergreen/unit-tests-sbom.sh
654647

655648
generate_perf_tests_tasks:
656649
- command: shell.exec

.evergreen.yml

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

285285
- name: lint_repo
286286
tags: [ "unit_tests" ]
@@ -631,6 +631,11 @@ task_groups:
631631
- unit_tests_python
632632
- unit_tests_helm
633633
- sbom_tests
634+
teardown_task:
635+
- command: attach.xunit_results
636+
params:
637+
files: [ "src/github.com/mongodb/mongodb-kubernetes/*-result.xml" ]
638+
634639

635640
# Task group for deploying mongodbcommunity resources and testing the (former) MCO
636641
- name: e2e_mdb_community_task_group

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ bundle
5555
.DS_Store
5656
cover.out
5757
result.suite
58+
*result.xml
5859
# loadtesting binary
5960
production_notes/cmd/runtest/runtest
6061
production_notes/helm_charts/opsmanager/charts/

Makefile

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

277277
golang-tests:
278-
scripts/evergreen/unit-tests.sh
278+
scripts/evergreen/unit-tests-golang.sh
279279

280280
golang-tests-race:
281-
USE_RACE=true scripts/evergreen/unit-tests.sh
281+
USE_RACE=true scripts/evergreen/unit-tests-golang.sh
282282

283283
sbom-tests:
284-
@ scripts/dev/run_python.sh -m pytest generate_ssdlc_report_test.py
284+
scripts/evergreen/unit-tests-sbom.sh
285285

286286
# e2e tests are also in python and we will need to ignore them as they are in the docker/mongodb-kubernetes-tests folder
287287
# additionally, we have one lib which we want to test which is in the =docker/mongodb-kubernetes-tests folder.
288288
python-tests:
289-
@ scripts/dev/run_python.sh -m pytest docker/mongodb-kubernetes-tests/kubeobject
290-
@ scripts/dev/run_python.sh -m pytest --ignore=docker/mongodb-kubernetes-tests
289+
scripts/evergreen/unit-tests-python.sh
291290

292291
generate-ssdlc-report:
293292
@ 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/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.

docker/mongodb-kubernetes-init-ops-manager/mmsconfiguration/edit_mms_configuration.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func readLinesFromFile(name string) ([]string, error) {
145145
func writeLinesToFile(name string, lines []string) error {
146146
output := strings.Join(lines, lineBreak)
147147

148-
err := os.WriteFile(name, []byte(output), 0o644)
148+
err := os.WriteFile(name, []byte(output), 0o644) // nolint:gosec
149149
if err != nil {
150150
return xerrors.Errorf("error writing to file %s: %w", name, err)
151151
}

docker/mongodb-kubernetes-init-ops-manager/scripts/backup-daemon-liveness-probe.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ check_backup_daemon_alive () {
66
pgrep --exact 'mms-app' || pgrep -f '/mongodb-ops-manager/jdk/bin/mms-app'
77
}
88

9-
check_backup_daemon_alive
9+
check_backup_daemon_alive

0 commit comments

Comments
 (0)