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

Run tests on supported databases #4639

Open
wants to merge 22 commits into
base: 7.11.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d2f8858
MNT-24335: tests generate more debug information
vrmoreira Apr 16, 2024
7b02bf4
MNT-24335: WIP
vrmoreira Apr 16, 2024
3fa0ff8
MNT-24335: selectCount + involvedUser
vrmoreira Apr 16, 2024
7eebd16
MNT-24335: refactor "orQueryObject_involvedGroups"
vrmoreira Apr 16, 2024
a0b2f05
Revert "MNT-24335: tests generate more debug information"
vrmoreira Apr 16, 2024
f1da4c1
MNT-24335: Ignored test is no longer ignored
vrmoreira Apr 16, 2024
6d3f16b
MNT-24335: fixed HistoricTaskAndVariablesQueryTest.testQuery
vrmoreira Apr 17, 2024
d25ae7e
MNT-24335: fixed HistoricTaskAndVariablesQueryTest.testOrQuery
vrmoreira Apr 17, 2024
72c86b1
trying to do a preview release
vrmoreira Apr 17, 2024
f18db44
MNT-24335: added branch on main workflow in order to make a preview-r…
vrmoreira Apr 17, 2024
289cd6a
MNT-24335: PSQL doesn't allow alias on orderBy after two or more UNIO…
vrmoreira Apr 17, 2024
8e8fc80
MNT-24335: alias for START_TIME orderBy is removed for Postgresql dat…
vrmoreira Apr 17, 2024
1392ac3
MNT-24335: alias for START_TIME orderBy is removed for Postgresql/H2 …
vrmoreira Apr 17, 2024
8f3f55a
MNT-24335: alias for START_TIME orderBy is removed for Postgresql/H2/…
vrmoreira Apr 18, 2024
8a5ce4b
MNT-24335: refactor "unfinished"
vrmoreira Apr 18, 2024
43333e4
MNT-24335: refactor "finished/unfinished"
vrmoreira Apr 19, 2024
d047c55
run test on msslq
balsarori Apr 19, 2024
2261f23
use case sensitive collation and 2019 image
balsarori Apr 19, 2024
b18251b
fix native queries order by
balsarori Apr 22, 2024
b612d71
increase timeouts
balsarori Apr 22, 2024
5f14c3c
run tests on supported databases
balsarori May 9, 2024
c4ffc74
disable fail-fast
balsarori May 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 39 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ on:
push:
branches:
- 7.11.x
- fix/MNT-24335-performance_issue_WF_tests_withUnitTests
pull_request:
branches:
- 7.11.x
- fix/MNT-24335-performance_issue_WF_tests_withUnitTests
# Allows to run this workflow manually from the Actions tab
workflow_dispatch:
concurrency:
Expand All @@ -16,9 +18,37 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: Alfresco/alfresco-build-tools/.github/actions/pre-commit@v1.21.0
build:

database-tests:
runs-on: ubuntu-latest
needs: pre-commit
strategy:
fail-fast: false
matrix:
database: [ none, mssql, mysql, postgres, mariadb, oracle ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
token: ${{ secrets.BOT_GITHUB_TOKEN }}
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Setup Java JDK 11
uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc # 3.6.0
with:
java-version: 11
distribution: 'temurin'
- name: Test
shell: bash
run: mvn test -Dlicense.skipAddThirdParty=true -Ddb=${{ matrix.database }} ${{ env.MAVEN_CLI_OPTS}}

build:
runs-on: ubuntu-latest
needs: [pre-commit, database-tests]
steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand Down Expand Up @@ -70,7 +100,7 @@ jobs:
DO_PUSH: ${{ github.event_name == 'push' || contains(github.head_ref, 'preview') }}
- name: Build and Test with Maven (and maybe Deploy)
shell: bash
run: mvn ${{ steps.define_maven_command.outputs.command }} ${{ env.MAVEN_CLI_OPTS}}
run: mvn -Dlicense.skipAddThirdParty=true ${{ matrix.database }} ${{ steps.define_maven_command.outputs.command }} ${{ env.MAVEN_CLI_OPTS}}
env:
MAVEN_CLI_OPTS: --show-version --no-transfer-progress --settings settings.xml
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
Expand All @@ -91,6 +121,13 @@ jobs:
git commit -am "Release $VERSION" --allow-empty
git tag -fa $VERSION -m "Release version $VERSION"
git push -f -q origin $VERSION


env:
MAVEN_CLI_OPTS: --show-version --no-transfer-progress --settings settings.xml
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}

notify:
runs-on: ubuntu-latest
needs: build
Expand Down
65 changes: 65 additions & 0 deletions activiti-core/activiti-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
<relativePath>../activiti-core-dependencies</relativePath>
</parent>

<properties>
<testcontainers.version>1.19.8</testcontainers.version>
</properties>

<artifactId>activiti-engine</artifactId>
<name>Activiti :: Engine</name>

Expand Down Expand Up @@ -163,6 +167,67 @@
<artifactId>hibernate-core</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${testcontainers.version}</version>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mssqlserver</artifactId>
<version>${testcontainers.version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>oracle-xe</artifactId>
<version>${testcontainers.version}</version>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
<version>${testcontainers.version}</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>mariadb</artifactId>
<version>${testcontainers.version}</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>${testcontainers.version}</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,8 @@ public Object execute(CommandContext commandContext) {
parameterMap.put("resultType", "LIST_PAGE");
parameterMap.put("firstResult", firstResult);
parameterMap.put("maxResults", maxResults);
if (StringUtils.isNotBlank(Objects.toString(parameterMap.get("orderBy")))) {
parameterMap.put("orderByColumns", "RES." + parameterMap.get("orderBy"));
} else {
parameterMap.put("orderByColumns", "RES.ID_ asc");
}
Object orderBy = parameterMap.getOrDefault("orderBy", "ID_ asc");
parameterMap.put("orderByColumns", "RES." + orderBy);

int firstRow = firstResult + 1;
parameterMap.put("firstRow", firstRow);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
import org.activiti.engine.DynamicBpmnConstants;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.history.HistoricTaskInstanceQuery;
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.CommandExecutor;
import org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntity;
import org.activiti.engine.impl.variable.VariableTypes;
import org.activiti.engine.query.QueryProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -43,6 +45,11 @@ public class HistoricTaskInstanceQueryImpl extends AbstractVariableQueryImpl<His

private static final Logger log = LoggerFactory.getLogger(HistoricTaskInstanceQueryImpl.class);

private static final HistoricTaskInstanceQueryProperty START_QUERY_PROPERTY_WITHOUT_ALIAS =
new HistoricTaskInstanceQueryProperty(
removeAliasFromPropertyName(HistoricTaskInstanceQueryProperty.START.getName())
);

protected String processDefinitionId;
protected String processDefinitionKey;
protected String processDefinitionKeyLike;
Expand Down Expand Up @@ -1217,8 +1224,25 @@ public HistoricTaskInstanceQueryImpl orderByHistoricActivityInstanceStartTime()
return this;
}

private boolean isPostgresqlDatabase() {
return ProcessEngineConfigurationImpl.DATABASE_TYPE_POSTGRES.equals(databaseType);
}
private boolean isH2Database() {
return ProcessEngineConfigurationImpl.DATABASE_TYPE_H2.equals(databaseType);
}

private boolean isMysqlDatabase() {
return ProcessEngineConfigurationImpl.DATABASE_TYPE_MYSQL.equals(databaseType);
}

public HistoricTaskInstanceQuery orderByHistoricTaskInstanceStartTime() {
orderBy(HistoricTaskInstanceQueryProperty.START);
QueryProperty queryProperty;
if( isPostgresqlDatabase() || isH2Database() || isMysqlDatabase() ) {
queryProperty = START_QUERY_PROPERTY_WITHOUT_ALIAS;
} else {
queryProperty = HistoricTaskInstanceQueryProperty.START;
}
orderBy(queryProperty);
return this;
}

Expand Down Expand Up @@ -1299,6 +1323,14 @@ public String getMssqlOrDB2OrderBy() {
return specialOrderBy;
}

public static String removeAliasFromPropertyName(String propertyName) {
String specialPropertyName = propertyName;
if (specialPropertyName != null && specialPropertyName.length() > 0) {
specialPropertyName = specialPropertyName.replace("RES.", "");
}
return specialPropertyName;
}

public List<String> getCandidateGroups() {
if (candidateGroup != null) {
List<String> candidateGroupList = new ArrayList<String>(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@
import org.activiti.engine.impl.interceptor.DebugCommandInvoker;
import org.activiti.engine.impl.interceptor.RetryInterceptor;
import org.activiti.engine.test.EnableVerboseExecutionTreeLogging;
import org.junit.Rule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.containers.JdbcDatabaseContainer;
import org.testcontainers.containers.MSSQLServerContainer;
import org.testcontainers.containers.MariaDBContainer;
import org.testcontainers.containers.MySQLContainer;
import org.testcontainers.containers.OracleContainer;
import org.testcontainers.containers.PostgreSQLContainer;

/**
* Base class for the activiti test cases.
Expand All @@ -45,6 +52,42 @@ public abstract class PluggableActivitiTestCase extends AbstractActivitiTestCase

private static Logger pluggableActivitiTestCaseLogger = LoggerFactory.getLogger(PluggableActivitiTestCase.class);


@Rule
public static JdbcDatabaseContainer databaseContainer = Database.getInstance().startNewJdbcDatabaseContainer();

public static class JDBCProperties {

private JDBCProperties() {
}

public static String getUrl() {
if (databaseContainer == null) return "jdbc:h2:mem:activiti;DB_CLOSE_DELAY=-1";
return databaseContainer.getJdbcUrl();
}

public static String getUsername() {
if (databaseContainer == null) return "sa";
return databaseContainer.getUsername();
}

public static String getPassword() {
if (databaseContainer == null) return "";
return databaseContainer.getPassword();
}

public static String getDriver() {
if (databaseContainer == null) return "org.h2.Driver";
return databaseContainer.getDriverClassName();
}

public static JDBCProperties getInstance() {
return new JDBCProperties();
}

}


protected static ProcessEngine cachedProcessEngine;

protected void initializeProcessEngine() {
Expand Down Expand Up @@ -130,4 +173,79 @@ protected void withRetryInterceptor(Runnable runnable) {
}
}

public enum Database {
POSTGRES {
@Override
protected JdbcDatabaseContainer startNewJdbcDatabaseContainer() {
PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer("postgres:13.7");
postgreSQLContainer.start();
return postgreSQLContainer;
}
},
ORACLE {
@Override
protected JdbcDatabaseContainer startNewJdbcDatabaseContainer() {
OracleContainer oracleContainer = new OracleContainer(
"gvenzl/oracle-xe:21-slim-faststart")
.withDatabaseName("testDB")
.withUsername("testUser")
.withPassword("testPassword");

oracleContainer.start();
return oracleContainer;
}

},
MYSQL {
@Override
protected JdbcDatabaseContainer startNewJdbcDatabaseContainer() {
MySQLContainer mySQLContainer = new MySQLContainer("mysql:8.0");
mySQLContainer.start();
return mySQLContainer;
}
},
MARIADB {
@Override
protected JdbcDatabaseContainer startNewJdbcDatabaseContainer() {
MariaDBContainer mariaDBContainer = new MariaDBContainer("mariadb:10.6.16");
mariaDBContainer.start();
return mariaDBContainer;
}
},
MSSQL {
@Override
protected JdbcDatabaseContainer startNewJdbcDatabaseContainer() {
MSSQLServerContainer mssqlserver = new MSSQLServerContainer("mcr.microsoft.com/mssql/server:2019-CU9-ubuntu-16.04")
.acceptLicense();
mssqlserver.addEnv("MSSQL_COLLATION", "LATIN1_GENERAL_100_CS_AS_SC_UTF8");
mssqlserver.start();
return mssqlserver;
}

},
NONE {
@Override
protected JdbcDatabaseContainer startNewJdbcDatabaseContainer() {
return null;
}
};

protected JdbcDatabaseContainer startNewJdbcDatabaseContainer() {
throw new UnsupportedOperationException(
String.format(
"The [%s] database was not configured to use Testcontainers!",
name()
)
);
}

public static Database getInstance() {
String database = System.getProperty("db");
database = database == null ? "NONE" : database.toUpperCase();
pluggableActivitiTestCaseLogger.info("Initiating " + database + " container");
return valueOf(database);
}

}

}