Skip to content

Conversation

@lsierant
Copy link
Contributor

@lsierant lsierant commented Jul 23, 2025

Summary

This PR simplifies unit tests execution to allow a simple go test ./... to always correctly execute all golang unit tests without running community e2e tests.
Additionally we use gotestsum wrapper by default to better present test output in the command line.

Changes

  • There is only one, unified go.mod in the repo now, so running go test ./... correctly identifies all go files. The last one from init-ops-manager was removed in this PR, and another one from kubectl plugin was removed recently in [CLOUDP-332196] Move kubectl-mongodb plugin to cmd dir for atomic releases #271.
  • All community e2e tests were marked with community_e2e tag, so we don't need to run tests with a filtered package list anymore.
  • gotestsum test runner is used to execute unit tests giving more readable output
  • gotestsum has been added as a tool in go.mod by running go get -tool gotest.tools/gotestsum@latest.
    • While using go.mod's tool directive allows for easy tool access (by go tool <tool>) and is not resulting in adding dependencies into the operators binary, it is still cluttering dependency list (in require section). We might consider removing it from go mod and installing it as a separate step.
  • All test (python and golang) are reporting results as xml and are all gathered by evg. Test output is gathered in the teardown_task section now.
  • Enabled back golang race tests - those were mistakenly disabled during operator merge to MCK (diff unit-tests.sh)

How to run tests now

Essentially as before:

$ make golang-tests

or

$ make test

Difference: we don't run with coverage enabled by default, thus allowing to use test caching for faster repeated runs from cli.

In order to run all unit tests without cache and with coverage run:

$ make golang-tests-race

We is use gotestsum as:

go tool gotestsum --junitfile golang-unit-result.xml --format-icons hivis -- -v ./...

But thanks to the overall go.mod/unitest simplifications you can use whatever suits you:

  1. Use gotestsum
$ go tool gotestsum
  1. Use plain go test
$ go test ./...
  1. Use other test runner/viewers. I recommend to look into gotestsum options as well..

  2. Also there is tparse which also has very nice summary table:

go get -tool github.com/mfridman/tparse@latest
go test -v ./... -json | go tool tparse

tparse is not supporting xunit output thus it's not used here as a default.

Proof of Work

Golang unit tests with remove locks to trigger race test error: link
Python unit test with injected error: evg link

Passing tests: evg link

@lsierant lsierant self-assigned this Jul 23, 2025
@lsierant lsierant changed the title tparse Refactor unit test execution Jul 23, 2025
@lsierant lsierant changed the title Refactor unit test execution CLOUDP-332943: Refactor unit test execution Jul 23, 2025
@lsierant lsierant force-pushed the lsierant/unit-test-parse branch 3 times, most recently from f3cd1b8 to 80c4de1 Compare July 29, 2025 11:38
@github-actions
Copy link

github-actions bot commented Jul 29, 2025

⚠️ (this preview might not be accurate if the PR is not rebased on current master branch)

MCK 1.6.1 Release Notes

Bug Fixes

  • Backed up the agent password in a secret for SCRAM authentication to prevent unnecessary password rotations.

@lsierant lsierant force-pushed the lsierant/unit-test-parse branch from d3f907a to f4e132b Compare August 23, 2025 21:20
@lsierant lsierant force-pushed the lsierant/unit-test-parse branch 2 times, most recently from bf880c6 to 24e9157 Compare September 22, 2025 10:34
@lsierant lsierant added the skip-changelog Use this label in Pull Request to not require new changelog entry file label Sep 22, 2025
@lsierant lsierant force-pushed the lsierant/unit-test-parse branch 2 times, most recently from d95212e to 481f562 Compare September 25, 2025 07:37
@lsierant lsierant force-pushed the lsierant/unit-test-parse branch from 481f562 to 23c4209 Compare October 1, 2025 09:08
@lsierant lsierant force-pushed the lsierant/unit-test-parse branch from 23c4209 to 71839e7 Compare December 3, 2025 10:03
@lsierant lsierant force-pushed the lsierant/unit-test-parse branch from 71839e7 to b051325 Compare December 3, 2025 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Use this label in Pull Request to not require new changelog entry file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants