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

[21233] Mitigate buffer recover test flakiness on mac #5035

Merged
merged 7 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/mac-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ jobs:
label: ${{ inputs.label || 'mac-ci' }}
colcon-args: ${{ inputs.colcon-args }}
cmake-args: '-DSECURITY=ON ${{ inputs.cmake-args }}'
ctest-args: ${{ inputs.ctest-args }}
ctest-args: ' -R buffer_recover ${{ inputs.ctest-args }}'
fastdds-branch: ${{ inputs.fastdds_branch || github.ref || 'master' }}
use-ccache: ${{ ((inputs.use-ccache == true) && true) || false }}
77 changes: 0 additions & 77 deletions .github/workflows/sanitizers-ci.yml

This file was deleted.

73 changes: 0 additions & 73 deletions .github/workflows/ubuntu-ci.yml

This file was deleted.

51 changes: 0 additions & 51 deletions .github/workflows/windows-ci.yml

This file was deleted.

40 changes: 34 additions & 6 deletions test/unittest/transport/SharedMemTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1447,7 +1447,7 @@ TEST_F(SHMTransportTests, buffer_recover)
{
auto buffer = listener1->pop();

if (buffer)
if (nullptr != buffer)
{
listener1_recv_count.fetch_add(1);
// This is a slow listener
Expand All @@ -1467,7 +1467,7 @@ TEST_F(SHMTransportTests, buffer_recover)
{
auto buffer = listener2->pop();

if (buffer)
if (nullptr != buffer)
{
listener2_recv_count.fetch_add(1);
std::this_thread::sleep_for(std::chrono::milliseconds(listener2_sleep_ms));
Expand Down Expand Up @@ -1568,17 +1568,45 @@ TEST_F(SHMTransportTests, buffer_recover)

exit_listeners = true;

// This third part of the test just tries to cleanly
// exit the threads.

// At this point, listeners are blocked
// in the pop() method, and the ring buffers
// may (or not) be full.

// In order to make the listeners exit the pop() method
// we have to options:
// - Waiting for the port_timeout_ms
// - try pushing another buffer, so that cv could be
// notified.

// Sleeping the thread waiting for the port timeout
// is more risky as the healthy timeout port watchdog
// can be triggered, so we chosse the second option.
MiguelCompany marked this conversation as resolved.
Show resolved Hide resolved

{
auto buf = segment->alloc_buffer(1u, std::chrono::steady_clock::time_point());
bool buffer_pushed = false;
{
is_port_ok = false;
ASSERT_TRUE(pub_sub1_write->try_push(buf, is_port_ok));
ASSERT_TRUE(is_port_ok);
while (!buffer_pushed)
{
buffer_pushed = pub_sub1_write->try_push(buf, is_port_ok);
//! In any case port should not be ok
ASSERT_TRUE(is_port_ok);
std::this_thread::sleep_for(std::chrono::milliseconds(150));
}
}
{
elianalf marked this conversation as resolved.
Show resolved Hide resolved
is_port_ok = false;
ASSERT_TRUE(pub_sub2_write->try_push(buf, is_port_ok));
ASSERT_TRUE(is_port_ok);
while (!buffer_pushed)
{
buffer_pushed = pub_sub2_write->try_push(buf, is_port_ok);
//! In any case port should not be ok
ASSERT_TRUE(is_port_ok);
std::this_thread::sleep_for(std::chrono::milliseconds(150));
}
}
}

Expand Down
Loading