Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: [e2e-verification] First draft for the automate test #234

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions process-instance-migration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,38 @@ camunda7:
rest-api-context: engine-rest
check-on-init: true
```

## Execution


### Compile the project
1. Execute these commands:
````
cd process-instance-migration
mvn install
````

2. Update the configuration:
edit `src/main/resources/application.yaml`



3. Start the program:
```
cd target
java -jar ./process-instance-migration-0.5.1-SNAPSHOT.jar
```


4. Access the front end
5. Acc

Access the front end on http://localhost:8085

### Docker image
Get the docker image:
````
docker pull ghcr.io/camunda-community-hub/camunda-7-to-8-migration/process-instance-migration:0.5.1-snapshot
````
Update the configuration file
???
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ operate:

camunda7:
client:
base-url: http://localhost:8082
base-url: http://localhost:8080
rest-api-context: engine-rest
check-on-init: true

server.port: 8085
101 changes: 100 additions & 1 deletion test-example-diagrams/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>camunda-7-to-8-migration</artifactId>
<groupId>org.camunda.community.migration</groupId>
Expand All @@ -10,4 +11,102 @@
<artifactId>test-example-diagrams</artifactId>


<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>io.camunda</groupId>
<artifactId>spring-zeebe-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.camunda.feel</groupId>
<artifactId>feel-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.camunda</groupId>
<artifactId>zeebe-protocol</artifactId>
</dependency>
<dependency>
<groupId>org.camunda.community.migration</groupId>
<artifactId>backend-diagram-converter-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.camunda</groupId>
<artifactId>camunda-operate-client-java</artifactId>
</dependency>

<dependency>
<groupId>org.camunda.automator</groupId>
<artifactId>process-execution-automator</artifactId>
<version>1.1.1</version>
</dependency>


<dependency>
<groupId>io.camunda</groupId>
<artifactId>spring-zeebe-test-testcontainer</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine</artifactId>
<scope>test</scope>
</dependency>


<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-bpm-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.camunda.bpm.assert</groupId>
<artifactId>camunda-bpm-assert</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies>

<build>
<plugins>

<!-- allow mvn spring-boot:run -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.7.5</version>
<configuration>
<mainClass>org.camunda.community.migration.autimatictext.AutomaticTestApp</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.camunda.community.migration.automatictest;

import io.camunda.zeebe.spring.client.EnableZeebeClient;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableZeebeClient
public class AutomaticTestApp {

// Spring starts service/ExecuteTest.init(), where the main part of the test starts
public static void main(String[] args) {
SpringApplication.run(AutomaticTestApp.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.camunda.community.migration.automatictest.detection;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.camunda.community.migration.automatictest.testpkg.TestPkg;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** This class search recursively in all folder to detect multiple tests */
public class Detection {
static Logger logger = LoggerFactory.getLogger(Detection.class);

File rootFolder;

public Detection(File rootFolder) {
this.rootFolder = rootFolder;
}

public List<TestPkg> detectTestPackage() {
return detectRecursiveTestPackage(rootFolder);
}

private List<TestPkg> detectRecursiveTestPackage(File folder) {
List<TestPkg> listPkg = new ArrayList<>();
for (File fileInFolder : folder.listFiles()) {
if (fileInFolder.isDirectory()) listPkg.addAll(detectRecursiveTestPackage(fileInFolder));
else if (fileInFolder.isFile())
// this folder is maybe a TestPackage
try {
TestPkg testPkg = TestPkg.createForFile(fileInFolder);
if (testPkg != null) listPkg.add(testPkg);
} catch (Exception e) {
logger.info("Detection failed " + e.getMessage());
}
}
return listPkg;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.camunda.community.migration.automatictest.report;

import org.camunda.community.migration.automatictest.testpkg.TestPkg;

public abstract class ReportExecution {

private int nbSuccess = 0;
private int nbErrors = 0;

private long startCurrentExecution;
private long cumulTimeExecution;

protected TestPkg currentTestPkg;

public void startExecution(TestPkg testPkg) {
startCurrentExecution = System.currentTimeMillis();
currentTestPkg = testPkg;
}

public void endExecution(boolean isSuccess, String message) {
long executionTime = System.currentTimeMillis() - startCurrentExecution;
reportEnd(isSuccess, message, executionTime);
if (isSuccess) {
nbSuccess++;
} else {
nbErrors++;
}
}

/**
* Abstract method: report a debug message
*
* @param message message to report
*/
public abstract void reportDebug(String message);

/**
* report the end,
*
* @param isSuccess true if the execution is successful
* @param message message to report
* @param executionTime time of execution (in ms)
*/
public abstract void reportEnd(boolean isSuccess, String message, long executionTime);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.camunda.community.migration.automatictest.report;

import java.util.ArrayList;
import java.util.List;
import org.camunda.community.migration.automatictest.testpkg.TestPkg;

public class ReportExecutionAggregate extends ReportExecution {

private List<ReportExecution> reportExecutionList = new ArrayList<>();

public void addReport(ReportExecution report) {
reportExecutionList.add(report);
}

@Override
public void startExecution(TestPkg testPkg) {
for (ReportExecution report : reportExecutionList) report.startExecution(testPkg);
super.startExecution(testPkg);
}

@Override
public void reportDebug(String message) {
for (ReportExecution report : reportExecutionList) report.reportDebug(message);
}

@Override
public void reportEnd(boolean isSuccess, String message, long executionTime) {
for (ReportExecution report : reportExecutionList)
report.reportEnd(isSuccess, message, executionTime);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.camunda.community.migration.automatictest.report;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ReportExecutionLog extends ReportExecution {
static Logger logger = LoggerFactory.getLogger(ReportExecutionLog.class);

@Override
public void reportDebug(String message) {
logger.info(message);
}

@Override
public void reportEnd(boolean isSuccess, String message, long executionTime) {
if (isSuccess) logger.info(message);
else logger.error(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.camunda.community.migration.automatictest.report;

import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ReportExecutionSynthesis extends ReportExecution {
static Logger logger = LoggerFactory.getLogger(ReportExecutionLog.class);

private final List<String> reportLine = new ArrayList<>();

@Override
public void reportDebug(String message) {
logger.info(message);
}

@Override
public void reportEnd(boolean isSuccess, String message, long executionTime) {

String messageLine = "| " + completeBlank(currentTestPkg.getName(), 40, false);
messageLine += " | " + completeBlank(isSuccess ? " CORRECT " : " FAIL ", 9, false);
messageLine += " | " + completeBlank(executionTime + " ms", 10, true);
messageLine += " | " + completeBlank(message, 300, false) + " |";
reportLine.add(messageLine);
}

private String completeBlank(String info, int lengthExpected, boolean before) {
if (before) {
while (info.length() < lengthExpected) {
info = " " + info;
}
return info.substring(info.length() - lengthExpected);
} else {
while (info.length() < lengthExpected) {
info += " ";
}

return info.substring(0, lengthExpected);
}
}

public void logSynthesis() {
for (String line : reportLine) {
logger.info(line);
}
}
}
Loading