Skip to content

Commit

Permalink
Add print to debug the deadlock.
Browse files Browse the repository at this point in the history
  • Loading branch information
mamaheux committed Jul 7, 2024
1 parent a483e52 commit fb25373
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cpp-python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ jobs:
working-directory: opentera-webrtc-native-client/OpenteraWebrtcNativeClient/python/test
run: |
if [ -f requirements.txt ]; then python -m pip install --user -r requirements.txt; fi
python -m pytest -v -s
python -m pytest -vv -s
# With stdout
- name: Run Python signaling-server Tests with STDOUT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,36 @@
class StreamClientTestCase(FailureTestCase):
@classmethod
def setUpClass(cls):
print('StreamClientTestCase.setUpClass', 1, flush=True)
super(StreamClientTestCase, cls).setUpClass()
print('StreamClientTestCase.setUpClass', 2, flush=True)
cls._signaling_server_runner = SignalingServerRunner()
print('StreamClientTestCase.setUpClass', 3, flush=True)

@classmethod
def tearDownClass(cls):
print('StreamClientTestCase.tearDownClass', 1, flush=True)
cls._signaling_server_runner.close()
print('StreamClientTestCase.tearDownClass', 2, flush=True)
super(StreamClientTestCase, cls).tearDownClass()
print('StreamClientTestCase.tearDownClass', 3, flush=True)

def test_video_stream__should_be_sent_and_received(self):
# Initialize the clients
setup_awaiter = CallbackAwaiter(2, 15)
print(1)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 1, flush=True)

frame1 = np.zeros((480, 640, 3), dtype=np.uint8)
frame1[:, :, 2] = 255
frame2 = np.zeros((480, 640, 3), dtype=np.uint8)
frame2[:, :, 0] = 255

print(2)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 2, flush=True)
video_source1 = webrtc.VideoSource(webrtc.VideoSourceConfiguration.create(False, True))
video_source2 = webrtc.VideoSource(webrtc.VideoSourceConfiguration.create(False, True))

def on_signaling_connection_opened():
print(3)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 3, flush=True)
setup_awaiter.done()

client1 = webrtc.StreamClient(
Expand All @@ -48,21 +54,21 @@ def on_signaling_connection_opened():
webrtc.WebrtcConfiguration.create(),
webrtc.VideoStreamConfiguration.create(),
video_source2)
print(4)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 4, flush=True)

client1.on_signaling_connection_opened = on_signaling_connection_opened
client2.on_signaling_connection_opened = on_signaling_connection_opened
print(5)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 5, flush=True)

client1.on_error = lambda: self.add_failure('client1.on_error')
client2.on_error = lambda: self.add_failure('client2.on_error')
print(6)
print('test_video_stream__should_be_sent_and_received', 6)

client1.connect()
client2.connect()
print(7)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 7, flush=True)
setup_awaiter.wait()
print(8)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 8, flush=True)

# Setup the callback
on_video_frame_awaiter1 = CallbackAwaiter(1, 15)
Expand All @@ -72,32 +78,32 @@ def on_signaling_connection_opened():
self._on_add_remote_stream_client_name2 = None
self._mean_color_1 = np.array([0, 0, 0], dtype=np.uint8)
self._mean_color_2 = np.array([0, 0, 0], dtype=np.uint8)
print(9)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 9, flush=True)

def on_add_remote_stream1(client):
print(10)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 10, flush=True)
self._on_add_remote_stream_client_name1 = client.name

def on_add_remote_stream2(client):
print(11)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 11, flush=True)
self._on_add_remote_stream_client_name2 = client.name

def on_remove_remote_stream(client):
print(12)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 12, flush=True)
self.add_failure('on_remove_remote_stream')

def on_video_frame_received1(client, frame, timestamp):
print(13)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 13, flush=True)
self._mean_color_1 = np.mean(frame, axis=(0, 1))
on_video_frame_awaiter1.done()

def on_video_frame_received2(client, frame, timestamp):
print(14)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 14, flush=True)
self._mean_color_2 = np.mean(frame, axis=(0, 1))
on_video_frame_awaiter2.done()

def on_audio_frame_received(client, data, sample_rate, number_of_channels, number_of_frames):
print(15)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 15, flush=True)
self.add_failure('on_audio_frame_received')

client1.on_add_remote_stream = on_add_remote_stream1
Expand All @@ -113,29 +119,29 @@ def on_audio_frame_received(client, data, sample_rate, number_of_channels, numbe
client2.on_audio_frame_received = on_audio_frame_received
client1.on_mixed_audio_frame_received = on_audio_frame_received
client2.on_mixed_audio_frame_received = on_audio_frame_received
print(16)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 16, flush=True)

# Setup the call
client1.call_all()
print(17)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 17, flush=True)

start_time = time.time()
while not on_video_frame_awaiter1.is_finished() or not on_video_frame_awaiter2.is_finished():
print(18)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 18, flush=True)
timestamp_us = int((time.time() - start_time) * 1e6)
video_source1.send_frame(frame1, timestamp_us)
video_source2.send_frame(frame2, timestamp_us)
time.sleep(0.005)

client1.close_all_room_peer_connections()
print(19)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 19, flush=True)
time.sleep(1)
print(20)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 20, flush=True)

client1.close_sync()
print(21)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 21, flush=True)
client2.close_sync()
print(22)
print('StreamClientTestCase.test_video_stream__should_be_sent_and_received', 22, flush=True)

# Asserts
self.assertEqual(self._on_add_remote_stream_client_name1, 'c2')
Expand Down

0 comments on commit fb25373

Please sign in to comment.