embedded zookeeper for unit/integration test
Asked Answered
T

4

16

Is there an embedded zookeeper so that we could use it in unit testing? It can be shipped with the test and run out of the box. Maybe we could mock some service and register to the embedded zookeeper

Thermoscope answered 28/12, 2012 at 6:18 Comment(0)
C
23

The Curator framework has TestingServer and TestingCluster classes (see https://github.com/Netflix/curator/wiki/Utilities) that are in a separate maven artifact (curator-test - see the Maven/Artifacts section of https://github.com/Netflix/curator/wiki).

They're pretty self explanatory, or you can download the curator code base and see how they're used internally in their own test cases.

We've used both successfully within unit tests at $DAY_JOB.

Coracorabel answered 28/12, 2012 at 18:26 Comment(1)
The Curator testing server also work without the Curator client (directly with the Zookeper client) !Leninist
H
17

You could use Apache Curator Utilities provided in-process ZooKeeper server TestingServer that can be used for testing. With maven you can dependency as follows

    <dependency>
        <groupId>org.apache.curator</groupId>
        <artifactId>curator-test</artifactId>
        <version>3.2.1</version>
    </dependency>

And you can create in process zookeeper server as folows

 TestingServer zkServer;

  @Before
  public void setUp() throws Exception
  {
    zkServer = new TestingServer(2181, true);
  }

  @After
  public void tearDown() throws Exception
  {
    zkServer.stop();
  }

For testing Cluster use can use TestingCluster, which creates an internally running ensemble of ZooKeeper servers

Hepatic answered 12/12, 2016 at 6:26 Comment(0)
S
0

You could use the zookeeper-maven-plugin, which is documented here.

Secrete answered 22/4, 2015 at 15:58 Comment(0)
P
0

The zookeeper project produces a "fat-jar" that it uses itself for system test.

There is a written up README, showing how easy it is to launch, but unfortunately it is not being made as an artifact, so cannot be linked to maven.

Pinwheel answered 18/5, 2015 at 23:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.