<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>io.debezium.quarkus</groupId>
        <artifactId>debezium-quarkus-mysql-parent</artifactId>
        <version>3.6.0.Beta2</version>
    </parent>

    <artifactId>debezium-quarkus-mysql-integration-tests</artifactId>

    <name>Debezium Quarkus :: Extension :: MySQL :: Integration Tests</name>

    <properties>
        <mysql.image.name>container-registry.oracle.com/mysql/community-server:9.1</mysql.image.name>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.debezium.quarkus</groupId>
            <artifactId>debezium-quarkus-mysql</artifactId>
            <exclusions>
                <!-- Disable dev services for testing purpose -->
                <exclusion>
                    <groupId>io.quarkus</groupId>
                    <artifactId>quarkus-devservices-mysql</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>io.debezium.quarkus</groupId>
            <artifactId>debezium-quarkus-testsuite-integration-tests</artifactId>
        </dependency>

        <dependency>
            <groupId>io.debezium.quarkus</groupId>
            <artifactId>debezium-quarkus-testsuite-integration-tests</artifactId>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-junit5</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.lz4</groupId>
            <artifactId>lz4-java</artifactId>
            <version>1.8.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                        <maven.home>${maven.home}</maven.home>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <systemPropertyVariables>
                                <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
                                <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                                <maven.home>${maven.home}</maven.home>
                            </systemPropertyVariables>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>io.quarkus</groupId>
                <artifactId>quarkus-maven-plugin</artifactId>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>start-mysql</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>build</goal>
                            <goal>start</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop-mysql</id>
                        <phase>post-integration-test</phase>
                        <goals><goal>stop</goal></goals>
                    </execution>
                </executions>
                <configuration>
                    <imagePullPolicy>IfNotPresent</imagePullPolicy>
                    <images>
                        <image>
                            <alias>native</alias>
                            <name>debezium/mysql-server-test-database</name>
                            <run>
                                <namingStrategy>none</namingStrategy>
                                <env>
                                    <MYSQL_ROOT_PASSWORD>debezium-rocks</MYSQL_ROOT_PASSWORD>
                                    <MYSQL_USER>mysqluser</MYSQL_USER>
                                    <MYSQL_PASSWORD>mysqlpwd</MYSQL_PASSWORD>
                                    <TZ>UTC</TZ>
                                </env>
                                <ports>
                                    <port>3306:3306</port>
                                </ports>
                                <log>
                                    <prefix>mysql</prefix>
                                    <enabled>true</enabled>
                                    <color>yellow</color>
                                </log>
                                <wait>
                                    <log>.*(MySQL) init process done. Ready for start up.(?s)(.*)(mysqld): ready for connections..*</log>
                                    <time>60000</time>
                                </wait>
                                <volumes>
                                    <bind>
                                        <volume>${project.basedir}/src/main/resources/sql/default/default.sql:/docker-entrypoint-initdb.d/default.sql</volume>
                                    </bind>
                                </volumes>
                            </run>
                            <build>
                                <from>${mysql.image.name}</from>
                                <runCmds>
                                    <run>rm -f /etc/localtime; ln -s /usr/share/zoneinfo/Pacific/Samoa /etc/localtime</run>
                                </runCmds>
                                <assembly>
                                    <inline>
                                        <fileSets>
                                            <fileSet>
                                                <directory>${project.basedir}/src/main/resources/configuration</directory>
                                                <includes>
                                                    <include>mysql.cnf</include>
                                                </includes>
                                                <outputDirectory>etc/mysql</outputDirectory>
                                            </fileSet>
                                        </fileSets>
                                    </inline>
                                    <targetDir>/</targetDir>
                                </assembly>
                            </build>
                            <external>
                                <type>properties</type>
                                <mode>override</mode>
                            </external>
                        </image>
                        <image>
                            <alias>alternative</alias>
                            <name>debezium/mysql-server-test-database-alternative</name>
                            <run>
                                <namingStrategy>none</namingStrategy>
                                <env>
                                    <MYSQL_ROOT_PASSWORD>debezium-rocks</MYSQL_ROOT_PASSWORD>
                                    <MYSQL_USER>mysqluser</MYSQL_USER>
                                    <MYSQL_PASSWORD>mysqlpwd</MYSQL_PASSWORD>
                                    <TZ>UTC</TZ>
                                </env>
                                <ports>
                                    <port>3307:3306</port>
                                </ports>
                                <log>
                                    <prefix>mysql</prefix>
                                    <enabled>true</enabled>
                                    <color>yellow</color>
                                </log>
                                <wait>
                                    <log>.*(MySQL) init process done. Ready for start up.(?s)(.*)(mysqld): ready for connections..*</log>
                                    <time>60000</time>
                                </wait>
                                <volumes>
                                    <bind>
                                        <volume>${project.basedir}/src/main/resources/sql/alternative/alternative.sql:/docker-entrypoint-initdb.d/alternative.sql</volume>
                                    </bind>
                                </volumes>
                            </run>
                            <build>
                                <from>${mysql.image.name}</from>
                                <runCmds>
                                    <run>rm -f /etc/localtime; ln -s /usr/share/zoneinfo/Pacific/Samoa /etc/localtime</run>
                                </runCmds>
                                <assembly>
                                    <inline>
                                        <fileSets>
                                            <fileSet>
                                                <directory>${project.basedir}/src/main/resources/configuration</directory>
                                                <includes>
                                                    <include>mysql.cnf</include>
                                                </includes>
                                                <outputDirectory>etc/mysql</outputDirectory>
                                            </fileSet>
                                        </fileSets>
                                    </inline>
                                    <targetDir>/</targetDir>
                                </assembly>
                            </build>
                            <external>
                                <type>properties</type>
                                <mode>override</mode>
                            </external>
                        </image>
                    </images>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>skip-integration-tests</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>skipITs</name>
                </property>
            </activation>
            <properties>
                <docker.skip>true</docker.skip>
            </properties>
        </profile>
        <profile>
            <id>quick</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>quick</name>
                </property>
            </activation>
            <properties>
                <skipITs>true</skipITs>
                <docker.skip>true</docker.skip>
            </properties>
        </profile>
    </profiles>

</project>