Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 10 additions & 5 deletions android/app/src/test/java/com/openipc/decoder/JieliTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,9 @@ public void noVideoListensElsewhereAndAsksAgain() throws Exception {
Jieli.noVideoMs = 300;
Jieli.reopenMs = 700;
Jieli.diagnosticPorts = new int[] {diag};
Jieli.diagnosticMs = 500;
// The port lives this long (then up to a receive timeout more): long enough for the
// packet below to arrive on a loaded CI runner, where a pause of a second failed it (#257)
Jieli.diagnosticMs = 3000;
Comment thread
compot-dev marked this conversation as resolved.
Resolved
try (FakeToy toy = new FakeToy(60000, true)) {
toy.rtpPort = rtp;
toy.sendVideo = false;
Expand All @@ -813,21 +815,24 @@ public void noVideoListensElsewhereAndAsksAgain() throws Exception {
byte[] p = {(byte) 0x80, 97, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 9};
u.send(new DatagramPacket(p, p.length, new InetSocketAddress(LOOPBACK, diag)));
}
until = now() + 3000;
// Generous on a loaded runner; the asserts read the snapshot the loop stopped on
// (Qodo on #259)
until = now() + 8000;
Map<String, Object> st = r.client.stats();
while (now() < until && (Collections.frequency(toy.topics(), Jieli.OPEN_RT_STREAM) < 2
|| r.client.stats().get("diagnostic_ports") == null)) {
|| st.get("diagnostic_ports") == null)) {
Thread.sleep(20);
st = r.client.stats();
}
assertTrue(Collections.frequency(toy.topics(), Jieli.OPEN_RT_STREAM) >= 2);
Map<String, Object> st = r.client.stats();
@SuppressWarnings("unchecked")
Map<String, Object> d = (Map<String, Object>) st.get("diagnostic_ports");
assertNotNull(d);
@SuppressWarnings("unchecked")
Map<String, Object> one = (Map<String, Object>) d.get(String.valueOf(diag));
assertEquals(1, one.get("packets"));
// The diagnostic port is freed after diagnosticMs while the session goes on
until = now() + 3000;
until = now() + 6000;
boolean freed = false;
while (now() < until && !freed) {
try (DatagramSocket again = new DatagramSocket(diag, LOOPBACK)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -101,9 +102,11 @@ public void badUrlsAreRefused() {
// ====================== Session ======================

private static final class Recorder implements RtspSession.Callback {
final List<String> statuses = Collections.synchronizedList(new ArrayList<>());
final List<Sdp> sdps = Collections.synchronizedList(new ArrayList<>());
final List<Integer> pts = Collections.synchronizedList(new ArrayList<>());
// Filled by the session thread while the test reads them: Collections.frequency() and
// for-each iterate, which a synchronizedList does not guard (#257)
final List<String> statuses = new CopyOnWriteArrayList<>();
final List<Sdp> sdps = new CopyOnWriteArrayList<>();
final List<Integer> pts = new CopyOnWriteArrayList<>();
volatile CountDownLatch latch = new CountDownLatch(3);

@Override public void onStatus(String status) { statuses.add(status); }
Expand Down
Loading