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

    Copyright 2015-2017 Red Hat, Inc. and/or its affiliates
    and other contributors as indicated by the @author tags.

    Licensed 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.

-->
<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>org.hawkular.apm</groupId>
    <artifactId>hawkular-apm-tests-parent</artifactId>
    <version>0.14.2.Final</version>
    <relativePath>../pom.xml</relativePath>
  </parent>

  <artifactId>hawkular-apm-tests-distribution</artifactId>
  <name>Hawkular APM::Tests::Distribution</name>

  <properties>
    <hawkular.host>127.0.0.1</hawkular.host>
    <hawkular.port>8080</hawkular.port>
    <hawkular.uri>http://${hawkular.host}:${hawkular.port}</hawkular.uri>
    <HAWKULAR_APM_URI>${hawkular.uri}</HAWKULAR_APM_URI>
    <!-- IMPORTANT: The port must be the port offset + 8080. -->
    <wildfly.port.offset>1897</wildfly.port.offset>
    <!-- IMPORTANT: The management port must be the port offset + 9990. -->
    <wildfly.management.port>11887</wildfly.management.port>
    <hawkular.home>${project.build.directory}/hawkular</hawkular.home>
    <hawkular.configuration>${hawkular.home}/standalone/configuration</hawkular.configuration>
    <hawkular.data>${hawkular.home}/standalone/data</hawkular.data>
    <hawkular.deployments>${hawkular.home}/standalone/deployments</hawkular.deployments>
    <hawkular.lib>${hawkular.home}/standalone/lib</hawkular.lib>
    <server.config>standalone.xml</server.config>
    <hawkular.log.apm>FINEST</hawkular.log.apm>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.hawkular.apm</groupId>
      <artifactId>hawkular-apm-api</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.hawkular.apm</groupId>
      <artifactId>hawkular-apm-tests-common</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.hawkular.apm</groupId>
      <artifactId>hawkular-apm-config-service-rest-client</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hawkular.apm</groupId>
      <artifactId>hawkular-apm-trace-service-rest-client</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hawkular.apm</groupId>
      <artifactId>hawkular-apm-trace-publisher-rest-client</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hawkular.apm</groupId>
      <artifactId>hawkular-apm-analytics-service-rest-client</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.hawkular.apm</groupId>
      <artifactId>hawkular-apm-dist</artifactId>
      <type>zip</type>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.squareup.okhttp3</groupId>
      <artifactId>okhttp</artifactId>
      <version>${version.com.squareup.okhttp}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>itest</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>unpack-hawkular</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>unpack-dependencies</goal>
                </goals>
                <configuration>
                  <includeGroupIds>org.hawkular.apm</includeGroupIds>
                  <includeArtifactIds>hawkular-apm-dist</includeArtifactIds>
                  <outputDirectory>${hawkular.home}</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <configuration>
              <systemPropertyVariables>
                <hawkular.host>${hawkular.host}</hawkular.host>
                <hawkular.port>${hawkular.port}</hawkular.port>
                <hawkular.uri>${hawkular.uri}</hawkular.uri>
                <HAWKULAR_APM_URI>${HAWKULAR_APM_URI}</HAWKULAR_APM_URI>
                <jboss.server.config.dir>${hawkular.configuration}</jboss.server.config.dir>
              </systemPropertyVariables>
            </configuration>
            <executions>
              <execution>
                <id>run-integration-tests</id>
                <goals>
                  <goal>integration-test</goal>
                </goals>
                <configuration>
                  <includes>
                    <include>**/*ITest.java</include>
                  </includes>
                </configuration>
              </execution>
              <execution>
                <id>final-verify</id>
                <goals>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>create-itest-user</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
                <configuration>
                  <executable>java</executable>
                  <environmentVariables>
                    <JBOSS_HOME>${hawkular.home}</JBOSS_HOME>
                  </environmentVariables>
                  <arguments>
                    <argument>-jar</argument>
                    <argument>${hawkular.home}/jboss-modules.jar</argument>
                    <argument>-mp</argument>
                    <argument>${hawkular.home}/modules</argument>
                    <argument>org.jboss.as.domain-add-user</argument>
                    <argument>-a</argument>
                    <argument>--user</argument>
                    <argument>jdoe</argument>
                    <argument>--password</argument>
                    <argument>password</argument>
                    <argument>--group</argument>
                    <argument>read-write,read-only</argument>
                  </arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <configuration>
              <jboss-home>${hawkular.home}</jboss-home>
            </configuration>
            <executions>
              <execution>
                <id>start-wildfly</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>start</goal>
                </goals>
                <configuration>
                  <javaOpts>
                    <javaOpt>-Xms64m</javaOpt>
                    <javaOpt>-Xmx512m</javaOpt>
                    <javaOpt>-Xss256k</javaOpt>
                    <javaOpt>-Djava.net.preferIPv4Stack=true</javaOpt>
                    <javaOpt>-Dsun.rmi.dgc.client.gcInterval=3600000</javaOpt>
                    <javaOpt>-Dsun.rmi.dgc.server.gcInterval=3600000</javaOpt>
                    <javaOpt>-Xdebug</javaOpt>
                    <javaOpt>-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787</javaOpt>
                    <javaOpt>-Dhawkular-apm.testmode=true</javaOpt>
                    <javaOpt>-Dhawkular.log.apm=${hawkular.log.apm}</javaOpt>
                  </javaOpts>
                  <startup-timeout>180</startup-timeout>
                </configuration>
              </execution>
              <execution>
                <id>stop-wildfly</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>shutdown</goal>
                </goals>
                <configuration>
                  <timeout>200</timeout>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
