Skip to content

Commit 7fbb8d8

Browse files
authored
Adjust DNS cache expiration in tests to reduce test timeout failures (#4586)
1 parent cdd854f commit 7fbb8d8

File tree

7 files changed

+22
-8
lines changed

7 files changed

+22
-8
lines changed

.github/workflows/bk-ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,13 @@ jobs:
159159
distribution: 'temurin'
160160
java-version: 11
161161

162+
- name: Tune Java DNS TTL settings
163+
run: |
164+
sudo tee -a $JAVA_HOME/conf/security/java.security <<EOF
165+
networkaddress.cache.ttl=1
166+
networkaddress.cache.negative.ttl=1
167+
EOF
168+
162169
- name: Build
163170
run: |
164171
projects_list=
@@ -233,6 +240,13 @@ jobs:
233240
distribution: 'temurin'
234241
java-version: 11
235242

243+
- name: Tune Java DNS TTL settings
244+
run: |
245+
sudo tee -a $JAVA_HOME/conf/security/java.security <<EOF
246+
networkaddress.cache.ttl=1
247+
networkaddress.cache.negative.ttl=1
248+
EOF
249+
236250
- name: Pick ubuntu mirror for the docker image build
237251
run: |
238252
# pick the closest ubuntu mirror and set it to UBUNTU_MIRROR environment variable

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@
10151015
<groupId>org.apache.maven.plugins</groupId>
10161016
<artifactId>maven-surefire-plugin</artifactId>
10171017
<configuration>
1018-
<argLine>-Xmx2G -Djava.net.preferIPv4Stack=true -Dio.netty.leakDetection.level=paranoid ${test.additional.args}</argLine>
1018+
<argLine>-Xmx2G -Dsun.net.inetaddr.ttl=1 -Dsun.net.inetaddr.negative.ttl=1 -Djava.net.preferIPv4Stack=true -Dio.netty.leakDetection.level=paranoid ${test.additional.args}</argLine>
10191019
<redirectTestOutputToFile>${redirectTestOutputToFile}</redirectTestOutputToFile>
10201020
<forkCount>${forkCount.variable}</forkCount>
10211021
<reuseForks>false</reuseForks>
@@ -1311,7 +1311,7 @@
13111311
<groupId>org.apache.maven.plugins</groupId>
13121312
<artifactId>maven-surefire-plugin</artifactId>
13131313
<configuration>
1314-
<argLine>-Xmx2G -Djava.net.preferIPv4Stack=true</argLine>
1314+
<argLine>-Xmx2G -Dsun.net.inetaddr.ttl=1 -Dsun.net.inetaddr.negative.ttl=1 -Djava.net.preferIPv4Stack=true</argLine>
13151315
<redirectTestOutputToFile>false</redirectTestOutputToFile>
13161316
<forkCount>${forkCount.variable}</forkCount>
13171317
<reuseForks>false</reuseForks>
@@ -1331,7 +1331,7 @@
13311331
<groupId>org.apache.maven.plugins</groupId>
13321332
<artifactId>maven-surefire-plugin</artifactId>
13331333
<configuration>
1334-
<argLine>-Xmx2G -Djava.net.preferIPv4Stack=true -Dio.netty.leakDetection.level=paranoid -Dbookkeeper.log.root.level=INFO -Dbookkeeper.log.root.appender=CONSOLE</argLine>
1334+
<argLine>-Xmx2G -Dsun.net.inetaddr.ttl=1 -Dsun.net.inetaddr.negative.ttl=1 -Djava.net.preferIPv4Stack=true -Dio.netty.leakDetection.level=paranoid -Dbookkeeper.log.root.level=INFO -Dbookkeeper.log.root.appender=CONSOLE</argLine>
13351335
<redirectTestOutputToFile>false</redirectTestOutputToFile>
13361336
<forkCount>${forkCount.variable}</forkCount>
13371337
<reuseForks>false</reuseForks>

stream/distributedlog/common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
<artifactId>maven-surefire-plugin</artifactId>
110110
<configuration>
111111
<redirectTestOutputToFile>${redirectTestOutputToFile}</redirectTestOutputToFile>
112-
<argLine>-Xmx3G -Djava.net.preferIPv4Stack=true -XX:MaxDirectMemorySize=2G ${test.additional.args}</argLine>
112+
<argLine>-Xmx3G -Dsun.net.inetaddr.ttl=1 -Dsun.net.inetaddr.negative.ttl=1 -Djava.net.preferIPv4Stack=true -XX:MaxDirectMemorySize=2G ${test.additional.args}</argLine>
113113
<forkCount>1</forkCount>
114114
<reuseForks>false</reuseForks>
115115
<forkedProcessTimeoutInSeconds>1800</forkedProcessTimeoutInSeconds>

stream/distributedlog/core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
<configuration>
111111
<trimStackTrace>false</trimStackTrace>
112112
<redirectTestOutputToFile>${redirectTestOutputToFile}</redirectTestOutputToFile>
113-
<argLine>-Xmx3G -Djava.net.preferIPv4Stack=true -XX:MaxDirectMemorySize=2G ${test.additional.args}</argLine>
113+
<argLine>-Xmx3G -Dsun.net.inetaddr.ttl=1 -Dsun.net.inetaddr.negative.ttl=1 -Djava.net.preferIPv4Stack=true -XX:MaxDirectMemorySize=2G ${test.additional.args}</argLine>
114114
<forkCount>1</forkCount>
115115
<reuseForks>false</reuseForks>
116116
<forkedProcessTimeoutInSeconds>1800</forkedProcessTimeoutInSeconds>

stream/distributedlog/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
<artifactId>maven-surefire-plugin</artifactId>
7676
<configuration>
7777
<redirectTestOutputToFile>${redirectTestOutputToFile}</redirectTestOutputToFile>
78-
<argLine>-Xmx3G -Djava.net.preferIPv4Stack=true -XX:MaxDirectMemorySize=2G -Dio.netty.leakDetection.level=PARANOID ${test.additional.args}</argLine>
78+
<argLine>-Xmx3G -Dsun.net.inetaddr.ttl=1 -Dsun.net.inetaddr.negative.ttl=1 -Djava.net.preferIPv4Stack=true -XX:MaxDirectMemorySize=2G -Dio.netty.leakDetection.level=PARANOID ${test.additional.args}</argLine>
7979
<forkCount>1</forkCount>
8080
<reuseForks>false</reuseForks>
8181
<forkedProcessTimeoutInSeconds>1800</forkedProcessTimeoutInSeconds>

stream/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<!-- only run tests when -DstreamTests is specified //-->
5858
<skipTests>true</skipTests>
5959
<redirectTestOutputToFile>${redirectTestOutputToFile}</redirectTestOutputToFile>
60-
<argLine>-Xmx3G -Djava.net.preferIPv4Stack=true -XX:MaxDirectMemorySize=2G -Dio.netty.leakDetection.level=PARANOID ${test.additional.args}</argLine>
60+
<argLine>-Xmx3G -Dsun.net.inetaddr.ttl=1 -Dsun.net.inetaddr.negative.ttl=1 -Djava.net.preferIPv4Stack=true -XX:MaxDirectMemorySize=2G -Dio.netty.leakDetection.level=PARANOID ${test.additional.args}</argLine>
6161
<forkCount>1</forkCount>
6262
<reuseForks>false</reuseForks>
6363
<forkedProcessTimeoutInSeconds>1800</forkedProcessTimeoutInSeconds>

tests/integration-tests-base-groovy/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
<groupId>org.apache.maven.plugins</groupId>
6868
<artifactId>maven-surefire-plugin</artifactId>
6969
<configuration>
70-
<argLine>-Xmx4G -Djava.net.preferIPv4Stack=true ${test.additional.args}</argLine>
70+
<argLine>-Xmx4G -Dsun.net.inetaddr.ttl=1 -Dsun.net.inetaddr.negative.ttl=1 -Djava.net.preferIPv4Stack=true ${test.additional.args}</argLine>
7171
<forkCount>1</forkCount>
7272
<useSystemClassLoader>false</useSystemClassLoader>
7373
</configuration>

0 commit comments

Comments
 (0)