Skip to content

Commit

Permalink
Deflake ScopeTest.WaitIdleFailure by increasing sleep time. (iree-org…
Browse files Browse the repository at this point in the history
…#17859)

This test has flaked a few times:

*
https://github.com/iree-org/iree/actions/runs/9653016869/job/26624436852#step:5:1882
*
https://github.com/iree-org/iree/actions/runs/9716312176/job/26819673196#step:4:18786

```
[ RUN      ] ScopeTest.WaitIdleFailure
/work/runtime/src/iree/task/scope_test.cc:225: Failure
Value of: iree_task_scope_is_idle(&scope)
  Actual: true
Expected: false

[  FAILED  ] ScopeTest.WaitIdleFailure (175 ms)
[----------] 9 tests from ScopeTest (326 ms total)

[----------] Global test environment tear-down
[==========] 9 tests from 1 test suite ran. (326 ms total)
[  PASSED  ] 8 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] ScopeTest.WaitIdleFailure

 1 FAILED TEST
```

We could instead drop the
`EXPECT_FALSE(iree_task_scope_is_idle(&scope));` check entirely.
Increasing the sleep time will increase test time regardless of OS
scheduler behavior (unlike iree-org#17857
which increased a _timeout_ duration).
  • Loading branch information
ScottTodd authored and saienduri committed Jul 12, 2024
1 parent bf04445 commit 19f8d07
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions runtime/src/iree/task/scope_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ TEST(ScopeTest, WaitIdleSuccess) {

// Spin up a thread to wait on the scope.
std::thread wait_thread([&]() {
// Note: if the thread takes longer to start than the sleep below, this
// will fail with a flake :(
EXPECT_FALSE(iree_task_scope_is_idle(&scope));
EXPECT_TRUE(iree_status_is_ok(
iree_task_scope_wait_idle(&scope, IREE_TIME_INFINITE_FUTURE)));
Expand All @@ -190,7 +192,7 @@ TEST(ScopeTest, WaitIdleSuccess) {

// Wait a moment for the thread to spin up.
// NOTE: this may flake. Need to see if there's a better way to do this.
std::this_thread::sleep_for(std::chrono::milliseconds(150));
std::this_thread::sleep_for(std::chrono::milliseconds(250));

// Complete the task.
iree_task_submission_t pending_submission;
Expand Down Expand Up @@ -222,6 +224,8 @@ TEST(ScopeTest, WaitIdleFailure) {

// Spin up a thread to wait on the scope.
std::thread wait_thread([&]() {
// Note: if the thread takes longer to start than the sleep below, this
// will fail with a flake :(
EXPECT_FALSE(iree_task_scope_is_idle(&scope));
EXPECT_TRUE(iree_status_is_ok(
iree_task_scope_wait_idle(&scope, IREE_TIME_INFINITE_FUTURE)));
Expand All @@ -230,7 +234,7 @@ TEST(ScopeTest, WaitIdleFailure) {

// Wait a moment for the thread to spin up.
// NOTE: this may flake. Need to see if there's a better way to do this.
std::this_thread::sleep_for(std::chrono::milliseconds(150));
std::this_thread::sleep_for(std::chrono::milliseconds(250));

// Set the failure state.
iree_task_scope_fail(
Expand Down

0 comments on commit 19f8d07

Please sign in to comment.