From f03eda1cc45df67b17496b37f0eaba50e717de21 Mon Sep 17 00:00:00 2001 From: Ondrej Babec Date: Tue, 25 Jul 2023 11:16:18 +0200 Subject: [PATCH] DBZ-6827 Testing farm onboarding --- .fmf/README.md | 6 + .fmf/version | 1 + .packit.yaml | 351 +++++++++++++++++++ debezium-connector-oracle/pom.xml | 2 +- debezium-testing/tmt/README.md | 72 ++++ debezium-testing/tmt/plans/main.fmf | 100 ++++++ debezium-testing/tmt/plans/oracle.fmf | 39 +++ debezium-testing/tmt/tests/debezium/main.fmf | 45 +++ debezium-testing/tmt/tests/debezium/test.sh | 52 +++ 9 files changed, 667 insertions(+), 1 deletion(-) create mode 100644 .fmf/README.md create mode 100644 .fmf/version create mode 100644 .packit.yaml create mode 100644 debezium-testing/tmt/README.md create mode 100644 debezium-testing/tmt/plans/main.fmf create mode 100644 debezium-testing/tmt/plans/oracle.fmf create mode 100644 debezium-testing/tmt/tests/debezium/main.fmf create mode 100755 debezium-testing/tmt/tests/debezium/test.sh diff --git a/.fmf/README.md b/.fmf/README.md new file mode 100644 index 000000000..aff919ce3 --- /dev/null +++ b/.fmf/README.md @@ -0,0 +1,6 @@ +## FMF + +Flexible Metadata Format [(doc)](https://fmf.readthedocs.io/en/stable/overview.html#description) + +This [folder](.) and version [file](version) are required for testing-farm and packit integration. +To see more information about testing-farm please read this [documentation](../debezium-testing/tmt/README.md). \ No newline at end of file diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/.packit.yaml b/.packit.yaml new file mode 100644 index 000000000..224e75b1b --- /dev/null +++ b/.packit.yaml @@ -0,0 +1,351 @@ +# Default packit instance is a prod and only this is used +# stg instance is present for testing new packit features in forked repositories where stg is installed. +packit_instances: ["prod", "stg"] +upstream_project_url: https://github.com/debezium/debezium +issue_repository: https://github.com/debezium/debezium +jobs: + - job: tests + trigger: pull_request + # Suffix for job name + identifier: "postgres-12-decoderbufs" + targets: + - centos-stream-8-x86_64 + skip_build: true + manual_trigger: true + labels: + - postgres + tf_extra_params: + test: + tmt: + name: postgres + environments: + - variables: + POSTGRESQL_VERSION: 12 + DECODER_PLUGIN: decoderbufs + + ############################################################################################### + - job: tests + trigger: pull_request + # Suffix for job name + identifier: "postgres-12-pgoutput" + targets: + - centos-stream-8-x86_64 + skip_build: true + manual_trigger: true + labels: + - postgres + tf_extra_params: + test: + tmt: + name: postgres + environments: + - variables: + POSTGRESQL_VERSION: 12 + DECODER_PLUGIN: pgoutput + + ############################################################################################### + - job: tests + trigger: pull_request + # Suffix for job name + identifier: "postgres-15-decoderbufs" + targets: + - centos-stream-8-x86_64 + skip_build: true + manual_trigger: true + labels: + - postgres + tf_extra_params: + test: + tmt: + name: postgres + environments: + - variables: + POSTGRESQL_VERSION: 15 + DECODER_PLUGIN: decoderbufs + + + ############################################################################################### + - job: tests + trigger: pull_request + # Suffix for job name + identifier: "postgres-15-pgoutput" + targets: + - centos-stream-8-x86_64 + skip_build: true + manual_trigger: true + labels: + - postgres + tf_extra_params: + test: + tmt: + name: postgres + environments: + - variables: + POSTGRESQL_VERSION: 15 + DECODER_PLUGIN: pgoutput + + ############################################################################################### + - job: tests + trigger: pull_request + # Suffix for job name + identifier: "mysql-8-none" + targets: + - centos-stream-8-x86_64 + skip_build: true + manual_trigger: true + labels: + - mysql + tf_extra_params: + test: + tmt: + name: mysql + environments: + - variables: + MYSQL_VERSION: 8.0.32 + PROFILE: none + + ############################################################################################### + - job: tests + trigger: pull_request + # Suffix for job name + identifier: "mysql-8-assembly" + targets: + - centos-stream-8-x86_64 + skip_build: true + manual_trigger: true + labels: + - mysql + tf_extra_params: + test: + tmt: + name: mysql + environments: + - variables: + MYSQL_VERSION: 8.0.32 + PROFILE: assembly + + ############################################################################################### + - job: tests + trigger: pull_request + # Suffix for job name + identifier: "mysql-5-none" + targets: + - centos-stream-8-x86_64 + skip_build: true + manual_trigger: true + labels: + - mysql + tf_extra_params: + test: + tmt: + name: mysql + environments: + - variables: + MYSQL_VERSION: 5.7 + PROFILE: none + + ############################################################################################### + - job: tests + trigger: pull_request + # Suffix for job name + identifier: "mysql-5-assembly" + targets: + - centos-stream-8-x86_64 + skip_build: true + manual_trigger: true + labels: + - mysql + tf_extra_params: + test: + tmt: + name: mysql + environments: + - variables: + MYSQL_VERSION: 5.7 + PROFILE: assembly + + ############################################################################################### + - job: tests + trigger: pull_request + # Suffix for job name + identifier: "sqlserver-2017" + targets: + - centos-stream-8-x86_64 + skip_build: true + manual_trigger: true + labels: + - sqlserver + tf_extra_params: + test: + tmt: + name: sqlserver + environments: + - variables: + SQL_SERVER_VERSION: 2017 + + ############################################################################################### + - job: tests + trigger: pull_request + # Suffix for job name + identifier: "sqlserver-2022" + targets: + - centos-stream-8-x86_64 + skip_build: true + manual_trigger: true + labels: + - sqlserver + tf_extra_params: + test: + tmt: + name: sqlserver + environments: + - variables: + SQL_SERVER_VERSION: 2022 + + ############################################################################################### + - job: tests + trigger: pull_request + # Suffix for job name + identifier: "mongodb-4" + targets: + - centos-stream-8-x86_64 + skip_build: true + manual_trigger: true + labels: + - mongodb + tf_extra_params: + test: + tmt: + name: mongodb + environments: + - variables: + MONGODB_VERSION: 4.4 + TEST_PROFILE: mongodb + + ############################################################################################### + - job: tests + trigger: pull_request + # Suffix for job name + identifier: "mongodb-5" + targets: + - centos-stream-8-x86_64 + skip_build: true + manual_trigger: true + labels: + - mongodb + tf_extra_params: + test: + tmt: + name: mongodb + environments: + - variables: + MONGODB_VERSION: 5.0 + TEST_PROFILE: mongodb + + ############################################################################################### + - job: tests + trigger: pull_request + # Suffix for job name + identifier: "mongodb-6" + targets: + - centos-stream-8-x86_64 + skip_build: true + manual_trigger: true + labels: + - mongodb + tf_extra_params: + test: + tmt: + name: mongodb + environments: + - variables: + MONGODB_VERSION: 6.0 + TEST_PROFILE: mongodb + + ############################################################################################### + - job: tests + trigger: pull_request + # Suffix for job name + identifier: "oracle-21" + targets: + centos-stream-8-x86_64: + distros: ["debezium-tf-2130"] + skip_build: true + manual_trigger: true + labels: + - oracle + tf_extra_params: + test: + tmt: + name: oracle + environments: + - variables: + ORACLE_VERSION: 21.3.0 + TEST_PROFILE: oracle + + ############################################################################################### + - job: tests + trigger: pull_request + # Suffix for job name + identifier: "oracle-21-xs" + targets: + centos-stream-8-x86_64: + distros: [ "debezium-tf-2130-xs" ] + skip_build: true + manual_trigger: true + labels: + - oracle + tf_extra_params: + test: + tmt: + name: oracle + environments: + - variables: + ORACLE_VERSION: 21.3.0-xs + TEST_PROFILE: oracle + ORACLE_ARG: "-Poracle-xstream" + + ############################################################################################### + - job: tests + trigger: pull_request + # Suffix for job name + identifier: "oracle-19" + targets: + centos-stream-8-x86_64: + distros: [ "debezium-tf-1930" ] + skip_build: true + manual_trigger: true + labels: + - oracle + tf_extra_params: + test: + tmt: + name: oracle + environments: + - variables: + ORACLE_VERSION: 19.3.0 + TEST_PROFILE: oracle + + ############################################################################################### + - job: tests + trigger: pull_request + # Suffix for job name + identifier: "oracle-19-xs" + targets: + centos-stream-8-x86_64: + distros: [ "debezium-tf-1930-xs" ] + skip_build: true + manual_trigger: true + labels: + - oracle + tf_extra_params: + test: + tmt: + name: oracle + environments: + - variables: + ORACLE_VERSION: 19.3.0-xs + TEST_PROFILE: oracle + ORACLE_ARG: "-Poracle-xstream" + + ############################################################################################### \ No newline at end of file diff --git a/debezium-connector-oracle/pom.xml b/debezium-connector-oracle/pom.xml index be1a43146..ec854bb8b 100644 --- a/debezium-connector-oracle/pom.xml +++ b/debezium-connector-oracle/pom.xml @@ -252,7 +252,7 @@ ${skipITs} true - 1 + 0 -Djava.library.path=${instantclient.dir} -Ddebezium.embedded.shutdown.pause.before.interrupt.ms=20000 -Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl ${adapter.name} diff --git a/debezium-testing/tmt/README.md b/debezium-testing/tmt/README.md new file mode 100644 index 000000000..e398d0724 --- /dev/null +++ b/debezium-testing/tmt/README.md @@ -0,0 +1,72 @@ +# Testing farm + +This document gives a detailed breakdown of the testing processes using testing farm service. + +## Pre-requisites + +* Python >=3.9 +* TMT command line tool (optional) - for lint and check tmt formatted test plans and tests + * `pip install tmt[all]` +* Testing farm command line tool - for trigger your test plan in testing-farm + * `pip install tft-cli` + +## Links + +* [Test Management Tool (tmt)](https://tmt.readthedocs.io/en/latest/index.html) +* [Testing farm](https://docs.testing-farm.io/general/0.1/index.html) + +## Current plans and tests +Plans are stored in [plans](./plans) folder, there are files called `main.fmf`, and `oracle.fmf` which contain test plan definitions. +This definition is composed of hw requirements, prepare steps for created VM executor and specific plans. Specific +plan defines selectors for [tests](./tests) which should be executed. + +### List of plans +* mysql +* postgres +* oracle +* sqlserver +* mongodb + +## Usage + +### Pre-requisites +1. Get API token for testing farm [(how-to obtain token)](https://docs.testing-farm.io/general/0.1/onboarding.html) +2. Store token into env var ```export TESTING_FARM_API_TOKEN="your_token"``` + +### Run tests + +Run all plans +```commandline +testing-farm request --compose CentOS-Stream-8 --git-url https://github.com/debezium/debezium.git +``` + +Select specific plan and git branch +```commandline +testing-farm request --compose CentOS-Stream-8 \ + --git-url https://github.com/debezium/debezium.git \ + --git-ref some-branch \ + --plan mysql +``` + +## Packit-as-a-service for PR check + +[Packit-as-a-service](https://github.com/marketplace/packit-as-a-service) is a GitHub application +for running testing-farm jobs from PR requested by command. Definition of the jobs is stored in +[.packit.yaml](../../.packit.yaml). Packit can be triggered from the PR by comment, but only members of Debezium +organization are able to run tests. + +### Usage + +Run all jobs for PR +``` +/packit test +``` + +Run selected jobs by label +``` +/packit test --labels mysql,postgres +``` +Run selected job by identifier +``` +/packit test --identifier mysql-8-assembly +``` \ No newline at end of file diff --git a/debezium-testing/tmt/plans/main.fmf b/debezium-testing/tmt/plans/main.fmf new file mode 100644 index 000000000..622433b3d --- /dev/null +++ b/debezium-testing/tmt/plans/main.fmf @@ -0,0 +1,100 @@ +# TMT test plan definition +# https://tmt.readthedocs.io/en/latest/overview.html + +# Baseline common for all test plans +####################################################################### +summary: Debezium functional testsuite +discover: + how: fmf + +# Required HW +provision: + hardware: + memory: ">= 24 GiB" + cpu: + processors: ">= 8" + + +# Install required packages and scripts for running debezium suite +prepare: + - name: Install packages + how: install + package: + - wget + - java-17-openjdk-devel + - xz + - make + - git + - zip + - coreutils + + - name: Install docker-ce + how: shell + script: | + OS=$(cat /etc/redhat-release || true) + if [[ ${OS} == *"CentOS"* ]]; then + sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo + else + sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo + fi + sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin + sudo systemctl enable docker --now + + - name: Install mvn + how: shell + script: | + mkdir -p /usr/share/maven /usr/share/maven/ref + curl -fsSL -o /tmp/apache-maven.tar.gz https://apache.osuosl.org/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz + tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 + rm -f /tmp/apache-maven.tar.gz + ln -s /usr/share/maven/bin/mvn /usr/bin/mvn + +# Discover tmt defined tests in tests/ folder +execute: + how: tmt + +####################################################################### + +/mysql: + summary: Run mysql connector functional tests + provision: + hardware: + memory: ">= 16 GiB" + cpu: + processors: ">= 4" + discover+: + test: + - mysql + +/postgres: + summary: Run postgresql connector functional tests + provision: + hardware: + memory: ">= 16 GiB" + cpu: + processors: ">= 4" + discover+: + test: + - postgres + +/sqlserver: + summary: Run sqlserver connector functional tests + provision: + hardware: + memory: ">= 16 GiB" + cpu: + processors: ">= 4" + discover+: + test: + - sqlserver + +/mongodb: + summary: Run mongodb connector functional tests + provision: + hardware: + memory: ">= 16 GiB" + cpu: + processors: ">= 4" + discover+: + test: + - mongodb diff --git a/debezium-testing/tmt/plans/oracle.fmf b/debezium-testing/tmt/plans/oracle.fmf new file mode 100644 index 000000000..d0b051fd8 --- /dev/null +++ b/debezium-testing/tmt/plans/oracle.fmf @@ -0,0 +1,39 @@ +# TMT test plan definition +# https://tmt.readthedocs.io/en/latest/overview.html + +# Baseline common for all test plans +####################################################################### +summary: Debezium oracle functional testsuite +discover: + how: fmf + +# Required HW +provision: + hardware: + memory: ">= 32 GiB" + cpu: + processors: ">= 16" + +# Install required packages and scripts for running debezium suite +prepare: + - name: Start docker-ce + how: shell + script: | + sudo systemctl enable docker --now + +# Discover tmt defined tests in tests/ folder +execute: + how: tmt + +####################################################################### + +/oracle: + summary: Run oracle connector functional tests + provision: + hardware: + memory: ">= 32 GiB" + cpu: + processors: ">= 16" + discover+: + test: + - oracle diff --git a/debezium-testing/tmt/tests/debezium/main.fmf b/debezium-testing/tmt/tests/debezium/main.fmf new file mode 100644 index 000000000..a6c2e5735 --- /dev/null +++ b/debezium-testing/tmt/tests/debezium/main.fmf @@ -0,0 +1,45 @@ +test: + ./test.sh +duration: 2h +environment: + MAVEN_ARGS: "-U -am -fae -Papicurio -Dinsecure.repositories=WARN -pl debezium-bom" + +/mysql: + summary: Run mysql connector functional tests + tags: [debezium, mysql] + duration: 4h + tier: 2 + environment+: + TEST_PROFILE: mysql + +/postgres: + summary: Run postgresql connector functional tests + tags: [debezium, postgresql] + duration: 4h + tier: 2 + environment+: + TEST_PROFILE: postgres + +/oracle: + summary: Run oracle connector functional tests + tags: [debezium, oracle] + duration: 4h + tier: 1 + environment+: + TEST_PROFILE: oracle + +/sqlserver: + summary: Run sqlserver connector functional tests + tags: [debezium, sqlserver] + duration: 4h + tier: 2 + environment+: + TEST_PROFILE: sqlserver + +/mongodb: + summary: Run mongodb connector functional tests + tags: [debezium, mongodb] + duration: 4h + tier: 2 + environment+: + TEST_PROFILE: mongodb \ No newline at end of file diff --git a/debezium-testing/tmt/tests/debezium/test.sh b/debezium-testing/tmt/tests/debezium/test.sh new file mode 100755 index 000000000..5088e2ee3 --- /dev/null +++ b/debezium-testing/tmt/tests/debezium/test.sh @@ -0,0 +1,52 @@ +#!/bin/sh -eux + +cd ../../../.. + +echo $PWD + +if [ "$TEST_PROFILE" = "mysql" ] +then + mvn clean install ${MAVEN_ARGS},debezium-connector-mysql \ + -Dversion.mysql.server=${MYSQL_VERSION} \ + -Dmysql.port=4301 \ + -Dmysql.replica.port=4301 \ + -Dmysql.gtid.port=4302 \ + -Dmysql.gtid.replica.port=4303 \ + -P${PROFILE} +elif [ "$TEST_PROFILE" = "postgres" ] +then + mvn clean install ${MAVEN_ARGS},debezium-connector-postgres \ + -Dpostgres.port=55432 \ + -Dversion.postgres.server=${POSTGRESQL_VERSION} \ + -Ddecoder.plugin.name=${DECODER_PLUGIN} \ + -Dtest.argline="-Ddebezium.test.records.waittime=5" +elif [ "$TEST_PROFILE" = "oracle" ] +then + source ${HOME}/install-oracle-driver.sh + export LD_LIBRARY_PATH=$ORACLE_ARTIFACT_DIR + mvn clean install -U-pl debezium-connector-oracle -am -fae \ + -Poracle-tests \ + ${ORACLE_ARG:-} \ + -Ddatabase.hostname=0.0.0.0 \ + -Ddatabase.admin.hostname=0.0.0.0 \ + -Dinstantclient.dir=${ORACLE_ARTIFACT_DIR} \ + -Dinsecure.repositories=WARN \ + -Ddatabase.user="c##dbzuser" \ + -Papicurio +elif [ "$TEST_PROFILE" = "sqlserver" ] +then + if [ "$SQL_SERVER_VERSION" = "2017" ] + then + export DATABASE_IMAGE="mcr.microsoft.com/mssql/server:2017-latest" + else + export DATABASE_IMAGE="mcr.microsoft.com/mssql/server:2022-latest" + fi + mvn clean install ${MAVEN_ARGS},debezium-connector-sqlserver \ + -Ddocker.db="${DATABASE_IMAGE}" +else + mvn clean install ${MAVEN_ARGS},debezium-connector-mongodb \ + -Dversion.mongo.server=${MONGODB_VERSION} +fi + + +