Skip to content

crystal-processes/crp-sample-upgrade-test

Repository files navigation

The project allows to test different process instance versions running after the sample acme application upgrade.

Prerequisites

How to run

./run_test.sh

How does it work

#!/bin/bash
set -e
echo '--- Testing upgrade from release-0.1.0 -> release-0.2.0'
# start postgres database to store version 0.1.0 data
docker-compose -f commons/docker-compose/postgres-docker-compose.yml up -d
# generate v 0.1.0 data
./mvnw --projects release-0.1.0 clean test -Dspring.profiles.active=generateData
# test process execution on the version 0.2.0
./mvnw --projects release-0.2.0 clean test
# drop the test database
docker exec -it "$(docker ps | grep docker-compose-db | awk '{print $1}')" psql -U flowable -d postgres -c "DROP DATABASE flowable"
# shut down postgres database
docker-compose -f commons/docker-compose/postgres-docker-compose.yml down

Generate data for release 0.1.0:

@SpringBootTest(classes = {AcmeApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@EnabledIf(value = "#{environment.getActiveProfiles().length > 0 && environment.getActiveProfiles()[0]=='generateData'}")
public class GenerateDataForVersion1Test {
@Autowired
RuntimeService runtimeService;
@Test
void generateDataForHelloWorldProcess() {
runtimeService.createProcessInstanceBuilder()
.processDefinitionKey("P001-helloWorld")
.name("instance from the release 0.1.0")
.start();
}

The tests on the process instance from version 0.1.0 performed on the version 0.2.0.

void continueInV4HelloWorldProcess() {
ProcessInstance helloWorldV4 = runtimeService.createProcessInstanceQuery().processInstanceName("instance from the release 0.1.0")
.singleResult();
assertThat(helloWorldV4)
.as("The v0.1.0 process instance must keep the same state.")
.isRunning()
.userTasks().extracting("name")
.containsExactly("Say hello world");
Task taskV4 = taskService.createTaskQuery().processInstanceId(helloWorldV4.getId()).singleResult();
taskService.complete(taskV4.getId());
assertThat(helloWorldV4)
.as("The process instance from the previous app version must allow to be continued after application upgrade.")
.doesNotExist()
.inHistory()
.isFinished();
}

About

Test version upgrades for running process instances.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published