Skip to content
Draft
24 changes: 22 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,30 @@ jobs:
repositories: '[{ "id": "jboss", "name": "JBoss", "url": "https://repository.jboss.org/nexus/content/groups/public" }]'
- name: Print Version
run: mvn -v
- name: Install coreutils
if: matrix.os == 'macos-latest'
run: |
brew install coreutils
alias timeout=gtimeout
- name: Run Tests
if: matrix.os == 'windows-latest'
run: |
.\scripts\run_command_with_timeout.bat 2 "mvn -U -B -fae test -Pproxy -DfailIfNoTests=false -pl ${{ matrix.module }}"
- name: Run Tests
run: mvn -U -B -fae test -Pproxy '-DfailIfNoTests=false' -pl ${{ matrix.module }}
if: matrix.os != 'windows-latest'
run: |
timeout --foreground 180s sh -c 'mvn -U -B -fae test -Pproxy '-DfailIfNoTests=false' -pl ${{ matrix.module }};exit' || echo "Hanging test found, we will proceed with a thread dump"
timeout_occurred=$?
hanging_test_pid=$(jps | awk '$2 ~ /surefirebooter/ {print $1}')
[ ! -z "$hanging_test_pid" ] && echo "Hanging test found. Pid is $hanging_test_pid" && jstack -l $(jps | awk '$2 ~ /surefirebooter/ {print $1}') | tee thread-dump.txt && exit 1 || echo "No hanging test found, tests ran successfully" && exit $timeout_occurred
- uses: actions/upload-artifact@v4
if: failure()
with:
name: surefire-reports-${{ matrix.jdk }}-${{ matrix.module }}-${{ matrix.os }}
path: |
**/surefire*-reports/*.txt
**/*.dump*
thread-dump.txt
test-matrix-ipv6:
name: JDK ${{ matrix.jdk }} - ipv6 - ${{ matrix.module }} ${{ matrix.proxy }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -156,11 +171,16 @@ jobs:
- name: Print Version
run: mvn -v
- name: Run Tests
run: mvn -U -B -fae test ${{ matrix.proxy }} '-DfailIfNoTests=false' -pl ${{ matrix.module }} -Dtest.ipv6=true
run: |
timeout --foreground 180s sh -c 'mvn -U -B -fae test ${{ matrix.proxy }} '-DfailIfNoTests=false' -pl ${{ matrix.module }} -Dtest.ipv6=true;exit' || echo "Hanging test found, we will proceed with a thread dump"
timeout_occurred=$?
hanging_test_pid=$(jps | awk '$2 ~ /surefirebooter/ {print $1}')
[ ! -z "$hanging_test_pid" ] && echo "Hanging test found. Pid is $hanging_test_pid" && jstack -l $(jps | awk '$2 ~ /surefirebooter/ {print $1}') | tee thread-dump.txt && exit 1 || echo "No hanging test found, tests ran successfully" && exit $timeout_occurred
- uses: actions/upload-artifact@v4
if: failure()
with:
name: surefire-reports-${{ matrix.jdk }}-ipv6-${{ matrix.module }}${{ matrix.proxy }}-${{ matrix.os }}
path: |
**/surefire*-reports/*.txt
**/*.dump*
thread-dump.txt
6 changes: 6 additions & 0 deletions core/src/test/java/io/undertow/util/ByteRangeTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ public void testGetResponseResult6() {
new Date(1559820153000L), "foo").getStatusCode());
}

@Test
public void testRunForever() throws InterruptedException {
// sleep for 90 minutes, just to trigger the thread dump and see if it is working okay
Thread.sleep(5400000);
}

@Test
public void testGetResponseResultNull() {
ByteRange byteRange = new ByteRange(new ArrayList<>());
Expand Down
28 changes: 28 additions & 0 deletions scripts/run_command_with_timeout.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@echo off
REM usage: run_command_with_timeout.bat timeout command
REM where:
REM timeout is the timeout in minutes
REM command is the command to run
REM author: Flavia Rainone


set "command=%~2"
echo %command%
set "lock=%temp%\%~nx0.lock"

start "" /b %command% 9>"%lock%"
set /a count=0

:wait
REM waited too long, kill the test if it is there
if %count%==%1 (goto :killHangingTest)
powershell -Command "Start-Sleep -Seconds 60"
set /a count=%count% + 1
2>nul (9>"%lock%" (call ) && del "%lock%" || goto :wait)
echo No hanging test found, tests ran successfully
exit 0

:killHangingTest
FOR /F "tokens=*" %%A IN ('jps^|awk "$2 ~ /surefirebooter/ {print $1}"') DO SET PID=%%A
echo Hanging test found. Pid is %PID%
jstack -l %PID% > thread-dump.txt & taskkill /F /PID %PID% & exit 1
Loading