Skip to content

Commit 3e91c96

Browse files
authored
Fix issue with connection for tests (#3704)
1 parent 02ab379 commit 3e91c96

14 files changed

+117
-48
lines changed

src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ abstract class BaseSpec extends Specification implements ObjectMapperWrapper {
4343
protected static final Map<String, String> GENERIC_ALIAS_CONFIG = ["adapters.generic.aliases.alias.enabled" : "true",
4444
"adapters.generic.aliases.alias.endpoint": "$networkServiceContainer.rootUri/auction".toString()]
4545

46-
protected final PrebidServerService defaultPbsService = pbsServiceFactory.getService([:])
46+
protected static final PrebidServerService defaultPbsService = pbsServiceFactory.getService([:])
4747

4848
def setupSpec() {
4949
prebidCache.setResponse()

src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ class AbTestingModuleSpec extends ModuleBaseSpec {
4848
private final static Map<String, String> MULTI_MODULE_CONFIG = getResponseCorrectionConfig() + getOrtb2BlockingSettings() +
4949
['hooks.host-execution-plan': null]
5050

51-
private final static PrebidServerService ortbModulePbsService = pbsServiceFactory.getService(getOrtb2BlockingSettings())
52-
private final static PrebidServerService pbsServiceWithMultipleModules = pbsServiceFactory.getService(MULTI_MODULE_CONFIG)
51+
private static final PrebidServerService ortbModulePbsService = pbsServiceFactory.getService(getOrtb2BlockingSettings())
52+
private static final PrebidServerService pbsServiceWithMultipleModules = pbsServiceFactory.getService(MULTI_MODULE_CONFIG)
53+
54+
def cleanupSpec() {
55+
pbsServiceFactory.removeContainer(getOrtb2BlockingSettings())
56+
pbsServiceFactory.removeContainer(MULTI_MODULE_CONFIG)
57+
}
5358

5459
def "PBS shouldn't apply a/b test config when config of ab test is disabled"() {
5560
given: "Default bid request with verbose trace"

src/test/groovy/org/prebid/server/functional/tests/module/GeneralModuleSpec.groovy

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@ class GeneralModuleSpec extends ModuleBaseSpec {
4545
getOrtb2BlockingSettings() +
4646
['hooks.host-execution-plan': encode(ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, MODULES_STAGES))]
4747

48-
private final static PrebidServerService pbsServiceWithMultipleModule = pbsServiceFactory.getService(MULTI_MODULE_CONFIG + DISABLED_INVOKE_CONFIG)
49-
private final static PrebidServerService pbsServiceWithMultipleModuleWithRequireInvoke = pbsServiceFactory.getService(MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG)
48+
private static final PrebidServerService pbsServiceWithMultipleModule = pbsServiceFactory.getService(MULTI_MODULE_CONFIG + DISABLED_INVOKE_CONFIG)
49+
private static final PrebidServerService pbsServiceWithMultipleModuleWithRequireInvoke = pbsServiceFactory.getService(MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG)
50+
51+
def cleanupSpec() {
52+
pbsServiceFactory.removeContainer(MULTI_MODULE_CONFIG + DISABLED_INVOKE_CONFIG)
53+
pbsServiceFactory.removeContainer(MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG)
54+
}
5055

5156
def "PBS should call all modules and traces response when account config is empty and require-config-to-invoke is disabled"() {
5257
given: "Default bid request with verbose trace"

src/test/groovy/org/prebid/server/functional/tests/module/analyticstag/AnalyticsTagsModuleSpec.groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ import static org.prebid.server.functional.model.response.auction.ErrorType.PREB
3030

3131
class AnalyticsTagsModuleSpec extends ModuleBaseSpec {
3232

33-
private final PrebidServerService pbsServiceWithEnabledOrtb2Blocking = pbsServiceFactory.getService(ortb2BlockingSettings)
33+
private static final PrebidServerService pbsServiceWithEnabledOrtb2Blocking = pbsServiceFactory.getService(getOrtb2BlockingSettings())
34+
35+
def cleanupSpec() {
36+
pbsServiceFactory.removeContainer(getOrtb2BlockingSettings())
37+
}
3438

3539
def "PBS should include analytics tag for ortb2-blocking module in response when request and account allow client details"() {
3640
given: "Default account with module config"

src/test/groovy/org/prebid/server/functional/tests/module/ortb2blocking/Ortb2BlockingSpec.groovy

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,14 @@ class Ortb2BlockingSpec extends ModuleBaseSpec {
5959
private static final String WILDCARD = '*'
6060
private static final Map IX_CONFIG = ["adapters.ix.enabled" : "true",
6161
"adapters.ix.endpoint": "$networkServiceContainer.rootUri/auction".toString()]
62+
private static final Map PBS_CONFIG = getOrtb2BlockingSettings() + IX_CONFIG +
63+
['adapter-defaults.ortb.multiformat-supported': 'false']
6264

63-
private final PrebidServerService pbsServiceWithEnabledOrtb2Blocking = pbsServiceFactory.getService(ortb2BlockingSettings + IX_CONFIG +
64-
['adapter-defaults.ortb.multiformat-supported': 'false'])
65+
private static final PrebidServerService pbsServiceWithEnabledOrtb2Blocking = pbsServiceFactory.getService(PBS_CONFIG)
66+
67+
def cleanupSpec() {
68+
pbsServiceFactory.removeContainer(PBS_CONFIG)
69+
}
6570

6671
def "PBS should send original array ortb2 attribute to bidder when enforce blocking is disabled"() {
6772
given: "Default bid request with proper ortb attribute"

src/test/groovy/org/prebid/server/functional/tests/module/pbrequestcorrection/PbRequestCorrectionSpec.groovy

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec {
2727
private static final String ANDROID = "android"
2828
private static final String IOS = "IOS"
2929

30-
private PrebidServerService pbsServiceWithRequestCorrectionModule = pbsServiceFactory.getService(requestCorrectionSettings)
30+
private static final PrebidServerService pbsServiceWithRequestCorrectionModule = pbsServiceFactory.getService(getRequestCorrectionSettings())
31+
32+
def cleanupSpec() {
33+
pbsServiceFactory.removeContainer(getRequestCorrectionSettings())
34+
}
3135

3236
def "PBS should remove positive instl from imps for android app when request correction is enabled for account"() {
3337
given: "Android APP bid request with version lover then version threshold"

src/test/groovy/org/prebid/server/functional/tests/module/responsecorrenction/ResponseCorrectionSpec.groovy

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ import static org.prebid.server.functional.model.response.auction.MediaType.VIDE
3232

3333
class ResponseCorrectionSpec extends ModuleBaseSpec {
3434

35-
private final PrebidServerService pbsServiceWithResponseCorrectionModule = pbsServiceFactory.getService(
36-
["adapter-defaults.modifying-vast-xml-allowed": "false",
37-
"adapters.generic.modifying-vast-xml-allowed": "false"] +
38-
responseCorrectionConfig)
39-
4035
private final static int OPTIMAL_MAX_LENGTH = 20
36+
private static final Map PBS_CONFIG = ["adapter-defaults.modifying-vast-xml-allowed": "false",
37+
"adapters.generic.modifying-vast-xml-allowed": "false"] +
38+
getResponseCorrectionConfig()
39+
40+
private static final PrebidServerService pbsServiceWithResponseCorrectionModule = pbsServiceFactory.getService(PBS_CONFIG)
41+
42+
def cleanupSpec() {
43+
pbsServiceFactory.removeContainer(PBS_CONFIG)
44+
}
4145

4246
def "PBS shouldn't modify response when in account correction module disabled"() {
4347
given: "Start up time"

src/test/groovy/org/prebid/server/functional/tests/module/richmedia/RichMediaFilterSpec.groovy

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,22 @@ class RichMediaFilterSpec extends ModuleBaseSpec {
2727

2828
private static final String PATTERN_NAME = PBSUtils.randomString
2929
private static final String PATTERN_NAME_ACCOUNT = PBSUtils.randomString
30-
private final PrebidServerService pbsServiceWithEnabledMediaFilter = pbsServiceFactory.getService(getRichMediaFilterSettings(PATTERN_NAME))
31-
private final PrebidServerService pbsServiceWithEnabledMediaFilterAndDifferentCaseStrategy = pbsServiceFactory.getService(
32-
(getRichMediaFilterSettings(PATTERN_NAME) + ["hooks.host-execution-plan": encode(ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, PB_RICHMEDIA_FILTER, [ALL_PROCESSED_BID_RESPONSES]).tap {
30+
private static final Map<String, String> DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG = getRichMediaFilterSettings(PATTERN_NAME, false)
31+
private static final Map<String, String> SPECIFIC_PATTERN_NAME_CONFIG = getRichMediaFilterSettings(PATTERN_NAME)
32+
private static final Map<String, String> SNAKE_SPECIFIC_PATTERN_NAME_CONFIG = (getRichMediaFilterSettings(PATTERN_NAME) +
33+
["hooks.host-execution-plan": encode(ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, PB_RICHMEDIA_FILTER, [ALL_PROCESSED_BID_RESPONSES]).tap {
3334
endpoints.values().first().stages.values().first().groups.first.hookSequenceSnakeCase = [new HookId(moduleCodeSnakeCase: PB_RICHMEDIA_FILTER.code, hookImplCodeSnakeCase: "${PB_RICHMEDIA_FILTER.code}-${ALL_PROCESSED_BID_RESPONSES.value}-hook")]
34-
})])
35-
.collectEntries { key, value -> [(key.toString()): value.toString()] })
36-
private final PrebidServerService pbsServiceWithDisabledMediaFilter = pbsServiceFactory.getService(getRichMediaFilterSettings(PATTERN_NAME, false))
35+
})]).collectEntries { key, value -> [(key.toString()): value.toString()] }
36+
37+
private static final PrebidServerService pbsServiceWithDisabledMediaFilter = pbsServiceFactory.getService(DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG)
38+
private static final PrebidServerService pbsServiceWithEnabledMediaFilter = pbsServiceFactory.getService(SPECIFIC_PATTERN_NAME_CONFIG)
39+
private static final PrebidServerService pbsServiceWithEnabledMediaFilterAndDifferentCaseStrategy = pbsServiceFactory.getService(SNAKE_SPECIFIC_PATTERN_NAME_CONFIG)
40+
41+
def cleanupSpec() {
42+
pbsServiceFactory.removeContainer(DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG)
43+
pbsServiceFactory.removeContainer(SPECIFIC_PATTERN_NAME_CONFIG)
44+
pbsServiceFactory.removeContainer(SNAKE_SPECIFIC_PATTERN_NAME_CONFIG)
45+
}
3746

3847
def "PBS should process request without rich media module when host config have empty settings"() {
3948
given: "Prebid server with empty settings for module"

src/test/groovy/org/prebid/server/functional/tests/privacy/GdprSetUidSpec.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ class GdprSetUidSpec extends PrivacyBaseSpec {
4141

4242
private static final PrebidServerService prebidServerService = pbsServiceFactory.getService(VENDOR_GENERIC_PBS_CONFIG)
4343

44+
def cleanupSpec() {
45+
pbsServiceFactory.removeContainer(VENDOR_GENERIC_PBS_CONFIG)
46+
}
47+
4448
def "PBS setuid shouldn't failed with tcf when purpose access device not enforced"() {
4549
given: "Default setuid request with account"
4650
def setuidRequest = SetuidRequest.defaultSetuidRequest.tap {

src/test/groovy/org/prebid/server/functional/tests/privacy/GppCookieSyncSpec.groovy

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ class GppCookieSyncSpec extends BaseSpec {
3333
"adapters.${GENERIC.value}.usersync.${USER_SYNC_TYPE.value}.url" : USER_SYNC_URL,
3434
"adapters.${GENERIC.value}.usersync.${USER_SYNC_TYPE.value}.support-cors": CORS_SUPPORT.toString()]
3535

36-
private PrebidServerService prebidServerService = pbsServiceFactory.getService(GENERIC_CONFIG)
36+
private static PrebidServerService prebidServerService = pbsServiceFactory.getService(GENERIC_CONFIG)
37+
38+
def cleanupSpec() {
39+
pbsServiceFactory.removeContainer(GENERIC_CONFIG)
40+
}
3741

3842
def "PBS cookie sync request should set GDPR to 1 when gpp_sid contains 2"() {
3943
given: "Request without GDPR and GPP SID"
@@ -204,9 +208,9 @@ class GppCookieSyncSpec extends BaseSpec {
204208

205209
def "PBS should return empty gpp and gppSid in usersync url when gpp and gppSid is not present in request"() {
206210
given: "Pbs config with usersync.#userSyncFormat.url"
207-
def prebidServerService = pbsServiceFactory.getService(
208-
["adapters.generic.usersync.${userSyncFormat.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(),
209-
"adapters.generic.usersync.${userSyncFormat.value}.support-cors": "false"])
211+
def pbsConfig = ["adapters.generic.usersync.${userSyncFormat.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(),
212+
"adapters.generic.usersync.${userSyncFormat.value}.support-cors": "false"]
213+
def prebidServerService = pbsServiceFactory.getService(pbsConfig)
210214

211215
and: "Default CookieSyncRequest without gpp and gppSid"
212216
def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest.tap {
@@ -222,15 +226,18 @@ class GppCookieSyncSpec extends BaseSpec {
222226
assert HttpUtil.findUrlParameterValue(bidderStatus.userSync?.url, "gpp").isEmpty()
223227
assert HttpUtil.findUrlParameterValue(bidderStatus.userSync?.url, "gpp_sid").isEmpty()
224228

229+
cleanup: "Stop and remove pbs container"
230+
pbsServiceFactory.removeContainer(pbsConfig)
231+
225232
where:
226233
userSyncFormat << [REDIRECT, IFRAME]
227234
}
228235

229236
def "PBS should populate gpp and gppSid in usersync url when gpp and gppSid is present in request"() {
230237
given: "Pbs config with usersync.#userSyncFormat.url"
231-
def prebidServerService = pbsServiceFactory.getService(
232-
["adapters.generic.usersync.${userSyncFormat.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(),
233-
"adapters.generic.usersync.${userSyncFormat.value}.support-cors": "false"])
238+
def pbsConfig = ["adapters.generic.usersync.${userSyncFormat.value}.url" : "$networkServiceContainer.rootUri/generic-usersync&redir={{redirect_url}}".toString(),
239+
"adapters.generic.usersync.${userSyncFormat.value}.support-cors": "false"]
240+
def prebidServerService = pbsServiceFactory.getService(pbsConfig)
234241

235242
and: "Default CookieSyncRequest with gpp and gppSid"
236243
def gpp = PBSUtils.randomString
@@ -248,6 +255,9 @@ class GppCookieSyncSpec extends BaseSpec {
248255
assert HttpUtil.findUrlParameterValue(bidderStatus.userSync?.url, "gpp") == gpp
249256
assert HttpUtil.findUrlParameterValue(bidderStatus.userSync?.url, "gpp_sid") == gppSid
250257

258+
cleanup: "Stop and remove pbs container"
259+
pbsServiceFactory.removeContainer(pbsConfig)
260+
251261
where:
252262
userSyncFormat << [REDIRECT, IFRAME]
253263
}

0 commit comments

Comments
 (0)