Search in sources :

Example 1 with ZeebeVolume

use of io.zeebe.containers.ZeebeVolume in project zeebe-test-container by camunda-community-hub.

the class RestartWithExtractedDataExampleTest method shouldGenerateData.

/**
 * Start a container with a volume, deploy a process, and extract the generated data to some
 * folder. In the next test, we will reuse this data to create a process instance, proving that
 * the data was successfully reused.
 *
 * <p>NOTE: since Zeebe is an asynchronous system, and we cannot guarantee when the engine is
 * idle, we stop the container before extracting the data. This causes us to start a second
 * (albeit tiny) container to extract the data.
 *
 * <p>If you all you wanted was to extract data from a live container, then you can use the {@link
 * ContainerArchive#builder()} directly and pass in your live container. For such a use case, you
 * wouldn't even need to be using a volume.
 */
@Test
@Order(1)
@Timeout(value = 5, unit = TimeUnit.MINUTES)
void shouldGenerateData() throws IOException {
    // given
    final ZeebeVolume volume = ZeebeVolume.newVolume();
    final Path destination = tempDir.resolve(DATA_DIR);
    // when
    try (final ZeebeContainer container = new ZeebeContainer().withZeebeData(volume)) {
        container.start();
        deployProcess(container);
    }
    volume.extract(destination);
    // then
    assertThat(destination).isNotEmptyDirectory();
}
Also used : Path(java.nio.file.Path) ZeebeContainer(io.zeebe.containers.ZeebeContainer) ZeebeVolume(io.zeebe.containers.ZeebeVolume) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test) Timeout(org.junit.jupiter.api.Timeout)

Aggregations

ZeebeContainer (io.zeebe.containers.ZeebeContainer)1 ZeebeVolume (io.zeebe.containers.ZeebeVolume)1 Path (java.nio.file.Path)1 Order (org.junit.jupiter.api.Order)1 Test (org.junit.jupiter.api.Test)1 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)1 Timeout (org.junit.jupiter.api.Timeout)1