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

fix running unit tests multiple times will cause a rare failed #380

Conversation

tommady
Copy link
Collaborator

@tommady tommady commented Oct 12, 2021

in the current main branch, the unit tests will fail into rare failures by running the unit test multiple times without single-thread testing setting for the cargo or using serial derive,

below are the failures I can capture.

  1. bad file descriptor (os error 9) at Process::new(pid.as_raw()) line caused
thread 'container::container::tests::test_get_set_refresh_status' panicked at 'assertion failed: `(left == right)`
  left: `Stopped`,
 right: `Paused`', src/container/container.rs:337:9
Caused by:
    Bad file descriptor (os error 9)
thread 'container::container::tests::test_refresh_load_save_state' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /rust
c/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/test/src/lib.rs:194:5
Caused by:
    0: Bad file descriptor (os error 9)
    1: Bad file descriptor (os error 9)
thread 'container::container::tests::test_get_spec' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /rust
c/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/test/src/lib.rs:194:5
Caused by:
    Bad file descriptor (os error 9)
thread 'commands::spec_json::tests::test_spec_json' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /rust
c/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/test/src/lib.rs:194:5
thread 'container::builder_impl::tests::setup_uid_mapping_should_succeed' panicked at 'unknown message: 49.', src/pr
ocess/message.rs:17:thread '18container::container::tests::test_get_set_refresh_status
' panicked at 'note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
attempt to subtract with overflow', /home/tommady/.cargo/registry/src/github.com-1ecc6299db9ec823/procfs-0.10.1/src/
process/stat.rs:255:28
thread 'thread 'container::container::tests::test_get_set_refresh_statuscontainer::builder_impl::tests::setup_uid_ma
pping_should_succeed' panicked at '' panicked at 'attempt to subtract with overflowunknown message: 49.', ', /home/t
ommady/.cargo/registry/src/github.com-1ecc6299db9ec823/procfs-0.10.1/src/process/stat.rssrc/process/message.rs::2551
7::2818

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: Failed to write message [2] to the pipe
Caused by:
    Broken pipe (os error 32)
thread 'container::builder_impl::tests::setup_uid_mapping_should_succeed' panicked at 'assertion failed: `(left == r
ight)`
  left: `1`,
 right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /rust
c/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/test/src/lib.rs:194:5

by running

./hack/stress_cargo_test.sh

will be very easy to reproduce.

thread container::container::tests::test_get_set_refresh_status panicked at assertion failed: (left == right)
left: Stopped,
right: Paused, src/container/container.rs:337:9
1. test_spec_json
2. test_refresh_load_save_state
3. test_get_spec
4. test_get_set_refresh_status
unit test cases
to resolve
@tommady tommady changed the title [WIP] fix running unit tests multiple times will cause a rare failed fix running unit tests multiple times will cause a rare failed Oct 15, 2021
@tommady tommady marked this pull request as ready for review October 15, 2021 13:51
@tommady
Copy link
Collaborator Author

tommady commented Oct 15, 2021

resolving by adding serial derive into those testcases

  1. test_spec_json
  2. test_refresh_load_save_state
  3. test_get_spec
  4. test_get_set_refresh_status

please help review 🙇🏻

Copy link
Member

@utam0k utam0k left a comment

Choose a reason for hiding this comment

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

LGTM

@utam0k utam0k merged commit 3ff35cc into youki-dev:main Oct 16, 2021
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.

2 participants