From 237c06c05d244fe7a172298704573a870cc1d473 Mon Sep 17 00:00:00 2001 From: Matt Riben Date: Mon, 18 Mar 2024 16:21:25 -0500 Subject: [PATCH] saving Signed-off-by: Matt Riben --- .github/workflows/run-reproducer.yml | 112 +++++++++++++++++++++++++-- build.gradle.kts | 28 +++++++ pom.xml | 34 ++++++++ src/test/java/IOTest.java | 51 ++++++++++++ 4 files changed, 218 insertions(+), 7 deletions(-) create mode 100644 pom.xml create mode 100644 src/test/java/IOTest.java diff --git a/.github/workflows/run-reproducer.yml b/.github/workflows/run-reproducer.yml index ba39928..cc21119 100644 --- a/.github/workflows/run-reproducer.yml +++ b/.github/workflows/run-reproducer.yml @@ -1,7 +1,106 @@ -name: Run reproducer on each commit -on: push +name: Run reproducer +on: workflow_dispatch jobs: - gradle: + gradle-macos-test1: + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: 21 + - uses: gradle/gradle-build-action@v2 + with: + arguments: test --tests 'IOTest.test1' -i --debug --stacktrace --no-daemon --no-build-cache --no-configuration-cache --rerun-tasks + gradle-ubuntu-test1: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: 21 + - uses: gradle/gradle-build-action@v2 + with: + arguments: test --tests 'IOTest.test1' -i --debug --stacktrace --no-daemon --no-build-cache --no-configuration-cache --rerun-tasks + gradle-windows-test1: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: 21 + - uses: gradle/gradle-build-action@v2 + with: + arguments: test --tests 'IOTest.test1' -i --debug --stacktrace --no-daemon --no-build-cache --no-configuration-cache --rerun-tasks + gradle-macos-test2: + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: 21 + - uses: gradle/gradle-build-action@v2 + with: + arguments: test --tests 'IOTest.test2' -i --debug --stacktrace --no-daemon --no-build-cache --no-configuration-cache --rerun-tasks + gradle-ubuntu-test2: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: 21 + - uses: gradle/gradle-build-action@v2 + with: + arguments: test --tests 'IOTest.test2' -i --debug --stacktrace --no-daemon --no-build-cache --no-configuration-cache --rerun-tasks + gradle-windows-test2: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: 21 + - uses: gradle/gradle-build-action@v2 + with: + arguments: test --tests 'IOTest.test2' -i --debug --stacktrace --no-daemon --no-build-cache --no-configuration-cache --rerun-tasks + gradle-macos-test3: + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: 21 + - uses: gradle/gradle-build-action@v2 + with: + arguments: test --tests 'IOTest.test3' -i --debug --stacktrace --no-daemon --no-build-cache --no-configuration-cache --rerun-tasks + gradle-ubuntu-test3: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: 21 + - uses: gradle/gradle-build-action@v2 + with: + arguments: test --tests 'IOTest.test3' -i --debug --stacktrace --no-daemon --no-build-cache --no-configuration-cache --rerun-tasks + gradle-windows-test3: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: 21 + - uses: gradle/gradle-build-action@v2 + with: + arguments: test --tests 'IOTest.test3' -i --debug --stacktrace --no-daemon --no-build-cache --no-configuration-cache --rerun-tasks + maven-all-tests: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] @@ -11,7 +110,6 @@ jobs: - uses: actions/setup-java@v2 with: distribution: 'zulu' - java-version: 11 - - uses: gradle/gradle-build-action@v2 - with: - arguments: help --info \ No newline at end of file + java-version: 21 + - name: Use maven + run: mvn test diff --git a/build.gradle.kts b/build.gradle.kts index e69de29..127ccc1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -0,0 +1,28 @@ +/* + * This file was generated by the Gradle 'init' task. + */ + +plugins { + `java-library` +} + +repositories { + mavenCentral() +} + +dependencies { + testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } +} + +tasks.named("test") { + // Use JUnit Platform for unit tests. + useJUnitPlatform() + setJvmArgs(listOf("-Xmx8G")) +} + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..aef81e6 --- /dev/null +++ b/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + org.example + reproducer-project + 1.0-SNAPSHOT + + + 21 + 21 + UTF-8 + + + + org.junit.jupiter + junit-jupiter + 5.10.2 + test + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.5 + + + + + diff --git a/src/test/java/IOTest.java b/src/test/java/IOTest.java new file mode 100644 index 0000000..1daf3b0 --- /dev/null +++ b/src/test/java/IOTest.java @@ -0,0 +1,51 @@ +import org.junit.jupiter.api.RepeatedTest; +import org.junit.platform.commons.logging.Logger; +import org.junit.platform.commons.logging.LoggerFactory; + +import java.lang.invoke.MethodHandles; +import java.util.ArrayList; +import java.util.List; + +public class IOTest { + private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + @RepeatedTest(50) + void test1() { + for (long loop = 0; loop < 10000; ++loop) { + System.out.println("0123456789".repeat(50)); + System.out.println("0123456789".repeat(50)); + } + } + + @RepeatedTest(50) + void test2() throws Exception { + List threads = new ArrayList<>(); + for (int i = 0; i < 100; ++i) { + threads.add(Thread.ofPlatform().start(() -> { + for (int j = 0; j < 100; ++j) { + logger.info(() -> "0123456789".repeat(50)); + logger.info(() -> "0123456789".repeat(50)); + } + })); + } + for (Thread thread : threads) { + thread.join(); + } + } + + @RepeatedTest(50) + void test3() throws Exception { + List threads = new ArrayList<>(); + for (int i = 0; i < 100; ++i) { + threads.add(Thread.ofVirtual().start(() -> { + for (int j = 0; j < 100; ++j) { + logger.info(() -> "0123456789".repeat(50)); + logger.info(() -> "0123456789".repeat(50)); + } + })); + } + for (Thread thread : threads) { + thread.join(); + } + } +}