Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable race detection in unit tests #264

Merged

Conversation

AlinaSecret
Copy link
Contributor

This pull request enables race detection in unit tests by modifying the Go test step in buildtest.yml. The test configuration is updated to include the '-race' flag, allowing thorough race detection during testing.

Race detection can help identifying potential data race conditions, which can lead to hard-to-debug issues in concurrent code. By enabling race detection in our unit tests, we can detect and address these race conditions, ensuring the reliability and stability of our code. (for further reference view: https://go.dev/doc/articles/race_detector)

@@ -33,7 +33,7 @@ jobs:

- name: Go test
if: ${{ matrix.goarch }} == "amd64"
run: sudo go test ./... # sudo needed for netns change in test
run: sudo go test -race ./... # sudo needed for netns change in test
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also saw there is a an option in the Makefile to run the tests with the race flag ( make test-race).
I wasn't sure why the CI doesn't use the Makefile to run the tests - so i decided to do minimal changes. But if there isn't any reason not to use the option in the Makefile i think its better to use it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test rules in Makefile need cleaning, but they can be done in a different PR.

This change updates "Go test" step in buildtest.yml to include the '-race' flag, enabling race detection in the CI during testing.
 
Signed-off-by: Alina Sudakov <asudakov@redhat.com>
Copy link
Member

@zeeke zeeke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thanks for working on this @AlinaSecret

@@ -33,7 +33,7 @@ jobs:

- name: Go test
if: ${{ matrix.goarch }} == "amd64"
run: sudo go test ./... # sudo needed for netns change in test
run: sudo go test -race ./... # sudo needed for netns change in test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test rules in Makefile need cleaning, but they can be done in a different PR.

Copy link
Collaborator

@SchSeba SchSeba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adrianchiris adrianchiris merged commit 99061d5 into k8snetworkplumbingwg:master May 22, 2023
@coveralls
Copy link

coveralls commented Nov 12, 2024

Pull Request Test Coverage Report for Build 5004616867

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 38.156%

Totals Coverage Status
Change from base Build 4993903956: 0.0%
Covered Lines: 422
Relevant Lines: 1106

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants