GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - davidburstrom/contester

BranchesTags
Open more actions menu

Latest commit

 

History

364 Commits
364 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
benchmarks
benchmarks
 
 
breakpoint
breakpoint
 
 
config
config
 
 
driver
driver
 
 
examples
examples
 
 
gradle
gradle
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle.kts
build.gradle.kts
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
proguard-rules.pro
proguard-rules.pro
 
 
settings.gradle.kts
settings.gradle.kts
 
 

Repository files navigation

ConTester – Concurrency Tester for JVM languages

Overview

ConTester is a tool that enables precise testing of Java concurrency, by providing granular control of thread execution. It is quite similar to how one would use a debugger to set breakpoints in the production code, which makes it easy to learn and apply. Thanks to JVM runtime optimizations, the library has zero performance impact in production.

It consists of two libraries: contester-breakpoint and contester-driver. The production code uses the former to define breakpoints, and the test code uses the latter to set up test scenarios based on those breakpoints.

    field=true;
    ConTesterBreakpoint.defineBreakpoint("my-breakpoint");
    field=false;
    ConTesterDriver.runToBreakpoint(thread,"my-breakpoint");
    assertTrue(field);
    ConTesterDriver.join(thread);
    assertFalse(field);

See examples for more use-cases.

Usage

  1. Introduce one or more ConTesterBreakpoint.defineBreakpoints in the production code, as required. Thinking in terms of debugging, place them before the statements that'd have debugger breakpoints set.
  2. In the test code, use ConTesterDriver.thread to set up two or more Threads that execute the production code, using the supplied Runnables.
  3. Use a combination of ConTesterDriver.runToBreakpoint and resume to control how the Threads execute the production code.
  4. If necessary, verify that the Threads did or didn't throw any uncaught exception by using ConTesterDriver.join and getUncaughtThrowable.

Gradle

Add the following dependencies to the project:

dependencies {
    implementation("io.github.davidburstrom.contester:contester-breakpoint:0.2.0")
    testImplementation("io.github.davidburstrom.contester:contester-driver:0.2.0")
}

Advanced usage

Breakpoint IDs

The breakpoint IDs don't have to be globally unique, though it might lead to confusion if a thread can hit two identical breakpoint IDs during execution. Therefore, it can be a good idea to namespace them.

Bring your own thread

If the production code requires a particular Thread class, the ConTesterDriver.thread method cannot be used. In that case, call ConTesterDriver.register first to let ConTester control the thread execution.

Parallel test execution

ConTester is designed to handle parallel unit test execution, by associating all thread operations with each individual test worker thread.

Production performance

Even though the production code invokes ConTesterBreakpoint.defineBreakpoint, there is no performance penalty, if the ConTesterDriver class is missing on the runtime classpath. The JVM will optimise away the calls.

If ProGuard/R8 is used (for example in an Android development environment), it is also possible to completely eliminate the ConTesterBreakpoint.defineBreakpoint invocations in the minification/obfuscation phase. See proguard-rules.pro.

Benchmarks

To verify that the production runtime is not impacted by defined breakpoints when the driver is not present on the classpath, run the ./gradlew jmh tasks. This tests both repeated calls to defineBreakpoint as well as first time invocations.

Sample output from JDK 1.8 on an M1 Max:

Benchmark                                                   Mode           Score  Units
WithDriverBenchmark.withBreakpoint                          thrpt  109101587.440  ops/s
WithDriverBenchmark.withConditionalBreakpoint               thrpt  109854616.334  ops/s
WithDriverBenchmark.withoutBreakpoint                       thrpt  465717746.227  ops/s
WithDriverBenchmark.withBreakpointSingleShot                ss            ≈ 10⁻⁶  s/op
WithDriverBenchmark.withConditionalBreakpointSingleShot     ss            ≈ 10⁻⁶  s/op
WithDriverBenchmark.withoutBreakpointSingleShot             ss            ≈ 10⁻⁵  s/op
WithoutDriverBenchmark.withBreakpoint                       thrpt  457506448.191  ops/s
WithoutDriverBenchmark.withConditionalBreakpoint            thrpt  462785179.461  ops/s
WithoutDriverBenchmark.withoutBreakpoint                    thrpt  453185836.467  ops/s
WithoutDriverBenchmark.withBreakpointSingleShot             ss            ≈ 10⁻⁶  s/op
WithoutDriverBenchmark.withConditionalBreakpointSingleShot  ss            ≈ 10⁻⁶  s/op
WithoutDriverBenchmark.withoutBreakpointSingleShot          ss            ≈ 10⁻⁵  s/op

Security

The signatures of the release artifact can be verified with this pubkey.

pub   ed25519 2022-04-03 [SC]
      C0612048F3393B80B22639B4F067A2FD751AE3E4
uid   David Burström <[email protected]>
sub   cv25519 2022-04-03 [E]

Releases

0.1.0

  • Initial release

0.2.0

  • Fixes a bug where runToBreakpoint doesn't reset the temporary breakpoint
  • Bumps build dependencies

License

License

Copyright 2022-2024 David Burström.

About

No description, website, or topics provided.

Resources

Readme
Apache-2.0 license
Activity

Stars

6 stars

Watchers

2 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.