From e9a1fd91493d5dd8d1d666d740ab018b5f796b20 Mon Sep 17 00:00:00 2001 From: mtuchkova Date: Tue, 28 Dec 2021 13:58:55 +0200 Subject: [PATCH 1/3] Externalize max number of containers through pom.xml and lower the default value --- .github/workflows/pr-functional-tests.yml | 2 +- pom.xml | 1 + .../server/functional/testcontainers/PbsServiceFactory.groovy | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-functional-tests.yml b/.github/workflows/pr-functional-tests.yml index fba38aa940a..d246a836fa9 100644 --- a/.github/workflows/pr-functional-tests.yml +++ b/.github/workflows/pr-functional-tests.yml @@ -36,4 +36,4 @@ jobs: ${{ runner.os }}-maven- - name: Build with Maven - run: mvn -B verify -DskipUnitTests=true --file extra/pom.xml + run: mvn -B verify -DskipUnitTests=true -Dmax.containers.count=5 --file extra/pom.xml diff --git a/pom.xml b/pom.xml index 2a886b62458..00f817658fc 100644 --- a/pom.xml +++ b/pom.xml @@ -748,6 +748,7 @@ target/allure-results ${mockserver-client.version} ${project.version} + 2 diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsServiceFactory.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsServiceFactory.groovy index ad40d76bf86..93c821682f7 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsServiceFactory.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsServiceFactory.groovy @@ -8,7 +8,7 @@ import org.prebid.server.functional.util.ObjectMapperWrapper class PbsServiceFactory { private static final Map, PrebidServerContainer> containers = [:] - private static final int MAX_CONTAINERS_COUNT = 5 + private static final Integer MAX_CONTAINERS_COUNT = Integer.valueOf(System.getProperty("max.containers.count")) private final ObjectMapperWrapper mapper private final NetworkServiceContainer networkServiceContainer From 4595db5f9cd29f615296f501ae2027d0c9b0447a Mon Sep 17 00:00:00 2001 From: mtuchkova Date: Tue, 28 Dec 2021 16:33:06 +0200 Subject: [PATCH 2/3] fix after review --- .../server/functional/testcontainers/Dependencies.groovy | 4 +++- .../server/functional/testcontainers/PbsServiceFactory.groovy | 4 +++- .../groovy/org/prebid/server/functional/util/PBSUtils.groovy | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy index 20b870dc337..5779c54e313 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy @@ -2,13 +2,15 @@ package org.prebid.server.functional.testcontainers import org.prebid.server.functional.testcontainers.container.NetworkServiceContainer import org.prebid.server.functional.util.ObjectMapperWrapper +import org.prebid.server.functional.util.PBSUtils import org.testcontainers.containers.MySQLContainer import org.testcontainers.containers.Network import org.testcontainers.lifecycle.Startables class Dependencies { - private static final Boolean IS_LAUNCH_CONTAINERS = Boolean.valueOf(System.getProperty("launchContainers")) + private static final Boolean IS_LAUNCH_CONTAINERS = Boolean.valueOf( + PBSUtils.getPropertyOrDefaultValue("launchContainers", "false")) static final ObjectMapperWrapper objectMapperWrapper = new ObjectMapperWrapper() diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsServiceFactory.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsServiceFactory.groovy index 93c821682f7..69f9457ea94 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsServiceFactory.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsServiceFactory.groovy @@ -4,11 +4,13 @@ import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.testcontainers.container.NetworkServiceContainer import org.prebid.server.functional.testcontainers.container.PrebidServerContainer import org.prebid.server.functional.util.ObjectMapperWrapper +import org.prebid.server.functional.util.PBSUtils class PbsServiceFactory { private static final Map, PrebidServerContainer> containers = [:] - private static final Integer MAX_CONTAINERS_COUNT = Integer.valueOf(System.getProperty("max.containers.count")) + private static final Integer MAX_CONTAINERS_COUNT = Integer.valueOf( + PBSUtils.getPropertyOrDefaultValue("max.containers.count", "2")) private final ObjectMapperWrapper mapper private final NetworkServiceContainer networkServiceContainer diff --git a/src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy b/src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy index 3189908f775..ddaa0df282d 100644 --- a/src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy @@ -50,4 +50,8 @@ class PBSUtils { } path } + + static String getPropertyOrDefaultValue(String property, String defaultValue) { + System.getProperty(property) ?: defaultValue + } } From c2baa0d935b47657e77d959e3f209ac9c51451a4 Mon Sep 17 00:00:00 2001 From: mtuchkova Date: Thu, 30 Dec 2021 14:51:09 +0200 Subject: [PATCH 3/3] fix after review --- .../server/functional/testcontainers/Dependencies.groovy | 2 +- .../server/functional/testcontainers/PbsServiceFactory.groovy | 4 ++-- .../groovy/org/prebid/server/functional/util/PBSUtils.groovy | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy index 5779c54e313..18488ac9d86 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy @@ -10,7 +10,7 @@ import org.testcontainers.lifecycle.Startables class Dependencies { private static final Boolean IS_LAUNCH_CONTAINERS = Boolean.valueOf( - PBSUtils.getPropertyOrDefaultValue("launchContainers", "false")) + PBSUtils.getPropertyOrDefault("launchContainers", "false")) static final ObjectMapperWrapper objectMapperWrapper = new ObjectMapperWrapper() diff --git a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsServiceFactory.groovy b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsServiceFactory.groovy index 69f9457ea94..f78f93aa1b7 100644 --- a/src/test/groovy/org/prebid/server/functional/testcontainers/PbsServiceFactory.groovy +++ b/src/test/groovy/org/prebid/server/functional/testcontainers/PbsServiceFactory.groovy @@ -9,8 +9,8 @@ import org.prebid.server.functional.util.PBSUtils class PbsServiceFactory { private static final Map, PrebidServerContainer> containers = [:] - private static final Integer MAX_CONTAINERS_COUNT = Integer.valueOf( - PBSUtils.getPropertyOrDefaultValue("max.containers.count", "2")) + private static final int MAX_CONTAINERS_COUNT = Integer.parseInt( + PBSUtils.getPropertyOrDefault("max.containers.count", "2")) private final ObjectMapperWrapper mapper private final NetworkServiceContainer networkServiceContainer diff --git a/src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy b/src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy index ddaa0df282d..1dccc13f1a0 100644 --- a/src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy +++ b/src/test/groovy/org/prebid/server/functional/util/PBSUtils.groovy @@ -51,7 +51,7 @@ class PBSUtils { path } - static String getPropertyOrDefaultValue(String property, String defaultValue) { + static String getPropertyOrDefault(String property, String defaultValue) { System.getProperty(property) ?: defaultValue } }