Skip to content

Commit 4d5bc6d

Browse files
move Low/HighFpsMultiPacket to stress tests, enable integration tests on mac runners
1 parent 3bad48c commit 4d5bc6d

4 files changed

Lines changed: 225 additions & 145 deletions

File tree

‎.github/workflows/tests.yml‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,11 @@ jobs:
6363
- os: macos-26-xlarge
6464
name: macos-arm64
6565
build_cmd: ./build.sh release-tests
66-
# E2E not possible on GHA Mac runner currently
67-
e2e-testing: false
66+
e2e-testing: true
6867
- os: macos-26-large
6968
name: macos-x64
7069
build_cmd: ./build.sh release-tests --macos-arch x86_64
71-
# E2E not possible on GHA Mac runner currently
72-
e2e-testing: false
70+
e2e-testing: true
7371
# Pinned to Windows 2022 for current VS 17 implementation
7472
- os: windows-2022
7573
name: windows-x64

‎client-sdk-rust‎

‎src/tests/integration/test_data_track.cpp‎

Lines changed: 0 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,12 @@
2525
#include <livekit/e2ee.h>
2626
#include <livekit/remote_data_track.h>
2727

28-
#include <cmath>
2928
#include <condition_variable>
3029
#include <exception>
3130
#include <future>
32-
#include <tuple>
3331

3432
#include "../common/test_common.h"
3533
#include "ffi_client.h"
36-
#include "lk_log.h"
3734

3835
namespace livekit::test {
3936

@@ -287,135 +284,9 @@ void runEncryptedDataTrackRoundTrip(KeyDerivationFunction key_derivation_functio
287284

288285
class DataTrackE2ETest : public LiveKitTestBase {};
289286

290-
class DataTrackTransportTest : public DataTrackE2ETest,
291-
public ::testing::WithParamInterface<std::tuple<double, size_t>> {};
292-
293287
class DataTrackKeyDerivationTest : public DataTrackE2ETest,
294288
public ::testing::WithParamInterface<KeyDerivationFunction> {};
295289

296-
TEST_P(DataTrackTransportTest, PublishesAndReceivesFramesEndToEnd) {
297-
const auto publish_fps = std::get<0>(GetParam());
298-
const auto payload_len = std::get<1>(GetParam());
299-
const auto track_name = makeTrackName("transport");
300-
301-
// How long to publish frames for.
302-
constexpr auto PUBLISH_DURATION = 10s;
303-
304-
// Percentage of total frames that must be received on the subscriber end in
305-
// order for the test to pass.
306-
constexpr float MIN_PERCENTAGE = 0.90f;
307-
308-
std::vector<TestRoomConnectionOptions> room_configs(2);
309-
room_configs[0].room_options.single_peer_connection = false;
310-
room_configs[1].room_options.single_peer_connection = false;
311-
312-
DataTrackPublishedDelegate subscriber_delegate;
313-
room_configs[1].delegate = &subscriber_delegate;
314-
315-
auto rooms = testRooms(room_configs);
316-
auto& publisher_room = rooms[0];
317-
const auto publisher_identity = publisher_room->localParticipant()->identity();
318-
319-
auto track = requirePublishedTrack(publisher_room->localParticipant(), track_name);
320-
std::cerr << "Track published\n";
321-
322-
auto remote_track = subscriber_delegate.waitForTrack(kTrackWaitTimeout);
323-
std::cerr << "Got remote track: " << remote_track->info().sid << "\n";
324-
325-
ASSERT_NE(remote_track, nullptr) << "Timed out waiting for remote data track";
326-
EXPECT_TRUE(remote_track->isPublished());
327-
EXPECT_FALSE(remote_track->info().uses_e2ee);
328-
EXPECT_EQ(remote_track->info().name, track_name);
329-
EXPECT_EQ(remote_track->publisherIdentity(), publisher_identity);
330-
331-
const auto frame_count =
332-
static_cast<size_t>(std::llround(std::chrono::duration<double>(PUBLISH_DURATION).count() * publish_fps));
333-
334-
auto publish = [&]() {
335-
if (!track->isPublished()) {
336-
throw std::runtime_error("Publisher failed to publish data track");
337-
}
338-
if (track->info().uses_e2ee) {
339-
throw std::runtime_error("Unexpected E2EE on test data track");
340-
}
341-
if (track->info().name != track_name) {
342-
throw std::runtime_error("Published track name mismatch");
343-
}
344-
345-
const auto frame_interval = std::chrono::duration_cast<std::chrono::steady_clock::duration>(
346-
std::chrono::duration<double>(1.0 / publish_fps));
347-
auto next_send = std::chrono::steady_clock::now();
348-
349-
std::cout << "Publishing " << frame_count << " frames with payload length " << payload_len << '\n';
350-
for (size_t index = 0; index < frame_count; ++index) {
351-
std::vector<std::uint8_t> payload(payload_len, static_cast<std::uint8_t>(index));
352-
requirePushSuccess(track->tryPush(std::move(payload)), "Failed to push data frame");
353-
354-
next_send += frame_interval;
355-
std::this_thread::sleep_until(next_send);
356-
}
357-
358-
track->unpublishDataTrack();
359-
};
360-
361-
auto subscribe_result = remote_track->subscribe();
362-
if (!subscribe_result) {
363-
FAIL() << describeDataTrackError(subscribe_result.error());
364-
}
365-
auto subscription = subscribe_result.value();
366-
367-
std::promise<size_t> receive_count_promise;
368-
auto receive_count_future = receive_count_promise.get_future();
369-
370-
auto subscribe = [&]() {
371-
size_t received_count = 0;
372-
DataTrackFrame frame;
373-
while (subscription->read(frame) && received_count < frame_count) {
374-
if (frame.payload.empty()) {
375-
throw std::runtime_error("Received empty data frame");
376-
}
377-
378-
const auto first_byte = frame.payload.front();
379-
if (!std::all_of(frame.payload.begin(), frame.payload.end(),
380-
[first_byte](std::uint8_t byte) { return byte == first_byte; })) {
381-
throw std::runtime_error("Received frame with inconsistent payload");
382-
}
383-
if (frame.user_timestamp.has_value()) {
384-
throw std::runtime_error("Received unexpected user timestamp in transport test");
385-
}
386-
387-
++received_count;
388-
}
389-
390-
receive_count_promise.set_value(received_count);
391-
};
392-
393-
// Launch both publisher and subscriber
394-
auto pub_fut = std::async(std::launch::async, publish);
395-
auto sub_fut = std::async(std::launch::async, subscribe);
396-
397-
// Wait for both, with a combined deadline (the timeout(...) wrapper).
398-
const auto deadline = std::chrono::steady_clock::now() + PUBLISH_DURATION + 25s;
399-
400-
const bool pub_ok = pub_fut.wait_until(deadline) == std::future_status::ready;
401-
const bool sub_ok = sub_fut.wait_until(deadline) == std::future_status::ready;
402-
403-
if (!pub_ok || !sub_ok) {
404-
ADD_FAILURE() << "Timed out waiting for data frames";
405-
}
406-
407-
// Equivalent of `try_join!`'s ? — re-throws any exception from either task
408-
pub_fut.get();
409-
sub_fut.get();
410-
411-
const auto received_count = receive_count_future.get();
412-
const auto received_percent = static_cast<float>(received_count) / static_cast<float>(frame_count);
413-
std::cout << "Received " << received_count << "/" << frame_count << " frames (" << received_percent * 100.0f << "%)"
414-
<< '\n';
415-
416-
EXPECT_GE(received_percent, MIN_PERCENTAGE) << "Received " << received_count << "/" << frame_count << " frames";
417-
}
418-
419290
TEST_F(DataTrackE2ETest, UnpublishUpdatesPublishedStateEndToEnd) {
420291
const auto track_name = makeTrackName("published_state");
421292

@@ -853,21 +724,10 @@ TEST_F(DataTrackE2ETest, PreservesUserTimestampOnEncryptedDataTrack) {
853724
local_track->unpublishDataTrack();
854725
}
855726

856-
std::string dataTrackParamName(const ::testing::TestParamInfo<std::tuple<double, size_t>>& info) {
857-
if (std::get<0>(info.param) > 100.0) {
858-
return "HighFpsSinglePacket";
859-
}
860-
return "LowFpsMultiPacket";
861-
}
862-
863727
std::string keyDerivationParamName(const ::testing::TestParamInfo<KeyDerivationFunction>& info) {
864728
return keyDerivationFunctionName(info.param);
865729
}
866730

867-
INSTANTIATE_TEST_SUITE_P(DataTrackScenarios, DataTrackTransportTest,
868-
::testing::Values(std::make_tuple(120.0, size_t{8192}), std::make_tuple(10.0, size_t{196608})),
869-
dataTrackParamName);
870-
871731
INSTANTIATE_TEST_SUITE_P(KeyDerivationFunctions, DataTrackKeyDerivationTest,
872732
::testing::Values(KeyDerivationFunction::PBKDF2, KeyDerivationFunction::HKDF),
873733
keyDerivationParamName);

0 commit comments

Comments
 (0)