From f4baa9ec6295c1596d641f0207e2e6f95ff7a4c4 Mon Sep 17 00:00:00 2001 From: Rafi Shamim Date: Fri, 22 Sep 2023 18:35:00 +0000 Subject: [PATCH] roachtest: fix flowable roachtest It no longer works with Java 8. Also, the test had decayed so requires some other fixes. Release note: None --- pkg/cmd/roachtest/tests/flowable.go | 78 +++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/roachtest/tests/flowable.go b/pkg/cmd/roachtest/tests/flowable.go index 1f53fb797c8c..918de65bd3aa 100644 --- a/pkg/cmd/roachtest/tests/flowable.go +++ b/pkg/cmd/roachtest/tests/flowable.go @@ -12,6 +12,7 @@ package tests import ( "context" + "fmt" "regexp" "github.com/cockroachdb/cockroach/pkg/cmd/roachtest/cluster" @@ -39,6 +40,29 @@ func registerFlowable(r registry.Registry) { c.Put(ctx, t.Cockroach(), "./cockroach", c.All()) c.Start(ctx, t.L(), option.DefaultStartOpts(), install.MakeClusterSettings(), c.All()) + t.Status("creating database used by tests") + db, err := c.ConnE(ctx, t.L(), node[0]) + if err != nil { + t.Fatal(err) + } + defer db.Close() + + if _, err := db.ExecContext( + ctx, `CREATE DATABASE flowable;`, + ); err != nil { + t.Fatal(err) + } + if _, err := db.ExecContext( + ctx, `CREATE USER flowable;`, + ); err != nil { + t.Fatal(err) + } + if _, err := db.ExecContext( + ctx, `GRANT admin TO flowable;`, + ); err != nil { + t.Fatal(err) + } + t.Status("cloning flowable and installing prerequisites") latestTag, err := repeatGetLatestTag( ctx, t, "flowable", "flowable-engine", flowableReleaseTagRegex, @@ -60,7 +84,7 @@ func registerFlowable(r registry.Registry) { c, node, "install dependencies", - `sudo apt-get -qq install default-jre openjdk-8-jdk-headless gradle maven`, + `sudo apt-get -qq install default-jre openjdk-17-jdk-headless gradle maven`, ); err != nil { t.Fatal(err) } @@ -90,13 +114,32 @@ func registerFlowable(r registry.Registry) { c, node, "building Flowable", - `cd /mnt/data1/flowable-engine/ && mvn clean install -DskipTests`, + `cd /mnt/data1/flowable-engine/ && ./mvnw clean install -DskipTests`, + ); err != nil { + t.Fatal(err) + } + + if err := repeatRunE( + ctx, + t, + c, + node, + "configuring tests for cockroachdb", + fmt.Sprintf(`mkdir -p $HOME/.flowable/jdbc/ && \ +echo "%s" > $HOME/.flowable/jdbc/build.flowable6.cockroachdb.properties && \ +cd /mnt/data1/flowable-engine/ && \ +echo '%s' > flowable_crdb.patch && \ +git apply --ignore-whitespace flowable_crdb.patch && \ +grep "force-commit" . -lr | xargs sed -i 's/-- force-commit//g'`, + flowableParams, flowablePatch, + ), ); err != nil { t.Fatal(err) } if err := c.RunE(ctx, node, - `cd /mnt/data1/flowable-engine/ && mvn clean test -Dtest=Flowable6Test#testLongServiceTaskLoop -Ddb=crdb`, + `cd /mnt/data1/flowable-engine/ && \ +./mvnw clean test -Dtest=Flowable6Test#testLongServiceTaskLoop -Ddatabase=cockroachdb`, ); err != nil { t.Fatal(err) } @@ -111,3 +154,32 @@ func registerFlowable(r registry.Registry) { }, }) } + +const flowableParams = ` +jdbc.url=jdbc:postgresql://127.0.0.1:26257/flowable?sslmode=disable +jdbc.driver=org.postgresql.Driver +jdbc.username=flowable +jdbc.password +` + +// This patch will not be needed once https://github.com/flowable/flowable-engine/pull/3752 +// is merged. +const flowablePatch = ` +diff --git a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/persistence/entity/TableDataManagerImpl.java b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/persistence/entity/TableDataManagerImpl.java +index 38a332b785..620ed787bf 100644 +--- a/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/persistence/entity/TableDataManagerImpl.java ++++ b/modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/persistence/entity/TableDataManagerImpl.java +@@ -101,6 +101,12 @@ public class TableDataManagerImpl implements TableDataManager { + List tableNames = new ArrayList<>(); + try (ResultSet tables = databaseMetaData.getTables(catalog, schema, tableNameFilter, DbSqlSession.JDBC_METADATA_TABLE_TYPES)) { + while (tables.next()) { ++ if ("cockroachdb".equals(getDbSqlSession().getDbSqlSessionFactory().getDatabaseType())) { ++ String schemaName = tables.getString("TABLE_SCHEM"); ++ if ("crdb_internal".equals(schemaName)) { ++ continue; ++ } ++ } + String tableName = tables.getString("TABLE_NAME"); + tableName = tableName.toUpperCase(Locale.ROOT); + tableNames.add(tableName); +`