<?xml version="1.0" encoding="UTF-8"?>
<!--
  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.
-->
<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.apache.qpid</groupId>
    <artifactId>qpid-broker-parent</artifactId>
    <version>7.0.0-SNAPSHOT</version>
  </parent>

  <artifactId>qpid-perftests</artifactId>
  <name>Apache Qpid Performance Tests</name>
  <description>Performance testing configuration, code and tests</description>

  <properties>
    <dependency-change-verification>true</dependency-change-verification>

    <!-- Properties filtered into the JNDI properties -->
    <perftests.messaging-hostport-plain>localhost:5672</perftests.messaging-hostport-plain>
    <perftests.messaging-hostport-tls>localhost:5672</perftests.messaging-hostport-tls>
    <perftests.messaging-user>guest</perftests.messaging-user>
    <perftests.messaging-password>guest</perftests.messaging-password>
    <perftests.results-directory>results</perftests.results-directory>

    <!-- Properties used by the REST API Queue Creator -->
    <perftests.manangement-user>guest</perftests.manangement-user>
    <perftests.manangement-password>guest</perftests.manangement-password>
    <perftests.broker-virtualhostnode>default</perftests.broker-virtualhostnode>
    <perftests.broker-virtualhost>default</perftests.broker-virtualhost>
    <perftests.manangement-url>http://localhost:8080</perftests.manangement-url>


    <perftests.hillclimb>false</perftests.hillclimb>
    <perftests.hillclimb.max_runs>3</perftests.hillclimb.max_runs>
    <perftests.hillclimb.start_target_rate>1025.0</perftests.hillclimb.start_target_rate>
    <perftests.hillclimb.production_to_target_ratio_success_threshold>0.95</perftests.hillclimb.production_to_target_ratio_success_threshold>
    <perftests.hillclimb.consumption_to_production_ratio_success_threshold>0.95</perftests.hillclimb.consumption_to_production_ratio_success_threshold>
    <perftests.hillclimb.minimum_delta>1.0</perftests.hillclimb.minimum_delta>
    <perftests.hillclimb.bias>0.25</perftests.hillclimb.bias>

    <!-- The following provide values for the disttest command line -->
    <perftests.test-config>${basedir}/etc/testdefs</perftests.test-config>
    <perftests.test-config.write_to_db>false</perftests.test-config.write_to_db>
    <perftests.distributed>false</perftests.distributed>

    <!-- Overrides for system properties understood by disttest itself -->
    <qpid.disttest.loglevel>info</qpid.disttest.loglevel>
    <qpid.disttest.duration>5000</qpid.disttest.duration>
    <qpid.disttest.registrationTimeout>60000</qpid.disttest.registrationTimeout>
    <qpid.disttest.commandResponseTimeout>120000</qpid.disttest.commandResponseTimeout>
  </properties>

  <dependencies>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
    </dependency>

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

    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.derby</groupId>
      <artifactId>derby</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
    </dependency>

    <!-- test deps -->
    <dependency>
      <groupId>org.apache.qpid</groupId>
      <artifactId>qpid-test-utils</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>

    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
      <resource>
        <directory>src/main/java</directory>
        <excludes>
          <exclude>**/*.java/</exclude>
        </excludes>
      </resource>
    </resources>

    <testResources>
      <testResource>
        <directory>src/test/java</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </testResource>
      <testResource>
        <directory>src/test/resources</directory>
        <filtering>true</filtering>
        <includes>
          <include>**/*</include>
        </includes>
      </testResource>
    </testResources>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
          <descriptors>
            <descriptor>src/main/assembly/qpid-perftests-bin.xml</descriptor>
          </descriptors>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.rat</groupId>
        <artifactId>apache-rat-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>src/main/java/json2.js</exclude>
            <exclude>src/test/java/org/apache/qpid/disttest/controller/config/sampleConfig.json</exclude>
            <exclude>src/test/java/org/apache/qpid/disttest/results/formatting/expectedOutput.csv</exclude>
            <exclude>visualisation-jfc/**</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <configuration>
          <delimiters>
            <delimiter>${*}</delimiter>
          </delimiters>
          <useDefaultDelimiters>false</useDefaultDelimiters>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>addJms11IfNecessary</id>
      <activation>
        <property>
          <name>perftests</name>
          <value>!qpid-jms-client</value>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>org.apache.geronimo.specs</groupId>
          <artifactId>geronimo-jms_1.1_spec</artifactId>
        </dependency>
      </dependencies>
    </profile>
    <profile>
      <id>perftests</id>
      <activation>
        <property>
          <name>perftests</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <executions>
              <execution>
                <id>enforce-property</id>
                <goals>
                  <goal>enforce</goal>
                </goals>
                <configuration>
                  <rules>
                    <requireProperty>
                      <property>perftests</property>
                      <regex>^(qpid-jms-client)|(jms-client-0-9)|(jms-client-0-10)$</regex>
                    </requireProperty>
                  </rules>
                  <fail>true</fail>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>run-perftests</id>
                <goals>
                  <goal>java</goal>
                </goals>
                <phase>integration-test</phase>
                <configuration>
                  <mainClass>org.apache.qpid.disttest.ControllerRunner</mainClass>
                  <classpathScope>compile</classpathScope>
                  <arguments>
                    <argument>jndi-config=${java.naming.provider.url}</argument>
                    <argument>test-config=${perftests.test-config}</argument>
                    <argument>distributed=${perftests.distributed}</argument>
                    <argument>writeToDb=${perftests.test-config.write_to_db}</argument>
                    <argument>registrationTimeout=${qpid.disttest.registrationTimeout}</argument>
                    <argument>commandResponseTimeout=${qpid.disttest.commandResponseTimeout}</argument>
                    <argument>hill-climb=${perftests.hillclimb}</argument>
                    <argument>hill-climber.max-runs=${perftests.hillclimb.max_runs}</argument>
                    <argument>hill-climber.start-target-rate=${perftests.hillclimb.start_target_rate}</argument>
                    <argument>hill-climber.production-to-target-ratio-success-threshold=${perftests.hillclimb.production_to_target_ratio_success_threshold}</argument>
                    <argument>hill-climber.consumption-to-production-ratio-success-threshold=${perftests.hillclimb.consumption_to_production_ratio_success_threshold}</argument>
                    <argument>hill-climber.minimum-delta=${perftests.hillclimb.minimum_delta}</argument>
                    <argument>hill-climber.bias=${perftests.hillclimb.bias}</argument>
                  </arguments>
                  <systemProperties>
                    <systemProperty>
                      <key>qpid.disttest.loglevel</key>
                      <value>${qpid.disttest.loglevel}</value>
                    </systemProperty>
                    <systemProperty>
                      <key>qpid.disttest.duration</key>
                      <value>${qpid.disttest.duration}</value>
                    </systemProperty>
                    <systemProperty>
                      <key>java.naming.factory.initial</key>
                      <value>${java.naming.factory.initial}</value>
                    </systemProperty>
                    <systemProperty>
                      <key>qpid.disttest.queue.creator.class</key>
                      <value>org.apache.qpid.disttest.jms.QpidRestAPIQueueCreator</value>
                    </systemProperty>
                    <systemProperty>
                      <key>perftests.manangement-user</key>
                      <value>${perftests.manangement-user}</value>
                    </systemProperty>
                    <systemProperty>
                      <key>perftests.manangement-password</key>
                      <value>${perftests.manangement-password}</value>
                    </systemProperty>
                    <systemProperty>
                      <key>perftests.broker-virtualhostnode</key>
                      <value>${perftests.broker-virtualhostnode}</value>
                    </systemProperty>
                    <systemProperty>
                      <key>perftests.broker-virtualhost</key>
                      <value>${perftests.broker-virtualhost}</value>
                    </systemProperty>
                    <systemProperty>
                      <key>perftests.manangement-url</key>
                      <value>${perftests.manangement-url}</value>
                    </systemProperty>
                    <!-- The following two are used by the legacy client only -->
                    <systemProperty>
                      <key>qpid.dest_syntax</key>
                      <value>${qpid.dest_syntax}</value>
                    </systemProperty>
                    <systemProperty>
                      <key>qpid.amqp.version</key>
                      <value>${qpid.amqp.version}</value>
                    </systemProperty>
                  </systemProperties>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <skip>true</skip>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>qpid-jms-client</id>
      <activation>
        <property>
          <name>perftests</name>
          <value>qpid-jms-client</value>
        </property>
      </activation>
      <properties>
        <java.naming.factory.initial>org.apache.qpid.jms.jndi.JmsInitialContextFactory</java.naming.factory.initial>
        <java.naming.provider.url>${project.build.directory}/test-classes/qpid-jms-client/jndi.properties</java.naming.provider.url>
        <qpid.amqp.version></qpid.amqp.version>
        <qpid.dest_syntax></qpid.dest_syntax>
      </properties>
      <dependencies>
        <dependency>
          <groupId>org.apache.qpid</groupId>
          <artifactId>qpid-jms-client</artifactId>
        </dependency>
      </dependencies>
    </profile>
    <profile>
      <id>jms-client-0-9</id>
      <activation>
        <property>
          <name>perftests</name>
          <value>jms-client-0-9</value>
        </property>
      </activation>
      <properties>
        <java.naming.factory.initial>org.apache.qpid.jndi.PropertiesFileInitialContextFactory</java.naming.factory.initial>
        <java.naming.provider.url>${project.build.directory}/test-classes/jms-client/jndi.properties</java.naming.provider.url>
        <qpid.amqp.version>0-9</qpid.amqp.version>
        <qpid.dest_syntax>BURL</qpid.dest_syntax>
      </properties>
      <dependencies>
        <dependency>
          <groupId>org.apache.qpid</groupId>
          <artifactId>qpid-client</artifactId>
          <scope>compile</scope>
        </dependency>
      </dependencies>
    </profile>
    <profile>
      <id>jms-client-0-10</id>
      <activation>
        <property>
          <name>perftests</name>
          <value>jms-client-0-10</value>
        </property>
      </activation>
      <properties>
        <java.naming.factory.initial>org.apache.qpid.jndi.PropertiesFileInitialContextFactory</java.naming.factory.initial>
        <java.naming.provider.url>${project.build.directory}/test-classes/jms-client/jndi.properties</java.naming.provider.url>
        <qpid.amqp.version>0-10</qpid.amqp.version>
        <qpid.dest_syntax>BURL</qpid.dest_syntax>
      </properties>
      <dependencies>
        <dependency>
          <groupId>org.apache.qpid</groupId>
          <artifactId>qpid-client</artifactId>
          <scope>compile</scope>
        </dependency>
      </dependencies>
    </profile>
  </profiles>
</project>
