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

[Bugfix] Fix ROS2StreamStatusMonitorTest #472

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@

import java.net.InetSocketAddress;

import static java.lang.Thread.interrupted;
import static org.junit.jupiter.api.Assertions.*;

public class ROS2StreamStatusMonitorTest
{
private static final ROS2Node ROS2_NODE = ROS2Tools.createROS2Node(PubSubImplementation.FAST_RTPS, "stream_status_monitor_test_node");
private static final ROS2Node ROS2_NODE = ROS2Tools.createROS2Node(PubSubImplementation.INTRAPROCESS, "stream_status_monitor_test_node");
private static final ROS2Helper ROS2_HELPER = new ROS2Helper(ROS2_NODE);
private static final ROS2Topic<SRTStreamStatus> TEST_TOPIC = PerceptionAPI.SRT_STREAM_STATUS.withSuffix("test");

Expand Down Expand Up @@ -107,8 +108,8 @@ public void testStreamingStatus() throws InterruptedException

Thread messagePublishThread = ThreadTools.startAsDaemon(() ->
{
// Publish messages for 1 second
for (float i = 0.0f; i < messagePublishFrequency; i++)
// Publish messages for 3 second
while (!interrupted())
{
ROS2_HELPER.publish(TEST_TOPIC, statusMessage);
}
Expand All @@ -117,11 +118,12 @@ public void testStreamingStatus() throws InterruptedException
ROS2_HELPER.publish(TEST_TOPIC, statusMessage);
}, getClass().getSimpleName() + "Thread");

streamStatusMonitor.waitForStream(1.0);
streamStatusMonitor.waitForStream(1.5);
assertTrue(streamStatusMonitor.isStreaming());

messagePublishThread.interrupt();
messagePublishThread.join();
MissingThreadTools.sleep(0.01);
MissingThreadTools.sleep(0.5);
assertFalse(streamStatusMonitor.isStreaming());
}
}
Loading