| <?xml version="1.0" encoding="UTF-8"?> | |
| <!-- | |
| Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved. | |
| This program and the accompanying materials are made available under the | |
| terms of the Eclipse Public License v. 2.0, which is available at | |
| http://www.eclipse.org/legal/epl-2.0. | |
| This Source Code may also be made available under the following Secondary | |
| Licenses when the conditions for such availability set forth in the | |
| Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | |
| version 2 with the GNU Classpath Exception, which is available at | |
| https://www.gnu.org/software/classpath/license.html. | |
| SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | |
| --> | |
| <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.glassfish.jersey.tests.memleaks</groupId> | |
| <artifactId>project</artifactId> | |
| <version>2.35-SNAPSHOT</version> | |
| </parent> | |
| <groupId>org.glassfish.jersey.tests.memleaks.testcases</groupId> | |
| <artifactId>project</artifactId> | |
| <packaging>pom</packaging> | |
| <name>jersey-tests-memleak-testcase</name> | |
| <description> | |
| Memory leaks test cases. | |
| Tests in this maven submodule can be either: | |
| [1] Simple tests executed by maven-surefire-plugin in a dedicated JVM. These tests should attempt to cause a memory leak | |
| directly. The heap can be configured by means of 'memleak.jvm.maxheap' property. It can be combined with other | |
| infrastructure which is described bellow. | |
| [2] Integration tests executed by maven-surefire-plugin. These tests should test against Jersey application deployed to a | |
| servlet container. The state of the servlet container (e.g., whether OutOfMemoryError occurred) should be inspected by | |
| infrastructure described bellow. | |
| TEST INFRASTRUCTURE | |
| The test infrastructure is configured from Maven and the tests should be executed by Maven. Normally, test-cases shall | |
| override maven properties defined in this pom and declare required maven plugins in their build section. All the maven | |
| plugin executions will be configured from this pom. | |
| [a] Container Runners (org.glassfish.jersey.test-framework.maven:container-runner-maven-plugin) feature Weblogic and | |
| Glassfish4 with functionality: download, start, deploy and stop. | |
| [b] Maven Enforce Custom Rules (org.glassfish.jersey.test-framework.maven:custom-enforcer-rules) that can enforce | |
| non-existent Java Heap dumps files in a certain path or no OutOfMemoryError errors in a log file. | |
| [c] Jetty execution in a dedicated JVM with configured to dump heap on OutOfMemoryError errors. | |
| [d] Common Memleak JUnit test infrastructure that provides means to stop a test after a certain period of time and mark | |
| the test as successful as well as to perform heap dumps from the Java code or to inspect log files for OutOfMemoryError | |
| errors. | |
| EXAMPLE OF EXECUTION | |
| (executes all memleak test cases) | |
| mvn clean install -amd -pl tests/mem-leaks -P gf4,memleak-test-cases -fae | |
| (executes shutdown hook leak single test case) | |
| mvn clean install -am -pl tests/mem-leaks/test-cases/shutdown-hook-leak -P gf4,memleak-test-cases -fae | |
| </description> | |
| <modules> | |
| <module>bean-param-leak</module> | |
| <module>shutdown-hook-leak</module> | |
| <module>shutdown-hook-leak-client</module> | |
| <module>leaking-test-app</module> | |
| </modules> | |
| <properties> | |
| <memleak.test.timeout>300000</memleak.test.timeout> | |
| <memleak.jetty.maxheap>${memleak.jvm.maxheap}</memleak.jetty.maxheap> | |
| <!-- by default, bound to 'none' phase; if 'memleak-test-cases' profile active, they're activated --> | |
| <phase.common.pre-integration-test>${phase.tests.pre-integration-test}</phase.common.pre-integration-test> | |
| <phase.common.post-integration-test>${phase.tests.post-integration-test}</phase.common.post-integration-test> | |
| <phase.tests.pre-integration-test.jetty>${phase.tests.pre-integration-test}</phase.tests.pre-integration-test.jetty> | |
| <phase.tests.post-integration-test.jetty>${phase.tests.post-integration-test}</phase.tests.post-integration-test.jetty> | |
| </properties> | |
| <build> | |
| <pluginManagement> | |
| <plugins> | |
| <plugin> | |
| <artifactId>maven-failsafe-plugin</artifactId> | |
| <configuration> | |
| <systemPropertyVariables> | |
| <jersey.config.test.memleak.timeout>${memleak.test.timeout}</jersey.config.test.memleak.timeout> | |
| <jersey.config.test.container.factory>${external.container.factory} | |
| </jersey.config.test.container.factory> | |
| <jersey.config.test.container.port>${external.container.port}</jersey.config.test.container.port> | |
| <jersey.config.test.container.contextRoot>${external.container.contextRoot} | |
| </jersey.config.test.container.contextRoot> | |
| <jersey.config.test.container.logfile>${external.container.logFile} | |
| </jersey.config.test.container.logfile> | |
| </systemPropertyVariables> | |
| </configuration> | |
| <executions> | |
| <execution> | |
| <!-- the 'default' id is bound to 'none' because it's not possible to split the goals and re-bind them | |
| while keeping the 'default' id --> | |
| <id>default</id> | |
| <phase>none</phase> | |
| </execution> | |
| <execution> | |
| <id>re-bound-integration-test</id> | |
| <goals> | |
| <goal>integration-test</goal> | |
| </goals> | |
| <phase>${phase.tests.integration-test}</phase> | |
| </execution> | |
| <execution> | |
| <id>re-bound-verify</id> | |
| <goals> | |
| <goal>verify</goal> | |
| </goals> | |
| <phase>${phase.tests.verify}</phase> | |
| </execution> | |
| </executions> | |
| </plugin> | |
| <plugin> | |
| <artifactId>maven-surefire-plugin</artifactId> | |
| <configuration> | |
| <systemPropertyVariables> | |
| <jersey.config.test.memleak.timeout>${memleak.test.timeout}</jersey.config.test.memleak.timeout> | |
| <jersey.config.test.memleak.heapDumpPath>${project.build.directory} | |
| </jersey.config.test.memleak.heapDumpPath> | |
| <jersey.config.test.container.factory>${external.container.factory} | |
| </jersey.config.test.container.factory> | |
| <jersey.config.test.container.port>${external.container.port}</jersey.config.test.container.port> | |
| <jersey.config.test.container.contextRoot>${external.container.contextRoot} | |
| </jersey.config.test.container.contextRoot> | |
| </systemPropertyVariables> | |
| <argLine>-Xmx${memleak.jvm.maxheap} -XX:+HeapDumpOnOutOfMemoryError | |
| -XX:HeapDumpPath=${memleak.jvm.heapdumpdir} -XX:GCTimeLimit=20 -XX:GCHeapFreeLimit=30 | |
| </argLine> | |
| </configuration> | |
| <executions> | |
| <execution> | |
| <id>default-test</id> | |
| <goals> | |
| <goal>test</goal> | |
| </goals> | |
| <phase>${phase.tests.test}</phase> | |
| </execution> | |
| </executions> | |
| </plugin> | |
| </plugins> | |
| </pluginManagement> | |
| </build> | |
| <profiles> | |
| <profile> | |
| <id>memleak-test-cases</id> | |
| <properties> | |
| <!-- set all the phases for this sub-module tree so that the executions are un-bound from the 'none' phase --> | |
| <phase.tests.test>test</phase.tests.test> | |
| <phase.tests.pre-integration-test>pre-integration-test</phase.tests.pre-integration-test> | |
| <phase.tests.integration-test>integration-test</phase.tests.integration-test> | |
| <phase.tests.post-integration-test>post-integration-test</phase.tests.post-integration-test> | |
| <phase.tests.verify>verify</phase.tests.verify> | |
| </properties> | |
| <build> | |
| <pluginManagement> | |
| <plugins> | |
| <plugin> | |
| <groupId>org.mortbay.jetty</groupId> | |
| <artifactId>jetty-maven-plugin</artifactId> | |
| <configuration> | |
| <skip>${skip.tests}</skip> | |
| <scanIntervalSeconds>10</scanIntervalSeconds> | |
| <stopPort>9999</stopPort> | |
| <stopKey>STOP</stopKey> | |
| <contextPath>/${external.container.contextRoot}</contextPath> | |
| <jvmArgs>-Xms64m -Xmx${memleak.jetty.maxheap} -XX:PermSize=128m -XX:MaxPermSize=256m | |
| -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${memleak.jvm.heapdumpdir} | |
| -Djetty.port=${external.container.port} -Djersey.config.test.memleak.jetty.magicRunnerIdentifier | |
| -Dorg.slf4j.simpleLogger.logFile=${external.container.logFile} | |
| </jvmArgs> | |
| <waitForChild>false</waitForChild> | |
| </configuration> | |
| <executions> | |
| <execution> | |
| <id>start-jetty</id> | |
| <phase>${phase.tests.pre-integration-test.jetty}</phase> | |
| <goals> | |
| <goal>run-forked</goal> | |
| </goals> | |
| </execution> | |
| <execution> | |
| <id>stop-jetty</id> | |
| <phase>${phase.tests.post-integration-test.jetty}</phase> | |
| <goals> | |
| <goal>stop</goal> | |
| </goals> | |
| </execution> | |
| </executions> | |
| <dependencies> | |
| <dependency> | |
| <groupId>org.slf4j</groupId> | |
| <artifactId>slf4j-simple</artifactId> | |
| <version>1.7.5</version> | |
| </dependency> | |
| </dependencies> | |
| </plugin> | |
| <plugin> | |
| <groupId>org.apache.maven.plugins</groupId> | |
| <artifactId>maven-enforcer-plugin</artifactId> | |
| <dependencies> | |
| <dependency> | |
| <groupId>org.glassfish.jersey.test-framework.maven</groupId> | |
| <artifactId>custom-enforcer-rules</artifactId> | |
| <version>${project.version}</version> | |
| </dependency> | |
| </dependencies> | |
| <executions> | |
| <execution> | |
| <id>enforce-out-of-memory-did-not-occur</id> | |
| <goals> | |
| <goal>enforce</goal> | |
| </goals> | |
| <phase>${phase.tests.post-integration-test}</phase> | |
| <configuration> | |
| <rules> | |
| <rule implementation="org.glassfish.jersey.test.maven.rule.FilePatternDoesNotExistRule"> | |
| <files> | |
| <file>${memleak.jvm.heapdumpdir}/java_pid*.hprof</file> | |
| </files> | |
| </rule> | |
| <rule implementation="org.glassfish.jersey.test.maven.rule.PatternNotMatchedInFileRule"> | |
| <file>${external.container.logFile}</file> | |
| <pattern>.*java\.lang\.OutOfMemoryError.*</pattern> | |
| </rule> | |
| </rules> | |
| <fail>true</fail> | |
| </configuration> | |
| </execution> | |
| </executions> | |
| </plugin> | |
| <plugin> | |
| <groupId>org.glassfish.jersey.test-framework.maven</groupId> | |
| <artifactId>container-runner-maven-plugin</artifactId> | |
| </plugin> | |
| </plugins> | |
| </pluginManagement> | |
| </build> | |
| </profile> | |
| <profile> | |
| <id>gf4</id> | |
| <properties> | |
| <phase.tests.pre-integration-test.jetty>none</phase.tests.pre-integration-test.jetty> | |
| <phase.tests.post-integration-test.jetty>none</phase.tests.post-integration-test.jetty> | |
| </properties> | |
| </profile> | |
| <profile> | |
| <id>wls</id> | |
| <properties> | |
| <phase.tests.pre-integration-test.jetty>none</phase.tests.pre-integration-test.jetty> | |
| <phase.tests.post-integration-test.jetty>none</phase.tests.post-integration-test.jetty> | |
| </properties> | |
| </profile> | |
| <profile> | |
| <id>tomcat</id> | |
| <properties> | |
| <phase.tests.pre-integration-test.jetty>none</phase.tests.pre-integration-test.jetty> | |
| <phase.tests.post-integration-test.jetty>none</phase.tests.post-integration-test.jetty> | |
| </properties> | |
| </profile> | |
| </profiles> | |
| </project> |