Skip to content
Closed
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
36 changes: 36 additions & 0 deletions .github/actions/upload-test-diagnostics/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Upload test diagnostics
description: Preserve test reports, application logs, and JVM crash reports after a failed build.

runs:
using: composite
steps:
- name: Report available memory and process limits
if: always()
shell: bash
run: |
ulimit -a
if command -v free >/dev/null 2>&1; then
free -m
elif command -v vm_stat >/dev/null 2>&1; then
vm_stat
fi
for counter in /sys/fs/cgroup/memory.events /sys/fs/cgroup/memory.current /sys/fs/cgroup/memory.max; do
if [ -r "$counter" ]; then
echo "$counter"
cat "$counter"
fi
done

- name: Upload diagnostic files
if: always()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: test-diagnostics-${{ github.job }}-${{ github.run_attempt }}
path: |
**/build/test-results/**
**/build/reports/tests/**
**/logs/tron-test*.log*
**/hs_err_pid*.log
if-no-files-found: warn
retention-days: 7
compression-level: 1
26 changes: 23 additions & 3 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ jobs:
java -jar "$JAR" db archive -h
java -jar "$JAR" keystore --help

- name: Upload test diagnostics
if: failure()
uses: ./.github/actions/upload-test-diagnostics

build-ubuntu:
name: Build ubuntu24 (JDK 17 / aarch64)
if: ${{ github.event_name == 'pull_request' || inputs.job == 'all' || inputs.job == 'ubuntu' }}
Expand Down Expand Up @@ -91,7 +95,9 @@ jobs:
restore-keys: ubuntu24-aarch64-gradle-

- name: Build
run: ./gradlew clean build --no-daemon
# Bound worker concurrency while retaining parallelism within the 60-minute job limit.
# Execute tests on every retry instead of restoring their outputs from the build cache.
run: ./gradlew clean build --no-daemon --max-workers=2 --rerun-tasks --info --stacktrace

- name: Toolkit jar smoke test
run: |
Expand All @@ -102,6 +108,10 @@ jobs:
java -jar "$JAR" db archive -h
java -jar "$JAR" keystore --help

- name: Upload test diagnostics
if: failure()
uses: ./.github/actions/upload-test-diagnostics

docker-build-rockylinux:
name: Build rockylinux (JDK 8 / x86_64)
if: ${{ github.event_name == 'pull_request' || inputs.job == 'all' || inputs.job == 'rockylinux' }}
Expand Down Expand Up @@ -143,7 +153,9 @@ jobs:
run: ./gradlew --stop || true

- name: Build
run: ./gradlew clean build --no-daemon
# Bound worker concurrency while retaining parallelism within the 60-minute job limit.
# Execute tests on every retry instead of restoring their outputs from the build cache.
run: ./gradlew clean build --no-daemon --max-workers=2 --rerun-tasks --info --stacktrace

- name: Toolkit jar smoke test
run: |
Expand All @@ -155,7 +167,11 @@ jobs:
java -jar "$JAR" keystore --help

- name: Test with RocksDB engine
run: ./gradlew :framework:testWithRocksDb --no-daemon
run: ./gradlew :framework:testWithRocksDb --no-daemon --max-workers=2 --rerun-tasks --info --stacktrace

- name: Upload test diagnostics
if: failure()
uses: ./.github/actions/upload-test-diagnostics

docker-build-debian11:
name: Build debian11 (JDK 8 / x86_64)
Expand Down Expand Up @@ -222,6 +238,10 @@ jobs:
**/build/reports/jacoco/test/jacocoTestReport.xml
if-no-files-found: error

- name: Upload test diagnostics
if: failure()
uses: ./.github/actions/upload-test-diagnostics

coverage-base:
name: Coverage Base (JDK 8 / x86_64)
if: ${{ github.event_name == 'pull_request' }}
Expand Down
4 changes: 4 additions & 0 deletions framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ def configureTestTask = { Task t ->
}
t.maxHeapSize = "512m"
t.maxParallelForks = Math.max(1, Math.min(4, Runtime.runtime.availableProcessors()))
if ('true'.equalsIgnoreCase(System.getenv('CI'))) {
// Keep fatal test-JVM diagnostics in the task output directory for CI artifacts.
t.jvmArgs "-XX:ErrorFile=${t.temporaryDir}/hs_err_pid%p.log"
}
t.systemProperty 'runPrecompileBenchmark',
System.getProperty('runPrecompileBenchmark', 'false')
t.doFirst {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -248,8 +250,15 @@ private void setUp() {
}

@Test
public void query() {
public void query() throws InterruptedException {
Assert.assertEquals(3189, mortgageService.queryReward(OWNER_ADDRESS));
// queryReward() can return before the background Merkle-root calculation finishes.
// Wait for it before modifying or closing the store used by that calculation.
ExecutorService rewardExecutor = ReflectUtils.getFieldValue(rewardViCalService, "es");
rewardExecutor.shutdown();
Assert.assertTrue("Reward calculation did not terminate before modifying its store",
rewardExecutor.awaitTermination(10, TimeUnit.SECONDS));

// mock root is error
rewardViStore.put("test".getBytes(), "test".getBytes());
ReflectUtils.invokeMethod(rewardViCalService,"maybeRun");
Expand Down
Loading