Use metaconfig, port some properties. (#212)
* Use metaconfig, port some properties. * ref: Use the typesource config to read system properties. * fix: Fix a typo. * Add tests for AgentConfig.
This commit is contained in:
parent
686164ffc4
commit
f8a506ef70
103
pom.xml
103
pom.xml
@ -17,6 +17,9 @@
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<jicoco.version>1.1-53-gdc63c67</jicoco.version>
|
||||
<kotlin.version>1.3.72</kotlin.version>
|
||||
<kotest.version>4.1.3</kotest.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@ -33,7 +36,12 @@
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>jitsi-utils</artifactId>
|
||||
<version>1.0-12-gcdf6537</version>
|
||||
<version>1.0-59-g5dc2b5f</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>jicoco-config</artifactId>
|
||||
<version>${jicoco.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- test -->
|
||||
@ -43,14 +51,103 @@
|
||||
<version>4.11</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.kotest</groupId>
|
||||
<artifactId>kotest-runner-junit5-jvm</artifactId>
|
||||
<version>${kotest.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.kotest</groupId>
|
||||
<artifactId>kotest-assertions-core-jvm</artifactId>
|
||||
<version>${kotest.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.kotest</groupId>
|
||||
<artifactId>kotest-runner-console-jvm</artifactId>
|
||||
<version>${kotest.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jitsi</groupId>
|
||||
<artifactId>jicoco-test-kotlin</artifactId>
|
||||
<version>${jicoco.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirs>
|
||||
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
|
||||
<sourceDir>${project.basedir}/src/main/java</sourceDir>
|
||||
</sourceDirs>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirs>
|
||||
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
|
||||
<sourceDir>${project.basedir}/src/test/java</sourceDir>
|
||||
</sourceDirs>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<jvmTarget>1.8</jvmTarget>
|
||||
<args>
|
||||
<arg>-Xallow-result-return-type</arg>
|
||||
</args>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<executions>
|
||||
<!-- Replacing default-compile as it is treated specially by maven -->
|
||||
<execution>
|
||||
<id>default-compile</id>
|
||||
<phase>none</phase>
|
||||
</execution>
|
||||
<!-- Replacing default-testCompile as it is treated specially by maven -->
|
||||
<execution>
|
||||
<id>default-testCompile</id>
|
||||
<phase>none</phase>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>java-compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>java-test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
@ -264,5 +361,9 @@
|
||||
</snapshots>
|
||||
<url>https://github.com/jitsi/jitsi-maven-repository/raw/master/releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
|
||||
@ -59,43 +59,6 @@ public class StackProperties
|
||||
*/
|
||||
public static final String BIND_WILDCARD = "org.ice4j.BIND_WILDCARD";
|
||||
|
||||
/**
|
||||
* How often a STUN Binding request used for consent freshness check will be
|
||||
* sent(value in milliseconds).
|
||||
*/
|
||||
public static final String CONSENT_FRESHNESS_INTERVAL
|
||||
= "org.ice4j.ice.CONSENT_FRESHNESS_INTERVAL";
|
||||
|
||||
/**
|
||||
* The maximum number of retransmissions of a STUN Binding request without
|
||||
* a valid STUN Binding response after which consent freshness is to be
|
||||
* considered unconfirmed according to "STUN Usage for Consent
|
||||
* Freshness".
|
||||
*/
|
||||
public static final String CONSENT_FRESHNESS_MAX_RETRANSMISSIONS
|
||||
= "org.ice4j.ice.CONSENT_FRESHNESS_MAX_RETRANSMISSIONS";
|
||||
|
||||
/**
|
||||
* The number of milliseconds without a valid STUN Binding response after
|
||||
* which a STUN Binding request is to be retransmitted according to
|
||||
* "STUN Usage for Consent Freshness". This is the final value
|
||||
* for the back-off strategy.
|
||||
* {@link #CONSENT_FRESHNESS_ORIGINAL_WAIT_INTERVAL} defines the initial
|
||||
* interval for the first request sent. Value in milliseconds.
|
||||
*/
|
||||
public static final String CONSENT_FRESHNESS_MAX_WAIT_INTERVAL
|
||||
= "org.ice4j.ice.CONSENT_FRESHNESS_MAX_WAIT_INTERVAL";
|
||||
|
||||
/**
|
||||
* The number of milliseconds without a valid STUN Binding response after
|
||||
* which a STUN Binding request is to be retransmitted according to
|
||||
* "STUN Usage for Consent Freshness". This is the original value
|
||||
* for back-off strategy. {@link #CONSENT_FRESHNESS_MAX_WAIT_INTERVAL} sets
|
||||
* the upper limit. Value in milliseconds.
|
||||
*/
|
||||
public static final String CONSENT_FRESHNESS_ORIGINAL_WAIT_INTERVAL
|
||||
= "org.ice4j.ice.CONSENT_FRESHNESS_WAIT_INTERVAL";
|
||||
|
||||
/**
|
||||
* The number of milliseconds a client transaction should wait before
|
||||
* retransmitting, after it has sent a request for the first time.
|
||||
@ -123,13 +86,6 @@ public class StackProperties
|
||||
public static final String MAX_CTRAN_RETRANSMISSIONS
|
||||
= "org.ice4j.MAX_RETRANSMISSIONS";
|
||||
|
||||
/**
|
||||
* The name of the System property that allows us to set a custom maximum
|
||||
* for check list sizes.
|
||||
*/
|
||||
public static final String MAX_CHECK_LIST_SIZE
|
||||
= "org.ice4j.MAX_CHECK_LIST_SIZE";
|
||||
|
||||
/**
|
||||
* The value of the SOFTWARE attribute that ice4j should include in all
|
||||
* outgoing messages.
|
||||
@ -164,14 +120,6 @@ public class StackProperties
|
||||
public static final String REQUIRE_MESSAGE_INTEGRITY
|
||||
= "org.ice4j.REQUIRE_MESSAGE_INTEGRITY";
|
||||
|
||||
/**
|
||||
* The name of the property that can be used to specify the number of
|
||||
* milliseconds that we must wait after ICE processing enters a COMPLTED
|
||||
* state and before we free candidates and move into the TERMINATED state.
|
||||
*/
|
||||
public static final String TERMINATION_DELAY
|
||||
= "org.ice4j.TERMINATION_DELAY";
|
||||
|
||||
/**
|
||||
* The name of the property that can be used to disable STUN keep alives.
|
||||
* Set to <tt>true</tt> to disable.
|
||||
|
||||
@ -36,6 +36,8 @@ import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.logging.*;
|
||||
|
||||
import static org.ice4j.ice.AgentConfig.config;
|
||||
|
||||
/**
|
||||
* An <tt>Agent</tt> could be described as the main class (i.e. the chef
|
||||
* d'orchestre) of an ICE implementation.
|
||||
@ -59,42 +61,6 @@ import java.util.logging.*;
|
||||
*/
|
||||
public class Agent
|
||||
{
|
||||
/**
|
||||
* Default value for {@link StackProperties#CONSENT_FRESHNESS_INTERVAL}.
|
||||
*/
|
||||
private static final int DEFAULT_CONSENT_FRESHNESS_INTERVAL = 15000;
|
||||
|
||||
/**
|
||||
* Default value for
|
||||
* {@link StackProperties#CONSENT_FRESHNESS_MAX_RETRANSMISSIONS}.
|
||||
*/
|
||||
private static final int DEFAULT_CONSENT_FRESHNESS_MAX_RETRANSMISSIONS = 30;
|
||||
|
||||
/**
|
||||
* Default value for
|
||||
* {@link StackProperties#CONSENT_FRESHNESS_MAX_WAIT_INTERVAL}.
|
||||
*/
|
||||
private static final int DEFAULT_CONSENT_FRESHNESS_MAX_WAIT_INTERVAL = 500;
|
||||
|
||||
/**
|
||||
* Default value for
|
||||
* {@link StackProperties#CONSENT_FRESHNESS_ORIGINAL_WAIT_INTERVAL}.
|
||||
*/
|
||||
private static final int DEFAULT_CONSENT_FRESHNESS_ORIGINAL_WAIT_INTERVAL
|
||||
= 500;
|
||||
|
||||
/**
|
||||
* The default maximum size for check lists.
|
||||
*/
|
||||
public static final int DEFAULT_MAX_CHECK_LIST_SIZE = 100;
|
||||
|
||||
/**
|
||||
* The default number of milliseconds we should wait before moving from
|
||||
* {@link IceProcessingState#COMPLETED} into {@link
|
||||
* IceProcessingState#TERMINATED}.
|
||||
*/
|
||||
public static final int DEFAULT_TERMINATION_DELAY = 3000;
|
||||
|
||||
/**
|
||||
* The constant which defines an empty array with element type
|
||||
* <tt>PropertyChangeListener</tt> and represents the fact that there are no
|
||||
@ -976,32 +942,25 @@ public class Agent
|
||||
*/
|
||||
protected void initCheckLists()
|
||||
{
|
||||
//first init the check list.
|
||||
List<IceMediaStream> streams
|
||||
= getStreamsWithPendingConnectivityEstablishment();
|
||||
// First init the check list.
|
||||
List<IceMediaStream> streams = getStreamsWithPendingConnectivityEstablishment();
|
||||
int streamCount = streams.size();
|
||||
|
||||
//init the maximum number of check list entries per stream.
|
||||
int maxCheckListSize = Integer.getInteger(
|
||||
StackProperties.MAX_CHECK_LIST_SIZE,
|
||||
DEFAULT_MAX_CHECK_LIST_SIZE);
|
||||
|
||||
int maxPerStreamSize =
|
||||
streamCount == 0
|
||||
? 0
|
||||
: maxCheckListSize / streamCount;
|
||||
if (streamCount > 0)
|
||||
{
|
||||
int maxCheckListSizePerStream = config.getMaxCheckListSize() / streamCount;
|
||||
|
||||
for (IceMediaStream stream : streams)
|
||||
{
|
||||
logger.info("Init checklist for stream " + stream.getName());
|
||||
stream.setMaxCheckListSize(maxPerStreamSize);
|
||||
stream.setMaxCheckListSize(maxCheckListSizePerStream);
|
||||
stream.initCheckList();
|
||||
}
|
||||
|
||||
//init the states of the first media stream as per 5245
|
||||
if (streamCount > 0)
|
||||
// Init the states of the first media stream as per 5245
|
||||
streams.get(0).getCheckList().computeInitialCheckListPairStates();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes and sets the foundations foundation for all <tt>Candidate</tt>s
|
||||
@ -2190,10 +2149,7 @@ public class Agent
|
||||
{
|
||||
if (terminationFuture == null)
|
||||
{
|
||||
long terminationDelay
|
||||
= Integer.getInteger(
|
||||
StackProperties.TERMINATION_DELAY,
|
||||
DEFAULT_TERMINATION_DELAY);
|
||||
long terminationDelay = config.getTerminationDelay().toMillis();
|
||||
|
||||
if (terminationDelay > 0)
|
||||
{
|
||||
@ -2690,21 +2646,14 @@ public class Agent
|
||||
*/
|
||||
private final class StunKeepAliveRunner extends PeriodicRunnable
|
||||
{
|
||||
private final long consentFreshnessInterval = Long.getLong(
|
||||
StackProperties.CONSENT_FRESHNESS_INTERVAL,
|
||||
DEFAULT_CONSENT_FRESHNESS_INTERVAL);
|
||||
private final long consentFreshnessInterval = config.getConsentFreshnessInterval().toMillis();
|
||||
private final int originalConsentFreshnessWaitInterval
|
||||
= (int) config.getConsentFreshnessOriginalWaitInterval().toMillis();
|
||||
|
||||
private final int originalConsentFreshnessWaitInterval = Integer.getInteger(
|
||||
StackProperties.CONSENT_FRESHNESS_ORIGINAL_WAIT_INTERVAL,
|
||||
DEFAULT_CONSENT_FRESHNESS_ORIGINAL_WAIT_INTERVAL);
|
||||
private final int maxConsentFreshnessWaitInterval
|
||||
= (int) config.getConsentFreshnessMaxWaitInterval().toMillis();
|
||||
|
||||
private final int maxConsentFreshnessWaitInterval = Integer.getInteger(
|
||||
StackProperties.CONSENT_FRESHNESS_MAX_WAIT_INTERVAL,
|
||||
DEFAULT_CONSENT_FRESHNESS_MAX_WAIT_INTERVAL);
|
||||
|
||||
private final int consentFreshnessMaxRetransmissions = Integer.getInteger(
|
||||
StackProperties.CONSENT_FRESHNESS_MAX_RETRANSMISSIONS,
|
||||
DEFAULT_CONSENT_FRESHNESS_MAX_RETRANSMISSIONS);
|
||||
private final int consentFreshnessMaxRetransmissions = config.getMaxConsentFreshnessRetransmissions();
|
||||
|
||||
private int keepAliveSent = 0;
|
||||
|
||||
|
||||
@ -24,6 +24,8 @@ import org.ice4j.*;
|
||||
import org.jitsi.utils.collections.*;
|
||||
import org.jitsi.utils.logging2.*;
|
||||
|
||||
import static org.ice4j.ice.AgentConfig.config;
|
||||
|
||||
/**
|
||||
* The class represents a media stream from the ICE perspective, i.e. a
|
||||
* collection of components.
|
||||
@ -127,7 +129,7 @@ public class IceMediaStream
|
||||
* across all check lists to a specific value, adn this value MUST be
|
||||
* configurable. A default of 100 is RECOMMENDED.
|
||||
*/
|
||||
private int maxCheckListSize = Agent.DEFAULT_MAX_CHECK_LIST_SIZE;
|
||||
private int maxCheckListSize = config.getMaxCheckListSize();
|
||||
|
||||
/**
|
||||
* The user fragment that we received from the remote party.
|
||||
|
||||
63
src/main/kotlin/org/ice4j/ice/AgentConfig.kt
Normal file
63
src/main/kotlin/org/ice4j/ice/AgentConfig.kt
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright @ 2020 - Present, 8x8 Inc
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.ice4j.ice
|
||||
|
||||
import org.jitsi.metaconfig.config
|
||||
import java.time.Duration
|
||||
|
||||
import org.jitsi.config.JitsiConfig.Companion.newConfig as configSource
|
||||
|
||||
class AgentConfig {
|
||||
val consentFreshnessInterval: Duration by config {
|
||||
"org.ice4j.ice.CONSENT_FRESHNESS_INTERVAL".from(configSource)
|
||||
.convertFrom<Long> { Duration.ofMillis(it) }
|
||||
"ice4j.consent-freshness.interval".from(configSource)
|
||||
}
|
||||
|
||||
val consentFreshnessOriginalWaitInterval: Duration by config {
|
||||
"org.ice4j.ice.CONSENT_FRESHNESS_WAIT_INTERVAL".from(configSource)
|
||||
.convertFrom<Long> { Duration.ofMillis(it) }
|
||||
"ice4j.consent-freshness.original-wait-interval".from(configSource)
|
||||
}
|
||||
|
||||
val consentFreshnessMaxWaitInterval: Duration by config {
|
||||
"org.ice4j.ice.CONSENT_FRESHNESS_MAX_WAIT_INTERVAL".from(configSource)
|
||||
.convertFrom<Long> { Duration.ofMillis(it) }
|
||||
"ice4j.consent-freshness.max-wait-interval".from(configSource)
|
||||
}
|
||||
|
||||
val maxConsentFreshnessRetransmissions: Int by config {
|
||||
"org.ice4j.ice.CONSENT_FRESHNESS_MAX_RETRANSMISSIONS".from(configSource)
|
||||
"ice4j.consent-freshness.max-retransmissions".from(configSource)
|
||||
}
|
||||
|
||||
val terminationDelay: Duration by config {
|
||||
"org.ice4j.TERMINATION_DELAY".from(configSource)
|
||||
.convertFrom<Long> { Duration.ofMillis(it) }
|
||||
"ice4j.ice.termination-delay".from(configSource)
|
||||
}
|
||||
|
||||
val maxCheckListSize: Int by config {
|
||||
"org.ice4j.MAX_CHECK_LIST_SIZE".from(configSource)
|
||||
"ice4j.ice.max-check-list-size".from(configSource)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val config = AgentConfig()
|
||||
}
|
||||
}
|
||||
25
src/main/resources/reference.conf
Normal file
25
src/main/resources/reference.conf
Normal file
@ -0,0 +1,25 @@
|
||||
ice4j {
|
||||
ice {
|
||||
max-check-list-size = 100
|
||||
# The amount of time that we must wait after ICE processing enters a COMPLETED state before we free candidates
|
||||
# and move into the TERMINATED state.
|
||||
termination-delay = 3 seconds
|
||||
}
|
||||
|
||||
consent-freshness {
|
||||
# How often a STUN Binding request used for consent freshness check will be sent.
|
||||
interval = 15 seconds
|
||||
# The amount of time without a valid STUN Binding response after which a STUN Binding request is to be
|
||||
# retransmitted according to `STUN Usage for Consent Freshness` (RFC7675).
|
||||
# This is the original value for back-off strategy, while `max-wait-interval` sets the upper limit.
|
||||
original-wait-interval = 500 milliseconds
|
||||
# The amount of time without a valid STUN Binding response after which a STUN Binding request is to be
|
||||
# retransmitted according to `STUN Usage for Consent Freshness` (RFC7675).
|
||||
# This is the final value for the back-off strategy, while `original-wait-interval` defines the initial interval for
|
||||
# the first request sent.
|
||||
max-wait-interval = 500 milliseconds
|
||||
# The maximum number of retransmissions of a STUN Binding request without a valid STUN Binding response after which
|
||||
# consent freshness is to be considered unconfirmed according to `STUN Usage for Consent Freshness` (RFC7675).
|
||||
max-retransmissions = 30
|
||||
}
|
||||
}
|
||||
42
src/test/kotlin/org/ice4j/ConfigTest.kt
Normal file
42
src/test/kotlin/org/ice4j/ConfigTest.kt
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright @ 2020 - present 8x8, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.ice4j
|
||||
|
||||
import io.kotest.core.spec.IsolationMode
|
||||
import io.kotest.core.spec.Spec
|
||||
import io.kotest.core.spec.style.ShouldSpec
|
||||
import io.kotest.extensions.system.withSystemProperties
|
||||
import org.jitsi.config.useNewConfig
|
||||
import org.jitsi.metaconfig.MetaconfigSettings
|
||||
|
||||
/**
|
||||
* A helper class for testing configuration properties
|
||||
*/
|
||||
abstract class ConfigTest : ShouldSpec() {
|
||||
override fun isolationMode(): IsolationMode? = IsolationMode.InstancePerLeaf
|
||||
|
||||
override fun beforeSpec(spec: Spec) {
|
||||
super.beforeSpec(spec)
|
||||
MetaconfigSettings.cacheEnabled = false
|
||||
}
|
||||
|
||||
inline fun withNewConfig(config: String, block: () -> Unit) {
|
||||
useNewConfig("new-${this::class.simpleName}", config, true, block)
|
||||
}
|
||||
|
||||
fun withLegacyConfig(config: Map<String,String?>, block: () -> Unit) = withSystemProperties(config) { block }
|
||||
}
|
||||
86
src/test/kotlin/org/ice4j/ice/AgentConfigTest.kt
Normal file
86
src/test/kotlin/org/ice4j/ice/AgentConfigTest.kt
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright @ 2020 - present 8x8, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.ice4j.ice
|
||||
|
||||
import io.kotest.matchers.shouldBe
|
||||
import org.ice4j.ConfigTest
|
||||
import org.ice4j.ice.AgentConfig.Companion.config
|
||||
import org.jitsi.utils.ms
|
||||
import org.jitsi.utils.secs
|
||||
|
||||
class AgentConfigTest : ConfigTest() {
|
||||
init {
|
||||
context("Default values") {
|
||||
config.consentFreshnessInterval shouldBe 15.secs
|
||||
config.consentFreshnessMaxWaitInterval shouldBe 500.ms
|
||||
config.consentFreshnessOriginalWaitInterval shouldBe 500.ms
|
||||
config.maxConsentFreshnessRetransmissions shouldBe 30
|
||||
config.maxCheckListSize shouldBe 100
|
||||
config.terminationDelay shouldBe 3.secs
|
||||
}
|
||||
context("Setting via legacy config (system properties)") {
|
||||
withLegacyConfig(legacyConfig) {
|
||||
config.consentFreshnessInterval shouldBe 5.secs
|
||||
config.consentFreshnessMaxWaitInterval shouldBe 5.secs
|
||||
config.consentFreshnessOriginalWaitInterval shouldBe 5.secs
|
||||
config.maxConsentFreshnessRetransmissions shouldBe 5000
|
||||
config.terminationDelay shouldBe 5.secs
|
||||
config.maxCheckListSize shouldBe 5000
|
||||
}
|
||||
}
|
||||
context("Setting via new config") {
|
||||
withNewConfig(newConfig) {
|
||||
config.consentFreshnessInterval shouldBe 6.secs
|
||||
config.consentFreshnessMaxWaitInterval shouldBe 6.secs
|
||||
config.consentFreshnessOriginalWaitInterval shouldBe 6.secs
|
||||
config.maxConsentFreshnessRetransmissions shouldBe 6000
|
||||
config.terminationDelay shouldBe 6.secs
|
||||
config.maxCheckListSize shouldBe 6000
|
||||
}
|
||||
}
|
||||
context("Legacy config must take precedence") {
|
||||
withLegacyConfig(legacyConfig) {
|
||||
withNewConfig(newConfig) {
|
||||
config.consentFreshnessInterval shouldBe 5.secs
|
||||
config.consentFreshnessMaxWaitInterval shouldBe 5.secs
|
||||
config.consentFreshnessOriginalWaitInterval shouldBe 5.secs
|
||||
config.maxConsentFreshnessRetransmissions shouldBe 5000
|
||||
config.terminationDelay shouldBe 5.secs
|
||||
config.maxCheckListSize shouldBe 5000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val legacyConfig = mapOf(
|
||||
"org.ice4j.ice.CONSENT_FRESHNESS_INTERVAL" to "5000",
|
||||
"org.ice4j.ice.CONSENT_FRESHNESS_MAX_WAIT_INTERVAL" to "5000",
|
||||
"org.ice4j.ice.CONSENT_FRESHNESS_WAIT_INTERVAL" to "5000",
|
||||
"org.ice4j.ice.CONSENT_FRESHNESS_MAX_RETRANSMISSIONS" to "5000",
|
||||
"org.ice4j.TERMINATION_DELAY" to "5000",
|
||||
"org.ice4j.MAX_CHECK_LIST_SIZE" to "5000")
|
||||
|
||||
private val newConfig = """
|
||||
ice4j.consent-freshness.interval = 6 seconds
|
||||
ice4j.consent-freshness.original-wait-interval = 6 seconds
|
||||
ice4j.consent-freshness.max-wait-interval = 6 seconds
|
||||
ice4j.consent-freshness.max-retransmissions = 6000
|
||||
ice4j.ice.max-check-list-size = 6000
|
||||
ice4j.ice.termination-delay = 6 seconds
|
||||
|
||||
""".trimIndent()
|
||||
Loading…
x
Reference in New Issue
Block a user