|
@@ -129,6 +129,19 @@ class VideoStopReceiptRestartTest {
|
|
|
assertEquals(2, world.closeRequests.size());
|
|
assertEquals(2, world.closeRequests.size());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Test void terminalReceiptGetsABoundedRetentionWhileUnresolvedOnesDoNot() throws Exception {
|
|
|
|
|
+ External world = new External(); Instance instance = new Instance(world);
|
|
|
|
|
+ SSRCInfo allocation = instance.open(STREAM);
|
|
|
|
|
+ assertNotNull(allocation);
|
|
|
|
|
+ int before = world.redis.expirations.size();
|
|
|
|
|
+ assertTrue(instance.rtp.closeManagedRTPServer(world.node, allocation));
|
|
|
|
|
+ // A confirmed stop keeps a bounded retention window instead of living forever.
|
|
|
|
|
+ assertEquals(before + 1, world.redis.expirations.size(),
|
|
|
|
|
+ "a confirmed stop still needs a bounded retention window");
|
|
|
|
|
+ assertEquals(java.time.Duration.ofDays(7), world.redis.expirations.values().stream().reduce((a, b) -> b).orElse(null),
|
|
|
|
|
+ "a confirmed stop still needs a bounded retention window");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Test void definitiveInviteRefusalLetsARealRtpCloseConvergeWithoutADialog() throws Exception {
|
|
@Test void definitiveInviteRefusalLetsARealRtpCloseConvergeWithoutADialog() throws Exception {
|
|
|
External world = new External(); Instance instance = new Instance(world);
|
|
External world = new External(); Instance instance = new Instance(world);
|
|
|
SSRCInfo allocation = instance.play.playManaged(world.node, "device", "channel", STREAM, (c, m, r) -> { });
|
|
SSRCInfo allocation = instance.play.playManaged(world.node, "device", "channel", STREAM, (c, m, r) -> { });
|
|
@@ -402,6 +415,7 @@ class VideoStopReceiptRestartTest {
|
|
|
final StringRedisSerializer strings = new StringRedisSerializer();
|
|
final StringRedisSerializer strings = new StringRedisSerializer();
|
|
|
final AtomicInteger ssrc = new AtomicInteger(1), sequence = new AtomicInteger();
|
|
final AtomicInteger ssrc = new AtomicInteger(1), sequence = new AtomicInteger();
|
|
|
Predicate<String> failWrite = value -> false;
|
|
Predicate<String> failWrite = value -> false;
|
|
|
|
|
+ final Map<String, java.time.Duration> expirations = new HashMap<>();
|
|
|
Runnable beforeExec;
|
|
Runnable beforeExec;
|
|
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
|
|
RedisTemplate<Object,Object> client() {
|
|
RedisTemplate<Object,Object> client() {
|
|
@@ -418,6 +432,16 @@ class VideoStopReceiptRestartTest {
|
|
|
doAnswer(i -> { watched.clear(); return null; }).when(redis).unwatch();
|
|
doAnswer(i -> { watched.clear(); return null; }).when(redis).unwatch();
|
|
|
when(vals.get(any())).thenAnswer(i -> serializer.deserialize(values.get(i.getArgument(0).toString())));
|
|
when(vals.get(any())).thenAnswer(i -> serializer.deserialize(values.get(i.getArgument(0).toString())));
|
|
|
when(vals.increment(any(), anyLong())).thenAnswer(i -> (long) sequence.incrementAndGet());
|
|
when(vals.increment(any(), anyLong())).thenAnswer(i -> (long) sequence.incrementAndGet());
|
|
|
|
|
+ doAnswer(i -> {
|
|
|
|
|
+ String key = i.getArgument(0).toString(); Object value = i.getArgument(1); byte[] encoded = serializer.serialize(value);
|
|
|
|
|
+ java.time.Duration ttl = i.getArguments().length > 2 ? i.getArgument(2) : null;
|
|
|
|
|
+ Runnable write = () -> {
|
|
|
|
|
+ if (failWrite.test(value.toString())) throw new IllegalStateException("Redis write unavailable");
|
|
|
|
|
+ values.put(key, encoded); versions.merge(key, 1L, Long::sum);
|
|
|
|
|
+ if (ttl != null) expirations.put(key, ttl);
|
|
|
|
|
+ };
|
|
|
|
|
+ if (multi[0]) queued.add(write); else write.run(); return null;
|
|
|
|
|
+ }).when(vals).set(any(), any(), any(java.time.Duration.class));
|
|
|
doAnswer(i -> {
|
|
doAnswer(i -> {
|
|
|
String key = i.getArgument(0).toString(); Object value = i.getArgument(1); byte[] encoded = serializer.serialize(value);
|
|
String key = i.getArgument(0).toString(); Object value = i.getArgument(1); byte[] encoded = serializer.serialize(value);
|
|
|
Runnable write = () -> {
|
|
Runnable write = () -> {
|