Skip to content

Commit c116892

Browse files
osulzhenkosergseven
authored andcommitted
update functional test for module execution (prebid#3617)
1 parent 4f909d2 commit c116892

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

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

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,6 @@ class GeneralModuleSpec extends ModuleBaseSpec {
323323
assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1
324324
assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1
325325

326-
and: "RB-Richmedia-Filter module call metrics shouldn't be updated"
327-
assert !metrics[CALL_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)]
328-
assert !metrics[NOOP_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)]
329-
330326
cleanup: "Stop and remove pbs container"
331327
pbsServiceFactory.removeContainer(pbsConfig)
332328
}
@@ -352,7 +348,7 @@ class GeneralModuleSpec extends ModuleBaseSpec {
352348
assert !response?.ext?.prebid?.modules?.trace?.stages?.outcomes?.groups?.invocationResults?.flatten()
353349

354350
and: "Ortb2blocking module call metrics shouldn't be updated"
355-
def metrics = pbsServiceWithMultipleModuleWithRequireInvoke.sendCollectedMetricsRequest()
351+
def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest()
356352
assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)]
357353
assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)]
358354
assert !metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)]
@@ -362,7 +358,7 @@ class GeneralModuleSpec extends ModuleBaseSpec {
362358
pbsServiceFactory.removeContainer(pbsConfig)
363359
}
364360

365-
def "PBS should call module without account config when default-account module-execution config enabled module"() {
361+
def "PBS shouldn't call module and not override host config when default-account module-execution config enabled module"() {
366362
given: "PBS service with module-execution and default account configs"
367363
def defaultAccountConfigSettings = AccountConfig.defaultAccountConfig.tap {
368364
hooks = new AccountHooksConfiguration(admin: new AdminConfig(moduleExecution: [(ORTB2_BLOCKING): true]))
@@ -391,15 +387,53 @@ class GeneralModuleSpec extends ModuleBaseSpec {
391387
assert !response?.ext?.prebid?.modules?.trace?.stages?.outcomes?.groups?.invocationResults?.flatten()
392388

393389
and: "Ortb2blocking module call metrics shouldn't be updated"
394-
def metrics = pbsServiceWithMultipleModuleWithRequireInvoke.sendCollectedMetricsRequest()
390+
def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest()
395391
assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)]
396392
assert !metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)]
397393
assert !metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)]
398394
assert !metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)]
399395

400-
and: "RB-Richmedia-Filter module call metrics shouldn't be updated"
401-
assert !metrics[CALL_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)]
402-
assert !metrics[NOOP_METRIC.formatted(PB_RICHMEDIA_FILTER.code, ALL_PROCESSED_BID_RESPONSES.metricValue, PB_RICHMEDIA_FILTER_ALL_PROCESSED_RESPONSES.code)]
396+
cleanup: "Stop and remove pbs container"
397+
pbsServiceFactory.removeContainer(pbsConfig)
398+
}
399+
400+
def "PBS should call module without account module config when default-account module-execution config enabling module"() {
401+
given: "PBS service with module-execution and default account configs"
402+
def defaultAccountConfigSettings = AccountConfig.defaultAccountConfig.tap {
403+
hooks = new AccountHooksConfiguration(admin: new AdminConfig(moduleExecution: [(ORTB2_BLOCKING): true]))
404+
}
405+
def pbsConfig = MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG + ["settings.default-account-config": encode(defaultAccountConfigSettings)]
406+
def pbsServiceWithMultipleModules = pbsServiceFactory.getService(pbsConfig)
407+
408+
and: "Default bid request with verbose trace"
409+
def bidRequest = defaultBidRequest.tap {
410+
ext.prebid.trace = TraceLevel.VERBOSE
411+
}
412+
413+
and: "Save account without modules config"
414+
def accountConfig = new AccountConfig(hooks: new AccountHooksConfiguration(modules: null))
415+
def account = new Account(uuid: bidRequest.getAccountId(), config: accountConfig)
416+
accountDao.save(account)
417+
418+
and: "Flush metrics"
419+
flushMetrics(pbsServiceWithMultipleModules)
420+
421+
when: "PBS processes auction request"
422+
def response = pbsServiceWithMultipleModules.sendAuctionRequest(bidRequest)
423+
424+
then: "PBS response should include trace information about called modules"
425+
verifyAll(response?.ext?.prebid?.modules?.trace?.stages?.outcomes?.groups?.invocationResults?.flatten() as List<InvocationResult>) {
426+
it.status == [SUCCESS, SUCCESS]
427+
it.action == [NO_ACTION, NO_ACTION]
428+
it.hookId.moduleCode.sort() == [ORTB2_BLOCKING, ORTB2_BLOCKING].code.sort()
429+
}
430+
431+
and: "Ortb2blocking module call metrics should be updated"
432+
def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest()
433+
assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1
434+
assert metrics[CALL_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1
435+
assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, BIDDER_REQUEST.metricValue, ORTB2_BLOCKING_BIDDER_REQUEST.code)] == 1
436+
assert metrics[NOOP_METRIC.formatted(ORTB2_BLOCKING.code, RAW_BIDDER_RESPONSE.metricValue, ORTB2_BLOCKING_RAW_BIDDER_RESPONSE.code)] == 1
403437

404438
cleanup: "Stop and remove pbs container"
405439
pbsServiceFactory.removeContainer(pbsConfig)

0 commit comments

Comments
 (0)