From 911dc6202ffcb7c78b694cd9a62aacec05353f8b Mon Sep 17 00:00:00 2001 From: rhkp Date: Tue, 22 Oct 2024 19:07:06 +0000 Subject: [PATCH 1/7] Add kogito-db-migrator-tool and kogito-db-migrator-tool-image packages --- .gitignore | 5 +- .../kogito-db-migrator-tool-image/README.md | 116 ++++++++++++++++++ .../env/index.js | 54 ++++++++ .../kogito-db-migrator-tool-image/install.js | 64 ++++++++++ .../package.json | 44 +++++++ ...tor-kie-kogito-db-migrator-tool-image.yaml | 50 ++++++++ .../module.yaml | 26 ++++ packages/kogito-db-migrator-tool/.gitignore | 4 + packages/kogito-db-migrator-tool/README.md | 31 +++++ packages/kogito-db-migrator-tool/env/index.js | 31 +++++ packages/kogito-db-migrator-tool/install.js | 27 ++++ packages/kogito-db-migrator-tool/package.json | 37 ++++++ packages/kogito-db-migrator-tool/pom.xml | 107 ++++++++++++++++ .../migrator/DBConnectionChecker.java | 66 ++++++++++ .../postgresql/migrator/DBMigrator.java | 94 ++++++++++++++ .../postgresql/migrator/MigrationService.java | 66 ++++++++++ .../src/main/resources/application.properties | 40 ++++++ .../migrator/DBConnectionCheckerTest.java | 72 +++++++++++ .../postgresql/migrator/DBMigratorTest.java | 102 +++++++++++++++ .../migrator/MigrationServiceTest.java | 80 ++++++++++++ packages/maven-base/pom.xml | 20 +++ .../scripts/build-kogito-apps-components.sh | 3 + pnpm-lock.yaml | 44 +++++++ repo/graph.dot | 5 + repo/graph.json | 19 +++ 25 files changed, 1205 insertions(+), 2 deletions(-) create mode 100644 packages/kogito-db-migrator-tool-image/README.md create mode 100644 packages/kogito-db-migrator-tool-image/env/index.js create mode 100644 packages/kogito-db-migrator-tool-image/install.js create mode 100644 packages/kogito-db-migrator-tool-image/package.json create mode 100644 packages/kogito-db-migrator-tool-image/resources/incubator-kie-kogito-db-migrator-tool-image.yaml create mode 100644 packages/kogito-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml create mode 100644 packages/kogito-db-migrator-tool/.gitignore create mode 100644 packages/kogito-db-migrator-tool/README.md create mode 100644 packages/kogito-db-migrator-tool/env/index.js create mode 100644 packages/kogito-db-migrator-tool/install.js create mode 100644 packages/kogito-db-migrator-tool/package.json create mode 100644 packages/kogito-db-migrator-tool/pom.xml create mode 100644 packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBConnectionChecker.java create mode 100644 packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBMigrator.java create mode 100644 packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/MigrationService.java create mode 100644 packages/kogito-db-migrator-tool/src/main/resources/application.properties create mode 100644 packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBConnectionCheckerTest.java create mode 100644 packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBMigratorTest.java create mode 100644 packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/MigrationServiceTest.java diff --git a/.gitignore b/.gitignore index 9b7817e7c6f..e68db79f20f 100644 --- a/.gitignore +++ b/.gitignore @@ -347,6 +347,7 @@ turbo.json packages/*/.idea examples/*/.idea - +# Jar files +**/*.jar # Apache RAT check excludes file -!.rat-excludes \ No newline at end of file +!.rat-excludes diff --git a/packages/kogito-db-migrator-tool-image/README.md b/packages/kogito-db-migrator-tool-image/README.md new file mode 100644 index 00000000000..4af61293cea --- /dev/null +++ b/packages/kogito-db-migrator-tool-image/README.md @@ -0,0 +1,116 @@ + + +# Kogito Postgres DB Migrator Tool Image + +This package contains the `Containerfile/Dockerfile` and scripts to build a container image for Kogito Postgres DB Migrator Tool. Details about the Kogito Postgres DB Migrator Tool can be found [here](../kogito-db-migrator-tool/README.md) + +## Additional requirements + +- docker + +## Build + +_NOTE_: Before performing this step, be sure that the Kogito Postgres DB Migrator Tool jar has been built and available for inclusion in the image. + +- Enable the image to be built: + + ```bash + export KIE_TOOLS_BUILD__buildContainerImages=true + ``` + +Run the following in the root folder of the repository to build the package: + +```bash +pnpm -F @kie-tools/kogito-db-migrator-tool-image... build:prod +``` + +- Then check if the image is correctly stored: + + ```bash + docker images + ``` + +## Run + +- Start up a clean container with: + + ```bash + docker run docker.io/apache/incubator-kie-kogito-service-db-migration-postgresql:latest + ``` + +## Customization + +1. Run a container with custom environment variables: + +| NAME | DESCRIPTION | DEFAULT | +| --------------------------------------- | -------------------------------------------------------------------------------- | ----------------------------------------- | +| MIGRATE_DB_DATAINDEX | Set to true if you want to migrate data index database, set to false otherwise | false | +| QUARKUS_DATASOURCE_DATAINDEX_JDBC_URL | Data index database url e.g. jdbc:postgresql://host.docker.internal:5432/di | jdbc:postgresql://localhost:5432/postgres | +| QUARKUS_DATASOURCE_DATAINDEX_USERNAME | Data index database username | postgres | +| QUARKUS_DATASOURCE_DATAINDEX_PASSWORD | Data index database password | postgres | +| QUARKUS_FLYWAY_DATAINDEX_SCHEMAS | Data index database schema | data-index-service | +| MIGRATE_DB_JOBSSERVICE | Set to true if you want to migrate jobs service database, set to false otherwise | false | +| QUARKUS_DATASOURCE_JOBSSERVICE_JDBC_URL | Jobs service database url e.g. jdbc:postgresql://host.docker.internal:5432/js | jdbc:postgresql://localhost:5432/postgres | +| QUARKUS_DATASOURCE_JOBSSERVICE_USERNAME | Jobs service database username | postgres | +| QUARKUS_DATASOURCE_JOBSSERVICE_PASSWORD | Jobs service database password | postgres | +| QUARKUS_FLYWAY_JOBSSERVICE_SCHEMAS | Jobs service database schema | jobs-service | + +### Example + +An example to use diverse environment variables + +```bash + docker run \ + --env MIGRATE_DB_DATAINDEX=true \ + --env QUARKUS_DATASOURCE_DATAINDEX_JDBC_URL= \ + --env QUARKUS_DATASOURCE_DATAINDEX_USERNAME= \ + --env QUARKUS_DATASOURCE_DATAINDEX_PASSWORD= \ + --env QUARKUS_FLYWAY_DATAINDEX_SCHEMAS=data-index-service \ + --env MIGRATE_DB_JOBSSERVICE=true \ + --env QUARKUS_DATASOURCE_JOBSSERVICE_JDBC_URL= \ + --env QUARKUS_DATASOURCE_JOBSSERVICE_USERNAME= \ + --env QUARKUS_DATASOURCE_JOBSSERVICE_PASSWORD= \ + --env QUARKUS_FLYWAY_JOBSSERVICE_SCHEMAS=jobs-service \ + docker.io/apache/incubator-kie-kogito-db-migrator-tool:main +``` + +--- + +Apache KIE (incubating) is an effort undergoing incubation at The Apache Software +Foundation (ASF), sponsored by the name of Apache Incubator. Incubation is +required of all newly accepted projects until a further review indicates that +the infrastructure, communications, and decision making process have stabilized +in a manner consistent with other successful ASF projects. While incubation +status is not necessarily a reflection of the completeness or stability of the +code, it does indicate that the project has yet to be fully endorsed by the ASF. + +Some of the incubating project’s releases may not be fully compliant with ASF +policy. For example, releases may have incomplete or un-reviewed licensing +conditions. What follows is a list of known issues the project is currently +aware of (note that this list, by definition, is likely to be incomplete): + +- Hibernate, an LGPL project, is being used. Hibernate is in the process of + relicensing to ASL v2 +- Some files, particularly test files, and those not supporting comments, may + be missing the ASF Licensing Header + +If you are planning to incorporate this work into your product/project, please +be aware that you will need to conduct a thorough licensing review to determine +the overall implications of including this work. For the current status of this +project through the Apache Incubator visit: +https://incubator.apache.org/projects/kie.html diff --git a/packages/kogito-db-migrator-tool-image/env/index.js b/packages/kogito-db-migrator-tool-image/env/index.js new file mode 100644 index 00000000000..00dc1399d44 --- /dev/null +++ b/packages/kogito-db-migrator-tool-image/env/index.js @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +const { varsWithName, composeEnv, getOrDefault } = require("@kie-tools-scripts/build-env"); + +const rootEnv = require("@kie-tools/root-env/env"); +const sonataflowImageCommonEnv = require("@kie-tools/sonataflow-image-common/env"); + +module.exports = composeEnv([rootEnv, sonataflowImageCommonEnv], { + vars: varsWithName({ + KOGITO_DB_MIGRATOR_TOOL_IMAGE__registry: { + default: "docker.io", + description: "The image registry.", + }, + KOGITO_DB_MIGRATOR_TOOL_IMAGE__account: { + default: "apache", + description: "The image registry account.", + }, + KOGITO_DB_MIGRATOR_TOOL_IMAGE__name: { + default: "incubator-kie-kogito-db-migrator-tool", + description: "The image name.", + }, + KOGITO_DB_MIGRATOR_TOOL_IMAGE__buildTag: { + default: rootEnv.env.root.streamName, + description: "The image tag.", + }, + }), + get env() { + return { + kogitoDbMigratorToolImage: { + registry: getOrDefault(this.vars.KOGITO_DB_MIGRATOR_TOOL_IMAGE__registry), + account: getOrDefault(this.vars.KOGITO_DB_MIGRATOR_TOOL_IMAGE__account), + name: getOrDefault(this.vars.KOGITO_DB_MIGRATOR_TOOL_IMAGE__name), + buildTag: getOrDefault(this.vars.KOGITO_DB_MIGRATOR_TOOL_IMAGE__buildTag), + }, + }; + }, +}); diff --git a/packages/kogito-db-migrator-tool-image/install.js b/packages/kogito-db-migrator-tool-image/install.js new file mode 100644 index 00000000000..cec8142a81d --- /dev/null +++ b/packages/kogito-db-migrator-tool-image/install.js @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +const { execSync } = require("child_process"); +const fs = require("fs"); + +const { env } = require("./env"); +const path = require("path"); +const pythonVenvDir = path.dirname(require.resolve("@kie-tools/python-venv/package.json")); +const sonataflowImageCommonDir = path.dirname(require.resolve("@kie-tools/sonataflow-image-common/package.json")); +const replaceInFile = require("replace-in-file"); + +const activateCmd = + process.platform === "win32" + ? `${pythonVenvDir}\\venv\\Scripts\\Activate.bat` + : `. ${pythonVenvDir}/venv/bin/activate`; + +execSync( + `${activateCmd} && \ + python3 ${sonataflowImageCommonDir}/resources/scripts/versions_manager.py --bump-to ${env.kogitoDbMigratorToolImage.buildTag} --source-folder ./resources`, + { stdio: "inherit" } +); + +// Find and read the -image.yaml file +const resourcesPath = path.resolve(__dirname, "./resources"); +const files = fs.readdirSync(resourcesPath); +const imageYamlFiles = files.filter((fileName) => fileName.endsWith("image.yaml")); +if (imageYamlFiles.length !== 1) { + throw new Error("There should only be one image.yaml file on ./resources!"); +} +const originalYamlPath = path.join(resourcesPath, imageYamlFiles[0]); +let imageYaml = fs.readFileSync(originalYamlPath, "utf8"); + +const imageUrl = `${env.kogitoDbMigratorToolImage.registry}/${env.kogitoDbMigratorToolImage.account}/${env.kogitoDbMigratorToolImage.name}`; + +// Replace the whole string between quotes ("") with the image name +imageYaml = imageYaml.replace(/(?<=")(.*kie-kogito-db-migrator-tool.*)(?=")/gm, imageUrl); + +// Write file and then rename it to match the image name +fs.writeFileSync(originalYamlPath, imageYaml); +fs.renameSync(originalYamlPath, path.join(resourcesPath, `${env.kogitoDbMigratorToolImage.name}-image.yaml`)); + +// Replace image URL in .feature files +replaceInFile.sync({ + files: ["**/*.feature"], + from: /@docker.io\/apache\/.*/g, + to: `@${imageUrl}`, +}); diff --git a/packages/kogito-db-migrator-tool-image/package.json b/packages/kogito-db-migrator-tool-image/package.json new file mode 100644 index 00000000000..8eac25601cd --- /dev/null +++ b/packages/kogito-db-migrator-tool-image/package.json @@ -0,0 +1,44 @@ +{ + "private": true, + "name": "@kie-tools/kogito-db-migrator-tool-image", + "version": "0.0.0", + "description": "", + "license": "Apache-2.0", + "homepage": "https://github.com/apache/incubator-kie-tools", + "repository": { + "type": "git", + "url": "https://github.com/apache/incubator-kie-tools.git" + }, + "bugs": { + "url": "https://github.com/apache/incubator-kie-tools/issues" + }, + "scripts": { + "build": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate && pnpm copy-assets && pnpm image:build && rimraf target && rimraf dist-tests-e2e", + "build:dev": "run-script-os", + "build:dev:linux": "pnpm build", + "build:dev:win32:darwin": "echo \"Build skipped on Windows and MacOS\"", + "build:prod": "run-script-os", + "build:prod:linux": "pnpm build", + "build:prod:win32:darwin": "echo \"Build skipped on Windows and MacOS\"", + "copy-assets": "run-script-os", + "copy-assets:linux:darwin": "rimraf build && cp -R ./node_modules/@kie-tools/sonataflow-image-common/resources build && cp -R resources/* build && mkdir -p build/modules/kogito-postgres-db-migration-deps/quarkus-app && cp -R ./node_modules/@kie-tools/kogito-db-migrator-tool/target/quarkus-app/* build/modules/kogito-postgres-db-migration-deps/quarkus-app", + "format": "prettier --write . --ignore-path=../../.prettierignore --ignore-path=../../.gitignore", + "image:build": "run-script-os", + "image:build:linux": "pnpm setup:env make -C ./build build", + "image:build:win32:darwin": "echo \"Build skipped on Windows and MacOS\"", + "install": "node install.js && pnpm format", + "setup:env": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate && cross-env KOGITO_IMAGE_REGISTRY=$(build-env kogitoDbMigratorToolImage.registry) KOGITO_IMAGE_REGISTRY_ACCOUNT=$(build-env kogitoDbMigratorToolImage.account) KOGITO_IMAGE_NAME=$(build-env kogitoDbMigratorToolImage.name) KOGITO_IMAGE_TAG=$(build-env kogitoDbMigratorToolImage.buildTag) QUARKUS_PLATFORM_GROUPID=$(build-env kogitoImagesCekitModules.quarkusGroupId) QUARKUS_PLATFORM_VERSION=$(build-env versions.quarkus) KOGITO_VERSION=$(build-env versions.kogito)" + }, + "dependencies": { + "@kie-tools/kogito-db-migrator-tool": "workspace:*", + "@kie-tools/python-venv": "workspace:*", + "@kie-tools/root-env": "workspace:*", + "@kie-tools/sonataflow-image-common": "workspace:*" + }, + "devDependencies": { + "cross-env": "^7.0.3", + "replace-in-file": "^7.1.0", + "rimraf": "^3.0.2", + "run-script-os": "^1.1.6" + } +} diff --git a/packages/kogito-db-migrator-tool-image/resources/incubator-kie-kogito-db-migrator-tool-image.yaml b/packages/kogito-db-migrator-tool-image/resources/incubator-kie-kogito-db-migrator-tool-image.yaml new file mode 100644 index 00000000000..fd29a2f39e5 --- /dev/null +++ b/packages/kogito-db-migrator-tool-image/resources/incubator-kie-kogito-db-migrator-tool-image.yaml @@ -0,0 +1,50 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +name: "docker.io/apache/incubator-kie-kogito-db-migrator-tool" +version: "main" +from: registry.access.redhat.com/ubi8/openjdk-17-runtime:1.20 +description: DBMigratorTool image for Data Index and Jobs Service database migration + +labels: + - name: "org.kie.kogito.version" + value: "### SET ME DURING BUILD PROCESS ###" + - name: "maintainer" + value: "Apache KIE " + - name: "io.k8s.description" + value: "Kogito DB Migration creates schemas and tables for Data Index and Jobs Service for PostgreSQL database" + - name: "io.k8s.display-name" + value: "Kogito DB Migration for Data Index and Jobs Service - PostgreSQL" + - name: "io.openshift.tags" + value: "kogito,db-migration" + +modules: + repositories: + - path: modules + install: + - name: org.kie.kogito.system.user + - name: org.kie.kogito.project.versions + - name: org.kie.kogito.postgresql.db-migration-deps + +run: + workdir: "/home/kogito/bin" + entrypoint: + - "java" + cmd: + - "-jar" + - "./quarkus-run.jar" diff --git a/packages/kogito-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml b/packages/kogito-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml new file mode 100644 index 00000000000..3cb2a3a8a85 --- /dev/null +++ b/packages/kogito-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml @@ -0,0 +1,26 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +schema_version: 1 +name: org.kie.kogito.postgresql.db-migration-deps +version: "main" +artifacts: + # The following artifact comes from the package kogito-db-migrator-tool during the pnpm build:dev phase + - name: kogito-db-migrator-tool-quarkus-app + path: ./quarkus-app + dest: /home/kogito/bin diff --git a/packages/kogito-db-migrator-tool/.gitignore b/packages/kogito-db-migrator-tool/.gitignore new file mode 100644 index 00000000000..8404612fa0f --- /dev/null +++ b/packages/kogito-db-migrator-tool/.gitignore @@ -0,0 +1,4 @@ +# kogito-db-migrator-tool +src/main/resources/postgresql +src/main/resources/ansi +src/main/resources/h2 \ No newline at end of file diff --git a/packages/kogito-db-migrator-tool/README.md b/packages/kogito-db-migrator-tool/README.md new file mode 100644 index 00000000000..18e28f7eea9 --- /dev/null +++ b/packages/kogito-db-migrator-tool/README.md @@ -0,0 +1,31 @@ +# Kogito Postgres DB Migrator Tool + +This is a Java, Quarkus-based PostgreSQL database migrator application for Data-Index and Jobs Service applications for use by SonataFlow Operator. + +_NOTE_: This postgres database migrator application and its corresponding images are only envisaged to be made use of by SonataFlow Operator, Data Index and Jobs Service internally. Conversely this application is of no use outside the usecases involved with SonataFlow Operator, Data Index and Jobs Service applications. + +--- + +Apache KIE (incubating) is an effort undergoing incubation at The Apache Software +Foundation (ASF), sponsored by the name of Apache Incubator. Incubation is +required of all newly accepted projects until a further review indicates that +the infrastructure, communications, and decision making process have stabilized +in a manner consistent with other successful ASF projects. While incubation +status is not necessarily a reflection of the completeness or stability of the +code, it does indicate that the project has yet to be fully endorsed by the ASF. + +Some of the incubating project’s releases may not be fully compliant with ASF +policy. For example, releases may have incomplete or un-reviewed licensing +conditions. What follows is a list of known issues the project is currently +aware of (note that this list, by definition, is likely to be incomplete): + +- Hibernate, an LGPL project, is being used. Hibernate is in the process of + relicensing to ASL v2 +- Some files, particularly test files, and those not supporting comments, may + be missing the ASF Licensing Header + +If you are planning to incorporate this work into your product/project, please +be aware that you will need to conduct a thorough licensing review to determine +the overall implications of including this work. For the current status of this +project through the Apache Incubator visit: +https://incubator.apache.org/projects/kie.html diff --git a/packages/kogito-db-migrator-tool/env/index.js b/packages/kogito-db-migrator-tool/env/index.js new file mode 100644 index 00000000000..fa7de21dad9 --- /dev/null +++ b/packages/kogito-db-migrator-tool/env/index.js @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +const { varsWithName, composeEnv } = require("@kie-tools-scripts/build-env"); + +module.exports = composeEnv([require("@kie-tools/root-env/env"), require("@kie-tools/maven-base/env")], { + vars: varsWithName({}), + get env() { + return { + kogitoDBMigratorTool: { + version: require("../package.json").version, + }, + }; + }, +}); diff --git a/packages/kogito-db-migrator-tool/install.js b/packages/kogito-db-migrator-tool/install.js new file mode 100644 index 00000000000..281ee1f9f2a --- /dev/null +++ b/packages/kogito-db-migrator-tool/install.js @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +const { env } = require("./env"); +const { setupMavenConfigFile, buildTailFromPackageJsonDependencies } = require("@kie-tools/maven-base"); + +setupMavenConfigFile( + ` + -Drevision=${env.kogitoDBMigratorTool.version} + -Dmaven.repo.local.tail=${buildTailFromPackageJsonDependencies()} +` +); diff --git a/packages/kogito-db-migrator-tool/package.json b/packages/kogito-db-migrator-tool/package.json new file mode 100644 index 00000000000..7ca5e31839b --- /dev/null +++ b/packages/kogito-db-migrator-tool/package.json @@ -0,0 +1,37 @@ +{ + "private": true, + "name": "@kie-tools/kogito-db-migrator-tool", + "version": "0.0.0", + "description": "", + "license": "Apache-2.0", + "homepage": "https://github.com/apache/incubator-kie-tools", + "repository": { + "type": "git", + "url": "https://github.com/apache/incubator-kie-tools.git" + }, + "bugs": { + "url": "https://github.com/apache/incubator-kie-tools/issues" + }, + "scripts": { + "build:dev": "pnpm pre-build && mvn clean install -DskipTests", + "build:prod": "pnpm pre-build && run-script-os", + "build:prod:darwin:linux": "mvn clean install -DskipTests=$(build-env tests.run --not) -Dmaven.test.failure.ignore=$(build-env tests.ignoreFailures)", + "build:prod:win32": "pnpm powershell \"mvn clean install `-DskipTests=$(build-env tests.run --not) `-Dmaven.test.failure.ignore=$(build-env tests.ignoreFailures)\"", + "install": "node install.js", + "pre-build": "mvn dependency:unpack" + }, + "dependencies": { + "@kie-tools/maven-base": "workspace:*" + }, + "devDependencies": { + "@kie-tools/root-env": "workspace:*", + "rimraf": "^3.0.2", + "run-script-os": "^1.1.6" + }, + "kieTools": { + "requiredPreinstalledCliCommands": [ + "java", + "mvn" + ] + } +} diff --git a/packages/kogito-db-migrator-tool/pom.xml b/packages/kogito-db-migrator-tool/pom.xml new file mode 100644 index 00000000000..92cdeaaa5ea --- /dev/null +++ b/packages/kogito-db-migrator-tool/pom.xml @@ -0,0 +1,107 @@ + + + + + org.kie + kie-tools-maven-base + ${revision} + ./node_modules/@kie-tools/maven-base/pom.xml + + + 4.0.0 + org.kie.kogito + kogito-db-migrator-tool + + + + io.quarkus + quarkus-flyway + + + io.quarkus + quarkus-jdbc-postgresql + + + io.quarkus + quarkus-arc + + + io.quarkus + quarkus-junit5 + test + + + org.mockito + mockito-junit-jupiter + test + + + org.mockito + mockito-core + test + + + + + src/test/java + + + + maven-dependency-plugin + + + + org.kie.kogito + kogito-ddl + ${version.org.kie.kogito} + db-scripts + zip + true + src/main/resources + kogito-ddl-db-scripts.zip + ansi/* + + + + + + io.quarkus + quarkus-maven-plugin + true + + + + build + + + + + + -parameters + + + + + + diff --git a/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBConnectionChecker.java b/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBConnectionChecker.java new file mode 100644 index 00000000000..c9143f850cc --- /dev/null +++ b/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBConnectionChecker.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.kogito.postgresql.migrator; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import io.quarkus.logging.Log; + +import org.eclipse.microprofile.config.inject.ConfigProperty; + +import jakarta.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class DBConnectionChecker { + @ConfigProperty(name = "quarkus.datasource.dataindex.jdbc.url") + String dataIndexDBURL; + + @ConfigProperty(name = "quarkus.datasource.dataindex.username") + String dataIndexDBUserName; + + @ConfigProperty(name = "quarkus.datasource.dataindex.password") + String dataIndexDBPassword; + + @ConfigProperty(name = "quarkus.datasource.jobsservice.jdbc.url") + String jobsServiceDBURL; + + @ConfigProperty(name = "quarkus.datasource.jobsservice.username") + String jobsServiceDBUserName; + + @ConfigProperty(name = "quarkus.datasource.jobsservice.password") + String jobsServiceDBPassword; + + private void checkDBConnection(String dbURL, String dbUser, String dbPassword) throws SQLException { + try (Connection db = DriverManager.getConnection(dbURL, dbUser, dbPassword)) { + Log.infof("Checking DB connection: %s - success", dbURL); + } catch (SQLException sqe) { + Log.infof("Checking DB connection %s- failed", dbURL); + throw sqe; + } + } + + public void checkDataIndexDBConnection() throws SQLException { + checkDBConnection(dataIndexDBURL, dataIndexDBUserName, dataIndexDBPassword); + } + + public void checkJobsServiceDBConnection() throws SQLException { + checkDBConnection(jobsServiceDBURL, jobsServiceDBUserName, jobsServiceDBPassword); + } +} diff --git a/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBMigrator.java b/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBMigrator.java new file mode 100644 index 00000000000..67c3f5e46a9 --- /dev/null +++ b/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBMigrator.java @@ -0,0 +1,94 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.kogito.postgresql.migrator; + +import io.quarkus.runtime.Quarkus; +import io.quarkus.runtime.QuarkusApplication; +import io.quarkus.runtime.annotations.QuarkusMain; +import jakarta.inject.Inject; +import io.quarkus.logging.Log; +import org.flywaydb.core.api.FlywayException; + +import java.sql.SQLException; + +import org.eclipse.microprofile.config.inject.ConfigProperty; + +@QuarkusMain +public class DBMigrator implements QuarkusApplication { + + private int SUCCESS_DB_MIGRATION = 0; + private int ERR_DATA_INDEX_DB_CONN = -1; + private int ERR_JOBS_SERVICE_DB_CONN = -2; + private int ERR_DATA_INDEX_MIGRATION = -3; + private int ERR_JOBS_SERVICE_MIGRATION = -4; + + @Inject + MigrationService service; + + @Inject + DBConnectionChecker dbConnectionChecker; + + @ConfigProperty(name = "migrate.db.dataindex") + Boolean migrateDataIndex; + + @ConfigProperty(name = "migrate.db.jobsservice") + Boolean migrateJobsService; + + @Override + public int run(String... args) { + if (migrateDataIndex) { + try { + dbConnectionChecker.checkDataIndexDBConnection(); + } catch (SQLException e) { + Log.error( "Error obtaining data index database connection. Cannot proceed, exiting."); + Quarkus.asyncExit(ERR_DATA_INDEX_DB_CONN); + return ERR_DATA_INDEX_DB_CONN; + } + + try{ + service.migrateDataIndex(); + } catch ( FlywayException fe ){ + Log.error( "Error migrating data index database, flyway service exception occured, please check logs."); + Quarkus.asyncExit(ERR_DATA_INDEX_MIGRATION); + return ERR_DATA_INDEX_MIGRATION; + } + } + + if (migrateJobsService) { + try { + dbConnectionChecker.checkJobsServiceDBConnection(); + } catch (SQLException e) { + Log.error( "Error obtaining jobs service database connection. Cannot proceed, exiting."); + Quarkus.asyncExit(ERR_JOBS_SERVICE_DB_CONN); + return ERR_JOBS_SERVICE_DB_CONN; + } + + try{ + service.migrateJobsService(); + } catch ( FlywayException fe ){ + Log.error( "Error migrating jobs service database, flyway service exception occured, please check logs."); + Quarkus.asyncExit(ERR_JOBS_SERVICE_MIGRATION); + return ERR_JOBS_SERVICE_MIGRATION; + } + } + + Quarkus.asyncExit(SUCCESS_DB_MIGRATION); + return SUCCESS_DB_MIGRATION; + } +} \ No newline at end of file diff --git a/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/MigrationService.java b/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/MigrationService.java new file mode 100644 index 00000000000..f6a86d704e0 --- /dev/null +++ b/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/MigrationService.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.kie.kogito.postgresql.migrator; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; +import io.quarkus.logging.Log; + +import org.eclipse.microprofile.config.inject.ConfigProperty; +import org.flywaydb.core.Flyway; + +import io.quarkus.flyway.FlywayDataSource; + +@ApplicationScoped +public class MigrationService { + @Inject + @FlywayDataSource("dataindex") + Flyway flywayDataIndex; + + @Inject + @FlywayDataSource("jobsservice") + Flyway flywayJobsService; + + @ConfigProperty(name = "quarkus.flyway.dataindex.clean-at-start") + Boolean cleanDataIndex; + + @ConfigProperty(name = "quarkus.flyway.jobsservice.clean-at-start") + Boolean cleanJobsService; + + private void migrateDB(Flyway flywayService, Boolean clean, String serviceName) { + Log.info("Migrating " + serviceName); + if (clean) { + Log.info("Cleaned the " + serviceName); + flywayService.clean(); + } + flywayService.migrate(); + if (flywayService.info() != null) { + Log.info("Migrated to version " + flywayService.info().current().toString()); + } + } + + public void migrateDataIndex() { + migrateDB(flywayDataIndex, cleanDataIndex, "data-index"); + } + + public void migrateJobsService() { + migrateDB(flywayJobsService, cleanJobsService, "jobs-service"); + } +} \ No newline at end of file diff --git a/packages/kogito-db-migrator-tool/src/main/resources/application.properties b/packages/kogito-db-migrator-tool/src/main/resources/application.properties new file mode 100644 index 00000000000..5f18a83ff28 --- /dev/null +++ b/packages/kogito-db-migrator-tool/src/main/resources/application.properties @@ -0,0 +1,40 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# Data Index data source +migrate.db.dataindex=false +quarkus.datasource.dataindex.db-kind=postgresql +quarkus.datasource.dataindex.username=postgres +quarkus.datasource.dataindex.password=postgres +quarkus.datasource.dataindex.jdbc.url=jdbc:postgresql://localhost:5432/postgres +quarkus.flyway.dataindex.locations=classpath:postgresql/data-index +quarkus.flyway.dataindex.schemas=data-index-service +quarkus.flyway.dataindex.migrate-at-start=false +quarkus.flyway.dataindex.clean-at-start=false + +# Jobs Service data source +migrate.db.jobsservice=false +quarkus.datasource.jobsservice.db-kind=postgresql +quarkus.datasource.jobsservice.username=postgres +quarkus.datasource.jobsservice.password=postgres +quarkus.datasource.jobsservice.jdbc.url=jdbc:postgresql://localhost:5432/postgres +quarkus.flyway.jobsservice.locations=classpath:postgresql/jobs-service +quarkus.flyway.jobsservice.schemas=jobs-service +quarkus.flyway.jobsservice.migrate-at-start=false +quarkus.flyway.jobsservice.clean-at-start=false \ No newline at end of file diff --git a/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBConnectionCheckerTest.java b/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBConnectionCheckerTest.java new file mode 100644 index 00000000000..77e23482f76 --- /dev/null +++ b/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBConnectionCheckerTest.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.kie.kogito.postgresql.migrator; + +import io.quarkus.test.Mock; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.mockStatic; + +class DBConnectionCheckerTest { + DBConnectionChecker dbConnectionChecker = new DBConnectionChecker(); + + @Mock + static DriverManager driverManager; + + @BeforeAll + static void init() { + mockStatic(DriverManager.class); + } + + @BeforeEach + void setupEach() { + dbConnectionChecker.dataIndexDBURL = "jdbc:postgresql://db-service:5432/di"; + dbConnectionChecker.dataIndexDBUserName = "postgres"; + dbConnectionChecker.dataIndexDBPassword = "postgres"; + + dbConnectionChecker.jobsServiceDBURL = "jdbc:postgresql://db-service:5432/js"; + dbConnectionChecker.jobsServiceDBUserName = "postgres"; + dbConnectionChecker.jobsServiceDBPassword = "postgres"; + } + + @Test + void testCheckDBConnections() throws SQLException { + Mockito.when(driverManager.getConnection(anyString(), anyString(), anyString())).thenReturn(Mockito.mock(Connection.class)); + assertDoesNotThrow(() -> dbConnectionChecker.checkDataIndexDBConnection()); + assertDoesNotThrow(() -> dbConnectionChecker.checkJobsServiceDBConnection()); + } + + @Test + void testCheckDBConnectionsThrowSQLException() throws SQLException { + Mockito.when(driverManager.getConnection(anyString(), anyString(), anyString())).thenThrow(SQLException.class); + assertThrows(SQLException.class, () -> dbConnectionChecker.checkDataIndexDBConnection()); + assertThrows(SQLException.class, () -> dbConnectionChecker.checkJobsServiceDBConnection()); + } +} diff --git a/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBMigratorTest.java b/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBMigratorTest.java new file mode 100644 index 00000000000..abb0516f364 --- /dev/null +++ b/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBMigratorTest.java @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.kie.kogito.postgresql.migrator; + +import io.quarkus.test.Mock; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.sql.SQLException; + +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.times; + +class DBMigratorTest { + + @Mock + MigrationService migrationService; + + @Mock + DBConnectionChecker dbConnectionChecker; + + DBMigrator dbMigrator = new DBMigrator(); + + @BeforeEach + void setupEach() { + migrationService = mock(MigrationService.class); + dbConnectionChecker = mock(DBConnectionChecker.class); + } + + @Test + void testMigratorWithNoMigrations() throws Exception { + dbMigrator.migrateDataIndex = false; + dbMigrator.migrateJobsService = false; + + dbMigrator.run(); + verify(dbConnectionChecker, times(0)).checkDataIndexDBConnection(); + verify(dbConnectionChecker, times(0)).checkJobsServiceDBConnection(); + verify(migrationService, times(0)).migrateDataIndex(); + verify(migrationService, times(0)).migrateJobsService(); + } + + @Test + void testMigratorWithAllMigrations() throws Exception { + dbMigrator.migrateDataIndex = true; + dbMigrator.migrateJobsService = true; + dbMigrator.dbConnectionChecker = dbConnectionChecker; + dbMigrator.service = migrationService; + + dbMigrator.run(); + verify(dbConnectionChecker, times(1)).checkDataIndexDBConnection(); + verify(dbConnectionChecker, times(1)).checkJobsServiceDBConnection(); + verify(migrationService, times(1)).migrateDataIndex(); + verify(migrationService, times(1)).migrateJobsService(); + } + + @Test + void testDataIndexMigrationWithException() throws Exception { + dbMigrator.migrateDataIndex = true; + dbMigrator.migrateJobsService = false; + dbMigrator.dbConnectionChecker = dbConnectionChecker; + dbMigrator.service = migrationService; + + doThrow(new SQLException()).when(dbConnectionChecker).checkDataIndexDBConnection(); + + dbMigrator.run(); + verify(migrationService, times(0)).migrateDataIndex(); + verify(migrationService, times(0)).migrateJobsService(); + } + + @Test + void testJobsServiceWithException() throws Exception { + dbMigrator.migrateDataIndex = false; + dbMigrator.migrateJobsService = true; + dbMigrator.dbConnectionChecker = dbConnectionChecker; + dbMigrator.service = migrationService; + + doThrow(new SQLException()).when(dbConnectionChecker).checkJobsServiceDBConnection(); + + dbMigrator.run(); + verify(migrationService, times(0)).migrateDataIndex(); + verify(migrationService, times(0)).migrateJobsService(); + } +} diff --git a/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/MigrationServiceTest.java b/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/MigrationServiceTest.java new file mode 100644 index 00000000000..b64f23f105d --- /dev/null +++ b/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/MigrationServiceTest.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.kie.kogito.postgresql.migrator; + +import io.quarkus.test.Mock; +import org.flywaydb.core.Flyway; +import org.flywaydb.core.api.output.CleanResult; +import org.flywaydb.core.api.output.MigrateResult; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.times; + +class MigrationServiceTest { + @Mock + Flyway flyway; + + MigrationService migrationService = new MigrationService(); + + @BeforeEach + void setupEach() { + flyway = mock(Flyway.class); + when(flyway.migrate()).thenReturn(new MigrateResult("flywayVersion", "db", "schema")); + when(flyway.clean()).thenReturn(new CleanResult("flywayVersion", "db")); + } + + @Test + void testMigrateDataIndexWithNoClean() { + migrationService.cleanDataIndex = false; + migrationService.flywayDataIndex = flyway; + migrationService.migrateDataIndex(); + verify(flyway, times(1)).migrate(); + } + + @Test + void testMigrateDataIndexWithClean() { + migrationService.cleanDataIndex = true; + migrationService.flywayDataIndex = flyway; + migrationService.migrateDataIndex(); + verify(flyway, times(1)).clean(); + verify(flyway, times(1)).migrate(); + } + + @Test + void testMigrateJobsServiceWithNoClean() { + migrationService.cleanJobsService = false; + migrationService.flywayJobsService = flyway; + migrationService.migrateJobsService(); + verify(flyway, times(1)).migrate(); + } + + @Test + void testMigrateJobsServiceWithClean() { + migrationService.cleanJobsService = true; + migrationService.flywayJobsService = flyway; + migrationService.migrateJobsService(); + verify(flyway, times(1)).clean(); + verify(flyway, times(1)).migrate(); + } +} diff --git a/packages/maven-base/pom.xml b/packages/maven-base/pom.xml index dd1518e52a8..b428d372ea8 100644 --- a/packages/maven-base/pom.xml +++ b/packages/maven-base/pom.xml @@ -140,6 +140,7 @@ 4.11.0 0.4 0.23.0 + 0.8.12 @@ -408,6 +409,25 @@ + + org.jacoco + jacoco-maven-plugin + ${version.jacoco.maven.plugin} + + + + prepare-agent + + + + report + prepare-package + + report + + + + diff --git a/packages/sonataflow-image-common/resources/scripts/build-kogito-apps-components.sh b/packages/sonataflow-image-common/resources/scripts/build-kogito-apps-components.sh index 12a2f50f03c..fc661b7dcdc 100755 --- a/packages/sonataflow-image-common/resources/scripts/build-kogito-apps-components.sh +++ b/packages/sonataflow-image-common/resources/scripts/build-kogito-apps-components.sh @@ -56,6 +56,9 @@ if [ ! -z "${CYPRESS_BINARY_URL}" ]; then fi case ${imageName} in + "incubator-kie-kogito-db-migrator-tool") + contextDir="db-migrator-tool/image" + ;; "incubator-kie-kogito-data-index-ephemeral") contextDir="data-index/data-index-service/data-index-service-inmemory" ;; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4ad259e4e41..a18bdfc6c42 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7403,6 +7403,50 @@ importers: specifier: ^1.1.6 version: 1.1.6 + packages/kogito-db-migrator-tool: + dependencies: + '@kie-tools/maven-base': + specifier: workspace:* + version: link:../maven-base + devDependencies: + '@kie-tools/root-env': + specifier: workspace:* + version: link:../root-env + rimraf: + specifier: ^3.0.2 + version: 3.0.2 + run-script-os: + specifier: ^1.1.6 + version: 1.1.6 + + packages/kogito-db-migrator-tool-image: + dependencies: + '@kie-tools/kogito-db-migrator-tool': + specifier: workspace:* + version: link:../kogito-db-migrator-tool + '@kie-tools/python-venv': + specifier: workspace:* + version: link:../python-venv + '@kie-tools/root-env': + specifier: workspace:* + version: link:../root-env + '@kie-tools/sonataflow-image-common': + specifier: workspace:* + version: link:../sonataflow-image-common + devDependencies: + cross-env: + specifier: ^7.0.3 + version: 7.0.3 + replace-in-file: + specifier: ^7.1.0 + version: 7.1.0 + rimraf: + specifier: ^3.0.2 + version: 3.0.2 + run-script-os: + specifier: ^1.1.6 + version: 1.1.6 + packages/kogito-jit-runner-image: devDependencies: '@kie-tools/maven-base': diff --git a/repo/graph.dot b/repo/graph.dot index f8a1a25983c..dab90395800 100644 --- a/repo/graph.dot +++ b/repo/graph.dot @@ -150,6 +150,8 @@ digraph G { "@kie-tools/sonataflow-image-common" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie/kogito-data-index-ephemeral-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie/kogito-data-index-postgresql-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; + "@kie-tools/kogito-db-migrator-tool" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; + "@kie-tools/kogito-db-migrator-tool-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie/kogito-jit-runner-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie/kogito-jobs-service-allinone-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie/kogito-jobs-service-ephemeral-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; @@ -471,6 +473,9 @@ digraph G { "@kie/kogito-data-index-ephemeral-image" -> "@kie-tools/sonataflow-image-common" [ style = "dashed", color = "black" ]; "@kie/kogito-data-index-postgresql-image" -> "@kie-tools/maven-base" [ style = "dashed", color = "black" ]; "@kie/kogito-data-index-postgresql-image" -> "@kie-tools/sonataflow-image-common" [ style = "dashed", color = "black" ]; + "@kie-tools/kogito-db-migrator-tool" -> "@kie-tools/maven-base" [ style = "solid", color = "black" ]; + "@kie-tools/kogito-db-migrator-tool-image" -> "@kie-tools/kogito-db-migrator-tool" [ style = "solid", color = "black" ]; + "@kie-tools/kogito-db-migrator-tool-image" -> "@kie-tools/sonataflow-image-common" [ style = "solid", color = "black" ]; "@kie/kogito-jit-runner-image" -> "@kie-tools/maven-base" [ style = "dashed", color = "black" ]; "@kie/kogito-jit-runner-image" -> "@kie-tools/sonataflow-image-common" [ style = "dashed", color = "black" ]; "@kie/kogito-jobs-service-allinone-image" -> "@kie-tools/maven-base" [ style = "dashed", color = "black" ]; diff --git a/repo/graph.json b/repo/graph.json index 5a4b9408bc6..55c4a9b4b5e 100644 --- a/repo/graph.json +++ b/repo/graph.json @@ -192,6 +192,8 @@ { "id": "@kie/kogito-base-builder-image" }, { "id": "@kie-tools/sonataflow-image-common" }, { "id": "@kie-tools/python-venv" }, + { "id": "@kie-tools/kogito-db-migrator-tool" }, + { "id": "@kie-tools/kogito-db-migrator-tool-image" }, { "id": "@kie/kogito-jit-runner-image" }, { "id": "@kie/kogito-jobs-service-allinone-image" }, { "id": "@kie-tools/unitables" }, @@ -2102,6 +2104,21 @@ "target": "@kie-tools/root-env", "weight": 1 }, + { + "source": "@kie-tools/kogito-db-migrator-tool", + "target": "@kie-tools/maven-base", + "weight": 1 + }, + { + "source": "@kie-tools/kogito-db-migrator-tool-image", + "target": "@kie-tools/kogito-db-migrator-tool", + "weight": 1 + }, + { + "source": "@kie-tools/kogito-db-migrator-tool-image", + "target": "@kie-tools/sonataflow-image-common", + "weight": 1 + }, { "source": "@kie/kogito-jit-runner-image", "target": "@kie-tools/maven-base", @@ -2831,6 +2848,8 @@ ["@kie/kogito-base-builder-image", "packages/kogito-base-builder-image"], ["@kie/kogito-data-index-ephemeral-image", "packages/kogito-data-index-ephemeral-image"], ["@kie/kogito-data-index-postgresql-image", "packages/kogito-data-index-postgresql-image"], + ["@kie-tools/kogito-db-migrator-tool", "packages/kogito-db-migrator-tool"], + ["@kie-tools/kogito-db-migrator-tool-image", "packages/kogito-db-migrator-tool-image"], ["@kie/kogito-jit-runner-image", "packages/kogito-jit-runner-image"], ["@kie/kogito-jobs-service-allinone-image", "packages/kogito-jobs-service-allinone-image"], ["@kie/kogito-jobs-service-ephemeral-image", "packages/kogito-jobs-service-ephemeral-image"], From 3cea124790231ff6243d256d3a0f7c4c46a839f3 Mon Sep 17 00:00:00 2001 From: rhkp Date: Fri, 10 Jan 2025 16:05:33 +0000 Subject: [PATCH 2/7] Address review comments --- packages/kogito-db-migrator-tool-image/package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/kogito-db-migrator-tool-image/package.json b/packages/kogito-db-migrator-tool-image/package.json index 8eac25601cd..106e3a540f8 100644 --- a/packages/kogito-db-migrator-tool-image/package.json +++ b/packages/kogito-db-migrator-tool-image/package.json @@ -13,7 +13,7 @@ "url": "https://github.com/apache/incubator-kie-tools/issues" }, "scripts": { - "build": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate && pnpm copy-assets && pnpm image:build && rimraf target && rimraf dist-tests-e2e", + "build": "run-script-if --bool \"$(build-env containerImages.build)\" --then \"pnpm venv-activate\" \"pnpm copy-assets\" \"pnpm image:build\" \"rimraf target\" \"rimraf dist-tests-e2e\"", "build:dev": "run-script-os", "build:dev:linux": "pnpm build", "build:dev:win32:darwin": "echo \"Build skipped on Windows and MacOS\"", @@ -27,7 +27,8 @@ "image:build:linux": "pnpm setup:env make -C ./build build", "image:build:win32:darwin": "echo \"Build skipped on Windows and MacOS\"", "install": "node install.js && pnpm format", - "setup:env": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate && cross-env KOGITO_IMAGE_REGISTRY=$(build-env kogitoDbMigratorToolImage.registry) KOGITO_IMAGE_REGISTRY_ACCOUNT=$(build-env kogitoDbMigratorToolImage.account) KOGITO_IMAGE_NAME=$(build-env kogitoDbMigratorToolImage.name) KOGITO_IMAGE_TAG=$(build-env kogitoDbMigratorToolImage.buildTag) QUARKUS_PLATFORM_GROUPID=$(build-env kogitoImagesCekitModules.quarkusGroupId) QUARKUS_PLATFORM_VERSION=$(build-env versions.quarkus) KOGITO_VERSION=$(build-env versions.kogito)" + "setup:env": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate && cross-env KOGITO_IMAGE_REGISTRY=$(build-env kogitoDbMigratorToolImage.registry) KOGITO_IMAGE_REGISTRY_ACCOUNT=$(build-env kogitoDbMigratorToolImage.account) KOGITO_IMAGE_NAME=$(build-env kogitoDbMigratorToolImage.name) KOGITO_IMAGE_TAG=$(build-env kogitoDbMigratorToolImage.buildTag) QUARKUS_PLATFORM_GROUPID=$(build-env kogitoImagesCekitModules.quarkusGroupId) QUARKUS_PLATFORM_VERSION=$(build-env versions.quarkus) KOGITO_VERSION=$(build-env versions.kogito)", + "venv-activate": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate" }, "dependencies": { "@kie-tools/kogito-db-migrator-tool": "workspace:*", From 5d9458a2f796133e2defd18af72ccaf24c1fa6d3 Mon Sep 17 00:00:00 2001 From: rhkp Date: Wed, 15 Jan 2025 20:53:44 +0000 Subject: [PATCH 3/7] Add DB Migrator CI files and address review comments --- .ci/jenkins/Jenkinsfile.daily-dev-publish | 20 ++ .../Jenkinsfile.kogito-db-migrator-tool | 210 ++++++++++++++++++ .gitignore | 2 - .../README.md | 30 +-- .../env/index.js | 2 +- .../install.js | 2 +- .../package.json | 6 +- ...to-postgresql-db-migrator-tool-image.yaml} | 4 +- .../module.yaml | 4 +- .../.gitignore | 2 +- .../README.md | 4 +- .../env/index.js | 2 +- .../install.js | 2 +- .../package.json | 2 +- .../pom.xml | 25 ++- .../migrator/DBConnectionChecker.java | 0 .../postgresql/migrator/DBMigrator.java | 0 .../postgresql/migrator/MigrationService.java | 0 .../src/main/resources/application.properties | 0 .../migrator/DBConnectionCheckerTest.java | 0 .../postgresql/migrator/DBMigratorTest.java | 0 .../migrator/MigrationServiceTest.java | 0 packages/maven-base/pom.xml | 20 -- .../scripts/build-kogito-apps-components.sh | 2 +- pnpm-lock.yaml | 8 +- repo/graph.dot | 10 +- repo/graph.json | 30 +-- 27 files changed, 298 insertions(+), 89 deletions(-) create mode 100644 .ci/jenkins/release-jobs/Jenkinsfile.kogito-db-migrator-tool rename packages/{kogito-db-migrator-tool-image => kogito-postgresql-db-migrator-tool-image}/README.md (87%) rename packages/{kogito-db-migrator-tool-image => kogito-postgresql-db-migrator-tool-image}/env/index.js (96%) rename packages/{kogito-db-migrator-tool-image => kogito-postgresql-db-migrator-tool-image}/install.js (96%) rename packages/{kogito-db-migrator-tool-image => kogito-postgresql-db-migrator-tool-image}/package.json (90%) rename packages/{kogito-db-migrator-tool-image/resources/incubator-kie-kogito-db-migrator-tool-image.yaml => kogito-postgresql-db-migrator-tool-image/resources/incubator-kie-kogito-postgresql-db-migrator-tool-image.yaml} (91%) rename packages/{kogito-db-migrator-tool-image => kogito-postgresql-db-migrator-tool-image}/resources/modules/kogito-postgres-db-migration-deps/module.yaml (84%) rename packages/{kogito-db-migrator-tool => kogito-postgresql-db-migrator-tool}/.gitignore (66%) rename packages/{kogito-db-migrator-tool => kogito-postgresql-db-migrator-tool}/README.md (81%) rename packages/{kogito-db-migrator-tool => kogito-postgresql-db-migrator-tool}/env/index.js (97%) rename packages/{kogito-db-migrator-tool => kogito-postgresql-db-migrator-tool}/install.js (95%) rename packages/{kogito-db-migrator-tool => kogito-postgresql-db-migrator-tool}/package.json (95%) rename packages/{kogito-db-migrator-tool => kogito-postgresql-db-migrator-tool}/pom.xml (83%) rename packages/{kogito-db-migrator-tool => kogito-postgresql-db-migrator-tool}/src/main/java/org/kie/kogito/postgresql/migrator/DBConnectionChecker.java (100%) rename packages/{kogito-db-migrator-tool => kogito-postgresql-db-migrator-tool}/src/main/java/org/kie/kogito/postgresql/migrator/DBMigrator.java (100%) rename packages/{kogito-db-migrator-tool => kogito-postgresql-db-migrator-tool}/src/main/java/org/kie/kogito/postgresql/migrator/MigrationService.java (100%) rename packages/{kogito-db-migrator-tool => kogito-postgresql-db-migrator-tool}/src/main/resources/application.properties (100%) rename packages/{kogito-db-migrator-tool => kogito-postgresql-db-migrator-tool}/src/test/java/org/kie/kogito/postgresql/migrator/DBConnectionCheckerTest.java (100%) rename packages/{kogito-db-migrator-tool => kogito-postgresql-db-migrator-tool}/src/test/java/org/kie/kogito/postgresql/migrator/DBMigratorTest.java (100%) rename packages/{kogito-db-migrator-tool => kogito-postgresql-db-migrator-tool}/src/test/java/org/kie/kogito/postgresql/migrator/MigrationServiceTest.java (100%) diff --git a/.ci/jenkins/Jenkinsfile.daily-dev-publish b/.ci/jenkins/Jenkinsfile.daily-dev-publish index 5571b5267f0..19af2199a87 100644 --- a/.ci/jenkins/Jenkinsfile.daily-dev-publish +++ b/.ci/jenkins/Jenkinsfile.daily-dev-publish @@ -135,6 +135,11 @@ pipeline { KOGITO_MANAGEMENT_CONSOLE__name = 'incubator-kie-kogito-management-console' KOGITO_MANAGEMENT_CONSOLE__buildTag = "${params.BRANCH_NAME}" + KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__registry = 'docker.io' + KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__account = 'apache' + KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__name = 'kogito-postgresql-db-migrator-tool' + KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__buildTag = "${params.BRANCH_NAME}" + SONATAFLOW_BUILDER_IMAGE__registry = 'docker.io' SONATAFLOW_BUILDER_IMAGE__account = 'apache' SONATAFLOW_BUILDER_IMAGE__name = 'incubator-kie-sonataflow-builder' @@ -550,6 +555,21 @@ pipeline { } } + stage('Push kogito-postgresql-db-migrator-tool to Docker Hub') { + steps { + script { + dockerUtils.pushImageToRegistry( + "${env.KOGITO_DB_MIGRATOR_TOOL__registry}", + "${env.KOGITO_DB_MIGRATOR_TOOL__account}", + "${env.KOGITO_DB_MIGRATOR_TOOL__name}", + "${env.KOGITO_DB_MIGRATOR_TOOL__buildTag}", + "${pipelineVars.dockerHubUserCredentialsId}", + "${pipelineVars.dockerHubTokenCredentialsId}" + ) + } + } + } + stage('Push kie-sandbox-helm-chart to Docker Hub') { steps { dir('kie-tools') { diff --git a/.ci/jenkins/release-jobs/Jenkinsfile.kogito-db-migrator-tool b/.ci/jenkins/release-jobs/Jenkinsfile.kogito-db-migrator-tool new file mode 100644 index 00000000000..a1eaff874f1 --- /dev/null +++ b/.ci/jenkins/release-jobs/Jenkinsfile.kogito-db-migrator-tool @@ -0,0 +1,210 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +pipeline { + agent { + docker { + image 'docker.io/apache/incubator-kie-tools-ci-build:main' + args '--shm-size=2g --privileged --group-add docker' + } + } + + options { + timeout(time: 60, unit: 'MINUTES') + } + + parameters { + booleanParam(description: 'Dry run', name: 'DRY_RUN', defaultValue: true) + string(description: 'Release Version', name: 'RELEASE_VERSION', defaultValue: '0.0.0') + string(description: 'Base Ref', name: 'BASE_REF') + string(description: 'Release Candidate Version', name: 'RELEASE_CANDIDATE_VERSION', defaultValue: '') + } + + environment { + KIE_TOOLS_BUILD__runLinters = 'false' + KIE_TOOLS_BUILD__runTests = 'false' + KIE_TOOLS_BUILD__runEndToEndTests = 'false' + KIE_TOOLS_BUILD__buildContainerImages = 'true' + + + KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__registry = 'docker.io' + KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__account = 'apache' + KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__name = 'kogito-postgresql-db-migrator-tool' + KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__buildTag = "${params.RELEASE_VERSION}" + + RELEASE_ARTIFACTS_DIR = "${WORKSPACE}/release-artifacts" + + DOCKER_CONFIG = "${WORKSPACE}/.docker" + + PNPM_FILTER_STRING = '-F @kie-tools/kogito-postgresql-db-migrator-tool...' + } + + stages { + stage('Load local shared scripts') { + steps { + script { + pipelineVars = load '.ci/jenkins/shared-scripts/pipelineVars.groovy' + buildUtils = load '.ci/jenkins/shared-scripts/buildUtils.groovy' + githubUtils = load '.ci/jenkins/shared-scripts/githubUtils.groovy' + dockerUtils = load '.ci/jenkins/shared-scripts/dockerUtils.groovy' + releaseUtils = load '.ci/jenkins/shared-scripts/releaseUtils.groovy' + } + } + } + + stage('Start required services for build and tests (DinD, Xvfb, Fluxbox)') { + steps { + script { + buildUtils.startRequiredServices() + } + } + } + + stage('Clean workspace before build') { + steps { + cleanWs(deleteDirs: true, disableDeferredWipeout: true) + } + } + + stage('Load upstream images') { + when { + expression { !params.DRY_RUN && params.RELEASE_CANDIDATE_VERSION != '' } + } + steps { + script { + upstreamReleaseArtifactsDir = "${WORKSPACE}/upstream-release-artifacts" + releaseUtils.downloadReleaseArtifacts("${pipelineVars.asfReleaseStagingRepository}", "${upstreamReleaseArtifactsDir}", "${params.RELEASE_CANDIDATE_VERSION}") + upstreamImagesArtifacts = releaseUtils.getUpstreamImagesArtifactsList("${upstreamReleaseArtifactsDir}", "${params.RELEASE_CANDIDATE_VERSION}") + dockerUtils.loadImages(upstreamImagesArtifacts as String[]) + } + } + } + + stage('Checkout kie-tools') { + steps { + dir('kie-tools') { + script { + githubUtils.checkoutRepo( + "http://github.com/${pipelineVars.githubRepositorySlug}.git", + "${params.BASE_REF}", + "${pipelineVars.kieToolsBotGithubCredentialsId}" + ) + } + } + } + } + + stage('Setup PNPM') { + steps { + dir('kie-tools') { + script { + buildUtils.setupPnpm("${pipelineVars.mavenSettingsReleaseConfigFileId}") + } + } + } + } + + stage('PNPM Bootstrap') { + steps { + dir('kie-tools') { + script { + buildUtils.pnpmBootstrap("${env.PNPM_FILTER_STRING}") + } + } + } + } + + stage('Build') { + steps { + dir('kie-tools') { + script { + buildUtils.pnpmBuild("${env.PNPM_FILTER_STRING}") + } + } + } + } + + stage('Push kogito-postgresql-db-migrator-tool to Docker Hub') { + when { + expression { !params.DRY_RUN && params.RELEASE_CANDIDATE_VERSION == '' } + } + steps { + script { + dockerUtils.pushImageToRegistry( + "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__registry}", + "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__account}", + "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__name}", + "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL_buildTag}", + "${pipelineVars.dockerHubUserCredentialsId}", + "${pipelineVars.dockerHubTokenCredentialsId}" + ) + } + } + } + + stage('Setup release candidate artifacts') { + when { + expression { !params.DRY_RUN && params.RELEASE_CANDIDATE_VERSION != '' } + } + steps { + script { + env.RELEASE_IMAGE_TAR_FILE = "incubator-kie-${params.RELEASE_CANDIDATE_VERSION}-kogito-postgresql-db-migrator-tool-image.tar.gz" + + sh """#!/bin/bash -el + mkdir ${env.RELEASE_ARTIFACTS_DIR} + docker save "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__registry}/${env.KOGITO_MANAGEMENT_CONSOLE__account}/${env.KOGITO_MANAGEMENT_CONSOLE__name}:${params.RELEASE_VERSION}" | gzip > "${env.RELEASE_ARTIFACTS_DIR}/${env.RELEASE_IMAGE_TAR_FILE}" + """.trim() + } + } + } + + stage('Sign artifact for Apache release') { + when { + expression { !params.DRY_RUN && params.RELEASE_CANDIDATE_VERSION != '' } + } + steps { + dir("${env.RELEASE_ARTIFACTS_DIR}") { + script { + releaseUtils.setupSigningKey("${pipelineVars.asfReleaseGPGKeyCredentialsId}") + releaseUtils.signArtifact("${env.RELEASE_IMAGE_TAR_FILE}") + } + } + } + } + + stage('Publish Release Candidate artifacts') { + when { + expression { !params.DRY_RUN && params.RELEASE_CANDIDATE_VERSION != '' } + } + steps { + script { + releaseUtils.publishArtifacts( + "${env.RELEASE_ARTIFACTS_DIR}", + "${pipelineVars.asfReleaseStagingRepository}", + "${params.RELEASE_CANDIDATE_VERSION}", + "${pipelineVars.asfReleaseSVNStagingCredentialsId}" + ) + } + } + } + } + + post { + always { + cleanWs(deleteDirs: true) + } + } +} diff --git a/.gitignore b/.gitignore index e68db79f20f..6facd1e436b 100644 --- a/.gitignore +++ b/.gitignore @@ -347,7 +347,5 @@ turbo.json packages/*/.idea examples/*/.idea -# Jar files -**/*.jar # Apache RAT check excludes file !.rat-excludes diff --git a/packages/kogito-db-migrator-tool-image/README.md b/packages/kogito-postgresql-db-migrator-tool-image/README.md similarity index 87% rename from packages/kogito-db-migrator-tool-image/README.md rename to packages/kogito-postgresql-db-migrator-tool-image/README.md index 4af61293cea..c357c0389b7 100644 --- a/packages/kogito-db-migrator-tool-image/README.md +++ b/packages/kogito-postgresql-db-migrator-tool-image/README.md @@ -15,42 +15,20 @@ under the License. --> -# Kogito Postgres DB Migrator Tool Image +# Kogito PostgreSQL DB Migrator Tool Image -This package contains the `Containerfile/Dockerfile` and scripts to build a container image for Kogito Postgres DB Migrator Tool. Details about the Kogito Postgres DB Migrator Tool can be found [here](../kogito-db-migrator-tool/README.md) +This package contains the `Containerfile/Dockerfile` and scripts to build a container image for Kogito PostgreSQL DB Migrator Tool. Details about the Kogito PostgreSQL DB Migrator Tool can be found [here](../kogito-postgresql-db-migrator-tool/README.md) ## Additional requirements - docker -## Build - -_NOTE_: Before performing this step, be sure that the Kogito Postgres DB Migrator Tool jar has been built and available for inclusion in the image. - -- Enable the image to be built: - - ```bash - export KIE_TOOLS_BUILD__buildContainerImages=true - ``` - -Run the following in the root folder of the repository to build the package: - -```bash -pnpm -F @kie-tools/kogito-db-migrator-tool-image... build:prod -``` - -- Then check if the image is correctly stored: - - ```bash - docker images - ``` - ## Run - Start up a clean container with: ```bash - docker run docker.io/apache/incubator-kie-kogito-service-db-migration-postgresql:latest + docker run docker.io/apache/incubator-kie-kogito-service-db-migration-postgresql:main ``` ## Customization @@ -86,7 +64,7 @@ An example to use diverse environment variables --env QUARKUS_DATASOURCE_JOBSSERVICE_USERNAME= \ --env QUARKUS_DATASOURCE_JOBSSERVICE_PASSWORD= \ --env QUARKUS_FLYWAY_JOBSSERVICE_SCHEMAS=jobs-service \ - docker.io/apache/incubator-kie-kogito-db-migrator-tool:main + docker.io/apache/incubator-kie-kogito-postgresql-db-migrator-tool:main ``` --- diff --git a/packages/kogito-db-migrator-tool-image/env/index.js b/packages/kogito-postgresql-db-migrator-tool-image/env/index.js similarity index 96% rename from packages/kogito-db-migrator-tool-image/env/index.js rename to packages/kogito-postgresql-db-migrator-tool-image/env/index.js index 00dc1399d44..6cbd330c45d 100644 --- a/packages/kogito-db-migrator-tool-image/env/index.js +++ b/packages/kogito-postgresql-db-migrator-tool-image/env/index.js @@ -33,7 +33,7 @@ module.exports = composeEnv([rootEnv, sonataflowImageCommonEnv], { description: "The image registry account.", }, KOGITO_DB_MIGRATOR_TOOL_IMAGE__name: { - default: "incubator-kie-kogito-db-migrator-tool", + default: "incubator-kie-kogito-postgresql-db-migrator-tool", description: "The image name.", }, KOGITO_DB_MIGRATOR_TOOL_IMAGE__buildTag: { diff --git a/packages/kogito-db-migrator-tool-image/install.js b/packages/kogito-postgresql-db-migrator-tool-image/install.js similarity index 96% rename from packages/kogito-db-migrator-tool-image/install.js rename to packages/kogito-postgresql-db-migrator-tool-image/install.js index cec8142a81d..3553989693a 100644 --- a/packages/kogito-db-migrator-tool-image/install.js +++ b/packages/kogito-postgresql-db-migrator-tool-image/install.js @@ -50,7 +50,7 @@ let imageYaml = fs.readFileSync(originalYamlPath, "utf8"); const imageUrl = `${env.kogitoDbMigratorToolImage.registry}/${env.kogitoDbMigratorToolImage.account}/${env.kogitoDbMigratorToolImage.name}`; // Replace the whole string between quotes ("") with the image name -imageYaml = imageYaml.replace(/(?<=")(.*kie-kogito-db-migrator-tool.*)(?=")/gm, imageUrl); +imageYaml = imageYaml.replace(/(?<=")(.*kie-kogito-postgresql-db-migrator-tool.*)(?=")/gm, imageUrl); // Write file and then rename it to match the image name fs.writeFileSync(originalYamlPath, imageYaml); diff --git a/packages/kogito-db-migrator-tool-image/package.json b/packages/kogito-postgresql-db-migrator-tool-image/package.json similarity index 90% rename from packages/kogito-db-migrator-tool-image/package.json rename to packages/kogito-postgresql-db-migrator-tool-image/package.json index 106e3a540f8..c1f105076dd 100644 --- a/packages/kogito-db-migrator-tool-image/package.json +++ b/packages/kogito-postgresql-db-migrator-tool-image/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "@kie-tools/kogito-db-migrator-tool-image", + "name": "@kie-tools/kogito-postgresql-db-migrator-tool-image", "version": "0.0.0", "description": "", "license": "Apache-2.0", @@ -21,7 +21,7 @@ "build:prod:linux": "pnpm build", "build:prod:win32:darwin": "echo \"Build skipped on Windows and MacOS\"", "copy-assets": "run-script-os", - "copy-assets:linux:darwin": "rimraf build && cp -R ./node_modules/@kie-tools/sonataflow-image-common/resources build && cp -R resources/* build && mkdir -p build/modules/kogito-postgres-db-migration-deps/quarkus-app && cp -R ./node_modules/@kie-tools/kogito-db-migrator-tool/target/quarkus-app/* build/modules/kogito-postgres-db-migration-deps/quarkus-app", + "copy-assets:linux:darwin": "rimraf build && cp -R ./node_modules/@kie-tools/sonataflow-image-common/resources build && cp -R resources/* build && mkdir -p build/modules/kogito-postgres-db-migration-deps/quarkus-app && cp -R ./node_modules/@kie-tools/kogito-postgresql-db-migrator-tool/target/quarkus-app/* build/modules/kogito-postgres-db-migration-deps/quarkus-app", "format": "prettier --write . --ignore-path=../../.prettierignore --ignore-path=../../.gitignore", "image:build": "run-script-os", "image:build:linux": "pnpm setup:env make -C ./build build", @@ -31,7 +31,7 @@ "venv-activate": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate" }, "dependencies": { - "@kie-tools/kogito-db-migrator-tool": "workspace:*", + "@kie-tools/kogito-postgresql-db-migrator-tool": "workspace:*", "@kie-tools/python-venv": "workspace:*", "@kie-tools/root-env": "workspace:*", "@kie-tools/sonataflow-image-common": "workspace:*" diff --git a/packages/kogito-db-migrator-tool-image/resources/incubator-kie-kogito-db-migrator-tool-image.yaml b/packages/kogito-postgresql-db-migrator-tool-image/resources/incubator-kie-kogito-postgresql-db-migrator-tool-image.yaml similarity index 91% rename from packages/kogito-db-migrator-tool-image/resources/incubator-kie-kogito-db-migrator-tool-image.yaml rename to packages/kogito-postgresql-db-migrator-tool-image/resources/incubator-kie-kogito-postgresql-db-migrator-tool-image.yaml index fd29a2f39e5..a063cf8a9f1 100644 --- a/packages/kogito-db-migrator-tool-image/resources/incubator-kie-kogito-db-migrator-tool-image.yaml +++ b/packages/kogito-postgresql-db-migrator-tool-image/resources/incubator-kie-kogito-postgresql-db-migrator-tool-image.yaml @@ -16,7 +16,7 @@ # specific language governing permissions and limitations # under the License. # -name: "docker.io/apache/incubator-kie-kogito-db-migrator-tool" +name: "docker.io/apache/incubator-kie-kogito-postgresql-db-migrator-tool" version: "main" from: registry.access.redhat.com/ubi8/openjdk-17-runtime:1.20 description: DBMigratorTool image for Data Index and Jobs Service database migration @@ -29,7 +29,7 @@ labels: - name: "io.k8s.description" value: "Kogito DB Migration creates schemas and tables for Data Index and Jobs Service for PostgreSQL database" - name: "io.k8s.display-name" - value: "Kogito DB Migration for Data Index and Jobs Service - PostgreSQL" + value: "Kogito DB Migration Tool for Data Index and Jobs Service - PostgreSQL" - name: "io.openshift.tags" value: "kogito,db-migration" diff --git a/packages/kogito-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml b/packages/kogito-postgresql-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml similarity index 84% rename from packages/kogito-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml rename to packages/kogito-postgresql-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml index 3cb2a3a8a85..e90ebaa5962 100644 --- a/packages/kogito-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml +++ b/packages/kogito-postgresql-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml @@ -20,7 +20,7 @@ schema_version: 1 name: org.kie.kogito.postgresql.db-migration-deps version: "main" artifacts: - # The following artifact comes from the package kogito-db-migrator-tool during the pnpm build:dev phase - - name: kogito-db-migrator-tool-quarkus-app + # The following artifact comes from the package kogito-postgresql-db-migrator-tool during the pnpm build:dev phase + - name: kogito-postgresql-db-migrator-tool-quarkus-app path: ./quarkus-app dest: /home/kogito/bin diff --git a/packages/kogito-db-migrator-tool/.gitignore b/packages/kogito-postgresql-db-migrator-tool/.gitignore similarity index 66% rename from packages/kogito-db-migrator-tool/.gitignore rename to packages/kogito-postgresql-db-migrator-tool/.gitignore index 8404612fa0f..f30772d459b 100644 --- a/packages/kogito-db-migrator-tool/.gitignore +++ b/packages/kogito-postgresql-db-migrator-tool/.gitignore @@ -1,4 +1,4 @@ -# kogito-db-migrator-tool +# kogito-postgresql-db-migrator-tool src/main/resources/postgresql src/main/resources/ansi src/main/resources/h2 \ No newline at end of file diff --git a/packages/kogito-db-migrator-tool/README.md b/packages/kogito-postgresql-db-migrator-tool/README.md similarity index 81% rename from packages/kogito-db-migrator-tool/README.md rename to packages/kogito-postgresql-db-migrator-tool/README.md index 18e28f7eea9..fae3670fc1a 100644 --- a/packages/kogito-db-migrator-tool/README.md +++ b/packages/kogito-postgresql-db-migrator-tool/README.md @@ -1,8 +1,8 @@ -# Kogito Postgres DB Migrator Tool +# Kogito PostgreSQL DB Migrator Tool This is a Java, Quarkus-based PostgreSQL database migrator application for Data-Index and Jobs Service applications for use by SonataFlow Operator. -_NOTE_: This postgres database migrator application and its corresponding images are only envisaged to be made use of by SonataFlow Operator, Data Index and Jobs Service internally. Conversely this application is of no use outside the usecases involved with SonataFlow Operator, Data Index and Jobs Service applications. +_NOTE_: This PostgreSQL database migrator application and its corresponding images are only envisaged to be made use of by SonataFlow Operator, Data Index and Jobs Service internally. Conversely this application is of no use outside the usecases involved with SonataFlow Operator, Data Index and Jobs Service applications. --- diff --git a/packages/kogito-db-migrator-tool/env/index.js b/packages/kogito-postgresql-db-migrator-tool/env/index.js similarity index 97% rename from packages/kogito-db-migrator-tool/env/index.js rename to packages/kogito-postgresql-db-migrator-tool/env/index.js index fa7de21dad9..d03521c2e5b 100644 --- a/packages/kogito-db-migrator-tool/env/index.js +++ b/packages/kogito-postgresql-db-migrator-tool/env/index.js @@ -23,7 +23,7 @@ module.exports = composeEnv([require("@kie-tools/root-env/env"), require("@kie-t vars: varsWithName({}), get env() { return { - kogitoDBMigratorTool: { + kogitoDbMigratorTool: { version: require("../package.json").version, }, }; diff --git a/packages/kogito-db-migrator-tool/install.js b/packages/kogito-postgresql-db-migrator-tool/install.js similarity index 95% rename from packages/kogito-db-migrator-tool/install.js rename to packages/kogito-postgresql-db-migrator-tool/install.js index 281ee1f9f2a..1770c93869f 100644 --- a/packages/kogito-db-migrator-tool/install.js +++ b/packages/kogito-postgresql-db-migrator-tool/install.js @@ -21,7 +21,7 @@ const { setupMavenConfigFile, buildTailFromPackageJsonDependencies } = require(" setupMavenConfigFile( ` - -Drevision=${env.kogitoDBMigratorTool.version} + -Drevision=${env.kogitoDbMigratorTool.version} -Dmaven.repo.local.tail=${buildTailFromPackageJsonDependencies()} ` ); diff --git a/packages/kogito-db-migrator-tool/package.json b/packages/kogito-postgresql-db-migrator-tool/package.json similarity index 95% rename from packages/kogito-db-migrator-tool/package.json rename to packages/kogito-postgresql-db-migrator-tool/package.json index 7ca5e31839b..07b805ebfd9 100644 --- a/packages/kogito-db-migrator-tool/package.json +++ b/packages/kogito-postgresql-db-migrator-tool/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "@kie-tools/kogito-db-migrator-tool", + "name": "@kie-tools/kogito-postgresql-db-migrator-tool", "version": "0.0.0", "description": "", "license": "Apache-2.0", diff --git a/packages/kogito-db-migrator-tool/pom.xml b/packages/kogito-postgresql-db-migrator-tool/pom.xml similarity index 83% rename from packages/kogito-db-migrator-tool/pom.xml rename to packages/kogito-postgresql-db-migrator-tool/pom.xml index 92cdeaaa5ea..fb8dc48f9e2 100644 --- a/packages/kogito-db-migrator-tool/pom.xml +++ b/packages/kogito-postgresql-db-migrator-tool/pom.xml @@ -31,7 +31,11 @@ 4.0.0 org.kie.kogito - kogito-db-migrator-tool + kogito-postgresql-db-migrator-tool + + + 0.8.12 + @@ -102,6 +106,25 @@ + + org.jacoco + jacoco-maven-plugin + ${version.jacoco.maven.plugin} + + + + prepare-agent + + + + report + prepare-package + + report + + + + diff --git a/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBConnectionChecker.java b/packages/kogito-postgresql-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBConnectionChecker.java similarity index 100% rename from packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBConnectionChecker.java rename to packages/kogito-postgresql-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBConnectionChecker.java diff --git a/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBMigrator.java b/packages/kogito-postgresql-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBMigrator.java similarity index 100% rename from packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBMigrator.java rename to packages/kogito-postgresql-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBMigrator.java diff --git a/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/MigrationService.java b/packages/kogito-postgresql-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/MigrationService.java similarity index 100% rename from packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/MigrationService.java rename to packages/kogito-postgresql-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/MigrationService.java diff --git a/packages/kogito-db-migrator-tool/src/main/resources/application.properties b/packages/kogito-postgresql-db-migrator-tool/src/main/resources/application.properties similarity index 100% rename from packages/kogito-db-migrator-tool/src/main/resources/application.properties rename to packages/kogito-postgresql-db-migrator-tool/src/main/resources/application.properties diff --git a/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBConnectionCheckerTest.java b/packages/kogito-postgresql-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBConnectionCheckerTest.java similarity index 100% rename from packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBConnectionCheckerTest.java rename to packages/kogito-postgresql-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBConnectionCheckerTest.java diff --git a/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBMigratorTest.java b/packages/kogito-postgresql-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBMigratorTest.java similarity index 100% rename from packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBMigratorTest.java rename to packages/kogito-postgresql-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBMigratorTest.java diff --git a/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/MigrationServiceTest.java b/packages/kogito-postgresql-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/MigrationServiceTest.java similarity index 100% rename from packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/MigrationServiceTest.java rename to packages/kogito-postgresql-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/MigrationServiceTest.java diff --git a/packages/maven-base/pom.xml b/packages/maven-base/pom.xml index b428d372ea8..dd1518e52a8 100644 --- a/packages/maven-base/pom.xml +++ b/packages/maven-base/pom.xml @@ -140,7 +140,6 @@ 4.11.0 0.4 0.23.0 - 0.8.12 @@ -409,25 +408,6 @@ - - org.jacoco - jacoco-maven-plugin - ${version.jacoco.maven.plugin} - - - - prepare-agent - - - - report - prepare-package - - report - - - - diff --git a/packages/sonataflow-image-common/resources/scripts/build-kogito-apps-components.sh b/packages/sonataflow-image-common/resources/scripts/build-kogito-apps-components.sh index fc661b7dcdc..88ac842f76b 100755 --- a/packages/sonataflow-image-common/resources/scripts/build-kogito-apps-components.sh +++ b/packages/sonataflow-image-common/resources/scripts/build-kogito-apps-components.sh @@ -56,7 +56,7 @@ if [ ! -z "${CYPRESS_BINARY_URL}" ]; then fi case ${imageName} in - "incubator-kie-kogito-db-migrator-tool") + "incubator-kie-kogito-postgresql-db-migrator-tool") contextDir="db-migrator-tool/image" ;; "incubator-kie-kogito-data-index-ephemeral") diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a18bdfc6c42..d5ce994492a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7403,7 +7403,7 @@ importers: specifier: ^1.1.6 version: 1.1.6 - packages/kogito-db-migrator-tool: + packages/kogito-postgresql-db-migrator-tool: dependencies: '@kie-tools/maven-base': specifier: workspace:* @@ -7419,11 +7419,11 @@ importers: specifier: ^1.1.6 version: 1.1.6 - packages/kogito-db-migrator-tool-image: + packages/kogito-postgresql-db-migrator-tool-image: dependencies: - '@kie-tools/kogito-db-migrator-tool': + '@kie-tools/kogito-postgresql-db-migrator-tool': specifier: workspace:* - version: link:../kogito-db-migrator-tool + version: link:../kogito-postgresql-db-migrator-tool '@kie-tools/python-venv': specifier: workspace:* version: link:../python-venv diff --git a/repo/graph.dot b/repo/graph.dot index dab90395800..26347531f62 100644 --- a/repo/graph.dot +++ b/repo/graph.dot @@ -150,13 +150,13 @@ digraph G { "@kie-tools/sonataflow-image-common" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie/kogito-data-index-ephemeral-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie/kogito-data-index-postgresql-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; - "@kie-tools/kogito-db-migrator-tool" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; - "@kie-tools/kogito-db-migrator-tool-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie/kogito-jit-runner-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie/kogito-jobs-service-allinone-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie/kogito-jobs-service-ephemeral-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie/kogito-jobs-service-postgresql-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie-tools/runtime-tools-management-console-webapp" [ color = "blue", fontcolor = "blue", style = "rounded" ]; + "@kie-tools/kogito-postgresql-db-migrator-tool" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; + "@kie-tools/kogito-postgresql-db-migrator-tool-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie-tools-core/kubernetes-bridge" [ color = "purple", fontcolor = "purple", style = "rounded" ]; "@kie-tools-core/workspace" [ color = "purple", fontcolor = "purple", style = "rounded" ]; "@kie-tools/unitables-dmn" [ color = "blue", fontcolor = "blue", style = "rounded" ]; @@ -473,9 +473,6 @@ digraph G { "@kie/kogito-data-index-ephemeral-image" -> "@kie-tools/sonataflow-image-common" [ style = "dashed", color = "black" ]; "@kie/kogito-data-index-postgresql-image" -> "@kie-tools/maven-base" [ style = "dashed", color = "black" ]; "@kie/kogito-data-index-postgresql-image" -> "@kie-tools/sonataflow-image-common" [ style = "dashed", color = "black" ]; - "@kie-tools/kogito-db-migrator-tool" -> "@kie-tools/maven-base" [ style = "solid", color = "black" ]; - "@kie-tools/kogito-db-migrator-tool-image" -> "@kie-tools/kogito-db-migrator-tool" [ style = "solid", color = "black" ]; - "@kie-tools/kogito-db-migrator-tool-image" -> "@kie-tools/sonataflow-image-common" [ style = "solid", color = "black" ]; "@kie/kogito-jit-runner-image" -> "@kie-tools/maven-base" [ style = "dashed", color = "black" ]; "@kie/kogito-jit-runner-image" -> "@kie-tools/sonataflow-image-common" [ style = "dashed", color = "black" ]; "@kie/kogito-jobs-service-allinone-image" -> "@kie-tools/maven-base" [ style = "dashed", color = "black" ]; @@ -487,6 +484,9 @@ digraph G { "@kie-tools/kogito-management-console" -> "@kie-tools/image-builder" [ style = "dashed", color = "black" ]; "@kie-tools/kogito-management-console" -> "@kie-tools/image-env-to-json" [ style = "dashed", color = "black" ]; "@kie-tools/kogito-management-console" -> "@kie-tools/runtime-tools-management-console-webapp" [ style = "dashed", color = "black" ]; + "@kie-tools/kogito-postgresql-db-migrator-tool" -> "@kie-tools/maven-base" [ style = "solid", color = "black" ]; + "@kie-tools/kogito-postgresql-db-migrator-tool-image" -> "@kie-tools/kogito-postgresql-db-migrator-tool" [ style = "solid", color = "black" ]; + "@kie-tools/kogito-postgresql-db-migrator-tool-image" -> "@kie-tools/sonataflow-image-common" [ style = "solid", color = "black" ]; "@kie-tools-core/kubernetes-bridge" -> "@kie-tools/cors-proxy-api" [ style = "solid", color = "purple" ]; "@kie-tools/maven-base" -> "@kie-tools/root-env" [ style = "dashed", color = "black" ]; "@kie-tools/maven-m2-repo-via-http-image" -> "@kie-tools/image-builder" [ style = "dashed", color = "black" ]; diff --git a/repo/graph.json b/repo/graph.json index 55c4a9b4b5e..87eb602e6a7 100644 --- a/repo/graph.json +++ b/repo/graph.json @@ -192,10 +192,10 @@ { "id": "@kie/kogito-base-builder-image" }, { "id": "@kie-tools/sonataflow-image-common" }, { "id": "@kie-tools/python-venv" }, - { "id": "@kie-tools/kogito-db-migrator-tool" }, - { "id": "@kie-tools/kogito-db-migrator-tool-image" }, { "id": "@kie/kogito-jit-runner-image" }, { "id": "@kie/kogito-jobs-service-allinone-image" }, + { "id": "@kie-tools/kogito-postgresql-db-migrator-tool" }, + { "id": "@kie-tools/kogito-postgresql-db-migrator-tool-image" }, { "id": "@kie-tools/unitables" }, { "id": "pmml-vscode-extension" }, { "id": "@kie-tools/runtime-tools-components" }, @@ -2105,37 +2105,37 @@ "weight": 1 }, { - "source": "@kie-tools/kogito-db-migrator-tool", + "source": "@kie/kogito-jit-runner-image", "target": "@kie-tools/maven-base", "weight": 1 }, { - "source": "@kie-tools/kogito-db-migrator-tool-image", - "target": "@kie-tools/kogito-db-migrator-tool", - "weight": 1 - }, - { - "source": "@kie-tools/kogito-db-migrator-tool-image", + "source": "@kie/kogito-jit-runner-image", "target": "@kie-tools/sonataflow-image-common", "weight": 1 }, { - "source": "@kie/kogito-jit-runner-image", + "source": "@kie/kogito-jobs-service-allinone-image", "target": "@kie-tools/maven-base", "weight": 1 }, { - "source": "@kie/kogito-jit-runner-image", + "source": "@kie/kogito-jobs-service-allinone-image", "target": "@kie-tools/sonataflow-image-common", "weight": 1 }, { - "source": "@kie/kogito-jobs-service-allinone-image", + "source": "@kie-tools/kogito-postgresql-db-migrator-tool", "target": "@kie-tools/maven-base", "weight": 1 }, { - "source": "@kie/kogito-jobs-service-allinone-image", + "source": "@kie-tools/kogito-postgresql-db-migrator-tool-image", + "target": "@kie-tools/kogito-postgresql-db-migrator-tool", + "weight": 1 + }, + { + "source": "@kie-tools/kogito-postgresql-db-migrator-tool-image", "target": "@kie-tools/sonataflow-image-common", "weight": 1 }, @@ -2848,13 +2848,13 @@ ["@kie/kogito-base-builder-image", "packages/kogito-base-builder-image"], ["@kie/kogito-data-index-ephemeral-image", "packages/kogito-data-index-ephemeral-image"], ["@kie/kogito-data-index-postgresql-image", "packages/kogito-data-index-postgresql-image"], - ["@kie-tools/kogito-db-migrator-tool", "packages/kogito-db-migrator-tool"], - ["@kie-tools/kogito-db-migrator-tool-image", "packages/kogito-db-migrator-tool-image"], ["@kie/kogito-jit-runner-image", "packages/kogito-jit-runner-image"], ["@kie/kogito-jobs-service-allinone-image", "packages/kogito-jobs-service-allinone-image"], ["@kie/kogito-jobs-service-ephemeral-image", "packages/kogito-jobs-service-ephemeral-image"], ["@kie/kogito-jobs-service-postgresql-image", "packages/kogito-jobs-service-postgresql-image"], ["@kie-tools/kogito-management-console", "packages/kogito-management-console"], + ["@kie-tools/kogito-postgresql-db-migrator-tool", "packages/kogito-postgresql-db-migrator-tool"], + ["@kie-tools/kogito-postgresql-db-migrator-tool-image", "packages/kogito-postgresql-db-migrator-tool-image"], ["@kie-tools-core/kubernetes-bridge", "packages/kubernetes-bridge"], ["@kie-tools/maven-base", "packages/maven-base"], ["@kie-tools/maven-m2-repo-via-http-image", "packages/maven-m2-repo-via-http-image"], From bf37827defc02e5941d2d598e513670d05bad488 Mon Sep 17 00:00:00 2001 From: rhkp Date: Wed, 15 Jan 2025 21:07:55 +0000 Subject: [PATCH 4/7] Quick minor change to CI file --- .ci/jenkins/Jenkinsfile.daily-dev-publish | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.ci/jenkins/Jenkinsfile.daily-dev-publish b/.ci/jenkins/Jenkinsfile.daily-dev-publish index 19af2199a87..d343e7d5a2d 100644 --- a/.ci/jenkins/Jenkinsfile.daily-dev-publish +++ b/.ci/jenkins/Jenkinsfile.daily-dev-publish @@ -559,10 +559,10 @@ pipeline { steps { script { dockerUtils.pushImageToRegistry( - "${env.KOGITO_DB_MIGRATOR_TOOL__registry}", - "${env.KOGITO_DB_MIGRATOR_TOOL__account}", - "${env.KOGITO_DB_MIGRATOR_TOOL__name}", - "${env.KOGITO_DB_MIGRATOR_TOOL__buildTag}", + "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__registry}", + "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__account}", + "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__name}", + "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__buildTag}", "${pipelineVars.dockerHubUserCredentialsId}", "${pipelineVars.dockerHubTokenCredentialsId}" ) From accaa5520081bb24dd78186cf267b7b9ddb92ca5 Mon Sep 17 00:00:00 2001 From: rhkp Date: Thu, 16 Jan 2025 14:08:29 +0000 Subject: [PATCH 5/7] Address review comments --- packages/kogito-postgresql-db-migrator-tool/pom.xml | 4 ---- packages/maven-base/pom.xml | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/kogito-postgresql-db-migrator-tool/pom.xml b/packages/kogito-postgresql-db-migrator-tool/pom.xml index fb8dc48f9e2..590391fdb2c 100644 --- a/packages/kogito-postgresql-db-migrator-tool/pom.xml +++ b/packages/kogito-postgresql-db-migrator-tool/pom.xml @@ -33,10 +33,6 @@ org.kie.kogito kogito-postgresql-db-migrator-tool - - 0.8.12 - - io.quarkus diff --git a/packages/maven-base/pom.xml b/packages/maven-base/pom.xml index dd1518e52a8..283982b6b06 100644 --- a/packages/maven-base/pom.xml +++ b/packages/maven-base/pom.xml @@ -140,6 +140,7 @@ 4.11.0 0.4 0.23.0 + 0.8.12 From 18e93a07b1ffd63d211f12611bffbc99862d34ed Mon Sep 17 00:00:00 2001 From: rhkp Date: Wed, 22 Jan 2025 15:34:58 +0000 Subject: [PATCH 6/7] Revert back db migrator tool package names --- .ci/jenkins/Jenkinsfile.daily-dev-publish | 18 +++++------ .../Jenkinsfile.kogito-db-migrator-tool | 24 +++++++-------- .../README.md | 4 +-- .../env/index.js | 2 +- .../install.js | 2 +- .../package.json | 6 ++-- ...or-kie-kogito-db-migrator-tool-image.yaml} | 2 +- .../module.yaml | 4 +-- .../.gitignore | 2 +- .../README.md | 0 .../env/index.js | 0 .../install.js | 0 .../package.json | 2 +- .../pom.xml | 2 +- .../migrator/DBConnectionChecker.java | 0 .../postgresql/migrator/DBMigrator.java | 0 .../postgresql/migrator/MigrationService.java | 0 .../src/main/resources/application.properties | 0 .../migrator/DBConnectionCheckerTest.java | 0 .../postgresql/migrator/DBMigratorTest.java | 0 .../migrator/MigrationServiceTest.java | 0 .../scripts/build-kogito-apps-components.sh | 2 +- pnpm-lock.yaml | 10 ++++--- repo/graph.dot | 10 +++---- repo/graph.json | 30 +++++++++---------- 25 files changed, 61 insertions(+), 59 deletions(-) rename packages/{kogito-postgresql-db-migrator-tool-image => kogito-db-migrator-tool-image}/README.md (97%) rename packages/{kogito-postgresql-db-migrator-tool-image => kogito-db-migrator-tool-image}/env/index.js (96%) rename packages/{kogito-postgresql-db-migrator-tool-image => kogito-db-migrator-tool-image}/install.js (96%) rename packages/{kogito-postgresql-db-migrator-tool-image => kogito-db-migrator-tool-image}/package.json (90%) rename packages/{kogito-postgresql-db-migrator-tool-image/resources/incubator-kie-kogito-postgresql-db-migrator-tool-image.yaml => kogito-db-migrator-tool-image/resources/incubator-kie-kogito-db-migrator-tool-image.yaml} (95%) rename packages/{kogito-postgresql-db-migrator-tool-image => kogito-db-migrator-tool-image}/resources/modules/kogito-postgres-db-migration-deps/module.yaml (84%) rename packages/{kogito-postgresql-db-migrator-tool => kogito-db-migrator-tool}/.gitignore (66%) rename packages/{kogito-postgresql-db-migrator-tool => kogito-db-migrator-tool}/README.md (100%) rename packages/{kogito-postgresql-db-migrator-tool => kogito-db-migrator-tool}/env/index.js (100%) rename packages/{kogito-postgresql-db-migrator-tool => kogito-db-migrator-tool}/install.js (100%) rename packages/{kogito-postgresql-db-migrator-tool => kogito-db-migrator-tool}/package.json (95%) rename packages/{kogito-postgresql-db-migrator-tool => kogito-db-migrator-tool}/pom.xml (98%) rename packages/{kogito-postgresql-db-migrator-tool => kogito-db-migrator-tool}/src/main/java/org/kie/kogito/postgresql/migrator/DBConnectionChecker.java (100%) rename packages/{kogito-postgresql-db-migrator-tool => kogito-db-migrator-tool}/src/main/java/org/kie/kogito/postgresql/migrator/DBMigrator.java (100%) rename packages/{kogito-postgresql-db-migrator-tool => kogito-db-migrator-tool}/src/main/java/org/kie/kogito/postgresql/migrator/MigrationService.java (100%) rename packages/{kogito-postgresql-db-migrator-tool => kogito-db-migrator-tool}/src/main/resources/application.properties (100%) rename packages/{kogito-postgresql-db-migrator-tool => kogito-db-migrator-tool}/src/test/java/org/kie/kogito/postgresql/migrator/DBConnectionCheckerTest.java (100%) rename packages/{kogito-postgresql-db-migrator-tool => kogito-db-migrator-tool}/src/test/java/org/kie/kogito/postgresql/migrator/DBMigratorTest.java (100%) rename packages/{kogito-postgresql-db-migrator-tool => kogito-db-migrator-tool}/src/test/java/org/kie/kogito/postgresql/migrator/MigrationServiceTest.java (100%) diff --git a/.ci/jenkins/Jenkinsfile.daily-dev-publish b/.ci/jenkins/Jenkinsfile.daily-dev-publish index d343e7d5a2d..3d2311d083d 100644 --- a/.ci/jenkins/Jenkinsfile.daily-dev-publish +++ b/.ci/jenkins/Jenkinsfile.daily-dev-publish @@ -135,10 +135,10 @@ pipeline { KOGITO_MANAGEMENT_CONSOLE__name = 'incubator-kie-kogito-management-console' KOGITO_MANAGEMENT_CONSOLE__buildTag = "${params.BRANCH_NAME}" - KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__registry = 'docker.io' - KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__account = 'apache' - KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__name = 'kogito-postgresql-db-migrator-tool' - KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__buildTag = "${params.BRANCH_NAME}" + KOGITO_DB_MIGRATOR_TOOL__registry = 'docker.io' + KOGITO_DB_MIGRATOR_TOOL__account = 'apache' + KOGITO_DB_MIGRATOR_TOOL__name = 'kogito-db-migrator-tool' + KOGITO_DB_MIGRATOR_TOOL__buildTag = "${params.BRANCH_NAME}" SONATAFLOW_BUILDER_IMAGE__registry = 'docker.io' SONATAFLOW_BUILDER_IMAGE__account = 'apache' @@ -555,14 +555,14 @@ pipeline { } } - stage('Push kogito-postgresql-db-migrator-tool to Docker Hub') { + stage('Push kogito-db-migrator-tool to Docker Hub') { steps { script { dockerUtils.pushImageToRegistry( - "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__registry}", - "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__account}", - "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__name}", - "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__buildTag}", + "${env.KOGITO_DB_MIGRATOR_TOOL__registry}", + "${env.KOGITO_DB_MIGRATOR_TOOL__account}", + "${env.KOGITO_DB_MIGRATOR_TOOL__name}", + "${env.KOGITO_DB_MIGRATOR_TOOL__buildTag}", "${pipelineVars.dockerHubUserCredentialsId}", "${pipelineVars.dockerHubTokenCredentialsId}" ) diff --git a/.ci/jenkins/release-jobs/Jenkinsfile.kogito-db-migrator-tool b/.ci/jenkins/release-jobs/Jenkinsfile.kogito-db-migrator-tool index a1eaff874f1..e6eec502f15 100644 --- a/.ci/jenkins/release-jobs/Jenkinsfile.kogito-db-migrator-tool +++ b/.ci/jenkins/release-jobs/Jenkinsfile.kogito-db-migrator-tool @@ -40,16 +40,16 @@ pipeline { KIE_TOOLS_BUILD__buildContainerImages = 'true' - KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__registry = 'docker.io' - KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__account = 'apache' - KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__name = 'kogito-postgresql-db-migrator-tool' - KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__buildTag = "${params.RELEASE_VERSION}" + KOGITO_DB_MIGRATOR_TOOL__registry = 'docker.io' + KOGITO_DB_MIGRATOR_TOOL__account = 'apache' + KOGITO_DB_MIGRATOR_TOOL__name = 'kogito-db-migrator-tool' + KOGITO_DB_MIGRATOR_TOOL__buildTag = "${params.RELEASE_VERSION}" RELEASE_ARTIFACTS_DIR = "${WORKSPACE}/release-artifacts" DOCKER_CONFIG = "${WORKSPACE}/.docker" - PNPM_FILTER_STRING = '-F @kie-tools/kogito-postgresql-db-migrator-tool...' + PNPM_FILTER_STRING = '-F @kie-tools/kogito-db-migrator-tool...' } stages { @@ -137,17 +137,17 @@ pipeline { } } - stage('Push kogito-postgresql-db-migrator-tool to Docker Hub') { + stage('Push kogito-db-migrator-tool to Docker Hub') { when { expression { !params.DRY_RUN && params.RELEASE_CANDIDATE_VERSION == '' } } steps { script { dockerUtils.pushImageToRegistry( - "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__registry}", - "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__account}", - "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__name}", - "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL_buildTag}", + "${env.KOGITO_DB_MIGRATOR_TOOL__registry}", + "${env.KOGITO_DB_MIGRATOR_TOOL__account}", + "${env.KOGITO_DB_MIGRATOR_TOOL__name}", + "${env.KOGITO_DB_MIGRATOR_TOOL_buildTag}", "${pipelineVars.dockerHubUserCredentialsId}", "${pipelineVars.dockerHubTokenCredentialsId}" ) @@ -161,11 +161,11 @@ pipeline { } steps { script { - env.RELEASE_IMAGE_TAR_FILE = "incubator-kie-${params.RELEASE_CANDIDATE_VERSION}-kogito-postgresql-db-migrator-tool-image.tar.gz" + env.RELEASE_IMAGE_TAR_FILE = "incubator-kie-${params.RELEASE_CANDIDATE_VERSION}-kogito-db-migrator-tool-image.tar.gz" sh """#!/bin/bash -el mkdir ${env.RELEASE_ARTIFACTS_DIR} - docker save "${env.KOGITO_POSTGRESQL_DB_MIGRATOR_TOOL__registry}/${env.KOGITO_MANAGEMENT_CONSOLE__account}/${env.KOGITO_MANAGEMENT_CONSOLE__name}:${params.RELEASE_VERSION}" | gzip > "${env.RELEASE_ARTIFACTS_DIR}/${env.RELEASE_IMAGE_TAR_FILE}" + docker save "${env.KOGITO_DB_MIGRATOR_TOOL__registry}/${env.KOGITO_MANAGEMENT_CONSOLE__account}/${env.KOGITO_MANAGEMENT_CONSOLE__name}:${params.RELEASE_VERSION}" | gzip > "${env.RELEASE_ARTIFACTS_DIR}/${env.RELEASE_IMAGE_TAR_FILE}" """.trim() } } diff --git a/packages/kogito-postgresql-db-migrator-tool-image/README.md b/packages/kogito-db-migrator-tool-image/README.md similarity index 97% rename from packages/kogito-postgresql-db-migrator-tool-image/README.md rename to packages/kogito-db-migrator-tool-image/README.md index c357c0389b7..b7369264d78 100644 --- a/packages/kogito-postgresql-db-migrator-tool-image/README.md +++ b/packages/kogito-db-migrator-tool-image/README.md @@ -17,7 +17,7 @@ # Kogito PostgreSQL DB Migrator Tool Image -This package contains the `Containerfile/Dockerfile` and scripts to build a container image for Kogito PostgreSQL DB Migrator Tool. Details about the Kogito PostgreSQL DB Migrator Tool can be found [here](../kogito-postgresql-db-migrator-tool/README.md) +This package contains the `Containerfile/Dockerfile` and scripts to build a container image for Kogito PostgreSQL DB Migrator Tool. Details about the Kogito PostgreSQL DB Migrator Tool can be found [here](../kogito-db-migrator-tool/README.md) ## Additional requirements @@ -64,7 +64,7 @@ An example to use diverse environment variables --env QUARKUS_DATASOURCE_JOBSSERVICE_USERNAME= \ --env QUARKUS_DATASOURCE_JOBSSERVICE_PASSWORD= \ --env QUARKUS_FLYWAY_JOBSSERVICE_SCHEMAS=jobs-service \ - docker.io/apache/incubator-kie-kogito-postgresql-db-migrator-tool:main + docker.io/apache/incubator-kie-kogito-db-migrator-tool:main ``` --- diff --git a/packages/kogito-postgresql-db-migrator-tool-image/env/index.js b/packages/kogito-db-migrator-tool-image/env/index.js similarity index 96% rename from packages/kogito-postgresql-db-migrator-tool-image/env/index.js rename to packages/kogito-db-migrator-tool-image/env/index.js index 6cbd330c45d..00dc1399d44 100644 --- a/packages/kogito-postgresql-db-migrator-tool-image/env/index.js +++ b/packages/kogito-db-migrator-tool-image/env/index.js @@ -33,7 +33,7 @@ module.exports = composeEnv([rootEnv, sonataflowImageCommonEnv], { description: "The image registry account.", }, KOGITO_DB_MIGRATOR_TOOL_IMAGE__name: { - default: "incubator-kie-kogito-postgresql-db-migrator-tool", + default: "incubator-kie-kogito-db-migrator-tool", description: "The image name.", }, KOGITO_DB_MIGRATOR_TOOL_IMAGE__buildTag: { diff --git a/packages/kogito-postgresql-db-migrator-tool-image/install.js b/packages/kogito-db-migrator-tool-image/install.js similarity index 96% rename from packages/kogito-postgresql-db-migrator-tool-image/install.js rename to packages/kogito-db-migrator-tool-image/install.js index 3553989693a..cec8142a81d 100644 --- a/packages/kogito-postgresql-db-migrator-tool-image/install.js +++ b/packages/kogito-db-migrator-tool-image/install.js @@ -50,7 +50,7 @@ let imageYaml = fs.readFileSync(originalYamlPath, "utf8"); const imageUrl = `${env.kogitoDbMigratorToolImage.registry}/${env.kogitoDbMigratorToolImage.account}/${env.kogitoDbMigratorToolImage.name}`; // Replace the whole string between quotes ("") with the image name -imageYaml = imageYaml.replace(/(?<=")(.*kie-kogito-postgresql-db-migrator-tool.*)(?=")/gm, imageUrl); +imageYaml = imageYaml.replace(/(?<=")(.*kie-kogito-db-migrator-tool.*)(?=")/gm, imageUrl); // Write file and then rename it to match the image name fs.writeFileSync(originalYamlPath, imageYaml); diff --git a/packages/kogito-postgresql-db-migrator-tool-image/package.json b/packages/kogito-db-migrator-tool-image/package.json similarity index 90% rename from packages/kogito-postgresql-db-migrator-tool-image/package.json rename to packages/kogito-db-migrator-tool-image/package.json index c1f105076dd..106e3a540f8 100644 --- a/packages/kogito-postgresql-db-migrator-tool-image/package.json +++ b/packages/kogito-db-migrator-tool-image/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "@kie-tools/kogito-postgresql-db-migrator-tool-image", + "name": "@kie-tools/kogito-db-migrator-tool-image", "version": "0.0.0", "description": "", "license": "Apache-2.0", @@ -21,7 +21,7 @@ "build:prod:linux": "pnpm build", "build:prod:win32:darwin": "echo \"Build skipped on Windows and MacOS\"", "copy-assets": "run-script-os", - "copy-assets:linux:darwin": "rimraf build && cp -R ./node_modules/@kie-tools/sonataflow-image-common/resources build && cp -R resources/* build && mkdir -p build/modules/kogito-postgres-db-migration-deps/quarkus-app && cp -R ./node_modules/@kie-tools/kogito-postgresql-db-migrator-tool/target/quarkus-app/* build/modules/kogito-postgres-db-migration-deps/quarkus-app", + "copy-assets:linux:darwin": "rimraf build && cp -R ./node_modules/@kie-tools/sonataflow-image-common/resources build && cp -R resources/* build && mkdir -p build/modules/kogito-postgres-db-migration-deps/quarkus-app && cp -R ./node_modules/@kie-tools/kogito-db-migrator-tool/target/quarkus-app/* build/modules/kogito-postgres-db-migration-deps/quarkus-app", "format": "prettier --write . --ignore-path=../../.prettierignore --ignore-path=../../.gitignore", "image:build": "run-script-os", "image:build:linux": "pnpm setup:env make -C ./build build", @@ -31,7 +31,7 @@ "venv-activate": ". ./node_modules/@kie-tools/python-venv/venv/bin/activate" }, "dependencies": { - "@kie-tools/kogito-postgresql-db-migrator-tool": "workspace:*", + "@kie-tools/kogito-db-migrator-tool": "workspace:*", "@kie-tools/python-venv": "workspace:*", "@kie-tools/root-env": "workspace:*", "@kie-tools/sonataflow-image-common": "workspace:*" diff --git a/packages/kogito-postgresql-db-migrator-tool-image/resources/incubator-kie-kogito-postgresql-db-migrator-tool-image.yaml b/packages/kogito-db-migrator-tool-image/resources/incubator-kie-kogito-db-migrator-tool-image.yaml similarity index 95% rename from packages/kogito-postgresql-db-migrator-tool-image/resources/incubator-kie-kogito-postgresql-db-migrator-tool-image.yaml rename to packages/kogito-db-migrator-tool-image/resources/incubator-kie-kogito-db-migrator-tool-image.yaml index a063cf8a9f1..b1e5727432e 100644 --- a/packages/kogito-postgresql-db-migrator-tool-image/resources/incubator-kie-kogito-postgresql-db-migrator-tool-image.yaml +++ b/packages/kogito-db-migrator-tool-image/resources/incubator-kie-kogito-db-migrator-tool-image.yaml @@ -16,7 +16,7 @@ # specific language governing permissions and limitations # under the License. # -name: "docker.io/apache/incubator-kie-kogito-postgresql-db-migrator-tool" +name: "docker.io/apache/incubator-kie-kogito-db-migrator-tool" version: "main" from: registry.access.redhat.com/ubi8/openjdk-17-runtime:1.20 description: DBMigratorTool image for Data Index and Jobs Service database migration diff --git a/packages/kogito-postgresql-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml b/packages/kogito-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml similarity index 84% rename from packages/kogito-postgresql-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml rename to packages/kogito-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml index e90ebaa5962..3cb2a3a8a85 100644 --- a/packages/kogito-postgresql-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml +++ b/packages/kogito-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml @@ -20,7 +20,7 @@ schema_version: 1 name: org.kie.kogito.postgresql.db-migration-deps version: "main" artifacts: - # The following artifact comes from the package kogito-postgresql-db-migrator-tool during the pnpm build:dev phase - - name: kogito-postgresql-db-migrator-tool-quarkus-app + # The following artifact comes from the package kogito-db-migrator-tool during the pnpm build:dev phase + - name: kogito-db-migrator-tool-quarkus-app path: ./quarkus-app dest: /home/kogito/bin diff --git a/packages/kogito-postgresql-db-migrator-tool/.gitignore b/packages/kogito-db-migrator-tool/.gitignore similarity index 66% rename from packages/kogito-postgresql-db-migrator-tool/.gitignore rename to packages/kogito-db-migrator-tool/.gitignore index f30772d459b..8404612fa0f 100644 --- a/packages/kogito-postgresql-db-migrator-tool/.gitignore +++ b/packages/kogito-db-migrator-tool/.gitignore @@ -1,4 +1,4 @@ -# kogito-postgresql-db-migrator-tool +# kogito-db-migrator-tool src/main/resources/postgresql src/main/resources/ansi src/main/resources/h2 \ No newline at end of file diff --git a/packages/kogito-postgresql-db-migrator-tool/README.md b/packages/kogito-db-migrator-tool/README.md similarity index 100% rename from packages/kogito-postgresql-db-migrator-tool/README.md rename to packages/kogito-db-migrator-tool/README.md diff --git a/packages/kogito-postgresql-db-migrator-tool/env/index.js b/packages/kogito-db-migrator-tool/env/index.js similarity index 100% rename from packages/kogito-postgresql-db-migrator-tool/env/index.js rename to packages/kogito-db-migrator-tool/env/index.js diff --git a/packages/kogito-postgresql-db-migrator-tool/install.js b/packages/kogito-db-migrator-tool/install.js similarity index 100% rename from packages/kogito-postgresql-db-migrator-tool/install.js rename to packages/kogito-db-migrator-tool/install.js diff --git a/packages/kogito-postgresql-db-migrator-tool/package.json b/packages/kogito-db-migrator-tool/package.json similarity index 95% rename from packages/kogito-postgresql-db-migrator-tool/package.json rename to packages/kogito-db-migrator-tool/package.json index 07b805ebfd9..7ca5e31839b 100644 --- a/packages/kogito-postgresql-db-migrator-tool/package.json +++ b/packages/kogito-db-migrator-tool/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "@kie-tools/kogito-postgresql-db-migrator-tool", + "name": "@kie-tools/kogito-db-migrator-tool", "version": "0.0.0", "description": "", "license": "Apache-2.0", diff --git a/packages/kogito-postgresql-db-migrator-tool/pom.xml b/packages/kogito-db-migrator-tool/pom.xml similarity index 98% rename from packages/kogito-postgresql-db-migrator-tool/pom.xml rename to packages/kogito-db-migrator-tool/pom.xml index 590391fdb2c..0130bd33fda 100644 --- a/packages/kogito-postgresql-db-migrator-tool/pom.xml +++ b/packages/kogito-db-migrator-tool/pom.xml @@ -31,7 +31,7 @@ 4.0.0 org.kie.kogito - kogito-postgresql-db-migrator-tool + kogito-db-migrator-tool diff --git a/packages/kogito-postgresql-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBConnectionChecker.java b/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBConnectionChecker.java similarity index 100% rename from packages/kogito-postgresql-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBConnectionChecker.java rename to packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBConnectionChecker.java diff --git a/packages/kogito-postgresql-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBMigrator.java b/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBMigrator.java similarity index 100% rename from packages/kogito-postgresql-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBMigrator.java rename to packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBMigrator.java diff --git a/packages/kogito-postgresql-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/MigrationService.java b/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/MigrationService.java similarity index 100% rename from packages/kogito-postgresql-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/MigrationService.java rename to packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/MigrationService.java diff --git a/packages/kogito-postgresql-db-migrator-tool/src/main/resources/application.properties b/packages/kogito-db-migrator-tool/src/main/resources/application.properties similarity index 100% rename from packages/kogito-postgresql-db-migrator-tool/src/main/resources/application.properties rename to packages/kogito-db-migrator-tool/src/main/resources/application.properties diff --git a/packages/kogito-postgresql-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBConnectionCheckerTest.java b/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBConnectionCheckerTest.java similarity index 100% rename from packages/kogito-postgresql-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBConnectionCheckerTest.java rename to packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBConnectionCheckerTest.java diff --git a/packages/kogito-postgresql-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBMigratorTest.java b/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBMigratorTest.java similarity index 100% rename from packages/kogito-postgresql-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBMigratorTest.java rename to packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBMigratorTest.java diff --git a/packages/kogito-postgresql-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/MigrationServiceTest.java b/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/MigrationServiceTest.java similarity index 100% rename from packages/kogito-postgresql-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/MigrationServiceTest.java rename to packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/MigrationServiceTest.java diff --git a/packages/sonataflow-image-common/resources/scripts/build-kogito-apps-components.sh b/packages/sonataflow-image-common/resources/scripts/build-kogito-apps-components.sh index 88ac842f76b..fc661b7dcdc 100755 --- a/packages/sonataflow-image-common/resources/scripts/build-kogito-apps-components.sh +++ b/packages/sonataflow-image-common/resources/scripts/build-kogito-apps-components.sh @@ -56,7 +56,7 @@ if [ ! -z "${CYPRESS_BINARY_URL}" ]; then fi case ${imageName} in - "incubator-kie-kogito-postgresql-db-migrator-tool") + "incubator-kie-kogito-db-migrator-tool") contextDir="db-migrator-tool/image" ;; "incubator-kie-kogito-data-index-ephemeral") diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d5ce994492a..dc2a65ef136 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7403,7 +7403,7 @@ importers: specifier: ^1.1.6 version: 1.1.6 - packages/kogito-postgresql-db-migrator-tool: + packages/kogito-db-migrator-tool: dependencies: '@kie-tools/maven-base': specifier: workspace:* @@ -7419,11 +7419,11 @@ importers: specifier: ^1.1.6 version: 1.1.6 - packages/kogito-postgresql-db-migrator-tool-image: + packages/kogito-db-migrator-tool-image: dependencies: - '@kie-tools/kogito-postgresql-db-migrator-tool': + '@kie-tools/kogito-db-migrator-tool': specifier: workspace:* - version: link:../kogito-postgresql-db-migrator-tool + version: link:../kogito-db-migrator-tool '@kie-tools/python-venv': specifier: workspace:* version: link:../python-venv @@ -24518,6 +24518,7 @@ packages: glob@8.1.0: resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} engines: {node: '>=12'} + deprecated: Glob versions prior to v9 are no longer supported global-dirs@3.0.0: resolution: {integrity: sha512-v8ho2DS5RiCjftj1nD9NmnfaOzTdud7RRnVd9kFNOjqZbISlx5DQ+OrTkywgd0dIt7oFCvKetZSHoHcP3sDdiA==} @@ -25033,6 +25034,7 @@ packages: inflight@1.0.6: resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} + deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. inherits@2.0.3: resolution: {integrity: sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==} diff --git a/repo/graph.dot b/repo/graph.dot index 26347531f62..dab90395800 100644 --- a/repo/graph.dot +++ b/repo/graph.dot @@ -150,13 +150,13 @@ digraph G { "@kie-tools/sonataflow-image-common" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie/kogito-data-index-ephemeral-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie/kogito-data-index-postgresql-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; + "@kie-tools/kogito-db-migrator-tool" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; + "@kie-tools/kogito-db-migrator-tool-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie/kogito-jit-runner-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie/kogito-jobs-service-allinone-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie/kogito-jobs-service-ephemeral-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie/kogito-jobs-service-postgresql-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie-tools/runtime-tools-management-console-webapp" [ color = "blue", fontcolor = "blue", style = "rounded" ]; - "@kie-tools/kogito-postgresql-db-migrator-tool" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; - "@kie-tools/kogito-postgresql-db-migrator-tool-image" [ color = "black", fontcolor = "black", style = "dashed, rounded" ]; "@kie-tools-core/kubernetes-bridge" [ color = "purple", fontcolor = "purple", style = "rounded" ]; "@kie-tools-core/workspace" [ color = "purple", fontcolor = "purple", style = "rounded" ]; "@kie-tools/unitables-dmn" [ color = "blue", fontcolor = "blue", style = "rounded" ]; @@ -473,6 +473,9 @@ digraph G { "@kie/kogito-data-index-ephemeral-image" -> "@kie-tools/sonataflow-image-common" [ style = "dashed", color = "black" ]; "@kie/kogito-data-index-postgresql-image" -> "@kie-tools/maven-base" [ style = "dashed", color = "black" ]; "@kie/kogito-data-index-postgresql-image" -> "@kie-tools/sonataflow-image-common" [ style = "dashed", color = "black" ]; + "@kie-tools/kogito-db-migrator-tool" -> "@kie-tools/maven-base" [ style = "solid", color = "black" ]; + "@kie-tools/kogito-db-migrator-tool-image" -> "@kie-tools/kogito-db-migrator-tool" [ style = "solid", color = "black" ]; + "@kie-tools/kogito-db-migrator-tool-image" -> "@kie-tools/sonataflow-image-common" [ style = "solid", color = "black" ]; "@kie/kogito-jit-runner-image" -> "@kie-tools/maven-base" [ style = "dashed", color = "black" ]; "@kie/kogito-jit-runner-image" -> "@kie-tools/sonataflow-image-common" [ style = "dashed", color = "black" ]; "@kie/kogito-jobs-service-allinone-image" -> "@kie-tools/maven-base" [ style = "dashed", color = "black" ]; @@ -484,9 +487,6 @@ digraph G { "@kie-tools/kogito-management-console" -> "@kie-tools/image-builder" [ style = "dashed", color = "black" ]; "@kie-tools/kogito-management-console" -> "@kie-tools/image-env-to-json" [ style = "dashed", color = "black" ]; "@kie-tools/kogito-management-console" -> "@kie-tools/runtime-tools-management-console-webapp" [ style = "dashed", color = "black" ]; - "@kie-tools/kogito-postgresql-db-migrator-tool" -> "@kie-tools/maven-base" [ style = "solid", color = "black" ]; - "@kie-tools/kogito-postgresql-db-migrator-tool-image" -> "@kie-tools/kogito-postgresql-db-migrator-tool" [ style = "solid", color = "black" ]; - "@kie-tools/kogito-postgresql-db-migrator-tool-image" -> "@kie-tools/sonataflow-image-common" [ style = "solid", color = "black" ]; "@kie-tools-core/kubernetes-bridge" -> "@kie-tools/cors-proxy-api" [ style = "solid", color = "purple" ]; "@kie-tools/maven-base" -> "@kie-tools/root-env" [ style = "dashed", color = "black" ]; "@kie-tools/maven-m2-repo-via-http-image" -> "@kie-tools/image-builder" [ style = "dashed", color = "black" ]; diff --git a/repo/graph.json b/repo/graph.json index 87eb602e6a7..55c4a9b4b5e 100644 --- a/repo/graph.json +++ b/repo/graph.json @@ -192,10 +192,10 @@ { "id": "@kie/kogito-base-builder-image" }, { "id": "@kie-tools/sonataflow-image-common" }, { "id": "@kie-tools/python-venv" }, + { "id": "@kie-tools/kogito-db-migrator-tool" }, + { "id": "@kie-tools/kogito-db-migrator-tool-image" }, { "id": "@kie/kogito-jit-runner-image" }, { "id": "@kie/kogito-jobs-service-allinone-image" }, - { "id": "@kie-tools/kogito-postgresql-db-migrator-tool" }, - { "id": "@kie-tools/kogito-postgresql-db-migrator-tool-image" }, { "id": "@kie-tools/unitables" }, { "id": "pmml-vscode-extension" }, { "id": "@kie-tools/runtime-tools-components" }, @@ -2105,37 +2105,37 @@ "weight": 1 }, { - "source": "@kie/kogito-jit-runner-image", + "source": "@kie-tools/kogito-db-migrator-tool", "target": "@kie-tools/maven-base", "weight": 1 }, { - "source": "@kie/kogito-jit-runner-image", + "source": "@kie-tools/kogito-db-migrator-tool-image", + "target": "@kie-tools/kogito-db-migrator-tool", + "weight": 1 + }, + { + "source": "@kie-tools/kogito-db-migrator-tool-image", "target": "@kie-tools/sonataflow-image-common", "weight": 1 }, { - "source": "@kie/kogito-jobs-service-allinone-image", + "source": "@kie/kogito-jit-runner-image", "target": "@kie-tools/maven-base", "weight": 1 }, { - "source": "@kie/kogito-jobs-service-allinone-image", + "source": "@kie/kogito-jit-runner-image", "target": "@kie-tools/sonataflow-image-common", "weight": 1 }, { - "source": "@kie-tools/kogito-postgresql-db-migrator-tool", + "source": "@kie/kogito-jobs-service-allinone-image", "target": "@kie-tools/maven-base", "weight": 1 }, { - "source": "@kie-tools/kogito-postgresql-db-migrator-tool-image", - "target": "@kie-tools/kogito-postgresql-db-migrator-tool", - "weight": 1 - }, - { - "source": "@kie-tools/kogito-postgresql-db-migrator-tool-image", + "source": "@kie/kogito-jobs-service-allinone-image", "target": "@kie-tools/sonataflow-image-common", "weight": 1 }, @@ -2848,13 +2848,13 @@ ["@kie/kogito-base-builder-image", "packages/kogito-base-builder-image"], ["@kie/kogito-data-index-ephemeral-image", "packages/kogito-data-index-ephemeral-image"], ["@kie/kogito-data-index-postgresql-image", "packages/kogito-data-index-postgresql-image"], + ["@kie-tools/kogito-db-migrator-tool", "packages/kogito-db-migrator-tool"], + ["@kie-tools/kogito-db-migrator-tool-image", "packages/kogito-db-migrator-tool-image"], ["@kie/kogito-jit-runner-image", "packages/kogito-jit-runner-image"], ["@kie/kogito-jobs-service-allinone-image", "packages/kogito-jobs-service-allinone-image"], ["@kie/kogito-jobs-service-ephemeral-image", "packages/kogito-jobs-service-ephemeral-image"], ["@kie/kogito-jobs-service-postgresql-image", "packages/kogito-jobs-service-postgresql-image"], ["@kie-tools/kogito-management-console", "packages/kogito-management-console"], - ["@kie-tools/kogito-postgresql-db-migrator-tool", "packages/kogito-postgresql-db-migrator-tool"], - ["@kie-tools/kogito-postgresql-db-migrator-tool-image", "packages/kogito-postgresql-db-migrator-tool-image"], ["@kie-tools-core/kubernetes-bridge", "packages/kubernetes-bridge"], ["@kie-tools/maven-base", "packages/maven-base"], ["@kie-tools/maven-m2-repo-via-http-image", "packages/maven-m2-repo-via-http-image"], From 5f57c07aa544eddd8cb369a18f672f744822fcc8 Mon Sep 17 00:00:00 2001 From: rhkp Date: Mon, 27 Jan 2025 16:07:00 +0000 Subject: [PATCH 7/7] Address review comments --- packages/kogito-db-migrator-tool-image/README.md | 6 +++--- packages/kogito-db-migrator-tool-image/package.json | 2 +- .../incubator-kie-kogito-db-migrator-tool-image.yaml | 6 +++--- .../postgresql}/module.yaml | 2 +- packages/kogito-db-migrator-tool/README.md | 6 +++--- .../postgresql}/DBConnectionChecker.java | 2 +- .../migrator => migrator/postgresql}/DBMigrator.java | 2 +- .../migrator => migrator/postgresql}/MigrationService.java | 2 +- .../postgresql}/DBConnectionCheckerTest.java | 2 +- .../migrator => migrator/postgresql}/DBMigratorTest.java | 2 +- .../postgresql}/MigrationServiceTest.java | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) rename packages/kogito-db-migrator-tool-image/resources/modules/{kogito-postgres-db-migration-deps => kogito-db-migrator-tool/postgresql}/module.yaml (94%) rename packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/{postgresql/migrator => migrator/postgresql}/DBConnectionChecker.java (98%) rename packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/{postgresql/migrator => migrator/postgresql}/DBMigrator.java (98%) rename packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/{postgresql/migrator => migrator/postgresql}/MigrationService.java (97%) rename packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/{postgresql/migrator => migrator/postgresql}/DBConnectionCheckerTest.java (98%) rename packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/{postgresql/migrator => migrator/postgresql}/DBMigratorTest.java (98%) rename packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/{postgresql/migrator => migrator/postgresql}/MigrationServiceTest.java (98%) diff --git a/packages/kogito-db-migrator-tool-image/README.md b/packages/kogito-db-migrator-tool-image/README.md index b7369264d78..687be814fe5 100644 --- a/packages/kogito-db-migrator-tool-image/README.md +++ b/packages/kogito-db-migrator-tool-image/README.md @@ -15,9 +15,9 @@ under the License. --> -# Kogito PostgreSQL DB Migrator Tool Image +# Kogito DB Migrator Tool Image -This package contains the `Containerfile/Dockerfile` and scripts to build a container image for Kogito PostgreSQL DB Migrator Tool. Details about the Kogito PostgreSQL DB Migrator Tool can be found [here](../kogito-db-migrator-tool/README.md) +This package contains the `Containerfile/Dockerfile` and scripts to build a container image for Kogito DB Migrator Tool, which currently supports PostgreSQL database. Future versions are expected to support more database variants. Details about the Kogito DB Migrator Tool can be found [here](../kogito-db-migrator-tool/README.md) ## Additional requirements @@ -28,7 +28,7 @@ This package contains the `Containerfile/Dockerfile` and scripts to build a cont - Start up a clean container with: ```bash - docker run docker.io/apache/incubator-kie-kogito-service-db-migration-postgresql:main + docker run docker.io/apache/incubator-kie-kogito-db-migrator-tool:main ``` ## Customization diff --git a/packages/kogito-db-migrator-tool-image/package.json b/packages/kogito-db-migrator-tool-image/package.json index 106e3a540f8..14ed917e88d 100644 --- a/packages/kogito-db-migrator-tool-image/package.json +++ b/packages/kogito-db-migrator-tool-image/package.json @@ -21,7 +21,7 @@ "build:prod:linux": "pnpm build", "build:prod:win32:darwin": "echo \"Build skipped on Windows and MacOS\"", "copy-assets": "run-script-os", - "copy-assets:linux:darwin": "rimraf build && cp -R ./node_modules/@kie-tools/sonataflow-image-common/resources build && cp -R resources/* build && mkdir -p build/modules/kogito-postgres-db-migration-deps/quarkus-app && cp -R ./node_modules/@kie-tools/kogito-db-migrator-tool/target/quarkus-app/* build/modules/kogito-postgres-db-migration-deps/quarkus-app", + "copy-assets:linux:darwin": "rimraf build && cp -R ./node_modules/@kie-tools/sonataflow-image-common/resources build && cp -R resources/* build && mkdir -p build/modules/kogito-db-migrator-tool/postgresql/quarkus-app && cp -R ./node_modules/@kie-tools/kogito-db-migrator-tool/target/quarkus-app/* build/modules/kogito-db-migrator-tool/postgresql/quarkus-app", "format": "prettier --write . --ignore-path=../../.prettierignore --ignore-path=../../.gitignore", "image:build": "run-script-os", "image:build:linux": "pnpm setup:env make -C ./build build", diff --git a/packages/kogito-db-migrator-tool-image/resources/incubator-kie-kogito-db-migrator-tool-image.yaml b/packages/kogito-db-migrator-tool-image/resources/incubator-kie-kogito-db-migrator-tool-image.yaml index b1e5727432e..77c938493f1 100644 --- a/packages/kogito-db-migrator-tool-image/resources/incubator-kie-kogito-db-migrator-tool-image.yaml +++ b/packages/kogito-db-migrator-tool-image/resources/incubator-kie-kogito-db-migrator-tool-image.yaml @@ -27,9 +27,9 @@ labels: - name: "maintainer" value: "Apache KIE " - name: "io.k8s.description" - value: "Kogito DB Migration creates schemas and tables for Data Index and Jobs Service for PostgreSQL database" + value: "Kogito DB Migration creates schemas and tables for Data Index and Jobs Service, currently supporting PostgreSQL database" - name: "io.k8s.display-name" - value: "Kogito DB Migration Tool for Data Index and Jobs Service - PostgreSQL" + value: "Kogito DB Migration Tool for Data Index and Jobs Service, currently supporting PostgreSQL" - name: "io.openshift.tags" value: "kogito,db-migration" @@ -39,7 +39,7 @@ modules: install: - name: org.kie.kogito.system.user - name: org.kie.kogito.project.versions - - name: org.kie.kogito.postgresql.db-migration-deps + - name: org.kie.kogito.db-migrator-tool.db-migration-deps run: workdir: "/home/kogito/bin" diff --git a/packages/kogito-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml b/packages/kogito-db-migrator-tool-image/resources/modules/kogito-db-migrator-tool/postgresql/module.yaml similarity index 94% rename from packages/kogito-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml rename to packages/kogito-db-migrator-tool-image/resources/modules/kogito-db-migrator-tool/postgresql/module.yaml index 3cb2a3a8a85..ac7ea41917e 100644 --- a/packages/kogito-db-migrator-tool-image/resources/modules/kogito-postgres-db-migration-deps/module.yaml +++ b/packages/kogito-db-migrator-tool-image/resources/modules/kogito-db-migrator-tool/postgresql/module.yaml @@ -17,7 +17,7 @@ # under the License. # schema_version: 1 -name: org.kie.kogito.postgresql.db-migration-deps +name: org.kie.kogito.db-migrator-tool.db-migration-deps version: "main" artifacts: # The following artifact comes from the package kogito-db-migrator-tool during the pnpm build:dev phase diff --git a/packages/kogito-db-migrator-tool/README.md b/packages/kogito-db-migrator-tool/README.md index fae3670fc1a..8b8d7dda24b 100644 --- a/packages/kogito-db-migrator-tool/README.md +++ b/packages/kogito-db-migrator-tool/README.md @@ -1,8 +1,8 @@ -# Kogito PostgreSQL DB Migrator Tool +# Kogito DB Migrator Tool -This is a Java, Quarkus-based PostgreSQL database migrator application for Data-Index and Jobs Service applications for use by SonataFlow Operator. +This is a Java, Quarkus-based database migrator application for Data-Index and Jobs Service applications for use by SonataFlow Operator supporting PostgreSQL database currently. Future versions are expected to support more database variants. -_NOTE_: This PostgreSQL database migrator application and its corresponding images are only envisaged to be made use of by SonataFlow Operator, Data Index and Jobs Service internally. Conversely this application is of no use outside the usecases involved with SonataFlow Operator, Data Index and Jobs Service applications. +_NOTE_: This database migrator application and its corresponding images are only envisaged to be made use of by SonataFlow Operator, Data Index and Jobs Service internally. Conversely this application is of no use outside the usecases involved with SonataFlow Operator, Data Index and Jobs Service applications. --- diff --git a/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBConnectionChecker.java b/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/migrator/postgresql/DBConnectionChecker.java similarity index 98% rename from packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBConnectionChecker.java rename to packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/migrator/postgresql/DBConnectionChecker.java index c9143f850cc..3fb4ea76bc9 100644 --- a/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBConnectionChecker.java +++ b/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/migrator/postgresql/DBConnectionChecker.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.postgresql.migrator; +package org.kie.kogito.migrator.postgresql; import java.sql.Connection; import java.sql.DriverManager; diff --git a/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBMigrator.java b/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/migrator/postgresql/DBMigrator.java similarity index 98% rename from packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBMigrator.java rename to packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/migrator/postgresql/DBMigrator.java index 67c3f5e46a9..9031a4365f2 100644 --- a/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/DBMigrator.java +++ b/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/migrator/postgresql/DBMigrator.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.kie.kogito.postgresql.migrator; +package org.kie.kogito.migrator.postgresql; import io.quarkus.runtime.Quarkus; import io.quarkus.runtime.QuarkusApplication; diff --git a/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/MigrationService.java b/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/migrator/postgresql/MigrationService.java similarity index 97% rename from packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/MigrationService.java rename to packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/migrator/postgresql/MigrationService.java index f6a86d704e0..aa94833aba5 100644 --- a/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/postgresql/migrator/MigrationService.java +++ b/packages/kogito-db-migrator-tool/src/main/java/org/kie/kogito/migrator/postgresql/MigrationService.java @@ -17,7 +17,7 @@ * under the License. */ -package org.kie.kogito.postgresql.migrator; + package org.kie.kogito.migrator.postgresql; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; diff --git a/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBConnectionCheckerTest.java b/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/migrator/postgresql/DBConnectionCheckerTest.java similarity index 98% rename from packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBConnectionCheckerTest.java rename to packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/migrator/postgresql/DBConnectionCheckerTest.java index 77e23482f76..0393c226c6b 100644 --- a/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBConnectionCheckerTest.java +++ b/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/migrator/postgresql/DBConnectionCheckerTest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.kie.kogito.postgresql.migrator; +package org.kie.kogito.migrator.postgresql; import io.quarkus.test.Mock; import org.junit.jupiter.api.BeforeAll; diff --git a/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBMigratorTest.java b/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/migrator/postgresql/DBMigratorTest.java similarity index 98% rename from packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBMigratorTest.java rename to packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/migrator/postgresql/DBMigratorTest.java index abb0516f364..eb431bc168d 100644 --- a/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/DBMigratorTest.java +++ b/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/migrator/postgresql/DBMigratorTest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.kie.kogito.postgresql.migrator; +package org.kie.kogito.migrator.postgresql; import io.quarkus.test.Mock; import org.junit.jupiter.api.BeforeEach; diff --git a/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/MigrationServiceTest.java b/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/migrator/postgresql/MigrationServiceTest.java similarity index 98% rename from packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/MigrationServiceTest.java rename to packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/migrator/postgresql/MigrationServiceTest.java index b64f23f105d..bce5e4f88c1 100644 --- a/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/postgresql/migrator/MigrationServiceTest.java +++ b/packages/kogito-db-migrator-tool/src/test/java/org/kie/kogito/migrator/postgresql/MigrationServiceTest.java @@ -17,7 +17,7 @@ * under the License. */ -package org.kie.kogito.postgresql.migrator; +package org.kie.kogito.migrator.postgresql; import io.quarkus.test.Mock; import org.flywaydb.core.Flyway;