Skip to content

Commit 481f562

Browse files
committed
Refactor unit-tests
1 parent 58f3569 commit 481f562

File tree

54 files changed

+155
-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.

54 files changed

+155
-80
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
@@ -679,12 +679,9 @@ functions:
679679
params:
680680
shell: bash
681681
working_dir: src/github.com/mongodb/mongodb-kubernetes
682-
script: |
683-
source .generated/context.export.env
684-
make test-race
685-
- command: gotest.parse_files
686-
params:
687-
files: [ "src/github.com/mongodb/mongodb-kubernetes/*.suite", "src/github.com/mongodb/mongodb-kubernetes/docker/mongodb-kubernetes-init-ops-manager/mmsconfiguration/*.suite" ]
682+
env:
683+
USE_RACE: "true"
684+
script: scripts/evergreen/unit-tests-golang.sh
688685

689686
test_helm_unit:
690687
- command: shell.exec
@@ -702,19 +699,15 @@ functions:
702699
params:
703700
shell: bash
704701
working_dir: src/github.com/mongodb/mongodb-kubernetes
705-
script: |
706-
source .generated/context.export.env
707-
make python-tests
702+
script: scripts/evergreen/unit-tests-python.sh
708703

709-
test_sboms:
704+
test_python_sbom:
710705
- command: shell.exec
711706
type: test
712707
params:
713708
shell: bash
714709
working_dir: src/github.com/mongodb/mongodb-kubernetes
715-
script: |
716-
source .generated/context.export.env
717-
make sbom-tests
710+
script: scripts/evergreen/unit-tests-sbom.sh
718711

719712
generate_perf_tests_tasks:
720713
- *switch_context

.evergreen.yml

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

276276
- name: lint_repo
277277
tags: [ "unit_tests" ]
@@ -567,6 +567,11 @@ task_groups:
567567
- unit_tests_python
568568
- unit_tests_helm
569569
- sbom_tests
570+
teardown_task:
571+
- command: attach.xunit_results
572+
params:
573+
files: [ "src/github.com/mongodb/mongodb-kubernetes/*-result.xml" ]
574+
570575

571576
# Task group for deploying mongodbcommunity resources and testing the (former) MCO
572577
- 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
@@ -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

api/v1/search/zz_generated.deepcopy.go

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controllers/operator/appdbreplicaset_controller_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77
"os"
88
"path/filepath"
9-
"strings"
109
"testing"
1110
"time"
1211

@@ -54,15 +53,14 @@ func init() {
5453

5554
// getReleaseJsonPath searches for a specified target directory by traversing the directory tree backwards from the current working directory
5655
func getReleaseJsonPath() (string, error) {
57-
repositoryRootDirName := "mongodb-kubernetes"
5856
releaseFileName := "release.json"
5957

6058
currentDir, err := os.Getwd()
6159
if err != nil {
6260
return "", err
6361
}
6462
for currentDir != "/" {
65-
if strings.HasSuffix(currentDir, repositoryRootDirName) {
63+
if _, err := os.Stat(filepath.Join(currentDir, releaseFileName)); err == nil {
6664
return filepath.Join(currentDir, releaseFileName), nil
6765
}
6866
currentDir = filepath.Dir(currentDir)

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.

0 commit comments

Comments
 (0)