Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr-functional-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ jobs:
java-version: ${{ matrix.java }}

- name: Build with Maven
run: mvn -B verify -DskipUnitTests=true -DskipModuleFunctionalTests=true -Dtests.max-container-count=5 -DdockerfileName=Dockerfile --file extra/pom.xml
run: mvn -B verify -DskipUnitTests=true -Drun-functional-tests=true -DdockerfileName=Dockerfile --file extra/pom.xml
2 changes: 1 addition & 1 deletion .github/workflows/pr-module-functional-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
run: mvn package -DskipUnitTests=true --file extra/pom.xml

- name: Run module tests
run: mvn -B verify -DskipUnitTests=true -DskipFunctionalTests=true -DskipModuleFunctionalTests=false -Dtests.max-container-count=5 -DdockerfileName=Dockerfile-modules --file extra/pom.xml
run: mvn -B verify -DskipUnitTests=true -Drun-module-functional-tests=true -DdockerfileName=Dockerfile-modules --file extra/pom.xml
23 changes: 7 additions & 16 deletions docs/developers/functional-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,15 @@ To prepare the PBS image, follow these steps from the root directory:

## Running Functional Tests

You have two options for running functional tests:
To run functional tests without modules (extra/modules), use:

1. Use `mvn verify` to include all previous steps (including Java tests and modular tests) because Groovy runs in the `failsafe:integration-test` phase.
2. For functional tests only, use a more granular command:

`mvn -B verify -DskipModuleFunctionalTests=true`
`mvn verify -Drun-functional-tests=true`

## Running Module Functional Tests

You have two options for running modular tests:

1. Use `mvn verify -DdockerfileName=Dockerfile-modules` to include all previous steps (including Java tests and functional tests) because Groovy runs in the `failsafe:integration-test` phase.
2. For modular tests only, use a more granular command:
To run module-only functional tests, use:

`mvn -B verify -DskipUnitTests=true -DskipFunctionalTests=true -DskipModuleFunctionalTests=false -DdockerfileName=Dockerfile-modules`
`mvn verify -Drun-module-functional-tests=true -DdockerfileName=Dockerfile-modules`

## Developing

Expand All @@ -58,20 +52,17 @@ Functional tests need to have name template **.\*Spec.groovy**
Primary Key will be inserted after saving instance into DB.
- `/functional/service/PrebidServerService` - responsible for all PBS http calls.
- `/functional/testcontainers/Dependencies` - stores dependencies and manages mySql and NetworkServiceContainer containers.
- `/functional/testcontainers/ErrorListener` - logs request and response in case of falling test.
- `/functional/testcontainers/PbsConfig` - collects PBS properties.
- `/functional/testcontainers/PbsServiceFactory` - manage PBS containers according to container limit.
- `/functional/testcontainers/PBSTestExtension` - allows to hook into a spec’s lifecycle to add ErrorListener using annotation `PBSTest`.
- `/functional/testcontainers/TestcontainersExtension` - allow to hook into a spec’s lifecycle to start and stop support service containers using global extension.
- `/functional/testcontainers/container` - responsible for creating and configuring containers.
- `/functional/testcontainers/scaffolding/NetworkScaffolding` - makes HTTP requests to a MockServer.
- `/functional/testcontainers/container/*` - responsible for creating and configuring containers.
- `/functional/testcontainers/scaffolding/NetworkScaffolding` - makes HTTP requests to a MockServer.


**Properties:**

`launchContainers` - responsible for starting the MockServer and the MySQLContainer container. Default value is false to not launch containers for unit tests.
`launchContainers` - responsible for starting the MockServer and MySQLContainer container. Default value is false to not launch containers for functional tests.
`tests.max-container-count` - maximum number of simultaneously running PBS containers. Default value is 5.
`skipFunctionalTests` - allow to skip funtional tests. Default value is false.
`skipUnitTests` - allow to skip unit tests. Default value is false.

**Debug:**
Expand Down
2 changes: 0 additions & 2 deletions extra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@

<!-- Test properties -->
<skipUnitTests>false</skipUnitTests>
<skipFunctionalTests>false</skipFunctionalTests>
<skipModuleFunctionalTests>true</skipModuleFunctionalTests>
</properties>

<modules>
Expand Down
227 changes: 149 additions & 78 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?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">
<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>
Expand Down Expand Up @@ -375,6 +376,7 @@
<launchContainers>false</launchContainers>
</systemPropertyVariables>
<skipTests>${skipUnitTests}</skipTests>
<excludeJUnit5Engines>spock</excludeJUnit5Engines>
</configuration>
</plugin>
<plugin>
Expand All @@ -386,20 +388,6 @@
<launchContainers>true</launchContainers>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<id>functional-tests</id>
<configuration>
<skip>${skipFunctionalTests}</skip>
</configuration>
</execution>
<execution>
<id>module-functional-tests</id>
<configuration>
<skip>${skipModuleFunctionalTests}</skip>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
Expand Down Expand Up @@ -585,69 +573,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<configuration>
<parallelParsing>true</parallelParsing>
<testSources>
<testSource>
<directory>${project.basedir}/src/test/groovy</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</testSource>
</testSources>
</configuration>
<executions>
<execution>
<goals>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<mockserver.version>${mockserver.version}</mockserver.version>
<pbs.version>${project.version}</pbs.version>
<tests.max-container-count>5</tests.max-container-count>
<tests.fixed-container-ports>false</tests.fixed-container-ports>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<id>functional-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<excludes>
<exclude>**/tests/module/**/*Spec</exclude>
</excludes>
<includes>
<include>**/*Spec</include>
</includes>
</configuration>
</execution>
<execution>
<id>module-functional-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<includes>
<include>**/tests/module/**/*Spec</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -660,6 +585,25 @@
</build>

<profiles>
<profile>
<id>Enabling function tests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<launchContainers>true</launchContainers>
</systemPropertyVariables>
<skipTests>${skipUnitTests}</skipTests>
<excludeJUnit5Engines>spock</excludeJUnit5Engines>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- Run only one application container instance on fixed ports for debugging purposes -->
<id>Container debugging</id>
Expand All @@ -677,5 +621,132 @@
</plugins>
</build>
</profile>
<profile>
<id>Run general functional tests without modules</id>
<activation>
<property>
<name>run-functional-tests</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<configuration>
<parallelParsing>true</parallelParsing>
<testSources>
<testSource>
<directory>${project.basedir}/src/test/groovy</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</testSource>
</testSources>
</configuration>
<executions>
<execution>
<goals>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<mockserver.version>${mockserver.version}</mockserver.version>
<pbs.version>${project.version}</pbs.version>
<tests.max-container-count>5</tests.max-container-count>
<!-- Run only one application container instance on fixed ports for debugging purposes -->
<tests.fixed-container-ports>false</tests.fixed-container-ports>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<id>general-functional-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<excludes>
<exclude>**/tests/module/**/*Spec</exclude>
</excludes>
<includes>
<include>**/*Spec</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>Run only module functional tests</id>
<activation>
<property>
<name>run-module-functional-tests</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<configuration>
<parallelParsing>true</parallelParsing>
<testSources>
<testSource>
<directory>${project.basedir}/src/test/groovy</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</testSource>
</testSources>
</configuration>
<executions>
<execution>
<goals>
<goal>compileTests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<mockserver.version>${mockserver.version}</mockserver.version>
<pbs.version>${project.version}</pbs.version>
<tests.max-container-count>5</tests.max-container-count>
<!-- Run only one application container instance on fixed ports for debugging purposes -->
<tests.fixed-container-ports>false</tests.fixed-container-ports>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<id>module-functional-tests</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<includes>
<include>**/tests/module/**/*Spec</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Loading