All Projects → vmlens → vmlens

vmlens / vmlens

Licence: Apache-2.0 License
unit-testing multi-threaded applications on the JVM made easy

Programming Languages

java
68154 projects - #9 most used programming language
scala
5932 projects
HTML
75241 projects

Projects that are alternatives of or similar to vmlens

Hamsters.js
100% Vanilla Javascript Multithreading & Parallel Execution Library
Stars: ✭ 517 (+487.5%)
Mutual labels:  multithreading, concurrent
myconcurrent
Java并发的系统性学习
Stars: ✭ 25 (-71.59%)
Mutual labels:  multithreading, concurrent
space
A SCI-FI community game server simulating space(ships). Built from the ground up to support moddable online action multiplayer and roleplay!
Stars: ✭ 25 (-71.59%)
Mutual labels:  multithreading, concurrent
java-multithread
Códigos feitos para o curso de Multithreading com Java, no canal RinaldoDev do YouTube.
Stars: ✭ 24 (-72.73%)
Mutual labels:  multithreading, concurrent
mapreduce
A in-process MapReduce library to help you optimizing service response time or concurrent task processing.
Stars: ✭ 93 (+5.68%)
Mutual labels:  concurrent
treap
A thread-safe, persistent Treap (tree + heap) for ordered key-value mapping and priority sorting.
Stars: ✭ 23 (-73.86%)
Mutual labels:  concurrent
web-scraping-engine
A simple web scraping engine supporting concurrent and anonymous scraping
Stars: ✭ 27 (-69.32%)
Mutual labels:  concurrent
ObviousAwait
🧵 Expressive aliases to ConfigureAwait(true) and ConfigureAwait(false)
Stars: ✭ 55 (-37.5%)
Mutual labels:  multithreading
Socket-Programming-Python
Client Server running code described with comments here.
Stars: ✭ 48 (-45.45%)
Mutual labels:  multithreading
bikeshed
Lock free hierarchical work scheduler
Stars: ✭ 78 (-11.36%)
Mutual labels:  multithreading
DynAdjust
Least squares adjustment software
Stars: ✭ 43 (-51.14%)
Mutual labels:  multithreading
hostbase
A Ruby GUI based on advanced rogue AP attack using the WPS
Stars: ✭ 43 (-51.14%)
Mutual labels:  multithreading
euler2d kokkos
Simple 2d finite volume solver for Euler equations using c++ kokkos library
Stars: ✭ 27 (-69.32%)
Mutual labels:  multithreading
theater
Actor framework for Dart. This package makes it easier to work with isolates, create clusters of isolates.
Stars: ✭ 29 (-67.05%)
Mutual labels:  multithreading
TradingMachine
TradingMachine is a mini-trading system simulation, whose components (market data and order feeds, FIX acceptor and initiator, back-end for filled orders) interact by queues and topics.
Stars: ✭ 26 (-70.45%)
Mutual labels:  multithreading
variadic future
Variadic, completion-based futures for C++17
Stars: ✭ 41 (-53.41%)
Mutual labels:  multithreading
b-rabbit
A thread safe library that aims to provide a simple API for interfacing with RabbitMQ. Built on top of rabbitpy, the library make it very easy to use the RabbitMQ message broker with just few lines of code. It implements all messaging pattern used by message brokers
Stars: ✭ 15 (-82.95%)
Mutual labels:  multithreading
sharded-slab
a lock-free concurrent slab (experimental)
Stars: ✭ 116 (+31.82%)
Mutual labels:  concurrent
concurrent-data-structure
Concurrent Data Structure for Rust
Stars: ✭ 18 (-79.55%)
Mutual labels:  concurrent
dystopia
Low to medium multithreaded Ubuntu Core honeypot coded in Python.
Stars: ✭ 59 (-32.95%)
Mutual labels:  multithreading

vmlens, unit-testing multi-threaded applications on the JVM made easy

Why vmlens?

Running your tests with multiple threads does not work. Bugs depend on a specific thread interleaving, which is often impossible to reach by simply rerunning your test multiple times. And data races only occur on specific hardware architectures and JVMs.

Therefore vmlens uses the Java Memory Model to execute all possible thread interleavings and to check for data races in the program flow. This blog post describes how vmlens uses the Java Memory Model to test all thread interleavings.

Easy to use

Using vmlens is easy.

Surround your test with a while loop iterating over all thread interleavings using the class AllInterleaving.

Example

The following example shows how to write multi-threaded tests with vmlens:

import com.vmlens.api.AllInterleavings;
public class TestUpdateWrong {
    public void update(ConcurrentHashMap<Integer, Integer> map) {
        Integer result = map.get(1);
        if (result == null) {
            map.put(1, 1);
        } else {
            map.put(1, result + 1);
        }
    }
    @Test
    public void testUpdate() throws InterruptedException {
        try (AllInterleavings allInterleavings = 
                new AllInterleavings("TestUpdateWrong");) {
	// surround the test with a while loop, iterationg over
	// the class AllInterleavings
            while (allInterleavings.hasNext()) {
                final ConcurrentHashMap<Integer, Integer> map = 
                        new ConcurrentHashMap<Integer, Integer>();
                Thread first = new Thread(() -> {
                    update(map);
                });
                Thread second = new Thread(() -> {
                    update(map);
                });
                first.start();
                second.start();
                first.join();
                second.join();
                assertEquals(2,map.get(1).intValue());
            }
        }
    }
}

In your test method, you surround the code you want to test with a while loop iterating over the class AllInterleavings. vmlens executes the block inside the while loop multiple times, for each thread interleaving once. If the test fails vmlens shows the thread interleaving which led to the failure. If the test succeeds vmlens shows the last thread interleaving.

The above example test fails, and vmlens reports the interleaving which led to the failed assertion:

In maven, you can see this report by clicking on the link TestUpdateWrong in the file target/interleave/elements.html. In eclipse you can see the report by clicking on the link TestUpdateWrong in the view under Window -> Show View -> Other... -> vmlens -> vmlens Explorer.

The maven reports are described here. The eclipse views are described here.

How to run the test

You can run the test in eclipse using the vmlens run short cut for JUnit. Right click on the JUnit class -> Run As -> JUnit Test traced with vmlens.

To run the test with maven put the vmlens interleave plugin in your maven pom.xml as described here.

Next steps

Read here more about how to use vmlens for testing multi-threaded software. And download and run the example tests.

Download

Eclipse

Install from marketplace:

  1. Start Eclipse (version 4.4 or greater)
  2. Drag to your running Eclipse* workspace. *Requires Eclipse Marketplace Client

Or install directly from the update site:

  1. Start Eclipse
  2. Select Help>Install New Software…
  3. Work with: https://vmlens.com/download/site/

To use the class AllInterleavings you need to include the jar api-1.1.5.jar into your classpath. You can download this jar from maven central here.

The usage of the eclipse plugin is described here.

MAVEN

To use vmlens with maven, configure a plugin tag to tell maven that the vmlens plugin should be executed at the test phase. And include the jar com.vmlens.api as test dependency.

<project>
<!-- to include the class AllInterleavings into the test class path.  -->	
<dependency>
  <groupId>com.vmlens</groupId>
  <artifactId>api</artifactId>
  <version>1.1.5</version>
  <scope>test</scope>
</dependency>	
	
<build>
  <plugins>
<!-- to run the vmlens maven plugin during the maven test phase  -->	 
    <plugin>
    <groupId>com.vmlens</groupId>
    <artifactId>interleave</artifactId>
    <version>1.1.5</version>
    <executions>
      <execution>
        <goals>
          <goal>test</goal>
        </goals>
      </execution>
    </executions>
    </plugin>
     ...
    </plugins>
</build>
      ...
</project>

The usage of the maven plugin is described here.

Documentation

Support

Post an issue in our issue tracker or send a message to our mailing list.

Stay in touch

Follow @ThomasKrieger and join our mailing list.

Build

To build vmlens, go to vmlens and run

mvn clean install

You need JDK 11 or higher and a toolchains.xml containing a tag for JDK 8. Example toolchains.xml:

<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<!-- JDK toolchains -->
  <toolchain>
    <type>jdk</type>
      <provides>
        <version>1.8</version>
        <vendor>sun</vendor>
      </provides>
      <configuration>
        <jdkHome>/path/to/jdk/1.8</jdkHome>
      </configuration>
  </toolchain>
</toolchains>

License

Apache License 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].