From 3717ef9766449bdfe2828ef8169126bdccbcfb67 Mon Sep 17 00:00:00 2001 From: osulzhenko Date: Tue, 12 May 2026 20:33:03 +0300 Subject: [PATCH] Tests: Rework metrics handling for functional tests --- .../functional/model/bidder/Adrino.groovy | 6 + .../{request/auction => bidder}/Amx.groovy | 4 +- .../{request/auction => bidder}/Ix.groovy | 4 +- .../{request/auction => bidder}/IxDiag.groovy | 2 +- .../functional/model/privacy/Metric.groovy | 52 --- .../model/request/auction/Adrino.groovy | 6 - .../request/auction/BidRequestExt.groovy | 8 +- .../model/request/auction/Bidder.groovy | 4 +- .../tests/AlternateBidderCodeSpec.groovy | 108 ++--- .../functional/tests/AuctionSpec.groovy | 30 +- .../server/functional/tests/BaseSpec.groovy | 1 - .../functional/tests/BidAdjustmentSpec.groovy | 2 +- .../functional/tests/BidValidationSpec.groovy | 11 +- .../functional/tests/BidderFormatSpec.groovy | 67 +-- .../functional/tests/BidderParamsSpec.groovy | 4 +- .../server/functional/tests/CacheSpec.groovy | 66 ++- .../functional/tests/CacheVtrackSpec.groovy | 71 ++- .../functional/tests/CookieSyncSpec.groovy | 9 +- .../server/functional/tests/DebugSpec.groovy | 31 +- .../server/functional/tests/GeoSpec.groovy | 67 +-- .../functional/tests/MetricsSpec.groovy | 47 +- .../functional/tests/ProfileSpec.groovy | 26 +- .../server/functional/tests/SetUidSpec.groovy | 15 +- .../server/functional/tests/UUIDSpec.groovy | 9 +- .../tests/module/AbTestingModuleSpec.groovy | 283 ++++++------ .../tests/module/GeneralModuleSpec.groovy | 149 +++---- .../tests/module/ModuleBaseSpec.groovy | 16 - .../optabletargeting/CacheStorageSpec.groovy | 52 +-- .../PbOrtb2BlockingSpec.groovy | 2 +- .../pbruleengine/PbRuleEngineAliasSpec.groovy | 2 +- .../pbruleengine/PbRuleEngineBaseSpec.groovy | 2 +- .../PbRuleEngineContextSpec.groovy | 2 +- .../pbruleengine/PbRuleEngineCoreSpec.groovy | 7 +- .../PbRuleEngineDeviceSpec.groovy | 2 +- .../PbRuleEngineInfrastructureSpec.groovy | 2 +- .../PbRuleEnginePrivacySpec.groovy | 2 +- .../PbRuleEngineSpecialSpec.groovy | 2 +- .../pbruleengine/PbRuleEngineSyncSpec.groovy | 2 +- .../PbRuleEngineValidationSpec.groovy | 11 +- .../pricefloors/PriceFloorsBaseSpec.groovy | 2 - .../PriceFloorsFetchingSpec.groovy | 72 ++- .../pricefloors/PriceFloorsRulesSpec.groovy | 2 +- .../PriceFloorsSignalingSpec.groovy | 35 +- .../tests/privacy/ccpa/CcpaAmpSpec.groovy | 27 +- .../tests/privacy/ccpa/CcpaAuctionSpec.groovy | 58 ++- .../tests/privacy/coppa/CoppaSpec.groovy | 88 ++-- .../tests/privacy/gdpr/GdprAmpSpec.groovy | 41 +- .../tests/privacy/gdpr/GdprAuctionSpec.groovy | 111 +++-- .../tests/privacy/gdpr/GdprSetUidSpec.groovy | 7 +- .../gpp/GppFetchBidActivitiesSpec.groovy | 86 ++-- .../gpp/GppSyncUserActivitiesSpec.groovy | 71 ++- .../gpp/GppTransmitEidsActivitiesSpec.groovy | 105 +++-- ...GppTransmitPreciseGeoActivitiesSpec.groovy | 82 ++-- .../gpp/GppTransmitTidActivitiesSpec.groovy | 19 +- .../gpp/GppTransmitUfpdActivitiesSpec.groovy | 117 +++-- .../tests/privacy/lmt/LmtSpec.groovy | 89 ++-- .../tests/privacy/tcf/TcfGeneralSpec.groovy | 16 +- .../server/functional/util/MetricsUtil.groovy | 410 ++++++++++++++++++ 58 files changed, 1459 insertions(+), 1165 deletions(-) create mode 100644 src/test/groovy/org/prebid/server/functional/model/bidder/Adrino.groovy rename src/test/groovy/org/prebid/server/functional/model/{request/auction => bidder}/Amx.groovy (62%) rename src/test/groovy/org/prebid/server/functional/model/{request/auction => bidder}/Ix.groovy (81%) rename src/test/groovy/org/prebid/server/functional/model/{request/auction => bidder}/IxDiag.groovy (75%) delete mode 100644 src/test/groovy/org/prebid/server/functional/model/privacy/Metric.groovy delete mode 100644 src/test/groovy/org/prebid/server/functional/model/request/auction/Adrino.groovy create mode 100644 src/test/groovy/org/prebid/server/functional/util/MetricsUtil.groovy diff --git a/src/test/groovy/org/prebid/server/functional/model/bidder/Adrino.groovy b/src/test/groovy/org/prebid/server/functional/model/bidder/Adrino.groovy new file mode 100644 index 00000000000..8b1ff813fe6 --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/model/bidder/Adrino.groovy @@ -0,0 +1,6 @@ +package org.prebid.server.functional.model.bidder + +class Adrino implements BidderAdapter { + + Integer hash +} diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Amx.groovy b/src/test/groovy/org/prebid/server/functional/model/bidder/Amx.groovy similarity index 62% rename from src/test/groovy/org/prebid/server/functional/model/request/auction/Amx.groovy rename to src/test/groovy/org/prebid/server/functional/model/bidder/Amx.groovy index 3ae0dcd17a3..28f89053cd6 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Amx.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/bidder/Amx.groovy @@ -1,8 +1,6 @@ -package org.prebid.server.functional.model.request.auction +package org.prebid.server.functional.model.bidder import com.fasterxml.jackson.annotation.JsonProperty -import org.prebid.server.functional.model.bidder.BidderAdapter -import org.prebid.server.functional.model.bidder.BidderName class Amx implements BidderAdapter { diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Ix.groovy b/src/test/groovy/org/prebid/server/functional/model/bidder/Ix.groovy similarity index 81% rename from src/test/groovy/org/prebid/server/functional/model/request/auction/Ix.groovy rename to src/test/groovy/org/prebid/server/functional/model/bidder/Ix.groovy index a620c7646b1..73fa3ef64e0 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Ix.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/bidder/Ix.groovy @@ -1,10 +1,10 @@ -package org.prebid.server.functional.model.request.auction +package org.prebid.server.functional.model.bidder import groovy.transform.EqualsAndHashCode import org.prebid.server.functional.util.PBSUtils @EqualsAndHashCode -class Ix { +class Ix implements BidderAdapter { String siteId List size diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/IxDiag.groovy b/src/test/groovy/org/prebid/server/functional/model/bidder/IxDiag.groovy similarity index 75% rename from src/test/groovy/org/prebid/server/functional/model/request/auction/IxDiag.groovy rename to src/test/groovy/org/prebid/server/functional/model/bidder/IxDiag.groovy index d68075b6668..5100c7d0f18 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/IxDiag.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/bidder/IxDiag.groovy @@ -1,4 +1,4 @@ -package org.prebid.server.functional.model.request.auction +package org.prebid.server.functional.model.bidder import groovy.transform.ToString diff --git a/src/test/groovy/org/prebid/server/functional/model/privacy/Metric.groovy b/src/test/groovy/org/prebid/server/functional/model/privacy/Metric.groovy deleted file mode 100644 index 9b238bc322a..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/privacy/Metric.groovy +++ /dev/null @@ -1,52 +0,0 @@ -package org.prebid.server.functional.model.privacy - -import org.prebid.server.functional.model.request.auction.ActivityType -import org.prebid.server.functional.model.request.auction.BidRequest -import org.prebid.server.functional.model.request.cookiesync.CookieSyncRequest -import org.prebid.server.functional.model.request.setuid.SetuidRequest - -enum Metric { - - PROCESSED_ACTIVITY_RULES_COUNT("requests.activity.processedrules.count"), - ACCOUNT_PROCESSED_RULES_COUNT("requests.activity.processedrules.count"), - TEMPLATE_ADAPTER_DISALLOWED_COUNT("adapter.{bidderName}.activity.{activityType}.disallowed.count"), - TEMPLATE_ACCOUNT_DISALLOWED_COUNT("account.{accountId}.activity.{activityType}.disallowed.count"), - TEMPLATE_REQUEST_DISALLOWED_COUNT("requests.activity.{activityType}.disallowed.count") - - final String value - - Metric(String value) { - this.value = value - } - - String getValue(BidRequest bidRequest, String accountId, ActivityType activityType) { - if (bidRequest.imp.size() != 1) { - throw new IllegalStateException("No imp found") - } - replaceValues(bidRequest.imp.first.bidderName.value, accountId, activityType.metricValue) - } - - String getValue(BidRequest bidRequest, ActivityType activityType) { - if (bidRequest.imp.size() != 1) { - throw new IllegalStateException("No imp found") - } - replaceValues(bidRequest.imp.first.bidderName.value, bidRequest.accountId, activityType.metricValue) - } - - String getValue(CookieSyncRequest syncRequest, ActivityType activityType) { - if (syncRequest.bidders.size() != 1) { - throw new IllegalStateException("No bidder found") - } - replaceValues(syncRequest.bidders.first.value, syncRequest.account, activityType.metricValue) - } - - String getValue(SetuidRequest syncRequest, ActivityType activityType) { - replaceValues(syncRequest.bidder.value, syncRequest.account, activityType.metricValue) - } - - private String replaceValues(String bidderName, String accountId, String activityType) { - this.value.replaceAll('\\{bidderName}', bidderName) - .replaceAll('\\{accountId}', accountId) - .replaceAll('\\{activityType}', activityType) - } -} diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Adrino.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Adrino.groovy deleted file mode 100644 index 2d1675194e9..00000000000 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Adrino.groovy +++ /dev/null @@ -1,6 +0,0 @@ -package org.prebid.server.functional.model.request.auction - -class Adrino { - - Integer hash -} diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/BidRequestExt.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/BidRequestExt.groovy index 3c39de5781e..efc7a9f3c37 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/BidRequestExt.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/BidRequestExt.groovy @@ -1,8 +1,10 @@ package org.prebid.server.functional.model.request.auction +import com.fasterxml.jackson.annotation.JsonProperty import groovy.transform.EqualsAndHashCode import groovy.transform.ToString import org.prebid.server.functional.model.bidder.AppNexus +import org.prebid.server.functional.model.bidder.IxDiag @EqualsAndHashCode @ToString(includeNames = true, ignoreNulls = true) @@ -10,8 +12,10 @@ class BidRequestExt { Prebid prebid SupplyChain schain - AppNexus appnexus + @JsonProperty("appnexus") + AppNexus appNexus String bc String platform - IxDiag ixdiag + @JsonProperty("ixdiag") + IxDiag ixDiag } diff --git a/src/test/groovy/org/prebid/server/functional/model/request/auction/Bidder.groovy b/src/test/groovy/org/prebid/server/functional/model/request/auction/Bidder.groovy index 5ea7a7d3270..b49024fe8a5 100644 --- a/src/test/groovy/org/prebid/server/functional/model/request/auction/Bidder.groovy +++ b/src/test/groovy/org/prebid/server/functional/model/request/auction/Bidder.groovy @@ -3,8 +3,11 @@ package org.prebid.server.functional.model.request.auction import com.fasterxml.jackson.annotation.JsonIgnore import com.fasterxml.jackson.annotation.JsonProperty import groovy.transform.ToString +import org.prebid.server.functional.model.bidder.Adrino +import org.prebid.server.functional.model.bidder.Amx import org.prebid.server.functional.model.bidder.AppNexus import org.prebid.server.functional.model.bidder.Generic +import org.prebid.server.functional.model.bidder.Ix import org.prebid.server.functional.model.bidder.Openx import org.prebid.server.functional.model.bidder.Magnite @@ -27,7 +30,6 @@ class Bidder { @JsonProperty("openxalias") Openx openxAlias Adrino adrino - Generic nativo Amx amx @JsonProperty("AMX") Amx amxUpperCase diff --git a/src/test/groovy/org/prebid/server/functional/tests/AlternateBidderCodeSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/AlternateBidderCodeSpec.groovy index 27bc35f3cc3..26d5f306aea 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/AlternateBidderCodeSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/AlternateBidderCodeSpec.groovy @@ -7,7 +7,7 @@ import org.prebid.server.functional.model.config.CodesBidderConfig import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.db.StoredImp import org.prebid.server.functional.model.db.StoredResponse -import org.prebid.server.functional.model.request.auction.Amx +import org.prebid.server.functional.model.bidder.Amx import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.model.request.auction.PrebidStoredRequest @@ -18,6 +18,7 @@ import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.model.response.auction.ErrorType import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import spock.lang.Shared @@ -37,7 +38,6 @@ import static org.prebid.server.functional.testcontainers.Dependencies.getNetwor class AlternateBidderCodeSpec extends BaseSpec { - private static final String ADAPTER_RESPONSE_VALIDATION_METRICS = "adapter.%s.response.validation.seat" private static final String ERROR_BID_CODE_VALIDATION = "BidId `%s` validation messages: " + "Error: invalid bidder code %s was set by the adapter %s for the account %s" private static final String INVALID_BIDDER_CODE_LOGS = "invalid bidder code %s was set by the adapter %s for the account %s" @@ -100,7 +100,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(ALIAS)] + assert !metrics[MetricsUtil.Adapter.validationSeat(ALIAS)] } def "PBS should populate meta demand source when bid response with demand source"() { @@ -149,7 +149,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[MetricsUtil.Adapter.validationSeat(AMX)] } def "PBS shouldn't populate meta demand source when bid response without demand source"() { @@ -197,7 +197,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[MetricsUtil.Adapter.validationSeat(AMX)] } def "PBS shouldn't discard bid for amx bidder same seat in response as seat in bid.ext.bidderCode"() { @@ -245,7 +245,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[MetricsUtil.Adapter.validationSeat(AMX)] where: bidderCode << [AMX, AMX_CAMEL_CASE] @@ -294,9 +294,9 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "Bidder request should be valid" assert bidder.getBidderRequests(bidRequest.id) - and: "PBS should emit metrics" + and: "PBS should emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert metrics[MetricsUtil.Adapter.validationSeat(AMX)] where: bidderName << [BOGUS, UNKNOWN, WILDCARD] @@ -351,7 +351,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS should emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(ALIAS)] + assert metrics[MetricsUtil.Adapter.validationSeat(ALIAS)] where: bidderName << [BOGUS, UNKNOWN, WILDCARD] @@ -413,7 +413,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(ALIAS)] + assert !metrics[MetricsUtil.Adapter.validationSeat(ALIAS)] where: requestAlternateBidderCode | accountAlternateBidderCodes @@ -470,7 +470,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(bidderCode)] + assert !metrics[MetricsUtil.Adapter.validationSeat(bidderCode)] where: bidderCode << [ALIAS, ALIAS_CAMEL_CASE] @@ -525,9 +525,9 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "Response shouldn't contain demand source" assert !response.seatbid.first.bid.first.ext.prebid.meta.demandSource - and: "Metric shouldn't be updated" + and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[MetricsUtil.Adapter.validationSeat(AMX)] where: accountAlternateBidderCodes << [null, @@ -593,9 +593,9 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "Response shouldn't contain demand source" assert !response.seatbid.first.bid.first.ext.prebid.meta.demandSource - and: "Metric shouldn't be updated" + and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[MetricsUtil.Adapter.validationSeat(AMX)] where: requestedAlternateBidderCodes << [null, @@ -693,9 +693,9 @@ class AlternateBidderCodeSpec extends BaseSpec { assert !response.ext?.errors assert !response.ext?.seatnonbid - and: "Metric shouldn't be updated" + and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] + assert !metrics[MetricsUtil.Adapter.validationSeat(GENERIC)] } def "PBS shouldn't discard bid when alternate bidder code allows bidder codes fully configured with different case"() { @@ -747,9 +747,9 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "Response shouldn't contain demand source" assert !response.seatbid.first.bid.first.ext.prebid.meta.demandSource - and: "Metric shouldn't be updated" + and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[MetricsUtil.Adapter.validationSeat(AMX)] where: configAccountAlternateBidderCodes << [ @@ -801,9 +801,9 @@ class AlternateBidderCodeSpec extends BaseSpec { def logs = pbsServiceWithAmxBidder.getLogsByValue(bidRequest.accountId) assert logs.contains(INVALID_BIDDER_CODE_LOGS.formatted(UNKNOWN, AMX, bidRequest.accountId)) - and: "PBS should emit metrics" + and: "PBS should emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert metrics[MetricsUtil.Adapter.validationSeat(AMX)] and: "Response should contain repose millis with corresponding bidder" assert response.ext.responsetimemillis.containsKey(AMX.value) @@ -857,9 +857,9 @@ class AlternateBidderCodeSpec extends BaseSpec { def logs = pbsServiceWithAmxBidder.getLogsByValue(bidRequest.accountId) assert logs.contains(INVALID_BIDDER_CODE_LOGS.formatted(UNKNOWN, AMX, bidRequest.accountId)) - and: "PBS should emit metrics" + and: "PBS should emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert metrics[MetricsUtil.Adapter.validationSeat(AMX)] and: "Response should contain repose millis with corresponding bidder" assert response.ext.responsetimemillis.containsKey(AMX.value) @@ -924,9 +924,9 @@ class AlternateBidderCodeSpec extends BaseSpec { assert !response.ext?.errors assert !response.ext?.seatnonbid - and: "PBs metric shouldn't be updated" + and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[MetricsUtil.Adapter.validationSeat(AMX)] where: accountAllowedBidderCodes << [[WILDCARD], [WILDCARD, EMPTY], [EMPTY, WILDCARD], null] @@ -977,9 +977,9 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "Response shouldn't contain demand source" assert !response.seatbid.first.bid.first.ext.prebid.meta.demandSource - and: "PBs metric shouldn't be updated" + and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[MetricsUtil.Adapter.validationSeat(AMX)] where: requestedAllowedBidderCodes << [[WILDCARD], [WILDCARD, EMPTY], [EMPTY, WILDCARD], null] @@ -1030,9 +1030,9 @@ class AlternateBidderCodeSpec extends BaseSpec { assert !response.ext?.errors assert !response.ext?.seatnonbid - and: "PBs metric shouldn't be updated" + and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[MetricsUtil.Adapter.validationSeat(AMX)] where: requestAlternateBidders << [[(AMX): new CodesBidderConfig(enabled: true, allowedBidderCodes: [GENERIC])], @@ -1090,9 +1090,9 @@ class AlternateBidderCodeSpec extends BaseSpec { assert !response.ext?.errors assert !response.ext?.seatnonbid - and: "PBs metric shouldn't be updated" + and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[MetricsUtil.Adapter.validationSeat(AMX)] where: accountAlternateBidders << [[(AMX): new CodesBidderConfig(enabled: true, allowedBidderCodes: [GENERIC])], @@ -1156,9 +1156,9 @@ class AlternateBidderCodeSpec extends BaseSpec { assert !response.ext?.errors assert !response.ext?.seatnonbid - and: "Alert.general metric shouldn't be updated" + and: "PBS shouldn't emit validation metrics" def metrics = pbsService.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[MetricsUtil.Adapter.validationSeat(AMX)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(config) @@ -1201,9 +1201,9 @@ class AlternateBidderCodeSpec extends BaseSpec { def logs = pbsServiceWithAmxBidder.getLogsByValue(bidRequest.accountId) assert logs.contains(INVALID_BIDDER_CODE_LOGS.formatted(requestedAllowedBidderCode, AMX, bidRequest.accountId)) - and: "PBS should emit metrics" + and: "PBS should emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert metrics[MetricsUtil.Adapter.validationSeat(AMX)] and: "Response should contain repose millis with corresponding bidder" assert response.ext.responsetimemillis.containsKey(AMX.value) @@ -1256,9 +1256,9 @@ class AlternateBidderCodeSpec extends BaseSpec { def logs = pbsServiceWithAmxBidder.getLogsByValue(bidRequest.accountId) assert logs.contains(INVALID_BIDDER_CODE_LOGS.formatted(requestedAllowedBidderCode, AMX, bidRequest.accountId)) - and: "PBS should emit metrics" + and: "PBS should emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert metrics[MetricsUtil.Adapter.validationSeat(AMX)] and: "Response should contain repose millis with corresponding bidder" assert response.ext.responsetimemillis.containsKey(AMX.value) @@ -1320,9 +1320,9 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "Response shouldn't contain demand source" assert !response?.seatbid?.bid?.ext?.prebid?.meta?.demandSource - and: "PBS should emit metrics" + and: "PBS should emit validation metrics" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert metrics[MetricsUtil.Adapter.validationSeat(AMX)] and: "Response should contain repose millis with corresponding bidder" assert response.ext.responsetimemillis.containsKey(AMX.value) @@ -1386,7 +1386,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] + assert !metrics[MetricsUtil.Adapter.validationSeat(GENERIC)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -1448,9 +1448,9 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(ALIAS)] - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[MetricsUtil.Adapter.validationSeat(ALIAS)] + assert !metrics[MetricsUtil.Adapter.validationSeat(GENERIC)] + assert !metrics[MetricsUtil.Adapter.validationSeat(AMX)] where: requestAlternateBidderCode | accountAlternateBidderCodes @@ -1514,9 +1514,9 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(ALIAS)] - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[MetricsUtil.Adapter.validationSeat(ALIAS)] + assert !metrics[MetricsUtil.Adapter.validationSeat(GENERIC)] + assert !metrics[MetricsUtil.Adapter.validationSeat(AMX)] where: requestAlternateBidderCode | accountAlternateBidderCodes @@ -1573,7 +1573,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] + assert !metrics[MetricsUtil.Adapter.validationSeat(GENERIC)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -1629,8 +1629,8 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] + assert !metrics[MetricsUtil.Adapter.validationSeat(AMX)] + assert !metrics[MetricsUtil.Adapter.validationSeat(GENERIC)] } def "PBS should return two seat when same bidder response with different bidder code"() { @@ -1689,8 +1689,8 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] + assert !metrics[MetricsUtil.Adapter.validationSeat(AMX)] + assert !metrics[MetricsUtil.Adapter.validationSeat(GENERIC)] } def "PBS should populate seat bid from stored bid response when stored bid response and alternate bidder code specified"() { @@ -1746,7 +1746,7 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[MetricsUtil.Adapter.validationSeat(AMX)] } def "PBS auction allow bidder code when imp stored request and allowed bidder code present"() { @@ -1797,8 +1797,8 @@ class AlternateBidderCodeSpec extends BaseSpec { and: "PBS shouldn't emit validation metrics" def metrics = pbsServiceWithAmxBidder.sendCollectedMetricsRequest() - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(GENERIC)] - assert !metrics[ADAPTER_RESPONSE_VALIDATION_METRICS.formatted(AMX)] + assert !metrics[MetricsUtil.Adapter.validationSeat(GENERIC)] + assert !metrics[MetricsUtil.Adapter.validationSeat(AMX)] } private static Account getAccountWithAlternateBidderCode(BidRequest bidRequest) { diff --git a/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy index 166f49e4cf6..2ef814d278d 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/AuctionSpec.groovy @@ -12,9 +12,6 @@ import org.prebid.server.functional.model.request.auction.Device import org.prebid.server.functional.model.request.auction.DeviceExt import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.model.request.auction.PrebidStoredRequest -import org.prebid.server.functional.model.request.auction.Renderer -import org.prebid.server.functional.model.request.auction.RendererData -import org.prebid.server.functional.model.request.auction.Sdk import org.prebid.server.functional.model.request.auction.User import org.prebid.server.functional.model.request.auction.UserExt import org.prebid.server.functional.model.request.auction.UserExtPrebid @@ -26,6 +23,7 @@ import org.prebid.server.functional.model.response.cookiesync.UserSyncInfo import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.util.HttpUtil +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import spock.lang.Shared @@ -54,8 +52,6 @@ class AuctionSpec extends BaseSpec { @Shared PrebidServerService prebidServerService = pbsServiceFactory.getService(PBS_CONFIG) - private static final String IMPS_REQUESTED_METRIC = 'imps_requested' - private static final String IMPS_DROPPED_METRIC = 'imps_dropped' private static final Integer IMP_LIMIT = 1 private static final Map PBS_CONFIG = ["auction.biddertmax.max" : MAX_TIMEOUT as String, "auction.default-timeout-ms": DEFAULT_TIMEOUT as String] @@ -92,7 +88,7 @@ class AuctionSpec extends BaseSpec { and: "account..requests.rejected.invalid-account metric should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics["account.${accountId}.requests.rejected.invalid-account" as String] == 1 + assert metrics[MetricsUtil.Account.rejectedInvalidAccount(accountId)] == 1 } def "PBS should update account..requests.rejected.#metricName metric when stored request is invalid"() { @@ -709,8 +705,8 @@ class AuctionSpec extends BaseSpec { and: "Metrics for imps should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[IMPS_DROPPED_METRIC] == bidRequest.imp.size() - IMP_LIMIT - assert metrics[IMPS_REQUESTED_METRIC] == IMP_LIMIT + assert metrics[MetricsUtil.General.impsDropped()] == bidRequest.imp.size() - IMP_LIMIT + assert metrics[MetricsUtil.General.impsRequested()] == IMP_LIMIT and: "Response should contain seat bid" assert response.seatbid[0].bid.size() == IMP_LIMIT @@ -751,8 +747,10 @@ class AuctionSpec extends BaseSpec { and: "Metrics for imps requested should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[IMPS_REQUESTED_METRIC] == bidRequest.imp.size() - assert !metrics[IMPS_DROPPED_METRIC] + assert metrics[MetricsUtil.General.impsRequested()] == bidRequest.imp.size() + + and: "Metrics for imps requested shouldn't be updated" + assert !metrics[MetricsUtil.General.impsDropped()] and: "Response should contain seat bid" assert response.seatbid[0].bid.size() == bidRequest.imp.size() @@ -788,8 +786,10 @@ class AuctionSpec extends BaseSpec { and: "Metrics for imps requested should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[IMPS_REQUESTED_METRIC] == bidRequest.imp.size() - assert !metrics[IMPS_DROPPED_METRIC] + assert metrics[MetricsUtil.General.impsRequested()] == bidRequest.imp.size() + + and: "Metrics for imps requested shouldn't be updated" + assert !metrics[MetricsUtil.General.impsDropped()] and: "Response should contain seat bid" assert response.seatbid[0].bid.size() == bidRequest.imp.size() @@ -824,8 +824,10 @@ class AuctionSpec extends BaseSpec { and: "Metrics for imps requested should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[IMPS_REQUESTED_METRIC] == bidRequest.imp.size() - assert !metrics[IMPS_DROPPED_METRIC] + assert metrics[MetricsUtil.General.impsRequested()] == bidRequest.imp.size() + + and: "Metrics for imps requested shouldn't be updated" + assert !metrics[MetricsUtil.General.impsDropped()] and: "Response should contain seat bid" assert response.seatbid[0].bid.size() == bidRequest.imp.size() diff --git a/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy index b50f9772eef..b066deb96a1 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BaseSpec.groovy @@ -46,7 +46,6 @@ abstract class BaseSpec extends Specification implements ObjectMapperWrapper { private static final int MIN_TIMEOUT = DEFAULT_TIMEOUT private static final int DEFAULT_TARGETING_PRECISION = 1 private static final String DEFAULT_CACHE_DIRECTORY = "/app/prebid-server/data" - protected static final String ALERT_GENERAL = "alerts.general" protected static final Map GENERIC_ALIAS_CONFIG = ["adapters.generic.aliases.alias.enabled" : "true", "adapters.generic.aliases.alias.meta-info.vendor-id": "0", "adapters.generic.aliases.alias.endpoint" : "$networkServiceContainer.rootUri/auction".toString()] diff --git a/src/test/groovy/org/prebid/server/functional/tests/BidAdjustmentSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BidAdjustmentSpec.groovy index 2c8837301bc..6285090e9e3 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BidAdjustmentSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BidAdjustmentSpec.groovy @@ -8,7 +8,7 @@ import org.prebid.server.functional.model.config.CodesBidderConfig import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.request.auction.AdjustmentRule import org.prebid.server.functional.model.request.auction.AdjustmentType -import org.prebid.server.functional.model.request.auction.Amx +import org.prebid.server.functional.model.bidder.Amx import org.prebid.server.functional.model.request.auction.BidAdjustment import org.prebid.server.functional.model.request.auction.BidAdjustmentFactors import org.prebid.server.functional.model.request.auction.BidAdjustmentRule diff --git a/src/test/groovy/org/prebid/server/functional/tests/BidValidationSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BidValidationSpec.groovy index 9dd17c31e0a..87a1a41d03d 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BidValidationSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BidValidationSpec.groovy @@ -12,6 +12,7 @@ import org.prebid.server.functional.model.response.auction.Bid import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.model.response.auction.ErrorType import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import spock.lang.PendingFeature @@ -61,9 +62,9 @@ class BidValidationSpec extends BaseSpec { assert exception.statusCode == 400 assert exception.responseBody.contains("no more than one of request.site or request.app or request.dooh can be defined") - and: "Bid validation metric value is incremented" + and: "Alerts.general metrics should be populated" def metrics = strictPrebidService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 where: bidRequest << [BidRequest.getDefaultBidRequest(DistributionChannel.APP).tap { @@ -103,9 +104,9 @@ class BidValidationSpec extends BaseSpec { assert response.ext?.warnings[ErrorType.PREBID]*.message == ["BidRequest contains $warningChannelsValues. Only the first one is applicable, the others are ignored" as String] - and: "Bid validation metric value is incremented" + and: "Alerts.general metrics should be populated" def metrics = softPrebidService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "PBS log should contain message" def logs = softPrebidService.getLogsByTime(startTime) @@ -376,7 +377,7 @@ class BidValidationSpec extends BaseSpec { then: "Bid validation metric value is incremented" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics["adapter.generic.requests.bid_validation"] == 1 + assert metrics[MetricsUtil.Adapter.bidValidation(GENERIC)] == 1 } def "PBS shouldn't throw error when two separate eids with same eids.source"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/BidderFormatSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BidderFormatSpec.groovy index b47a2e47ddf..2cd4b295c1c 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BidderFormatSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BidderFormatSpec.groovy @@ -18,6 +18,7 @@ import org.prebid.server.functional.model.request.auction.Video import org.prebid.server.functional.model.response.auction.Adm import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import spock.lang.PendingFeature import spock.lang.Shared @@ -191,8 +192,8 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric should increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics["account.${bidRequest.accountId}.response.validation.size.warn"] == 1 - assert metrics["adapter.generic.response.validation.size.warn"] == 1 + assert metrics[MetricsUtil.Account.validationSizeWarn(bidRequest.accountId)] == 1 + assert metrics[MetricsUtil.Adapter.validationSizeWarn(BidderName.GENERIC)] == 1 and: "Response should contain error" assert bidResponse.ext?.errors[GENERIC]*.code == [5] @@ -255,8 +256,8 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric shouldn't increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert !metrics["account.${bidRequest.accountId}.response.validation.size.warn"] - assert !metrics["account.${bidRequest.accountId}.response.validation.size.err"] + assert !metrics[MetricsUtil.Account.validationSizeWarn(bidRequest.accountId)] + assert !metrics[MetricsUtil.Account.validationSizeError(bidRequest.accountId)] and: "Response should contain error" assert !bidResponse.ext?.errors @@ -322,8 +323,8 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric should increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics["account.${bidRequest.accountId}.response.validation.size.err"] == 1 - assert metrics["adapter.generic.response.validation.size.err"] == 1 + assert metrics[MetricsUtil.Account.validationSizeError(bidRequest.accountId)] == 1 + assert metrics[MetricsUtil.Adapter.validationSizeError(BidderName.GENERIC)] == 1 and: "Response should contain error" assert bidResponse.ext?.errors[GENERIC]*.code == [5] @@ -382,8 +383,8 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric shouldn't increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert !metrics["account.${bidRequest.accountId}.response.validation.size.warn"] - assert !metrics["account.${bidRequest.accountId}.response.validation.size.err"] + assert !metrics[MetricsUtil.Account.validationSizeWarn(bidRequest.accountId)] + assert !metrics[MetricsUtil.Account.validationSizeError(bidRequest.accountId)] and: "Response should contain error" assert !bidResponse.ext?.errors @@ -436,10 +437,10 @@ class BidderFormatSpec extends BaseSpec { when: "Requesting PBS auction" def bidResponse = pbsService.sendAuctionRequest(bidRequest) - then: "Corresponding metric should increments" + then: "Corresponding metric shouldn't increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert !metrics["account.${bidRequest.accountId}.response.validation.size.err"] - assert !metrics["adapter.generic.response.validation.size.err"] + assert !metrics[MetricsUtil.Account.validationSizeError(bidRequest.accountId)] + assert !metrics[MetricsUtil.Adapter.validationSizeError(BidderName.GENERIC)] and: "Response shouldn't contain error" assert !bidResponse.ext?.errors @@ -509,8 +510,8 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric should increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics["account.${bidRequest.accountId}.response.validation.size.err"] == 1 - assert metrics["adapter.generic.response.validation.size.err"] == 1 + assert metrics[MetricsUtil.Account.validationSizeError(bidRequest.accountId)] == 1 + assert metrics[MetricsUtil.Adapter.validationSizeError(BidderName.GENERIC)] == 1 and: "Bid response should contain error" assert bidResponse.ext?.errors[GENERIC]*.code == [5] @@ -567,10 +568,10 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric shouldn't be increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert !metrics["account.${bidRequest.accountId}.response.validation.secure.warn"] - assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.warn"] - assert !metrics["account.${bidRequest.accountId}.response.validation.secure.err"] - assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.err"] + assert !metrics[MetricsUtil.Account.validationSizeWarn(bidRequest.accountId)] + assert !metrics[MetricsUtil.Adapter.validationSizeWarn(BidderName.GENERIC)] + assert !metrics[MetricsUtil.Account.validationSizeError(bidRequest.accountId)] + assert !metrics[MetricsUtil.Adapter.validationSizeError(BidderName.GENERIC)] and: "Bid response should contain error" assert !bidResponse.ext?.errors @@ -622,8 +623,8 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric should increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics["account.${bidRequest.accountId}.response.validation.secure.warn"] == 1 - assert metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.warn"] == 1 + assert metrics[MetricsUtil.Account.validationSecureWarn(bidRequest.accountId)] == 1 + assert metrics[MetricsUtil.Adapter.validationSecureWarn(BidderName.GENERIC)] == 1 and: "Bid response should contain error" assert bidResponse.ext?.errors[GENERIC]*.code == [5] @@ -673,12 +674,12 @@ class BidderFormatSpec extends BaseSpec { when: "Requesting PBS auction" def bidResponse = pbsService.sendAuctionRequest(bidRequest) - then: "Corresponding metric should increments" + then: "Corresponding metric shouldn't increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert !metrics["account.${bidRequest.accountId}.response.validation.secure.warn"] - assert !metrics["account.${bidRequest.accountId}.response.validation.secure.err"] - assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.warn"] - assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.err"] + assert !metrics[MetricsUtil.Account.validationSizeWarn(bidRequest.accountId)] + assert !metrics[MetricsUtil.Adapter.validationSizeWarn(BidderName.GENERIC)] + assert !metrics[MetricsUtil.Account.validationSizeError(bidRequest.accountId)] + assert !metrics[MetricsUtil.Adapter.validationSizeError(BidderName.GENERIC)] and: "Bid response shouldn't contain error" assert !bidResponse.ext?.errors @@ -730,8 +731,8 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric should increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics["account.${bidRequest.accountId}.response.validation.secure.err"] == 1 - assert metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.err"] == 1 + assert metrics[MetricsUtil.Account.validationSecureError(bidRequest.accountId)] == 1 + assert metrics[MetricsUtil.Adapter.validationSecureError(BidderName.GENERIC)] == 1 and: "Bid response should contain error" assert bidResponse.ext?.errors[GENERIC]*.code == [5] @@ -783,10 +784,10 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric shouldn't increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert !metrics["account.${bidRequest.accountId}.response.validation.secure.warn"] - assert !metrics["account.${bidRequest.accountId}.response.validation.secure.err"] - assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.warn"] - assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.err"] + assert !metrics[MetricsUtil.Account.validationSizeWarn(bidRequest.accountId)] + assert !metrics[MetricsUtil.Adapter.validationSizeWarn(BidderName.GENERIC)] + assert !metrics[MetricsUtil.Account.validationSizeError(bidRequest.accountId)] + assert !metrics[MetricsUtil.Adapter.validationSizeError(BidderName.GENERIC)] and: "Bid response shouldn't contain error" assert !bidResponse.ext?.errors @@ -836,8 +837,10 @@ class BidderFormatSpec extends BaseSpec { then: "Corresponding metric shouldn't increments" def metrics = pbsService.sendCollectedMetricsRequest() - assert !metrics["account.${bidRequest.accountId}.response.validation.secure.warn"] - assert !metrics["adapter.${BidderName.GENERIC.value}.response.validation.secure.warn"] + assert !metrics[MetricsUtil.Account.validationSizeWarn(bidRequest.accountId)] + assert !metrics[MetricsUtil.Adapter.validationSizeWarn(BidderName.GENERIC)] + assert !metrics[MetricsUtil.Account.validationSizeError(bidRequest.accountId)] + assert !metrics[MetricsUtil.Adapter.validationSizeError(BidderName.GENERIC)] and: "Bid response shouldn't contain error" assert !bidResponse.ext?.errors diff --git a/src/test/groovy/org/prebid/server/functional/tests/BidderParamsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/BidderParamsSpec.groovy index 49bbd9c2e17..8deac111a32 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/BidderParamsSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/BidderParamsSpec.groovy @@ -8,8 +8,8 @@ import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.db.StoredImp import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.amp.AmpRequest -import org.prebid.server.functional.model.request.auction.Adrino -import org.prebid.server.functional.model.request.auction.Amx +import org.prebid.server.functional.model.bidder.Adrino +import org.prebid.server.functional.model.bidder.Amx import org.prebid.server.functional.model.request.auction.Banner import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Device diff --git a/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy index c5974022061..ad24af2d6f4 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CacheSpec.groovy @@ -10,6 +10,7 @@ import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.model.request.auction.Targeting import org.prebid.server.functional.model.response.auction.Adm import org.prebid.server.functional.model.response.auction.BidResponse +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import static org.prebid.server.functional.model.response.auction.ErrorType.CACHE @@ -25,19 +26,6 @@ class CacheSpec extends BaseSpec { private static final Integer MAX_DATACENTER_REGION_LENGTH = 4 private static final Integer DEFAULT_UUID_LENGTH = 36 - private static final String ACCOUNT_JSON_CREATIVE_SIZE_METRIC = "account.%s.prebid_cache.creative_size.json" - private static final String ACCOUNT_XML_CREATIVE_SIZE_METRIC = "account.%s.prebid_cache.creative_size.xml" - private static final String ACCOUNT_XML_CREATIVE_TTL_METRIC = "account.%s.prebid_cache.creative_ttl.xml" - private static final String ACCOUNT_JSON_CREATIVE_TTL_METRIC = "account.%s.prebid_cache.creative_ttl.json" - - private static final String ACCOUNT_REQUEST_OK_METRIC = "account.%s.prebid_cache.requests.ok" - private static final String REQUEST_OK_METRIC = "prebid_cache.requests.ok" - - private static final String JSON_CREATIVE_SIZE_GLOBAL_METRIC = "prebid_cache.creative_size.json" - private static final String XML_CREATIVE_SIZE_GLOBAL_METRIC = "prebid_cache.creative_size.xml" - private static final String XML_CREATIVE_TTL_METRIC = "prebid_cache.creative_ttl.xml" - private static final String JSON_CREATIVE_TTL_METRIC = "prebid_cache.creative_ttl.json" - private static final String CACHE_PATH = "/${PBSUtils.randomString}".toString() private static final String CACHE_HOST = "${PBSUtils.randomString}:${PBSUtils.getRandomNumber(0, 65535)}".toString() private static final String INTERNAL_CACHE_PATH = '/cache' @@ -46,7 +34,7 @@ class CacheSpec extends BaseSpec { def "PBS should update prebid_cache.creative_size.json metric when json creative is received"() { given: "Current value of metric prebid_cache.requests.ok" - def initialValue = getCurrentMetricValue(defaultPbsService, REQUEST_OK_METRIC) + def initialValue = getCurrentMetricValue(defaultPbsService, MetricsUtil.Cache.requestsOk()) and: "Default BidRequest with cache, targeting" def bidRequest = BidRequest.defaultBidRequest.tap { @@ -71,17 +59,17 @@ class CacheSpec extends BaseSpec { and: "prebid_cache.creative_size.json metric should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[REQUEST_OK_METRIC] == initialValue + 1 - assert metrics[JSON_CREATIVE_SIZE_GLOBAL_METRIC] == creativeSize + assert metrics[MetricsUtil.Cache.requestsOk()] == initialValue + 1 + assert metrics[MetricsUtil.Cache.creativeSizeJson()] == creativeSize and: "account..prebid_cache.creative_size.json should be update" - assert metrics[ACCOUNT_REQUEST_OK_METRIC.formatted(bidRequest.accountId)] == 1 - assert metrics[ACCOUNT_JSON_CREATIVE_SIZE_METRIC.formatted(bidRequest.accountId)] == creativeSize + assert metrics[MetricsUtil.Cache.accountRequestsOk(bidRequest.accountId)] == 1 + assert metrics[MetricsUtil.Cache.accountCreativeSizeJson(bidRequest.accountId)] == creativeSize } def "PBS should update prebid_cache.creative_size.xml metric when video bid and xml creative is received"() { given: "Current value of metric prebid_cache.requests.ok" - def initialValue = getCurrentMetricValue(defaultPbsService, REQUEST_OK_METRIC) + def initialValue = getCurrentMetricValue(defaultPbsService, MetricsUtil.Cache.requestsOk()) and: "Default BidRequest with cache, targeting" def bidRequest = BidRequest.defaultVideoRequest.tap { @@ -107,12 +95,12 @@ class CacheSpec extends BaseSpec { and: "prebid_cache.creative_size.json metric should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[REQUEST_OK_METRIC] == initialValue + 1 - assert metrics[XML_CREATIVE_SIZE_GLOBAL_METRIC] == creativeSize + assert metrics[MetricsUtil.Cache.requestsOk()] == initialValue + 1 + assert metrics[MetricsUtil.Cache.creativeSizeXml()] == creativeSize and: "account..prebid_cache.creative_size.json should be update" - assert metrics[ACCOUNT_REQUEST_OK_METRIC.formatted(bidRequest.accountId)] == 1 - assert metrics[ACCOUNT_XML_CREATIVE_SIZE_METRIC.formatted(bidRequest.accountId)] == creativeSize + assert metrics[MetricsUtil.Cache.accountRequestsOk(bidRequest.accountId)] == 1 + assert metrics[MetricsUtil.Cache.accountCreativeSizeXml(bidRequest.accountId)] == creativeSize } def "PBS should cache bids when targeting is specified"() { @@ -213,8 +201,8 @@ class CacheSpec extends BaseSpec { and: "PBS should include metrics for request" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics[ACCOUNT_JSON_CREATIVE_TTL_METRIC.formatted(bidRequest.accountId)] == bannerHostTtl - assert metrics[ACCOUNT_REQUEST_OK_METRIC.formatted(bidRequest.accountId)] == 1 + assert metrics[MetricsUtil.Cache.accountCreativeTtlJson(bidRequest.accountId)] == bannerHostTtl + assert metrics[MetricsUtil.Cache.accountRequestsOk(bidRequest.accountId)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -255,13 +243,13 @@ class CacheSpec extends BaseSpec { and: "PBS should include metrics for account" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics[ACCOUNT_JSON_CREATIVE_TTL_METRIC.formatted(bidRequest.accountId)] == videoHostTtl - assert metrics[ACCOUNT_XML_CREATIVE_TTL_METRIC.formatted(bidRequest.accountId)] == videoHostTtl - assert metrics[ACCOUNT_REQUEST_OK_METRIC.formatted(bidRequest.accountId)] == 1 + assert metrics[MetricsUtil.Cache.accountCreativeTtlJson(bidRequest.accountId)] == videoHostTtl + assert metrics[MetricsUtil.Cache.accountCreativeTtlXml(bidRequest.accountId)] == videoHostTtl + assert metrics[MetricsUtil.Cache.accountRequestsOk(bidRequest.accountId)] == 1 and: "PBS should include metrics prebid_cache_creative.{xml,json}.creative.ttl for general" - assert metrics[JSON_CREATIVE_TTL_METRIC] == videoHostTtl - assert metrics[XML_CREATIVE_TTL_METRIC] == videoHostTtl + assert metrics[MetricsUtil.Cache.creativeTtlXml()] == videoHostTtl + assert metrics[MetricsUtil.Cache.creativeTtlJson()] == videoHostTtl cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -297,8 +285,8 @@ class CacheSpec extends BaseSpec { and: "PBS should include metrics for request" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics[ACCOUNT_JSON_CREATIVE_TTL_METRIC.formatted(bidRequest.accountId)] == bannerHostTtl - assert metrics[ACCOUNT_REQUEST_OK_METRIC.formatted(bidRequest.accountId)] == 1 + assert metrics[MetricsUtil.Cache.accountCreativeTtlJson(bidRequest.accountId)] == bannerHostTtl + assert metrics[MetricsUtil.Cache.accountRequestsOk(bidRequest.accountId)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -333,8 +321,8 @@ class CacheSpec extends BaseSpec { and: "PBS should include metrics for request" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics[ACCOUNT_JSON_CREATIVE_TTL_METRIC.formatted(bidRequest.accountId)] == bannerHostTtl - assert metrics[ACCOUNT_REQUEST_OK_METRIC.formatted(bidRequest.accountId)] == 1 + assert metrics[MetricsUtil.Cache.accountCreativeTtlJson(bidRequest.accountId)] == bannerHostTtl + assert metrics[MetricsUtil.Cache.accountRequestsOk(bidRequest.accountId)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -367,8 +355,8 @@ class CacheSpec extends BaseSpec { and: "PBS should include metrics for request" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics[ACCOUNT_JSON_CREATIVE_TTL_METRIC.formatted(bidRequest.accountId)] == bannerHostTtl - assert metrics[ACCOUNT_REQUEST_OK_METRIC.formatted(bidRequest.accountId)] == 1 + assert metrics[MetricsUtil.Cache.accountCreativeTtlJson(bidRequest.accountId)] == bannerHostTtl + assert metrics[MetricsUtil.Cache.accountRequestsOk(bidRequest.accountId)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -626,7 +614,7 @@ class CacheSpec extends BaseSpec { def "PBS should cache bids and add targeting values when account cache config #accountAuctionConfig"() { given: "Current value of metric prebid_cache.requests.ok" - def initialValue = getCurrentMetricValue(defaultPbsService, REQUEST_OK_METRIC) + def initialValue = getCurrentMetricValue(defaultPbsService, MetricsUtil.Cache.requestsOk()) and: "Default BidRequest with cache, targeting" def bidRequest = BidRequest.getDefaultVideoRequest().tap { @@ -660,8 +648,8 @@ class CacheSpec extends BaseSpec { and: "Metrics should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[REQUEST_OK_METRIC] == initialValue + 1 - assert metrics[ACCOUNT_REQUEST_OK_METRIC.formatted(bidRequest.accountId)] == 1 + assert metrics[MetricsUtil.Cache.requestsOk()] == initialValue + 1 + assert metrics[MetricsUtil.Cache.accountRequestsOk(bidRequest.accountId)] == 1 where: accountAuctionConfig << [ diff --git a/src/test/groovy/org/prebid/server/functional/tests/CacheVtrackSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/CacheVtrackSpec.groovy index bfab691b3f3..8b9df0975af 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CacheVtrackSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CacheVtrackSpec.groovy @@ -12,6 +12,7 @@ import org.prebid.server.functional.model.request.vtrack.xml.Vast import org.prebid.server.functional.model.response.vtrack.TransferValue import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import static io.netty.handler.codec.http.HttpResponseStatus.BAD_REQUEST @@ -20,18 +21,6 @@ import static org.prebid.server.functional.testcontainers.Dependencies.getNetwor class CacheVtrackSpec extends BaseSpec { - private static final String ACCOUNT_VTRACK_XML_CREATIVE_SIZE_METRIC = "account.%s.prebid_cache.vtrack.creative_size.xml" - private static final String ACCOUNT_VTRACK_CREATIVE_TTL_XML_METRIC = "account.%s.prebid_cache.vtrack.creative_ttl.xml" - private static final String ACCOUNT_VTRACK_WRITE_ERR_METRIC = "account.%s.prebid_cache.vtrack.write.err" - private static final String ACCOUNT_VTRACK_WRITE_OK_METRIC = "account.%s.prebid_cache.vtrack.write.ok" - - private static final String VTRACK_XML_CREATIVE_SIZE_METRIC = "prebid_cache.vtrack.creative_size.xml" - private static final String VTRACK_XML_CREATIVE_TTL_METRIC = "prebid_cache.vtrack.creative_ttl.xml" - private static final String VTRACK_WRITE_OK_METRIC = "prebid_cache.vtrack.write.ok" - private static final String VTRACK_WRITE_ERROR_METRIC = "prebid_cache.vtrack.write.err" - private static final String VTRACK_READ_OK_METRIC = "prebid_cache.vtrack.read.ok" - private static final String VTRACK_READ_ERROR_METRIC = "prebid_cache.vtrack.read.err" - private static final String CACHE_ENDPOINT = "/cache" private static final String CACHE_PATH = "/${PBSUtils.randomString}".toString() private static final String CACHE_HOST = "${PBSUtils.randomString}:${PBSUtils.getRandomNumber(0, 65535)}".toString() @@ -59,7 +48,7 @@ class CacheVtrackSpec extends BaseSpec { def "PBS should update prebid_cache.creative_size.xml metric and adding tracking xml when xml creative contain #wrapper and impression are valid xml value"() { given: "Current value of metric prebid_cache.vtrack.write.ok" - def initialOkVTrackValue = getCurrentMetricValue(defaultPbsService, VTRACK_WRITE_OK_METRIC) + def initialOkVTrackValue = getCurrentMetricValue(defaultPbsService, MetricsUtil.Cache.vtrackWriteOk()) and: "Create and save enabled events config in account" def accountId = PBSUtils.randomNumber.toString() @@ -93,14 +82,14 @@ class CacheVtrackSpec extends BaseSpec { assert prebidCacheRequest[0].contains("${Endpoint.EVENT}?t=imp&b=${request.puts[0].bidid}&a=$accountId&bidder=${request.puts[0].bidder}") and: "prebid_cache.creative_size.xml metric should be updated" - def metrics = defaultPbsService.sendCollectedMetricsRequest() def ttlSeconds = request.puts[0].ttlseconds - assert metrics[VTRACK_WRITE_OK_METRIC] == initialOkVTrackValue + 1 - assert metrics[VTRACK_XML_CREATIVE_TTL_METRIC] == ttlSeconds + def metrics = defaultPbsService.sendCollectedMetricsRequest() + assert metrics[MetricsUtil.Cache.vtrackWriteOk()] == initialOkVTrackValue + 1 + assert metrics[MetricsUtil.Cache.vtrackCreativeTtlXml()] == ttlSeconds and: "account..prebid_cache.vtrack.creative_size.xml should be updated" - assert metrics[ACCOUNT_VTRACK_WRITE_OK_METRIC.formatted(accountId) as String] == 1 - assert metrics[ACCOUNT_VTRACK_CREATIVE_TTL_XML_METRIC.formatted(accountId) as String] == ttlSeconds + assert metrics[MetricsUtil.Account.cacheVtrackWriteOk(accountId)] == 1 + assert metrics[MetricsUtil.Account.cacheVtrackCreativeTtlXml(accountId)] == ttlSeconds where: wrapper | impression @@ -114,7 +103,7 @@ class CacheVtrackSpec extends BaseSpec { def "PBS should update prebid_cache.creative_size.xml metric when xml creative is received"() { given: "Current value of metric prebid_cache.requests.ok" - def initialValue = getCurrentMetricValue(defaultPbsService, VTRACK_WRITE_OK_METRIC) + def initialValue = getCurrentMetricValue(defaultPbsService, MetricsUtil.Cache.vtrackWriteOk()) and: "Cache set up response" prebidCache.setResponse() @@ -133,11 +122,11 @@ class CacheVtrackSpec extends BaseSpec { then: "prebid_cache.vtrack.creative_size.xml metric should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() def creativeSize = creative.bytes.length - assert metrics[VTRACK_WRITE_OK_METRIC] == initialValue + 1 + assert metrics[MetricsUtil.Cache.vtrackWriteOk()] == initialValue + 1 and: "account..prebid_cache.creative_size.xml should be updated" - assert metrics[ACCOUNT_VTRACK_WRITE_OK_METRIC.formatted(accountId)] == 1 - assert metrics[ACCOUNT_VTRACK_XML_CREATIVE_SIZE_METRIC.formatted(accountId)] == creativeSize + assert metrics[MetricsUtil.Account.cacheVtrackWriteOk(accountId)] == 1 + assert metrics[MetricsUtil.Account.cacheVtrackCreativeSizeXml(accountId)] == creativeSize } def "PBS should failed VTrack request when sending request without account"() { @@ -185,7 +174,7 @@ class CacheVtrackSpec extends BaseSpec { then: "Pbs should emit creative_ttl.xml with lowest value" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[ACCOUNT_VTRACK_CREATIVE_TTL_XML_METRIC.formatted(accountId)] + assert metrics[MetricsUtil.Account.cacheVtrackCreativeTtlXml(accountId)] == [requestedTtl, accountTtl].findAll { it -> it > 0 }.min() where: requestedTtl | accountTtl @@ -222,7 +211,7 @@ class CacheVtrackSpec extends BaseSpec { then: "Pbs should emit creative_ttl.xml with lowest value" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[ACCOUNT_VTRACK_CREATIVE_TTL_XML_METRIC.formatted(accountId)] == [requestedTtl, accountTtl].min() + assert metrics[MetricsUtil.Account.cacheVtrackCreativeTtlXml(accountId)] == [requestedTtl, accountTtl].min() where: requestedTtl | accountTtl @@ -260,7 +249,7 @@ class CacheVtrackSpec extends BaseSpec { then: "Pbs shouldn't emit creative_ttl.xml" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert !metrics[ACCOUNT_VTRACK_CREATIVE_TTL_XML_METRIC.formatted(accountId)] + assert !metrics[MetricsUtil.Account.cacheVtrackCreativeTtlXml(accountId)] } def "PBS should return 400 status code when get vtrack request without uuid"() { @@ -286,7 +275,7 @@ class CacheVtrackSpec extends BaseSpec { then: "Metrics should contain ok metric" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert metricsRequest[VTRACK_READ_OK_METRIC] == 1 + assert metricsRequest[MetricsUtil.Cache.vtrackReadOk()] == 1 } def "PBS should return status code that came from pbc when get vtrack request and response from pbc invalid"() { @@ -307,12 +296,12 @@ class CacheVtrackSpec extends BaseSpec { and: "Metrics should contain error metric" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert metricsRequest[VTRACK_READ_ERROR_METRIC] == 1 + assert metricsRequest[MetricsUtil.Cache.vtrackReadErr()] == 1 } def "PBS should return 200 status code and body when get vtrack request with uuid and ch"() { given: "Current value of metric prebid_cache.vtrack.read.ok" - def initialValue = getCurrentMetricValue(defaultPbsService, VTRACK_READ_OK_METRIC) + def initialValue = getCurrentMetricValue(defaultPbsService, MetricsUtil.Cache.vtrackReadOk()) and: "Random uuid and cache host" def uuid = UUID.randomUUID().toString() @@ -330,12 +319,12 @@ class CacheVtrackSpec extends BaseSpec { and: "Metrics should contain ok metrics" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert metricsRequest[VTRACK_READ_OK_METRIC] == initialValue + 1 + assert metricsRequest[MetricsUtil.Cache.vtrackReadOk()] == initialValue + 1 } def "PBS should return 200 status code and body when internal cache configured and get vtrack request with uuid and ch"() { given: "Current value of metric prebid_cache.vtrack.read.ok" - def initialValue = getCurrentMetricValue(pbsServiceWithInternalCache, VTRACK_READ_OK_METRIC) + def initialValue = getCurrentMetricValue(pbsServiceWithInternalCache, MetricsUtil.Cache.vtrackReadOk()) and: "Flush metric" flushMetrics(pbsServiceWithInternalCache) @@ -356,7 +345,7 @@ class CacheVtrackSpec extends BaseSpec { and: "Metrics should contain ok metrics" def metricsRequest = pbsServiceWithInternalCache.sendCollectedMetricsRequest() - assert metricsRequest[VTRACK_READ_OK_METRIC] == initialValue + 1 + assert metricsRequest[MetricsUtil.Cache.vtrackReadOk()] == initialValue + 1 and: "Verify parameters that came to external cache services" def requestParams = prebidCache.getVTracGetRequestParams() @@ -365,7 +354,7 @@ class CacheVtrackSpec extends BaseSpec { def "PBS should return 200 status code when internal cache and get vtrack request contain uuid"() { given: "Current value of metric prebid_cache.vtrack.read.ok" - def initialValue = getCurrentMetricValue(pbsServiceWithInternalCache, VTRACK_READ_OK_METRIC) + def initialValue = getCurrentMetricValue(pbsServiceWithInternalCache, MetricsUtil.Cache.vtrackReadOk()) and: "Random uuid" def uuid = UUID.randomUUID().toString() @@ -385,7 +374,7 @@ class CacheVtrackSpec extends BaseSpec { and: "Metrics should contain ok metrics" def metricsRequest = pbsServiceWithInternalCache.sendCollectedMetricsRequest() - assert metricsRequest[VTRACK_READ_OK_METRIC] == initialValue + 1 + assert metricsRequest[MetricsUtil.Cache.vtrackReadOk()] == initialValue + 1 and: "Verify parameters that came to external cache services" def requestParams = prebidCache.getVTracGetRequestParams() @@ -413,7 +402,7 @@ class CacheVtrackSpec extends BaseSpec { and: "Metrics should contain error metric" def metricsRequest = pbsServiceWithInternalCache.sendCollectedMetricsRequest() - assert metricsRequest[VTRACK_READ_ERROR_METRIC] == 1 + assert metricsRequest[MetricsUtil.Cache.vtrackReadErr()] == 1 and: "Verify parameters that came to external cache services" def requestParams = prebidCache.getVTracGetRequestParams() @@ -432,7 +421,7 @@ class CacheVtrackSpec extends BaseSpec { def "PBS should update prebid_cache.creative_size.xml metric when account cache config #enabledCacheConcfig"() { given: "Current value of metric prebid_cache.requests.ok" - def okInitialValue = getCurrentMetricValue(defaultPbsService, VTRACK_WRITE_OK_METRIC) + def okInitialValue = getCurrentMetricValue(defaultPbsService, MetricsUtil.Cache.vtrackWriteOk()) and: "Default VtrackRequest" def accountId = PBSUtils.randomNumber.toString() @@ -460,11 +449,11 @@ class CacheVtrackSpec extends BaseSpec { then: "prebid_cache.creative_size.xml metric should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() def creativeSize = creative.bytes.length - assert metrics[VTRACK_WRITE_OK_METRIC] == okInitialValue + 1 + assert metrics[MetricsUtil.Cache.vtrackWriteOk()] == okInitialValue + 1 and: "account..prebid_cache.creative_size.xml should be updated" - assert metrics[ACCOUNT_VTRACK_WRITE_OK_METRIC.formatted(accountId)] == 1 - assert metrics[ACCOUNT_VTRACK_XML_CREATIVE_SIZE_METRIC.formatted(accountId)] == creativeSize + assert metrics[MetricsUtil.Account.cacheVtrackWriteOk(accountId)] == 1 + assert metrics[MetricsUtil.Account.cacheVtrackCreativeSizeXml(accountId)] == creativeSize where: enabledCacheConcfig << [null, false, true] @@ -472,7 +461,7 @@ class CacheVtrackSpec extends BaseSpec { def "PBS should failed cache and update prebid_cache.vtrack.write.err metric when cache service respond with invalid status code"() { given: "Current value of metric prebid_cache.requests.ok" - def okInitialValue = getCurrentMetricValue(defaultPbsService, VTRACK_WRITE_ERROR_METRIC) + def okInitialValue = getCurrentMetricValue(defaultPbsService, MetricsUtil.Cache.vtrackWriteErr()) and: "Default VtrackRequest" def accountId = PBSUtils.randomNumber.toString() @@ -504,9 +493,9 @@ class CacheVtrackSpec extends BaseSpec { then: "prebid_cache.vtrack.write.err metric should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[VTRACK_WRITE_ERROR_METRIC] == okInitialValue + 1 + assert metrics[MetricsUtil.Cache.vtrackWriteErr()] == okInitialValue + 1 and: "account..prebid_cache.vtrack.write.err should be updated" - assert metrics[ACCOUNT_VTRACK_WRITE_ERR_METRIC.formatted(accountId)] == 1 + assert metrics[MetricsUtil.Account.cacheVtrackWriteErr(accountId)] == 1 } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy index 43453891d1a..81775781dc4 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/CookieSyncSpec.groovy @@ -19,6 +19,7 @@ import org.prebid.server.functional.model.response.cookiesync.UserSyncInfo import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.util.HttpUtil +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.CcpaConsent import org.prebid.server.functional.util.privacy.TcfConsent @@ -379,7 +380,7 @@ class CookieSyncSpec extends BaseSpec { and: "Metric should contain cookie_sync.BIDDER.tcf.blocked" def metric = this.prebidServerService.sendCollectedMetricsRequest() - assert metric["cookie_sync.generic.tcf.blocked"] == 1 + assert metric[MetricsUtil.CookieSync.tcfBlocked(GENERIC)] == 1 } def "PBS cookie sync request should reflect error when coop-sync enabled and coop sync bidder with ccpa"() { @@ -427,7 +428,7 @@ class CookieSyncSpec extends BaseSpec { and: "Metric should contain cookie_sync.generic.filtered" def metric = prebidServerService.sendCollectedMetricsRequest() - assert metric["cookie_sync.generic.filtered"] == 1 + assert metric[MetricsUtil.CookieSync.filtered(GENERIC)] == 1 } def "PBS cookie sync request should reflect error even when response is full by account cookie sync config limit"() { @@ -1363,7 +1364,7 @@ class CookieSyncSpec extends BaseSpec { and: "Metric should contain cookie_sync.FAMILY.filtered" def metric = prebidServerService.sendCollectedMetricsRequest() - assert metric["cookie_sync.generic.filtered"] == 1 + assert metric[MetricsUtil.CookieSync.filtered(GENERIC)] == 1 } def "PBS cookie sync with gdpr should reject bidder sync"() { @@ -1389,7 +1390,7 @@ class CookieSyncSpec extends BaseSpec { and: "Metric should contain cookie_sync.BIDDER.tcf.blocked" def metric = prebidServerService.sendCollectedMetricsRequest() - assert metric["cookie_sync.generic.tcf.blocked"] == 1 + assert metric[MetricsUtil.CookieSync.tcfBlocked(GENERIC)] == 1 } def "PBS cookie sync with ccpa should reject bidder sync"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/DebugSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/DebugSpec.groovy index cb21fc92675..237be95238b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/DebugSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/DebugSpec.groovy @@ -1,6 +1,7 @@ package org.prebid.server.functional.tests import org.apache.commons.lang3.StringUtils +import org.prebid.server.functional.model.ChannelType import org.prebid.server.functional.model.config.AccountAuctionConfig import org.prebid.server.functional.model.config.AccountConfig import org.prebid.server.functional.model.config.AccountMetricsConfig @@ -14,6 +15,7 @@ import org.prebid.server.functional.model.request.auction.StoredBidResponse import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.model.response.auction.ErrorType import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import spock.lang.PendingFeature @@ -29,9 +31,6 @@ class DebugSpec extends BaseSpec { private static final String overrideToken = PBSUtils.randomString private static final String ACCOUNT_METRICS_PREFIX_NAME = "account" - private static final String DEBUG_REQUESTS_METRIC = "debug_requests" - private static final String ACCOUNT_DEBUG_REQUESTS_METRIC = "account.%s.debug_requests" - private static final String REQUEST_OK_WEB_METRICS = "requests.ok.openrtb2-web" def "PBS should return debug information and emit metrics when debug flag is #debug and test flag is #test"() { given: "Default BidRequest with test flag" @@ -50,7 +49,7 @@ class DebugSpec extends BaseSpec { and: "Debug metrics should be incremented" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert metricsRequest[DEBUG_REQUESTS_METRIC] == 1 + assert metricsRequest[MetricsUtil.General.debugRequests()] == 1 and: "Account debug metrics shouldn't be incremented" assert !metricsRequest.keySet().contains(ACCOUNT_METRICS_PREFIX_NAME) @@ -79,11 +78,11 @@ class DebugSpec extends BaseSpec { and: "Debug metrics shouldn't be populated" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert !metricsRequest[DEBUG_REQUESTS_METRIC] + assert !metricsRequest[MetricsUtil.General.debugRequests()] assert !metricsRequest.keySet().contains(ACCOUNT_METRICS_PREFIX_NAME) and: "General metrics should be present" - assert metricsRequest[REQUEST_OK_WEB_METRICS] == 1 + assert metricsRequest[MetricsUtil.General.requestOk(ChannelType.WEB)] == 1 where: debug | test @@ -405,8 +404,8 @@ class DebugSpec extends BaseSpec { and: "Debug metrics should be incremented" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert metricsRequest[ACCOUNT_DEBUG_REQUESTS_METRIC.formatted(bidRequest.accountId)] == 1 - assert metricsRequest[DEBUG_REQUESTS_METRIC] == 1 + assert metricsRequest[MetricsUtil.General.debugRequests().formatted(bidRequest.accountId)] == 1 + assert metricsRequest[MetricsUtil.General.debugRequests()] == 1 } def "PBS shouldn't return debug information and emit metrics when account debug enabled and verbosity #verbosityLevel"() { @@ -431,10 +430,10 @@ class DebugSpec extends BaseSpec { and: "Account debug metrics shouldn't be incremented" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert !metricsRequest[ACCOUNT_DEBUG_REQUESTS_METRIC.formatted(bidRequest.accountId)] + assert !metricsRequest[MetricsUtil.Account.debugRequests(bidRequest.accountId)] and: "Request debug metrics should be incremented" - assert metricsRequest[DEBUG_REQUESTS_METRIC] == 1 + assert metricsRequest[MetricsUtil.General.debugRequests()] == 1 where: verbosityLevel << [NONE, BASIC] @@ -469,8 +468,8 @@ class DebugSpec extends BaseSpec { and: "Debug metrics should be incremented" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert metricsRequest[ACCOUNT_DEBUG_REQUESTS_METRIC.formatted(ampRequest.account)] == 1 - assert metricsRequest[DEBUG_REQUESTS_METRIC] == 1 + assert metricsRequest[MetricsUtil.General.debugRequests().formatted(ampRequest.account)] == 1 + assert metricsRequest[MetricsUtil.General.debugRequests()] == 1 } def "PBS amp should return debug information and emit metrics when account debug enabled and verbosity #verbosityLevel"() { @@ -502,10 +501,10 @@ class DebugSpec extends BaseSpec { and: "Account debug metrics shouldn't be incremented" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert !metricsRequest[ACCOUNT_DEBUG_REQUESTS_METRIC.formatted(ampRequest.account)] + assert !metricsRequest[MetricsUtil.Account.debugRequests(ampRequest.account)] and: "Debug metrics should be incremented" - assert metricsRequest[DEBUG_REQUESTS_METRIC] == 1 + assert metricsRequest[MetricsUtil.General.debugRequests()] == 1 where: verbosityLevel << [NONE, BASIC] @@ -529,10 +528,10 @@ class DebugSpec extends BaseSpec { and: "Debug metrics shouldn't be populated" def metricsRequest = defaultPbsService.sendCollectedMetricsRequest() - assert !metricsRequest[DEBUG_REQUESTS_METRIC] + assert !metricsRequest[MetricsUtil.General.debugRequests()] assert !metricsRequest.keySet().contains(ACCOUNT_METRICS_PREFIX_NAME) and: "General metrics shouldn't be present" - assert !metricsRequest[REQUEST_OK_WEB_METRICS] + assert !metricsRequest[MetricsUtil.General.requestOk(ChannelType.WEB)] } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/GeoSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/GeoSpec.groovy index 3d19d9d878d..3e5b92bed07 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/GeoSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/GeoSpec.groovy @@ -7,6 +7,7 @@ import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Device import org.prebid.server.functional.model.request.auction.Geo +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import java.time.Instant @@ -74,11 +75,13 @@ class GeoSpec extends BaseSpec { assert bidderRequests.device.geo.country == USA assert bidderRequests.device.geo.region == ALABAMA.abbreviation - and: "Metrics processed across activities should be updated" + and: "Metrics processed across activities should include successful geolocation metrics" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[GEO_LOCATION_REQUESTS] == 1 - assert metrics[GEO_LOCATION_SUCCESSFUL] == 1 - assert !metrics[GEO_LOCATION_FAIL] + assert metrics[MetricsUtil.General.geolocationRequests()] == 1 + assert metrics[MetricsUtil.General.geolocationSuccessful()] == 1 + + and: "Metrics processed across activities should not include fail geolocation metrics" + assert !metrics[MetricsUtil.General.geolocationFail()] where: settingDefaultAccountGeoLookup | settingAccountDefaultAccountGeoLookup @@ -129,11 +132,13 @@ class GeoSpec extends BaseSpec { assert bidderRequests.device.geo.country == USA assert bidderRequests.device.geo.region == ALABAMA.abbreviation - and: "Metrics processed across activities should be updated" + and: "Metrics processed across activities should include successful geolocation metrics" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[GEO_LOCATION_REQUESTS] == 1 - assert metrics[GEO_LOCATION_SUCCESSFUL] == 1 - assert !metrics[GEO_LOCATION_FAIL] + assert metrics[MetricsUtil.General.geolocationRequests()] == 1 + assert metrics[MetricsUtil.General.geolocationSuccessful()] == 1 + + and: "Metrics processed across activities should not include fail geolocation metrics" + assert !metrics[MetricsUtil.General.geolocationFail()] where: defaultAccountGeoLookup | accountGeoLookup @@ -182,11 +187,13 @@ class GeoSpec extends BaseSpec { assert bidderRequests.device.geo.country == USA assert bidderRequests.device.geo.region == ALABAMA.abbreviation - and: "Metrics processed across activities should be updated" + and: "Metrics processed across activities should include successful geolocation metrics" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[GEO_LOCATION_REQUESTS] == 1 - assert metrics[GEO_LOCATION_SUCCESSFUL] == 1 - assert !metrics[GEO_LOCATION_FAIL] + assert metrics[MetricsUtil.General.geolocationRequests()] == 1 + assert metrics[MetricsUtil.General.geolocationSuccessful()] == 1 + + and: "Metrics processed across activities should not include fail geolocation metrics" + assert !metrics[MetricsUtil.General.geolocationFail()] where: defaultAccountGeoLookup | accountGeoLookup @@ -237,9 +244,9 @@ class GeoSpec extends BaseSpec { and: "Metrics processed across geo location shouldn't be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert !metrics[GEO_LOCATION_REQUESTS] - assert !metrics[GEO_LOCATION_SUCCESSFUL] - assert !metrics[GEO_LOCATION_FAIL] + assert !metrics[MetricsUtil.General.geolocationRequests()] + assert !metrics[MetricsUtil.General.geolocationSuccessful()] + assert !metrics[MetricsUtil.General.geolocationFail()] where: defaultAccountGeoLookupConfig | hostGeolocation | accountGeoLookup @@ -291,9 +298,9 @@ class GeoSpec extends BaseSpec { and: "Metrics processed across geo location shouldn't be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert !metrics[GEO_LOCATION_REQUESTS] - assert !metrics[GEO_LOCATION_SUCCESSFUL] - assert !metrics[GEO_LOCATION_FAIL] + assert !metrics[MetricsUtil.General.geolocationRequests()] + assert !metrics[MetricsUtil.General.geolocationSuccessful()] + assert !metrics[MetricsUtil.General.geolocationFail()] where: defaultAccountGeoLookupConfig | hostGeolocation | accountGeoLookup @@ -345,9 +352,9 @@ class GeoSpec extends BaseSpec { and: "Metrics processed across geo location should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[GEO_LOCATION_REQUESTS] == 1 - assert metrics[GEO_LOCATION_FAIL] == 1 - assert !metrics[GEO_LOCATION_SUCCESSFUL] + assert metrics[MetricsUtil.General.geolocationRequests()] == 1 + assert metrics[MetricsUtil.General.geolocationFail()] == 1 + assert !metrics[MetricsUtil.General.geolocationSuccessful()] and: "PBs should emit geo failed logs" def logs = defaultPbsService.getLogsByTime(startTime) @@ -399,9 +406,9 @@ class GeoSpec extends BaseSpec { and: "Metrics processed across geo location should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[GEO_LOCATION_REQUESTS] == 1 - assert metrics[GEO_LOCATION_FAIL] == 1 - assert !metrics[GEO_LOCATION_SUCCESSFUL] + assert metrics[MetricsUtil.General.geolocationRequests()] == 1 + assert metrics[MetricsUtil.General.geolocationFail()] == 1 + assert !metrics[MetricsUtil.General.geolocationSuccessful()] and: "PBs should emit geo failed logs" def logs = defaultPbsService.getLogsByTime(startTime) @@ -449,9 +456,9 @@ class GeoSpec extends BaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert !metrics[GEO_LOCATION_REQUESTS] - assert !metrics[GEO_LOCATION_SUCCESSFUL] - assert !metrics[GEO_LOCATION_FAIL] + assert !metrics[MetricsUtil.General.geolocationRequests()] + assert !metrics[MetricsUtil.General.geolocationSuccessful()] + assert !metrics[MetricsUtil.General.geolocationFail()] } def "PBS shouldn't populate country and region via geo when geo enabled in account and country and region specified in request and ip present in header"() { @@ -492,8 +499,8 @@ class GeoSpec extends BaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert !metrics[GEO_LOCATION_REQUESTS] - assert !metrics[GEO_LOCATION_SUCCESSFUL] - assert !metrics[GEO_LOCATION_FAIL] + assert !metrics[MetricsUtil.General.geolocationRequests()] + assert !metrics[MetricsUtil.General.geolocationSuccessful()] + assert !metrics[MetricsUtil.General.geolocationFail()] } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy index ee3e808a56e..5265e8292c6 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/MetricsSpec.groovy @@ -1,5 +1,7 @@ package org.prebid.server.functional.tests +import org.prebid.server.functional.model.ChannelType +import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.config.AccountConfig import org.prebid.server.functional.model.config.AccountMetricsConfig import org.prebid.server.functional.model.db.Account @@ -8,6 +10,7 @@ import org.prebid.server.functional.model.request.auction.Dooh import org.prebid.server.functional.model.request.auction.Site import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.MetricsUtil import static org.prebid.server.functional.model.config.AccountMetricsVerbosityLevel.BASIC import static org.prebid.server.functional.model.config.AccountMetricsVerbosityLevel.DETAILED @@ -56,11 +59,11 @@ class MetricsSpec extends BaseSpec { then: "account..requests should be populated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics["account.${accountId}.requests" as String] == 1 + assert metrics[MetricsUtil.Account.requests(accountId)] == 1 and: "account..generic and requests.type.openrtb2-web metrics shouldn't populated" assert !metrics.findAll({ it.key.startsWith("account.${accountId}.generic") }) - assert !metrics["account.${accountId}.requests.type.openrtb2-web" as String] + assert !metrics[MetricsUtil.Account.requestType(accountId, ChannelType.WEB)] where: accountMetricsConfig << [new AccountConfig(metrics: new AccountMetricsConfig(verbosityLevel: BASIC)), @@ -89,12 +92,12 @@ class MetricsSpec extends BaseSpec { then: "account..* should be populated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics["account.${accountId}.adapter.generic.bids_received" as String] == 1 - assert metrics["account.${accountId}.adapter.generic.prices" as String] == bidPrice - assert metrics["account.${accountId}.adapter.generic.request_time" as String] == 1 - assert metrics["account.${accountId}.adapter.generic.requests.gotbids" as String] == 1 - assert metrics["account.${accountId}.requests" as String] == 1 - assert metrics["account.${accountId}.requests.type.openrtb2-web" as String] == 1 + assert metrics[MetricsUtil.Account.bidsReceived(accountId, BidderName.GENERIC)] == 1 + assert metrics[MetricsUtil.Account.prices(accountId, BidderName.GENERIC)] == bidPrice + assert metrics[MetricsUtil.Account.requestTime(accountId, BidderName.GENERIC)] == 1 + assert metrics[MetricsUtil.Account.requestsGotBids(accountId, BidderName.GENERIC)] == 1 + assert metrics[MetricsUtil.Account.requests(accountId)] == 1 + assert metrics[MetricsUtil.Account.requestType(accountId, ChannelType.WEB)] == 1 } def "PBS should update hood metrics when bid request contains hood channel type and verbosity level is detailed"() { @@ -112,12 +115,12 @@ class MetricsSpec extends BaseSpec { then: "account..* should be populated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics["account.${accountId}.requests.type.openrtb2-dooh" as String] == 1 - assert metrics["adapter.generic.requests.type.openrtb2-dooh" as String] == 1 + assert metrics[MetricsUtil.Account.requestType(accountId, ChannelType.DOOH)] == 1 + assert metrics[MetricsUtil.Adapter.requestType(BidderName.GENERIC, ChannelType.DOOH)] == 1 and: "ather channel types should not be populated" - assert !metrics["account.${accountId}.requests.type.openrtb2-web" as String] - assert !metrics["account.${accountId}.requests.type.openrtb2-app" as String] + assert !metrics[MetricsUtil.Account.requestType(accountId, ChannelType.WEB)] + assert !metrics[MetricsUtil.Account.requestType(accountId, ChannelType.APP)] } def "PBS with soft setup should ignore site distribution channel and update only dooh metrics when presented dooh and site in request"() { @@ -142,15 +145,15 @@ class MetricsSpec extends BaseSpec { and: "Metrics processed across site should be updated" def metrics = softPrebidService.sendCollectedMetricsRequest() - assert metrics["account.${accountId}.requests.type.openrtb2-dooh" as String] == 1 - assert metrics["adapter.generic.requests.type.openrtb2-dooh" as String] == 1 + assert metrics[MetricsUtil.Account.requestType(accountId, ChannelType.DOOH)] == 1 + assert metrics[MetricsUtil.Adapter.requestType(BidderName.GENERIC, ChannelType.DOOH)] == 1 and: "alert.general metric should be updated" - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Other channel types should not be populated" - assert !metrics["account.${accountId}.requests.type.openrtb2-web" as String] - assert !metrics["account.${accountId}.requests.type.openrtb2-app" as String] + assert !metrics[MetricsUtil.Account.requestType(accountId, ChannelType.WEB)] + assert !metrics[MetricsUtil.Account.requestType(accountId, ChannelType.APP)] } def "PBS with soft setup should ignore other distribution channel and update only app metrics when presented app ant other channels in request"() { @@ -171,15 +174,15 @@ class MetricsSpec extends BaseSpec { and: "Metrics processed across site should be updated" def metrics = softPrebidService.sendCollectedMetricsRequest() - assert metrics["account.${accountId}.requests.type.openrtb2-app" as String] == 1 - assert metrics["adapter.generic.requests.type.openrtb2-app" as String] == 1 + assert metrics[MetricsUtil.Account.requestType(accountId, ChannelType.APP)] == 1 + assert metrics[MetricsUtil.Adapter.requestType(BidderName.GENERIC, ChannelType.APP)] == 1 and: "alert.general metric should be updated" - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Other channel types should not be populated" - assert !metrics["account.${accountId}.requests.type.openrtb2-dooh" as String] - assert !metrics["account.${accountId}.requests.type.openrtb2-web" as String] + assert !metrics[MetricsUtil.Account.requestType(accountId, ChannelType.DOOH)] + assert !metrics[MetricsUtil.Account.requestType(accountId, ChannelType.WEB)] where: bidRequest << [BidRequest.getDefaultBidRequest(APP).tap { diff --git a/src/test/groovy/org/prebid/server/functional/tests/ProfileSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/ProfileSpec.groovy index dd3b49efcc1..5621adf88a4 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/ProfileSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/ProfileSpec.groovy @@ -33,6 +33,7 @@ import org.prebid.server.functional.repository.dao.ProfileRequestDao import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.testcontainers.container.PrebidServerContainer +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import org.testcontainers.images.builder.Transferable import spock.lang.PendingFeature @@ -76,9 +77,6 @@ class ProfileSpec extends BaseSpec { private static final String NO_REQUEST_PROFILE_MESSAGE = "No request profiles for ids [%s] were found" private static final String NO_PROFILE_MESSAGE = "No profile found for id: %s" - private static final String LIMIT_EXCEEDED_ACCOUNT_PROFILE_METRIC = "account.%s.profiles.limit_exceeded" - private static final String MISSING_ACCOUNT_PROFILE_METRIC = "account.%s.profiles.missing" - private static final ProfileImpDao profileImpDao = repository.profileImpDao private static final ProfileRequestDao profileRequestDao = repository.profileRequestDao @@ -645,7 +643,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[LIMIT_EXCEEDED_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[MetricsUtil.Account.profilesLimitExceeded(accountId)] == 1 and: "Bidder request should contain data from profile" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -733,7 +731,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric shouldn't increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert !metrics[LIMIT_EXCEEDED_ACCOUNT_PROFILE_METRIC.formatted(accountId)] + assert !metrics[MetricsUtil.Account.profilesLimitExceeded(accountId)] and: "Bidder request should contain data from profiles" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -815,7 +813,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[LIMIT_EXCEEDED_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[MetricsUtil.Account.profilesLimitExceeded(accountId)] == 1 and: "Bidder request should contain data from original request" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -995,7 +993,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[MISSING_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[MetricsUtil.Account.profilesMissing(accountId)] == 1 where: profilesConfigs << [ @@ -1201,7 +1199,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[LIMIT_EXCEEDED_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[MetricsUtil.Account.profilesLimitExceeded(accountId)] == 1 and: "Bidder request should contain data from original request" verifyAll(bidder.getBidderRequest(bidRequest.id)) { @@ -1242,7 +1240,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[MISSING_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[MetricsUtil.Account.profilesMissing(accountId)] == 1 and: "Bidder request should contain data from profile" verifyAll(bidder.getBidderRequest(bidRequest.id)) { @@ -1296,7 +1294,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[MISSING_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[MetricsUtil.Account.profilesMissing(accountId)] == 1 and: "Bidder request should contain data from profile" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -1349,7 +1347,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[MISSING_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[MetricsUtil.Account.profilesMissing(accountId)] == 1 and: "Bidder request imp should contain data from original imp" assert bidder.getBidderRequest(bidRequest.id).imp.banner == bidRequest.imp.banner @@ -1381,7 +1379,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[MISSING_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[MetricsUtil.Account.profilesMissing(accountId)] == 1 and: "Bidder request should contain data from profile" verifyAll(bidder.getBidderRequest(bidRequest.id)) { @@ -1429,7 +1427,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[MISSING_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[MetricsUtil.Account.profilesMissing(accountId)] == 1 and: "Bidder request imp should contain data from original imp" assert bidder.getBidderRequest(bidRequest.id).imp.banner == bidRequest.imp.banner @@ -1469,7 +1467,7 @@ class ProfileSpec extends BaseSpec { and: "Missing metric should increments" def metrics = pbsWithStoredProfiles.sendCollectedMetricsRequest() - assert metrics[MISSING_ACCOUNT_PROFILE_METRIC.formatted(accountId)] == 1 + assert metrics[MetricsUtil.Account.profilesMissing(accountId)] == 1 and: "Bidder request should contain data from profile" verifyAll(bidder.getBidderRequest(bidRequest.id)) { diff --git a/src/test/groovy/org/prebid/server/functional/tests/SetUidSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/SetUidSpec.groovy index d14d58c3f61..e647623cf94 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/SetUidSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/SetUidSpec.groovy @@ -6,6 +6,7 @@ import org.prebid.server.functional.model.response.cookiesync.UserSyncInfo import org.prebid.server.functional.model.response.setuid.SetuidResponse import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.TcfConsent import org.prebid.server.util.ResourceUtil @@ -126,7 +127,7 @@ class SetUidSpec extends BaseSpec { and: "usersync.BIDDER.sets metric should be updated" def metrics = singleCookiesPbsService.sendCollectedMetricsRequest() - assert metrics["usersync.${GENERIC.value}.sets"] == 1 + assert metrics[MetricsUtil.UserSync.sets(GENERIC)] == 1 } def "PBS setuid should remove expired uids cookie"() { @@ -246,7 +247,7 @@ class SetUidSpec extends BaseSpec { then: "usersync.FAMILY.sizeblocked metric should be updated" def metrics = prebidServerService.sendCollectedMetricsRequest() - assert metrics["usersync.${bidderName.value}.sizeblocked"] == 1 + assert metrics[MetricsUtil.UserSync.sizeBlocked(bidderName)] == 1 and: "Response should contain uids cookies" assert response.uidsCookie.tempUIDs[APPNEXUS] @@ -283,7 +284,7 @@ class SetUidSpec extends BaseSpec { and: "usersync.BIDDER.tcf.blocked metric should be updated" def metric = prebidServerService.sendCollectedMetricsRequest() - assert metric["usersync.${MAGNITE.value}.tcf.blocked"] == 1 + assert metric[MetricsUtil.UserSync.tcfBlocked(MAGNITE)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -312,7 +313,7 @@ class SetUidSpec extends BaseSpec { and: "usersync.FAMILY.sizeblocked metric should be updated" def metrics = prebidServerService.sendCollectedMetricsRequest() - assert metrics["usersync.${MAGNITE.value}.sizeblocked"] == 1 + assert metrics[MetricsUtil.UserSync.sizeBlocked(MAGNITE)] == 1 then: "Response should contain uids cookies" assert response.uidsCookie.tempUIDs[APPNEXUS] @@ -356,10 +357,10 @@ class SetUidSpec extends BaseSpec { and: "usersync.FAMILY.sizeblocked metric should be updated" def metricsRequest = prebidServerService.sendCollectedMetricsRequest() - assert metricsRequest["usersync.${APPNEXUS.value}.sizeblocked"] == 1 + assert metricsRequest[MetricsUtil.UserSync.sizeBlocked(APPNEXUS)] == 1 and: "usersync.BIDDER.sets metric should be updated" - assert metricsRequest["usersync.${OPENX.value}.sets"] == 1 + assert metricsRequest[MetricsUtil.UserSync.sets(OPENX)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -395,7 +396,7 @@ class SetUidSpec extends BaseSpec { and: "usersync.FAMILY.sizedout metric should be updated" def metricsRequest = prebidServerService.sendCollectedMetricsRequest() - assert metricsRequest["usersync.${APPNEXUS.value}.sizedout"] == 1 + assert metricsRequest[MetricsUtil.UserSync.sizedOut(APPNEXUS)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) diff --git a/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy index eb988ac130b..61308083d67 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/UUIDSpec.groovy @@ -7,6 +7,7 @@ import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.model.request.auction.PrebidStoredRequest import org.prebid.server.functional.model.request.auction.Source +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import static org.prebid.server.functional.model.request.auction.DistributionChannel.APP @@ -39,7 +40,7 @@ class UUIDSpec extends BaseSpec { then: "Metric stored_requests_found should be updated" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics["stored_requests_found"] == 1 + assert metrics[MetricsUtil.General.storedRequestFound()] == 1 and: "BidResponse should be merged with stored request" def bidderRequest = bidder.getBidderRequest(bidResponse.id) @@ -136,7 +137,7 @@ class UUIDSpec extends BaseSpec { then: "Metric stored_requests_found should be updated" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics["stored_requests_found"] == 1 + assert metrics[MetricsUtil.General.storedRequestFound()] == 1 and: "BidResponse should be merged with stored request" def bidderRequest = bidder.getBidderRequest(bidResponse.id) @@ -208,7 +209,7 @@ class UUIDSpec extends BaseSpec { then: "Metric stored_requests_found should be updated" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics["stored_requests_found"] == 1 + assert metrics[MetricsUtil.General.storedRequestFound()] == 1 and: "BidResponse should be merged with stored request" def bidderRequest = bidder.getBidderRequest(bidResponse.id) @@ -303,7 +304,7 @@ class UUIDSpec extends BaseSpec { then: "Metric stored_requests_found should be updated" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics["stored_requests_found"] == 1 + assert metrics[MetricsUtil.General.storedRequestFound()] == 1 and: "BidResponse should be merged with stored request" def bidderRequest = bidder.getBidderRequest(bidResponse.id) diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy index de9d940de43..3d7a171ceb4 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/AbTestingModuleSpec.groovy @@ -13,6 +13,7 @@ import org.prebid.server.functional.model.request.auction.TraceLevel import org.prebid.server.functional.model.response.auction.AnalyticResult import org.prebid.server.functional.model.response.auction.InvocationResult import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import static org.prebid.server.functional.model.config.HookHttpEndpoint.AUCTION @@ -81,15 +82,16 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Shouldn't include any analytics tags" assert (invocationResults.analyticsTags.activities.flatten() as List).findAll { it.name != AB_TESTING.value } - and: "Metric for specified module should be as default call" + and: "Metrics for specified module should include invocation metrics as default call" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - - assert !metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + assert metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noop(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noop(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + + and: "Metrics for specified module should not include noInvocation metrics as default call" + assert !metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] } def "PBS shouldn't apply valid a/b test config when module is disabled"() { @@ -123,17 +125,16 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.message == [INVALID_HOOK_MESSAGE, INVALID_HOOK_MESSAGE] } - and: "Metric for specified module should be with error call" + and: "Metrics for specified module should include invocation and error metrics" def metrics = prebidServerService.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[EXECUTION_ERROR_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[EXECUTION_ERROR_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.executionError(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.executionError(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert !metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + and: "Metrics for specified module should not include noInvocation metrics with error call" + assert !metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -167,15 +168,16 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Shouldn't include any analytics tags" assert (invocationResults.analyticsTags.activities.flatten() as List).findAll { it.name != AB_TESTING.value } - and: "Metric for specified module should be as default call" + and: "Metrics for specified module should include invocation metrics as default call" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noop(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noop(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert !metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + and: "Metrics for specified module should not include noInvocation metrics as default call" + assert !metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] where: moduleName << [ModuleName.PB_ORTB2_BLOCKING.code.toUpperCase(), PBSUtils.randomString] @@ -228,18 +230,21 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } - and: "Metric for allowed to run pb-ortb2blocking module should be updated based on ab test config" + and: "Metrics for allowed to run pb-ortb2blocking module should include invocation metrics based on ab test config" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert !metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] - assert !metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] - - and: "Metric for allowed to run pb-response-correction module should be updated based on ab test config" - assert metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert !metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] - assert !metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] + assert metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + + and: "Metrics for allowed to run pb-ortb2blocking module should not include noInvocation metrics based on ab test config" + assert !metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + + and: "Metrics for allowed to run response-correction module should include invocation metrics based on ab test config" + assert metrics[MetricsUtil.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + + and: "Metrics for allowed to run response-correction module should not include noInvocation metrics based on ab test config" + assert !metrics[MetricsUtil.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] } def "PBS should apply a/b test config for each module when multiple config are presents and set to skip modules"() { @@ -289,18 +294,16 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } - and: "Metric for skipped pb-ortb2blocking module should be updated based on ab test config" + and: "Metrics for skipped pb-ortb2blocking module should not include invocation metrics based on ab test config" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert !metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] - assert metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - - and: "Metric for skipped pb-response-correction module should be updated based on ab test config" - assert !metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] - assert !metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] - assert metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert !metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + + and: "Metrics for skipped response-correction module should include noInvocation metrics based on ab test config" + assert metrics[MetricsUtil.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + + and: "Metrics for skipped response-correction module should not include invocation metrics based on ab test config" + assert !metrics[MetricsUtil.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] } def "PBS should apply a/b test config for each module when multiple config are presents with different percentage"() { @@ -350,16 +353,17 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } - and: "Metric for skipped ortb2blocking module should be updated based on ab test config" + and: "Metrics for skipped ortb2blocking module should include noInvocation metrics based on ab test config" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - - and: "Metric for allowed to run pb-response-correction module should be updated based on ab test config" - assert metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert !metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] - assert !metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + + and: "Metrics for allowed to run response-correction module should include invocation metrics based on ab test config" + assert metrics[MetricsUtil.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[MetricsUtil.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + + and: "Metrics for allowed to run response-correction module should not include noInvocation metrics based on ab test config" + assert !metrics[MetricsUtil.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] } def "PBS should ignore accounts property for a/b test config when ab test config specialize for specific account"() { @@ -393,10 +397,10 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.PB_ORTB2_BLOCKING, ModuleName.PB_ORTB2_BLOCKING] } - and: "Metric for specified module should be updated based on ab test config" + and: "Metrics for specified module should include noInvocation metrics based on ab test config" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 } def "PBS should apply a/b test config and run module when config is on max percentage or default value"() { @@ -431,15 +435,14 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.PB_ORTB2_BLOCKING, ModuleName.PB_ORTB2_BLOCKING] } - and: "Metric for specified module should be as default call" + and: "Metrics for specified module should include invocation metrics as default call" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert !metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + and: "Metrics for specified module should not include noInvocation metrics as default call" + assert !metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] where: percentActive | percentActiveSnakeCase @@ -480,10 +483,10 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.PB_ORTB2_BLOCKING, ModuleName.PB_ORTB2_BLOCKING] } - and: "Metric for specified module should be updated based on ab test config" + and: "Metrics for specified module should include noInvocation metrics based on ab test config" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 where: percentActive | percentActiveSnakeCase @@ -527,10 +530,10 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.PB_ORTB2_BLOCKING, ModuleName.PB_ORTB2_BLOCKING] } - and: "Metric for specified module should be updated based on ab test config" + and: "Metrics for specified module should include noInvocation metrics based on ab test config" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 where: percentActive | percentActiveSnakeCase @@ -575,15 +578,14 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.PB_ORTB2_BLOCKING, ModuleName.PB_ORTB2_BLOCKING] } - and: "Metric for specified module should be as default call" + and: "Metrics for specified module should include invocation metrics as default call" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert !metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + and: "Metrics for specified module should not include noInvocation metrics as default call" + assert !metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] where: percentActive | percentActiveSnakeCase @@ -624,10 +626,10 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.analyticsTags.activities.results.values.module.flatten() == [ModuleName.PB_ORTB2_BLOCKING, ModuleName.PB_ORTB2_BLOCKING] } - and: "Metric for specified module should be updated based on ab test config" + and: "Metrics for specified module should include noInvocation metrics based on ab test config" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 where: logAnalyticsTag | logAnalyticsTagSnakeCase @@ -668,10 +670,10 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Shouldn't include any analytics tags" assert !invocationResults?.analyticsTags?.any() - and: "Metric for specified module should be updated based on ab test config" + and: "Metrics for specified module should include noInvocation metrics based on ab test config" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 where: logAnalyticsTag | logAnalyticsTagSnakeCase @@ -711,15 +713,14 @@ class AbTestingModuleSpec extends ModuleBaseSpec { and: "Shouldn't include any analytics tags" assert (invocationResults.analyticsTags.activities.flatten() as List).findAll { it.name != AB_TESTING.value } - and: "Metric for specified module should be as default call" + and: "Metrics for specified module should include invocation metrics as default call" def metrics = ortbModulePbsService.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert !metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + and: "Metrics for specified module should not include noInvocation metrics as default call" + assert !metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] where: logAnalyticsTag | logAnalyticsTagSnakeCase @@ -803,17 +804,16 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.analyticsTags.every { it == null } } - and: "Metric for specified module should be updated based on ab test config" + and: "Metrics for specified module should include noInvocation metrics based on ab test config" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - and: "Metric for non specified module should be as default call" - assert metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + and: "Metrics for non specified module should include invocation metrics as default call" + assert metrics[MetricsUtil.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert !metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] - assert !metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] + and: "Metrics for non specified module should not include noInvocation metrics as default call" + assert !metrics[MetricsUtil.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -866,17 +866,16 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.analyticsTags.every { it == null } } - and: "Metric for specified module should be updated based on ab test config" + and: "Metrics for specified module should include noInvocation metrics based on ab test config" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - and: "Metric for non specified module should be as default call" - assert metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + and: "Metrics for non specified module should include invocation metrics as default call" + assert metrics[MetricsUtil.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert !metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] - assert !metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] + and: "Metrics for non specified module should not include noInvocation metrics as default call" + assert !metrics[MetricsUtil.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -932,18 +931,16 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.analyticsTags.activities.results.values.module.flatten() == [PB_RESPONSE_CORRECTION] } - and: "Metric for skipped pb-ortb2blocking module should be updated based on ab test config" + and: "Metrics for skipped pb-ortb2blocking module should not include invocation metrics based on ab test config" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert !metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] - assert metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert !metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + + and: "Metrics for skipped response-correction module should include noInvocation metrics based on ab test config" + assert metrics[MetricsUtil.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - and: "Metric for skipped pb-response-correction module should be updated based on ab test config" - assert !metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] - assert !metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] - assert metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + and: "Metrics for skipped response-correction module should not include invocation metrics based on ab test config" + assert !metrics[MetricsUtil.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -990,22 +987,20 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.analyticsTags.every { it == null } } - and: "Metric for specified module should be as default call" + and: "Metrics for specified module should include invocation metrics as default call" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.call(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert !metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + and: "Metrics for specified module should not include noInvocation metrics as default call" + assert !metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] - and: "Metric for non specified module should be as default call" - assert metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + and: "Metrics for non specified module should include invocation metrics as default call" + assert metrics[MetricsUtil.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert !metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] - assert !metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] + and: "Metrics for non specified module should not include noInvocation metrics as default call" + assert !metrics[MetricsUtil.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -1059,17 +1054,16 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.analyticsTags.every { it == null } } - and: "Metric for specified module should be updated based on ab test config" + and: "Metrics for specified module should include noInvocation metrics based on ab test config" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 2 - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 2 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 2 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 2 - and: "Metric for non specified module should be as default call" - assert metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 2 - assert metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 2 + and: "Metrics for non specified module should include invocation metrics as default call" + assert metrics[MetricsUtil.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 2 - assert !metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] - assert !metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] + and: "Metrics for non specified module should not include noInvocation metrics as default call" + assert !metrics[MetricsUtil.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -1130,17 +1124,16 @@ class AbTestingModuleSpec extends ModuleBaseSpec { it.analyticsTags.every { it == null } } - and: "Metric for specified module should be updated based on ab test config" + and: "Metrics for specified module should include noInvocation metrics based on ab test config" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[NO_INVOCATION_METRIC(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noInvocation(ModuleName.PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - and: "Metric for non specified module should be as default call" - assert metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert metrics[CALL_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 + and: "Metrics for non specified module should include invocation metrics as default call" + assert metrics[MetricsUtil.Module.call(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert !metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] - assert !metrics[NO_INVOCATION_METRIC(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] + and: "Metrics for non specified module should not include noInvocation metrics as default call" + assert !metrics[MetricsUtil.Module.noInvocation(PB_RESPONSE_CORRECTION, ALL_PROCESSED_BID_RESPONSES)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/GeneralModuleSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/GeneralModuleSpec.groovy index d883da8f219..3dcbfc1eede 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/GeneralModuleSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/GeneralModuleSpec.groovy @@ -15,6 +15,7 @@ import org.prebid.server.functional.model.request.auction.TraceLevel import org.prebid.server.functional.model.response.auction.InvocationResult import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import java.time.Instant @@ -82,14 +83,14 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics should be updated" def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 and: "RB-Richmedia-Filter module call metrics should be updated" - assert metrics[CALL_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert metrics[NOOP_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[MetricsUtil.Module.call(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 where: modulesConfig << [null, new PbsModulesConfig()] @@ -122,14 +123,14 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics should be updated" def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 and: "RB-Richmedia-Filter module call metrics should be updated" - assert metrics[CALL_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert metrics[NOOP_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[MetricsUtil.Module.call(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 where: pbRichmediaFilterConfig | pbResponseCorrectionConfig @@ -174,14 +175,14 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics should be updated" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 and: "RB-Richmedia-Filter module call metrics should be updated" - assert metrics[CALL_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert metrics[NOOP_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[MetricsUtil.Module.call(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -214,14 +215,14 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics should be updated" def metrics = pbsServiceWithMultipleModuleWithRequireInvoke.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 and: "RB-Richmedia-Filter module call metrics should be updated" - assert metrics[CALL_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert metrics[NOOP_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[MetricsUtil.Module.call(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 where: pbRichmediaFilterConfig | ortb2BlockingConfig @@ -257,16 +258,16 @@ class GeneralModuleSpec extends ModuleBaseSpec { it.hookId.moduleCode.sort() == [PB_RICHMEDIA_FILTER].code.sort() } - and: "Ortb2blocking module call metrics should be updated" + and: "Ortb2blocking module call metrics shouldn't be updated" def metrics = pbsServiceWithMultipleModuleWithRequireInvoke.sendCollectedMetricsRequest() - assert !metrics[CALL_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[CALL_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] - assert !metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + assert !metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + assert !metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] and: "RB-Richmedia-Filter module call metrics should be updated" - assert metrics[CALL_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 - assert metrics[NOOP_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[MetricsUtil.Module.call(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == 1 } def "PBS shouldn't call any modules and traces that in response when account config is empty and require-config-to-invoke is enabled"() { @@ -291,14 +292,14 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics shouldn't be updated" def metrics = pbsServiceWithMultipleModuleWithRequireInvoke.sendCollectedMetricsRequest() - assert !metrics[CALL_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[CALL_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] - assert !metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + assert !metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + assert !metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] and: "RB-Richmedia-Filter module call metrics shouldn't be updated" - assert !metrics[CALL_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] - assert !metrics[NOOP_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] + assert !metrics[MetricsUtil.Module.call(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] + assert !metrics[MetricsUtil.Module.noop(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] where: modulesConfig << [null, new PbsModulesConfig()] @@ -334,10 +335,10 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics should be updated" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -368,11 +369,11 @@ class GeneralModuleSpec extends ModuleBaseSpec { assert !response?.ext?.prebid?.modules?.trace?.stages?.outcomes?.groups?.invocationResults?.flatten() and: "Ortb2blocking module call metrics shouldn't be updated" - def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert !metrics[CALL_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[CALL_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] - assert !metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() + assert !metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + assert !metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -407,11 +408,11 @@ class GeneralModuleSpec extends ModuleBaseSpec { assert !response?.ext?.prebid?.modules?.trace?.stages?.outcomes?.groups?.invocationResults?.flatten() and: "Ortb2blocking module call metrics shouldn't be updated" - def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert !metrics[CALL_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[CALL_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] - assert !metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() + assert !metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + assert !metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -450,10 +451,10 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics should be updated" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -487,15 +488,15 @@ class GeneralModuleSpec extends ModuleBaseSpec { assert !response?.ext?.prebid?.modules?.trace?.stages?.outcomes?.groups?.invocationResults?.flatten() and: "Ortb2blocking module call metrics shouldn't be updated" - def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert !metrics[CALL_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[CALL_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] - assert !metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] - assert !metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() + assert !metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] + assert !metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] + assert !metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] and: "RB-Richmedia-Filter module call metrics shouldn't be updated" - assert !metrics[CALL_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] - assert !metrics[NOOP_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] + assert !metrics[MetricsUtil.Module.call(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] + assert !metrics[MetricsUtil.Module.noop(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -537,14 +538,14 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics should be updated" def metrics = pbsServiceWithMultipleModules.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 and: "RB-Richmedia-Filter module call metrics shouldn't be updated" - assert !metrics[CALL_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] - assert !metrics[NOOP_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] + assert !metrics[MetricsUtil.Module.call(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] + assert !metrics[MetricsUtil.Module.noop(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -582,15 +583,15 @@ class GeneralModuleSpec extends ModuleBaseSpec { and: "Ortb2blocking module call metrics should be updated" def metrics = pbsServiceWithMultipleModule.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[CALL_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 - assert metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 - assert metrics[NOOP_METRIC(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.call(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, BIDDER_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_ORTB2_BLOCKING, RAW_BIDDER_RESPONSE)] == 1 and: "RB-Richmedia-Filter module call metrics should be updated" def richmediaCounts = modulesCodes.count(PB_RICHMEDIA_FILTER.code) - assert metrics[CALL_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == richmediaCounts - assert metrics[NOOP_METRIC(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == richmediaCounts + assert metrics[MetricsUtil.Module.call(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == richmediaCounts + assert metrics[MetricsUtil.Module.noop(PB_RICHMEDIA_FILTER, ALL_PROCESSED_BID_RESPONSES)] == richmediaCounts and: "Response shouldn't contain warnings and errors" assert !response.ext?.warnings diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy index da5057d472b..694c86da5a8 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/ModuleBaseSpec.groovy @@ -34,22 +34,6 @@ class ModuleBaseSpec extends BaseSpec { repository.removeAllDatabaseData() } - protected final static Closure CALL_METRIC = { ModuleName module, Stage stage -> - "modules.module.${module.code}.stage.${stage.metricValue}.hook.${module.code}-${stage.value}-hook.call" - } - protected final static Closure UPDATE_METRIC = { ModuleName module, Stage stage -> - "modules.module.${module.code}.stage.${stage.metricValue}.hook.${module.code}-${stage.value}-hook.success.update" - } - protected final static Closure NOOP_METRIC = { ModuleName module, Stage stage -> - "modules.module.${module.code}.stage.${stage.metricValue}.hook.${module.code}-${stage.value}-hook.success.noop" - } - protected final static Closure NO_INVOCATION_METRIC = { ModuleName module, Stage stage -> - "modules.module.${module.code}.stage.${stage.metricValue}.hook.${module.code}-${stage.value}-hook.success.no-invocation" - } - protected final static Closure EXECUTION_ERROR_METRIC = { ModuleName module, Stage stage -> - "modules.module.${module.code}.stage.${stage.metricValue}.hook.${module.code}-${stage.value}-hook.execution-error" - } - protected static Map getResponseCorrectionConfig(HookHttpEndpoint endpoint = AUCTION) { ["hooks.${PB_RESPONSE_CORRECTION.code}.enabled": true, "hooks.host-execution-plan" : encode(ExecutionPlan.getSingleEndpointExecutionPlan(endpoint, [(ALL_PROCESSED_BID_RESPONSES): [PB_RESPONSE_CORRECTION]]))] diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/optabletargeting/CacheStorageSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/optabletargeting/CacheStorageSpec.groovy index f3452ddd92d..1c7a219ede5 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/optabletargeting/CacheStorageSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/optabletargeting/CacheStorageSpec.groovy @@ -17,23 +17,15 @@ import org.prebid.server.functional.model.request.auction.User import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.testcontainers.scaffolding.StoredCache import org.prebid.server.functional.tests.module.ModuleBaseSpec +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils -import static org.apache.commons.codec.binary.Base64.encodeBase64 import static org.apache.http.HttpStatus.SC_NOT_FOUND import static org.prebid.server.functional.model.config.ModuleName.OPTABLE_TARGETING import static org.prebid.server.functional.testcontainers.Dependencies.getNetworkServiceContainer class CacheStorageSpec extends ModuleBaseSpec { - private static final String METRIC_CREATIVE_SIZE_TEXT = "prebid_cache.module_storage.${OPTABLE_TARGETING.code}.entry_size.text" - private static final String METRIC_CREATIVE_TTL_TEXT = "prebid_cache.module_storage.${OPTABLE_TARGETING.code}.entry_ttl.text" - - private static final String METRIC_CREATIVE_READ_OK = "prebid_cache.module_storage.${OPTABLE_TARGETING.code}.read.ok" - private static final String METRIC_CREATIVE_READ_ERR = "prebid_cache.module_storage.${OPTABLE_TARGETING.code}.read.err" - private static final String METRIC_CREATIVE_WRITE_OK = "prebid_cache.module_storage.${OPTABLE_TARGETING.code}.write.ok" - private static final String METRIC_CREATIVE_WRITE_ERR = "prebid_cache.module_storage.${OPTABLE_TARGETING.code}.write.err" - private static final StoredCache storedCache = new StoredCache(networkServiceContainer) private static final Map CACHE_STORAGE_CONFIG = ['storage.pbc.path' : 'stored-cache', @@ -72,12 +64,12 @@ class CacheStorageSpec extends ModuleBaseSpec { then: "PBS should update metrics for new saved text storage cache" def metrics = prebidServerStoredCacheService.sendCollectedMetricsRequest() - assert metrics[METRIC_CREATIVE_READ_ERR] == 1 + assert metrics[MetricsUtil.Cache.readErr(OPTABLE_TARGETING)] == 1 and: "No updates for success metrics" - assert !metrics[METRIC_CREATIVE_SIZE_TEXT] - assert !metrics[METRIC_CREATIVE_TTL_TEXT] - assert !metrics[METRIC_CREATIVE_READ_OK] + assert !metrics[MetricsUtil.Cache.creativeSizeText(OPTABLE_TARGETING)] + assert !metrics[MetricsUtil.Cache.creativeTtlText(OPTABLE_TARGETING)] + assert !metrics[MetricsUtil.Cache.readOk(OPTABLE_TARGETING)] } def "PBS should update error metrics when external service responded with invalid values"() { @@ -103,15 +95,15 @@ class CacheStorageSpec extends ModuleBaseSpec { then: "PBS should update error metrics" def metrics = prebidServerStoredCacheService.sendCollectedMetricsRequest() - assert metrics[METRIC_CREATIVE_WRITE_ERR] == 1 + assert metrics[MetricsUtil.Cache.writeErr(OPTABLE_TARGETING)] == 1 and: "No updates for success metrics" - assert !metrics[METRIC_CREATIVE_WRITE_OK] + assert !metrics[MetricsUtil.Cache.writeOk(OPTABLE_TARGETING)] } def "PBS should update metrics for new saved text storage cache when no cached requests"() { given: "Current value of metric prebid cache" - def okInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_WRITE_OK) + def okInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, MetricsUtil.Cache.writeOk(OPTABLE_TARGETING)) and: "Default BidRequest with cache and device info" def randomIfa = PBSUtils.randomString @@ -135,20 +127,20 @@ class CacheStorageSpec extends ModuleBaseSpec { then: "PBS should update metrics for new saved text storage cache" def metrics = prebidServerStoredCacheService.sendCollectedMetricsRequest() - assert metrics[METRIC_CREATIVE_SIZE_TEXT] != 0 - assert metrics[METRIC_CREATIVE_WRITE_OK] == okInitialValue + 1 + assert metrics[MetricsUtil.Cache.creativeSizeText(OPTABLE_TARGETING)] != 0 + assert metrics[MetricsUtil.Cache.writeOk(OPTABLE_TARGETING)] == okInitialValue + 1 and: "PBS should include histogram metric" - assert metrics[METRIC_CREATIVE_TTL_TEXT] + assert metrics[MetricsUtil.Cache.creativeTtlText(OPTABLE_TARGETING)] } def "PBS should update metrics for stored cached requests cache when proper record present"() { given: "Current value of metric prebid cache" - def textInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_SIZE_TEXT) - def ttlInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_TTL_TEXT) - def writeInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_WRITE_OK) - def readErrorInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_READ_ERR) - def writeErrorInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, METRIC_CREATIVE_WRITE_ERR) + def textInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, MetricsUtil.Cache.creativeSizeText(OPTABLE_TARGETING)) + def ttlInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, MetricsUtil.Cache.creativeTtlText(OPTABLE_TARGETING)) + def writeInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, MetricsUtil.Cache.writeOk(OPTABLE_TARGETING)) + def readErrorInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, MetricsUtil.Cache.readErr(OPTABLE_TARGETING)) + def writeErrorInitialValue = getCurrentMetricValue(prebidServerStoredCacheService, MetricsUtil.Cache.writeErr(OPTABLE_TARGETING)) and: "Default BidRequest with cache and device info" def randomIfa = PBSUtils.randomString @@ -172,16 +164,16 @@ class CacheStorageSpec extends ModuleBaseSpec { then: "PBS should update metrics for stored cached requests" def metrics = prebidServerStoredCacheService.sendCollectedMetricsRequest() - assert metrics[METRIC_CREATIVE_READ_OK] == 1 + assert metrics[MetricsUtil.Cache.readOk(OPTABLE_TARGETING)] == 1 and: "No updates for new saved text storage metrics" - assert metrics[METRIC_CREATIVE_SIZE_TEXT] == textInitialValue - assert metrics[METRIC_CREATIVE_TTL_TEXT] == ttlInitialValue - assert metrics[METRIC_CREATIVE_WRITE_OK] == writeInitialValue + assert metrics[MetricsUtil.Cache.creativeSizeText(OPTABLE_TARGETING)] == textInitialValue + assert metrics[MetricsUtil.Cache.creativeTtlText(OPTABLE_TARGETING)] == ttlInitialValue + assert metrics[MetricsUtil.Cache.writeOk(OPTABLE_TARGETING)] == writeInitialValue and: "No update for error metrics" - assert metrics[METRIC_CREATIVE_READ_ERR] == readErrorInitialValue - assert metrics[METRIC_CREATIVE_WRITE_ERR] == writeErrorInitialValue + assert metrics[MetricsUtil.Cache.readErr(OPTABLE_TARGETING)] == readErrorInitialValue + assert metrics[MetricsUtil.Cache.writeErr(OPTABLE_TARGETING)] == writeErrorInitialValue } private static BidRequest getBidRequestForModuleCacheStorage(String ifa, OperatingSystem os) { diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbortb2blocking/PbOrtb2BlockingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbortb2blocking/PbOrtb2BlockingSpec.groovy index 29e45b86955..42c8ce934fb 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbortb2blocking/PbOrtb2BlockingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbortb2blocking/PbOrtb2BlockingSpec.groovy @@ -19,7 +19,7 @@ import org.prebid.server.functional.model.request.auction.Audio import org.prebid.server.functional.model.request.auction.Banner import org.prebid.server.functional.model.request.auction.BidderControls import org.prebid.server.functional.model.request.auction.GenericPreferredBidder -import org.prebid.server.functional.model.request.auction.Ix +import org.prebid.server.functional.model.bidder.Ix import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.model.request.auction.Video diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineAliasSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineAliasSpec.groovy index 9eb712715d5..752996355f5 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineAliasSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineAliasSpec.groovy @@ -2,12 +2,12 @@ package org.prebid.server.functional.tests.module.pbruleengine import org.prebid.server.functional.model.request.auction.Imp -import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.ALIAS import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX import static org.prebid.server.functional.model.bidder.BidderName.OPENX_ALIAS +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithExcludeResult import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithIncludeResult diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineBaseSpec.groovy index 494a44f8460..3d53d6239df 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineBaseSpec.groovy @@ -1,5 +1,6 @@ package org.prebid.server.functional.tests.module.pbruleengine +import org.prebid.server.functional.model.bidder.Amx import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.bidder.Generic import org.prebid.server.functional.model.bidder.Openx @@ -9,7 +10,6 @@ import org.prebid.server.functional.model.config.PbRulesEngine import org.prebid.server.functional.model.config.PbsModulesConfig import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.pricefloors.Country -import org.prebid.server.functional.model.request.auction.Amx import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Device import org.prebid.server.functional.model.request.auction.DistributionChannel diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineContextSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineContextSpec.groovy index 02820762c87..0225000a69a 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineContextSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineContextSpec.groovy @@ -16,10 +16,10 @@ import org.prebid.server.functional.util.PBSUtils import java.time.Instant import static org.prebid.server.functional.model.ChannelType.WEB -import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineFunction.AD_UNIT_CODE import static org.prebid.server.functional.model.config.RuleEngineFunction.AD_UNIT_CODE_IN diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineCoreSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineCoreSpec.groovy index ab986d3bc3a..49623cdf9e5 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineCoreSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineCoreSpec.groovy @@ -7,13 +7,14 @@ import org.prebid.server.functional.model.config.RuleSet import org.prebid.server.functional.model.config.RulesEngineModelGroup import org.prebid.server.functional.model.config.Stage import org.prebid.server.functional.model.request.auction.Imp +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils -import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX import static org.prebid.server.functional.model.bidder.BidderName.UNKNOWN +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.ResultFunction.LOG_A_TAG import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithExcludeResult @@ -65,8 +66,8 @@ class PbRuleEngineCoreSpec extends PbRuleEngineBaseSpec { and: "PBs should populate call and update metrics" def metrics = pbsServiceWithRulesEngineModule.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(PB_RULE_ENGINE, PROCESSED_AUCTION_REQUEST)] == 1 - assert metrics[UPDATE_METRIC(PB_RULE_ENGINE, PROCESSED_AUCTION_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.call(PB_RULE_ENGINE, PROCESSED_AUCTION_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.update(PB_RULE_ENGINE, PROCESSED_AUCTION_REQUEST)] == 1 and: "Response should seatNon bid with code 203" assert bidResponse.ext.seatnonbid.size() == 1 diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineDeviceSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineDeviceSpec.groovy index fabcab27548..e73fd51eee1 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineDeviceSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineDeviceSpec.groovy @@ -9,10 +9,10 @@ import org.prebid.server.functional.util.PBSUtils import java.time.Instant -import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineFunction.DEVICE_COUNTRY import static org.prebid.server.functional.model.config.RuleEngineFunction.DEVICE_COUNTRY_IN diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineInfrastructureSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineInfrastructureSpec.groovy index ba125f07a3a..6c2e911ca29 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineInfrastructureSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineInfrastructureSpec.groovy @@ -6,10 +6,10 @@ import org.prebid.server.functional.util.PBSUtils import java.time.Instant -import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineFunction.DATA_CENTER import static org.prebid.server.functional.model.config.RuleEngineFunction.DATA_CENTER_IN diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEnginePrivacySpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEnginePrivacySpec.groovy index 25804dc614e..bf022e961c2 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEnginePrivacySpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEnginePrivacySpec.groovy @@ -19,10 +19,10 @@ import org.prebid.server.functional.util.privacy.TcfConsent import java.time.Instant -import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineFunction.EID_AVAILABLE import static org.prebid.server.functional.model.config.RuleEngineFunction.EID_IN diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineSpecialSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineSpecialSpec.groovy index 8d9a53d13f0..6a3c62bac28 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineSpecialSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineSpecialSpec.groovy @@ -5,10 +5,10 @@ import org.prebid.server.functional.util.PBSUtils import java.time.Instant -import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineFunction.PERCENT import static org.prebid.server.functional.model.config.RuleEngineFunction.PREBID_KEY diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineSyncSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineSyncSpec.groovy index 3128e047aae..b6c4e688d50 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineSyncSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineSyncSpec.groovy @@ -3,10 +3,10 @@ package org.prebid.server.functional.tests.module.pbruleengine import org.prebid.server.functional.model.UidsCookie import org.prebid.server.functional.util.HttpUtil -import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.bidder.BidderName.AMX import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.bidder.BidderName.OPENX +import static org.prebid.server.functional.model.config.ModuleName.PB_RULE_ENGINE import static org.prebid.server.functional.model.config.PbRulesEngine.createRulesEngineWithRule import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithExcludeResult import static org.prebid.server.functional.model.config.RuleEngineModelRuleResult.createRuleEngineModelRuleWithIncludeResult diff --git a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineValidationSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineValidationSpec.groovy index d43a5114f5d..b493ce5cc63 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineValidationSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/module/pbruleengine/PbRuleEngineValidationSpec.groovy @@ -1,6 +1,7 @@ package org.prebid.server.functional.tests.module.pbruleengine import org.prebid.server.functional.model.config.RuleEngineFunctionArgs +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import java.time.Instant @@ -60,11 +61,11 @@ class PbRuleEngineValidationSpec extends PbRuleEngineBaseSpec { and: "PBs should populate call and noop metrics" def metrics = pbsServiceWithRulesEngineModule.sendCollectedMetricsRequest() - assert metrics[CALL_METRIC(PB_RULE_ENGINE, PROCESSED_AUCTION_REQUEST)] == 1 - assert metrics[NOOP_METRIC(PB_RULE_ENGINE,PROCESSED_AUCTION_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.call(PB_RULE_ENGINE, PROCESSED_AUCTION_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_RULE_ENGINE, PROCESSED_AUCTION_REQUEST)] == 1 and: "PBs should populate update metrics" - assert !metrics[UPDATE_METRIC(PB_RULE_ENGINE,PROCESSED_AUCTION_REQUEST)] + assert !metrics[MetricsUtil.Module.update(PB_RULE_ENGINE, PROCESSED_AUCTION_REQUEST)] where: pbRulesEngine << [ @@ -114,7 +115,7 @@ class PbRuleEngineValidationSpec extends PbRuleEngineBaseSpec { and: "PBs should populate noop metrics" def metrics = pbsServiceWithRulesEngineModule.sendCollectedMetricsRequest() - assert metrics[NOOP_METRIC(PB_RULE_ENGINE,PROCESSED_AUCTION_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_RULE_ENGINE, PROCESSED_AUCTION_REQUEST)] == 1 } def "PBS shouldn't remove bidder and emit a warning when args rule engine not fully configured in account"() { @@ -152,7 +153,7 @@ class PbRuleEngineValidationSpec extends PbRuleEngineBaseSpec { and: "PBs should populate failer metrics" def metrics = pbsServiceWithRulesEngineModule.sendCollectedMetricsRequest() - assert metrics[NOOP_METRIC(PB_RULE_ENGINE,PROCESSED_AUCTION_REQUEST)] == 1 + assert metrics[MetricsUtil.Module.noop(PB_RULE_ENGINE, PROCESSED_AUCTION_REQUEST)] == 1 } def "PBS shouldn't remove bidder and emit a warning when model group rule engine not fully configured in account"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsBaseSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsBaseSpec.groovy index 95ef1318637..09952e7f255 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsBaseSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsBaseSpec.groovy @@ -40,8 +40,6 @@ abstract class PriceFloorsBaseSpec extends BaseSpec { protected static final String BASIC_FETCH_URL = networkServiceContainer.rootUri + FloorsProvider.FLOORS_ENDPOINT protected static final int MAX_MODEL_WEIGHT = 100 - protected static final Closure INVALID_CONFIG_METRIC = { account -> "alerts.account_config.${account}.price-floors" } - protected static final Closure URL_EMPTY_ERROR = { url -> "Failed to fetch price floor from provider for fetch.url '${url}'" } protected static final String FETCHING_DISABLED_ERROR = "Fetching is disabled" diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy index fcfa39f6e9d..d20e1374965 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsFetchingSpec.groovy @@ -10,6 +10,7 @@ import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.ExtPrebidFloors import org.prebid.server.functional.model.request.auction.PrebidStoredRequest import org.prebid.server.functional.model.response.auction.BidResponse +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import java.time.Instant @@ -45,7 +46,6 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { private static final int DEFAULT_FLOOR_VALUE_MIN = 0 private static final int FLOOR_MIN = 0 - private static final String FETCH_FAILURE_METRIC = "price-floors.fetch.failure" private static final String PRICE_FLOOR_VALUES_MISSING = 'Price floor rules values can\'t be null or empty, but were null' private static final String MODEL_WEIGHT_INVALID = "Price floor modelGroup modelWeight must be in range(1-100), but was %s" private static final String SKIP_RATE_INVALID = "Price floor modelGroup skipRate must be in range(0-100), but was %s" @@ -155,7 +155,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[MetricsUtil.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid.isEmpty() @@ -181,7 +181,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[MetricsUtil.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid?.isEmpty() @@ -208,7 +208,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[MetricsUtil.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid?.isEmpty() @@ -229,7 +229,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[MetricsUtil.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid?.isEmpty() @@ -250,7 +250,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[MetricsUtil.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid?.isEmpty() @@ -280,7 +280,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[MetricsUtil.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid?.isEmpty() @@ -561,7 +561,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "metric should be updated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[MetricsUtil.General.floorsFetchFailure()] == 1 and: "PBS should fetch data" assert floorsProvider.getRequestCount(bidRequest.accountId) == 1 @@ -643,7 +643,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "metric should be updated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[MetricsUtil.General.floorsFetchFailure()] == 1 and: "PBS should add single warning" assert response.ext?.warnings[PREBID]*.code == [999] @@ -752,7 +752,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def metrics = floorsPbsService.sendCollectedMetricsRequest() then: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[MetricsUtil.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def message = "Failed to request, provider respond with status 400" @@ -794,7 +794,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def metrics = floorsPbsService.sendCollectedMetricsRequest() then: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[MetricsUtil.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def message = "Failed to parse price floor response, cause: DecodeException: Failed to decode" @@ -835,7 +835,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def metrics = floorsPbsService.sendCollectedMetricsRequest() then: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[MetricsUtil.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def message = "Failed to parse price floor response, response body can not be empty" @@ -879,7 +879,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def metrics = floorsPbsService.sendCollectedMetricsRequest() then: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[MetricsUtil.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def message = "Price floor rules should contain at least one model group" @@ -923,7 +923,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def metrics = floorsPbsService.sendCollectedMetricsRequest() then: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[MetricsUtil.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def logs = floorsPbsService.getLogsByTime(startTime) @@ -969,7 +969,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def metrics = floorsPbsService.sendCollectedMetricsRequest() then: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[MetricsUtil.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def message = "Price floor rules number 2 exceeded its maximum number $maxRules" @@ -1017,7 +1017,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def metrics = pbsService.sendCollectedMetricsRequest() then: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[MetricsUtil.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def logs = pbsService.getLogsByTime(startTime) @@ -1062,7 +1062,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def metrics = floorsPbsService.sendCollectedMetricsRequest() then: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + assert metrics[MetricsUtil.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def message = "Response size $responseSize exceeded ${convertKilobyteSizeToByte(maxSize)} bytes limit" @@ -1745,7 +1745,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics shouldn't be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert !metrics[ALERT_GENERAL] + assert !metrics[MetricsUtil.General.alert()] where: bidRequest << [BidRequest.getDefaultBidRequest(), getBidRequestWithFloors().tap { it.ext.prebid.floors = null }] @@ -1796,7 +1796,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 where: requestFloorEnabled << [null, true] @@ -1837,7 +1837,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics shouldn't be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert !metrics[ALERT_GENERAL] + assert !metrics[MetricsUtil.General.alert()] } def "PBS shouldn't emit error in log and response when data is invalid and floors fetching enabled for account"() { @@ -1880,7 +1880,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics shouldn't be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert !metrics[ALERT_GENERAL] + assert !metrics[MetricsUtil.General.alert()] where: requestEnabledFloors << [null, true] @@ -1925,7 +1925,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics shouldn't be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert !metrics[ALERT_GENERAL] + assert !metrics[MetricsUtil.General.alert()] } def "PBS should not invalidate previously good fetched data when floors provider return invalid data"() { @@ -2011,7 +2011,6 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { def response = floorsPbsService.sendAuctionRequest(bidRequest) and: "PBS processes collected metrics request" - def metrics = floorsPbsService.sendCollectedMetricsRequest() then: "Bidder request bidFloor should not be passed" def bidderRequest = bidder.getBidderRequests(bidRequest.id).last() @@ -2019,7 +2018,8 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { assert bidderRequest.ext?.prebid?.floors?.fetchStatus == ERROR and: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + def metrics = floorsPbsService.sendCollectedMetricsRequest() + assert metrics[MetricsUtil.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def logs = floorsPbsService.getLogsByTime(startTime) @@ -2067,16 +2067,14 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { when: "PBS processes auction request" def response = floorsPbsService.sendAuctionRequest(bidRequest) - and: "PBS processes collected metrics request" - def metrics = floorsPbsService.sendCollectedMetricsRequest() - then: "Bidder request bidFloor should not be passed" def bidderRequest = bidder.getBidderRequests(bidRequest.id).last() assert !bidderRequest.imp[0].bidFloor assert bidderRequest.ext?.prebid?.floors?.fetchStatus == ERROR and: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + def metrics = floorsPbsService.sendCollectedMetricsRequest() + assert metrics[MetricsUtil.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def message = "Price floor data skipRate must be in range(0-100), but was $invalidSkipRate" @@ -2125,16 +2123,14 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { when: "PBS processes auction request" def response = floorsPbsService.sendAuctionRequest(bidRequest) - and: "PBS processes collected metrics request" - def metrics = floorsPbsService.sendCollectedMetricsRequest() - then: "Bidder request bidFloor should not be passed" def bidderRequest = bidder.getBidderRequests(bidRequest.id).last() assert !bidderRequest.imp[0].bidFloor assert bidderRequest.ext?.prebid?.floors?.fetchStatus == ERROR and: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + def metrics = floorsPbsService.sendCollectedMetricsRequest() + assert metrics[MetricsUtil.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def logs = floorsPbsService.getLogsByTime(startTime) @@ -2182,16 +2178,14 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { when: "PBS processes auction request" def response = floorsPbsService.sendAuctionRequest(bidRequest) - and: "PBS processes collected metrics request" - def metrics = floorsPbsService.sendCollectedMetricsRequest() - then: "Bidder request bidFloor should not be passed" def bidderRequest = bidder.getBidderRequests(bidRequest.id).last() assert !bidderRequest.imp[0].bidFloor assert bidderRequest.ext?.prebid?.floors?.fetchStatus == ERROR and: "#FETCH_FAILURE_METRIC should be update" - assert metrics[FETCH_FAILURE_METRIC] == 1 + def metrics = floorsPbsService.sendCollectedMetricsRequest() + assert metrics[MetricsUtil.General.floorsFetchFailure()] == 1 and: "PBS log should contain error" def message = "Price floor modelGroup default must be positive float, but was $invalidDefaultFloor" @@ -2398,7 +2392,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[MetricsUtil.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid?.isEmpty() @@ -2427,7 +2421,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[MetricsUtil.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid?.isEmpty() @@ -2454,7 +2448,7 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec { then: "Metric alerts.account_config.ACCOUNT.price-floors should be update" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 + assert metrics[MetricsUtil.Account.invalidConfigFloors(bidRequest.accountId)] == 1 and: "PBS floors validation failure should not reject the entire auction" assert !response.seatbid?.isEmpty() diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy index bd892ca8746..960b04eef1c 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsRulesSpec.groovy @@ -13,7 +13,7 @@ import org.prebid.server.functional.model.pricefloors.PriceFloorData import org.prebid.server.functional.model.pricefloors.PriceFloorSchema import org.prebid.server.functional.model.pricefloors.Rule import org.prebid.server.functional.model.request.Channel -import org.prebid.server.functional.model.request.auction.Amx +import org.prebid.server.functional.model.bidder.Amx import org.prebid.server.functional.model.request.auction.Banner import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Device diff --git a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy index e9b819d23fa..8efa7aba040 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/pricefloors/PriceFloorsSignalingSpec.groovy @@ -16,6 +16,7 @@ import org.prebid.server.functional.model.request.auction.Imp import org.prebid.server.functional.model.request.auction.Video import org.prebid.server.functional.model.response.auction.BidResponse import org.prebid.server.functional.model.response.auction.MediaType +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import java.math.RoundingMode @@ -85,7 +86,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics shouldn't be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert !metrics[ALERT_GENERAL] + assert !metrics[MetricsUtil.General.alert()] where: requestEnabled | accountEnabled @@ -572,7 +573,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics shouldn't be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert !metrics[ALERT_GENERAL] + assert !metrics[MetricsUtil.General.alert()] } def "PBS should emit warning when request has more rules than price-floor.max-rules"() { @@ -611,7 +612,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 where: maxRules | maxRulesSnakeCase @@ -652,7 +653,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 where: maxSchemaDims | maxSchemaDimsSnakeCase @@ -704,8 +705,8 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Metrics should be updated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.Account.invalidConfigFloors(bidRequest.accountId)] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsFloorConfig) @@ -757,8 +758,8 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Metrics should be updated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[INVALID_CONFIG_METRIC(bidRequest.accountId) as String] == 1 - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.Account.invalidConfigFloors(bidRequest.accountId)] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsFloorConfig) @@ -798,7 +799,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 where: maxSchemaDims | maxSchemaDimsSnakeCase @@ -843,7 +844,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 } def "PBS shouldn't fail with error and maxSchemaDims take precede over fetch.maxSchemaDims when requested both"() { @@ -918,7 +919,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 where: maxRules | maxRulesSnakeCase @@ -954,7 +955,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 where: requestSkipRate << [PBSUtils.randomNegativeNumber, PBSUtils.getRandomNumber(100)] @@ -988,7 +989,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 where: requestModelGroups << [null, []] @@ -1024,7 +1025,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 where: requestModelWeight << [PBSUtils.randomNegativeNumber, PBSUtils.getRandomNumber(100)] @@ -1061,7 +1062,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 } def "PBS should emit error in log and response when modelGroup defaultFloor is negative"() { @@ -1096,7 +1097,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 } def "PBS should emit error in log and response when account have disabled dynamic data config"() { @@ -1136,7 +1137,7 @@ class PriceFloorsSignalingSpec extends PriceFloorsBaseSpec { and: "Alerts.general metrics should be populated" def metrics = floorsPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 } private static int getSchemaSize(BidRequest bidRequest) { diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/ccpa/CcpaAmpSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/ccpa/CcpaAmpSpec.groovy index ad6a320b943..0013a17e03b 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/ccpa/CcpaAmpSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/ccpa/CcpaAmpSpec.groovy @@ -7,6 +7,7 @@ import org.prebid.server.functional.model.db.Account import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.response.auction.ErrorType +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.tests.privacy.PrivacyBaseSpec import org.prebid.server.functional.util.privacy.BogusConsent import org.prebid.server.functional.util.privacy.CcpaConsent @@ -15,8 +16,6 @@ import spock.lang.PendingFeature import static org.prebid.server.functional.model.ChannelType.AMP import static org.prebid.server.functional.model.bidder.BidderName.GENERIC -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ADAPTER_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_REQUEST_DISALLOWED_COUNT import static org.prebid.server.functional.model.request.amp.ConsentType.BOGUS import static org.prebid.server.functional.model.request.amp.ConsentType.TCF_1 import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_EIDS @@ -131,12 +130,12 @@ class CcpaAmpSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 where: ccpaConfig << [new AccountCcpaConfig(enabled: false, channelEnabled: [(AMP): true]), @@ -173,12 +172,12 @@ class CcpaAmpSpec extends PrivacyBaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, ampRequest.account, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] where: ccpaConfig << [new AccountCcpaConfig(enabled: true, channelEnabled: [(AMP): false]), diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/ccpa/CcpaAuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/ccpa/CcpaAuctionSpec.groovy index fde801a3529..e392e46dac2 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/ccpa/CcpaAuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/ccpa/CcpaAuctionSpec.groovy @@ -4,6 +4,7 @@ import org.prebid.server.functional.model.ChannelType import org.prebid.server.functional.model.config.AccountCcpaConfig import org.prebid.server.functional.model.request.Channel import org.prebid.server.functional.model.request.auction.DistributionChannel +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.tests.privacy.PrivacyBaseSpec import org.prebid.server.functional.util.privacy.BogusConsent import org.prebid.server.functional.util.privacy.CcpaConsent @@ -12,9 +13,6 @@ import spock.lang.PendingFeature import static org.prebid.server.functional.model.ChannelType.PBJS import static org.prebid.server.functional.model.ChannelType.WEB import static org.prebid.server.functional.model.bidder.BidderName.GENERIC -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ADAPTER_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_REQUEST_DISALLOWED_COUNT import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_EIDS import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_PRECISE_GEO import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_UFPD @@ -146,15 +144,15 @@ class CcpaAuctionSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 where: ccpaConfig << [new AccountCcpaConfig(enabled: false, channelEnabled: [(ChannelType.APP): true]), @@ -183,17 +181,17 @@ class CcpaAuctionSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 and: "Metrics account shouldn't be populated" - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] where: ccpaConfig << [new AccountCcpaConfig(enabled: false, channelEnabled: [(ChannelType.APP): true]), @@ -238,15 +236,15 @@ class CcpaAuctionSpec extends PrivacyBaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] where: ccpaConfig << [new AccountCcpaConfig(enabled: true, channelEnabled: [(ChannelType.APP): false]), diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/coppa/CoppaSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/coppa/CoppaSpec.groovy index 36d6ea3d13d..967d3c83715 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/coppa/CoppaSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/coppa/CoppaSpec.groovy @@ -2,13 +2,11 @@ package org.prebid.server.functional.tests.privacy.coppa import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.amp.AmpRequest +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.tests.privacy.PrivacyBaseSpec import spock.lang.PendingFeature import static org.prebid.server.functional.model.bidder.BidderName.GENERIC -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ADAPTER_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_REQUEST_DISALLOWED_COUNT import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_EIDS import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_PRECISE_GEO import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_UFPD @@ -198,15 +196,15 @@ class CoppaSpec extends PrivacyBaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] } def "PBS should mask device and user fields for auction request when coppa = 1 was passed and trace level verbose"() { @@ -268,15 +266,15 @@ class CoppaSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 } def "PBS should mask device and user fields for auction request when coppa = 1 was passed and trace level basic"() { @@ -338,17 +336,17 @@ class CoppaSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 and: "Account metrics shouldn't be updated" - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] } def "PBS shouldn't mask device and user fields for amp request when coppa = 0 was passed"() { @@ -402,15 +400,15 @@ class CoppaSpec extends PrivacyBaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(ampStoredRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(ampStoredRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(ampStoredRequest.accountId, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] } def "PBS should mask device and user fields for amp request when coppa = 1 was passed"() { @@ -476,11 +474,11 @@ class CoppaSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 } } diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/gdpr/GdprAmpSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/gdpr/GdprAmpSpec.groovy index e24e8fdc563..ac2513150a6 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/gdpr/GdprAmpSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/gdpr/GdprAmpSpec.groovy @@ -12,6 +12,7 @@ import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.DistributionChannel import org.prebid.server.functional.model.request.auction.Regs import org.prebid.server.functional.model.request.auction.RegsExt +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.tests.privacy.PrivacyBaseSpec import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.BogusConsent @@ -30,8 +31,6 @@ import static org.prebid.server.functional.model.config.PurposeEnforcement.BASIC import static org.prebid.server.functional.model.config.PurposeEnforcement.NO import static org.prebid.server.functional.model.mock.services.vendorlist.GvlSpecificationVersion.V3 import static org.prebid.server.functional.model.pricefloors.Country.BULGARIA -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ADAPTER_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_REQUEST_DISALLOWED_COUNT import static org.prebid.server.functional.model.request.amp.ConsentType.BOGUS import static org.prebid.server.functional.model.request.amp.ConsentType.TCF_1 import static org.prebid.server.functional.model.request.amp.ConsentType.US_PRIVACY @@ -398,7 +397,7 @@ class GdprAmpSpec extends PrivacyBaseSpec { and: "Alerts.general metrics should be populated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Bidder should be called" assert bidder.getBidderRequest(ampStoredRequest.id) @@ -507,8 +506,8 @@ class GdprAmpSpec extends PrivacyBaseSpec { then: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 } def "PBS auction should update activity controls privacy metrics when tcf requirement disallow privacy fields"() { @@ -583,12 +582,12 @@ class GdprAmpSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 } def "PBS auction should not update activity controls privacy metrics when tcf requirement allow privacy fields"() { @@ -660,12 +659,12 @@ class GdprAmpSpec extends PrivacyBaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] } def "PBS amp should set 3 for tcfPolicyVersion when tcfPolicyVersion is #tcfPolicyVersion"() { @@ -746,8 +745,8 @@ class GdprAmpSpec extends PrivacyBaseSpec { then: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 where: gdpr | coppa | extGdpr | extCoppa @@ -829,8 +828,8 @@ class GdprAmpSpec extends PrivacyBaseSpec { then: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 where: requestCountry | accountCountry | requestIpV4 | requestIpV6 | header diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/gdpr/GdprAuctionSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/gdpr/GdprAuctionSpec.groovy index ffbbbcbbd79..8876b7bbd66 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/gdpr/GdprAuctionSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/gdpr/GdprAuctionSpec.groovy @@ -14,6 +14,7 @@ import org.prebid.server.functional.model.request.auction.DistributionChannel import org.prebid.server.functional.model.request.auction.Regs import org.prebid.server.functional.model.request.auction.RegsExt import org.prebid.server.functional.model.response.auction.ErrorType +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.model.response.auction.NoBidResponse import org.prebid.server.functional.service.PrebidServerService import org.prebid.server.functional.testcontainers.scaffolding.VendorList @@ -40,9 +41,6 @@ import static org.prebid.server.functional.model.mock.services.vendorlist.GvlSpe import static org.prebid.server.functional.model.pricefloors.Country.BULGARIA import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ADAPTER_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_REQUEST_DISALLOWED_COUNT import static org.prebid.server.functional.model.request.auction.ActivityType.FETCH_BIDS import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_EIDS import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_PRECISE_GEO @@ -373,7 +371,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Alerts.general metrics should be populated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Bid response should contain seatBid" assert response.seatbid.size() == 1 @@ -472,8 +470,8 @@ class GdprAuctionSpec extends PrivacyBaseSpec { then: "PBs should increment metrics when eea-country matched" def metricsRequest = privacyPbsService.sendCollectedMetricsRequest() - assert metricsRequest["privacy.tcf.v2.in-geo"] == 1 - assert !metricsRequest["privacy.tcf.v2.out-geo"] + assert metricsRequest[MetricsUtil.Privacy.tcfInGeo(2)] == 1 + assert !metricsRequest[MetricsUtil.Privacy.tcfOutGeo(2)] } def "PBS should apply gdpr and not emit metrics when host and device.geo.country doesn't contain same eea-country"() { @@ -501,8 +499,9 @@ class GdprAuctionSpec extends PrivacyBaseSpec { then: "PBs should increment metrics when eea-country doens't matched" def metricsRequest = privacyPbsService.sendCollectedMetricsRequest() - assert !metricsRequest["privacy.tcf.v2.in-geo"] - assert metricsRequest["privacy.tcf.v2.out-geo"] == 1 + assert !metricsRequest[MetricsUtil.Privacy.tcfInGeo(2)] + assert metricsRequest[MetricsUtil.Privacy.tcfOutGeo(2)] == 1 + } def "PBS should apply gdpr and emit metrics when account and device.geo.country contains same eea-country"() { @@ -530,8 +529,8 @@ class GdprAuctionSpec extends PrivacyBaseSpec { then: "PBs should increment metrics when eea-country matched" def metricsRequest = privacyPbsService.sendCollectedMetricsRequest() - assert metricsRequest["privacy.tcf.v2.in-geo"] == 1 - assert !metricsRequest["privacy.tcf.v2.out-geo"] + assert metricsRequest[MetricsUtil.Privacy.tcfInGeo(2)] == 1 + assert !metricsRequest[MetricsUtil.Privacy.tcfOutGeo(2)] } def "PBS should apply gdpr and not emit metrics when account and device.geo.country doesn't contain same eea-country"() { @@ -559,8 +558,8 @@ class GdprAuctionSpec extends PrivacyBaseSpec { then: "PBs shouldn't increment metrics when eea-country matched" def metricsRequest = privacyPbsService.sendCollectedMetricsRequest() - assert !metricsRequest["privacy.tcf.v2.in-geo"] - assert metricsRequest["privacy.tcf.v2.out-geo"] == 1 + assert !metricsRequest[MetricsUtil.Privacy.tcfInGeo(2)] + assert metricsRequest[MetricsUtil.Privacy.tcfOutGeo(2)] == 1 } def "PBS auction should update activity controls fetch bids metrics when tcf requirement disallow request"() { @@ -588,9 +587,9 @@ class GdprAuctionSpec extends PrivacyBaseSpec { then: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 } def "PBS auction should update activity controls privacy metrics when tcf requirement disallow privacy fields and trace level verbosity"() { @@ -660,15 +659,15 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 } def "PBS auction should update activity controls privacy metrics when tcf requirement disallow privacy fields and trace level basic"() { @@ -738,17 +737,17 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 and: "Account metrics shouldn't be updated" - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] } def "PBS auction should not update activity controls privacy metrics when tcf requirement allow privacy fields"() { @@ -816,15 +815,15 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] } def "PBS auction should set 3 for tcfPolicyVersion when tcfPolicyVersion is #tcfPolicyVersion"() { @@ -891,8 +890,8 @@ class GdprAuctionSpec extends PrivacyBaseSpec { then: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 where: gdpr | coppa | extGdpr | extCoppa @@ -968,8 +967,8 @@ class GdprAuctionSpec extends PrivacyBaseSpec { then: "Metrics processed across activities should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 where: requestCountry | accountCountry | requestIpV4 | requestIpV6 | header @@ -1047,8 +1046,8 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Metrics buyeruid scrubbed shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics["adapter.${GENERIC.value}.requests.buyeruid_scrubbed"] - assert !metrics["account.${account.uuid}.adapter.${GENERIC.value}.requests.buyeruid_scrubbed"] + assert !metrics[MetricsUtil.Adapter.buyerUidScrubbed(GENERIC)] + assert !metrics[MetricsUtil.Account.buyerUidScrubbed(account.uuid, GENERIC)] where: verbosityLevel << [DETAILED, AccountMetricsVerbosityLevel.BASIC] @@ -1093,10 +1092,10 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Metrics buyeruid scrubbed should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics["adapter.${GENERIC.value}.requests.buyeruid_scrubbed"] == 1 + assert metrics[MetricsUtil.Adapter.buyerUidScrubbed(GENERIC)] == 1 and: "Account metric shouldn't be populated" - assert !metrics["account.${account.uuid}.adapter.${GENERIC.value}.requests.buyeruid_scrubbed"] + assert !metrics[MetricsUtil.Account.buyerUidScrubbed(account.uuid, GENERIC)] } def "PBS auction should update buyeruid scrubbed general and account metrics when user.buyeruid requested and verbosityLevel DETAILED"() { @@ -1138,8 +1137,8 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Metrics buyeruid scrubbed should be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert metrics["adapter.${GENERIC.value}.requests.buyeruid_scrubbed"] == 1 - assert metrics["account.${account.uuid}.adapter.${GENERIC.value}.requests.buyeruid_scrubbed"] == 1 + assert metrics[MetricsUtil.Adapter.buyerUidScrubbed(GENERIC)] == 1 + assert metrics[MetricsUtil.Account.buyerUidScrubbed(account.uuid, GENERIC)] == 1 } def "PBS should treated GVL record as valid when it's don't marked as deleted for GVL file"() { @@ -1188,7 +1187,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Disallowed metrics shouldn't be updated" def metrics = pbsWithLiveGvlSetup.sendCollectedMetricsRequest() - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, FETCH_BIDS)] cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(REFRESH_LIVE_VENDOR_LIST_CONFIG) @@ -1246,7 +1245,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Disallowed metrics should be updated" def metrics = pbsWithLiveGvlSetup.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, FETCH_BIDS)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(REFRESH_LIVE_VENDOR_LIST_CONFIG) @@ -1303,7 +1302,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Disallowed metrics should be updated" def metrics = pbsWithLiveGvlSetup.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, FETCH_BIDS)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(REFRESH_LIVE_VENDOR_LIST_CONFIG) @@ -1368,7 +1367,7 @@ class GdprAuctionSpec extends PrivacyBaseSpec { and: "Disallowed metrics shouldn't be updated" def metrics = pbsWithLiveGvlSetup.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 0 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, FETCH_BIDS)] == 0 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(config) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/gdpr/GdprSetUidSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/gdpr/GdprSetUidSpec.groovy index a4ff12f45bd..c6683d8693a 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/gdpr/GdprSetUidSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/gdpr/GdprSetUidSpec.groovy @@ -11,6 +11,7 @@ import org.prebid.server.functional.model.request.setuid.SetuidRequest import org.prebid.server.functional.model.response.cookiesync.UserSyncInfo import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.testcontainers.Dependencies import org.prebid.server.functional.tests.privacy.PrivacyBaseSpec import org.prebid.server.functional.util.PBSUtils @@ -163,7 +164,7 @@ class GdprSetUidSpec extends PrivacyBaseSpec { and: "Metric should be increased usersync.BIDDER.tcf.blocked" def metric = prebidServerService.sendCollectedMetricsRequest() - assert metric["usersync.${GENERIC.value}.tcf.blocked"] == 1 + assert metric[MetricsUtil.UserSync.tcfBlocked(GENERIC)] == 1 } def "PBS setuid should failed with tcf when purpose access device enforced for account"() { @@ -205,7 +206,7 @@ class GdprSetUidSpec extends PrivacyBaseSpec { and: "Metric should be increased usersync.BIDDER.tcf.blocked" def metric = prebidServerService.sendCollectedMetricsRequest() - assert metric["usersync.${GENERIC.value}.tcf.blocked"] == 1 + assert metric[MetricsUtil.UserSync.tcfBlocked(GENERIC)] == 1 } def "PBS setuid should failed with tcf when purpose access device enforced for host"() { @@ -251,7 +252,7 @@ class GdprSetUidSpec extends PrivacyBaseSpec { and: "Metric should be increased usersync.BIDDER.tcf.blocked" def metric = prebidServerService.sendCollectedMetricsRequest() - assert metric["usersync.${GENERIC.value}.tcf.blocked"] == 1 + assert metric[MetricsUtil.UserSync.tcfBlocked(GENERIC)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppFetchBidActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppFetchBidActivitiesSpec.groovy index 7160c95c0ea..f0935cdb690 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppFetchBidActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppFetchBidActivitiesSpec.groovy @@ -1,5 +1,6 @@ package org.prebid.server.functional.tests.privacy.gpp +import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.config.AccountGppConfig import org.prebid.server.functional.model.config.ActivityConfig import org.prebid.server.functional.model.config.EqualityValueRule @@ -22,6 +23,7 @@ import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.model.request.auction.RegsExt import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.tests.privacy.PrivacyBaseSpec +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.gpp.v1.UsCaV1Consent import org.prebid.server.functional.util.privacy.gpp.v1.UsCoV1Consent @@ -57,11 +59,6 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.privacy.Metric.ACCOUNT_PROCESSED_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.PROCESSED_ACTIVITY_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ADAPTER_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_REQUEST_DISALLOWED_COUNT import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.CONSENT import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NOT_APPLICABLE import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NO_CONSENT @@ -108,8 +105,9 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + MetricsUtil.Privacy.requestProcessedActivityCount() + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(accountId)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(FETCH_BIDS, Activity.defaultActivity), @@ -141,9 +139,9 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, FETCH_BIDS)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(FETCH_BIDS, Activity.getDefaultActivity([ActivityRule.getDefaultActivityRule(Condition.baseCondition, false)])), @@ -292,8 +290,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(accountId)] == 1 where: regsGppSid | conditionGppSid @@ -329,9 +327,9 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, FETCH_BIDS)] == 1 where: condition << [Condition.baseCondition.tap { @@ -384,8 +382,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(accountId)] == 1 where: deviceGeo | conditionGeo @@ -430,9 +428,9 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, FETCH_BIDS)] == 1 where: deviceGeo | conditionGeo @@ -475,9 +473,9 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, FETCH_BIDS)] == 1 } def "PBS auction shouldn't disallowed rule when regs.ext.gpc doesn't intersect"() { @@ -513,8 +511,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(accountId)] == 1 } def "PBS auction should disallowed rule when header sec-gpc intersect with condition.gpc"() { @@ -549,9 +547,9 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, FETCH_BIDS)] == 1 where: gpcHeader << [VALID_VALUE_FOR_GPC_HEADER as Integer, VALID_VALUE_FOR_GPC_HEADER] @@ -589,8 +587,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(accountId)] == 1 where: gpcHeader << [1, "1"] @@ -779,9 +777,9 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { then: "Generic bidder should be called due to positive allow in activities" assert bidder.getBidderRequest(genericBidRequest.id) - and: "Metrics for disallowed activities should be updated" + and: "Alerts.general metrics should be populated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 where: gppAccountsConfig << [[new AccountGppConfig(code: IAB_US_GENERAL, config: new GppModuleConfig(skipSids: [US_NAT_V1]), enabled: false), @@ -961,9 +959,9 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { then: "Generic bidder should be called due to positive allow in activities" assert bidder.getBidderRequest(bidRequest.id) - and: "Metrics for disallowed activities should be updated" + and: "Alerts.general metrics should be populated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) @@ -1160,7 +1158,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp call when bidder rejected in activities should skip call to restricted bidders and update disallowed metrics"() { @@ -1198,8 +1196,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, FETCH_BIDS)] == 1 } def "PBS amp call when default activity setting set to false should skip call to restricted bidder"() { @@ -1394,7 +1392,7 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp should disallow rule when header gpc intersection with condition.gpc"() { @@ -1437,8 +1435,8 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(FETCH_BIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, FETCH_BIDS)] == 1 } def "PBS amp call when privacy regulation match should call bid adapter"() { @@ -1571,9 +1569,9 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { then: "Generic bidder should be called" assert bidder.getBidderRequest(ampStoredRequest.id) - and: "Metrics for disallowed activities should be updated" + and: "Alerts.general metrics should be populated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 } def "PBS amp call when privacy module contain invalid property should respond with an error"() { @@ -1770,9 +1768,9 @@ class GppFetchBidActivitiesSpec extends PrivacyBaseSpec { then: "Generic bidder should be called" assert bidder.getBidderRequests(ampStoredRequest.id) - and: "Metrics for disallowed activities should be updated" + and: "Alerts.general metrics should be populated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppSyncUserActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppSyncUserActivitiesSpec.groovy index 99540d55220..9dd4b3108ec 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppSyncUserActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppSyncUserActivitiesSpec.groovy @@ -23,6 +23,7 @@ import org.prebid.server.functional.model.request.auction.Condition import org.prebid.server.functional.model.request.cookiesync.CookieSyncRequest import org.prebid.server.functional.model.request.setuid.SetuidRequest import org.prebid.server.functional.service.PrebidServerException +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.tests.privacy.PrivacyBaseSpec import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.gpp.v1.UsCaV1Consent @@ -56,9 +57,6 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.privacy.Metric.PROCESSED_ACTIVITY_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ADAPTER_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_REQUEST_DISALLOWED_COUNT import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.CONSENT import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NOT_APPLICABLE import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NO_CONSENT @@ -83,9 +81,6 @@ import static org.prebid.server.functional.util.privacy.model.State.MANITOBA class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { - private static final String GEO_LOCATION_REQUESTS = "geolocation_requests" - private static final String GEO_LOCATION_SUCCESSFUL = "geolocation_successful" - private final static int INVALID_STATUS_CODE = 451 private final static String INVALID_STATUS_MESSAGE = "Unavailable For Legal Reasons." @@ -115,7 +110,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(SYNC_USER, Activity.defaultActivity), @@ -145,8 +140,8 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, SYNC_USER)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(SYNC_USER, Activity.getDefaultActivity([ActivityRule.getDefaultActivityRule(Condition.baseCondition, false)])), @@ -295,7 +290,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 where: gppSid | conditionGppSid @@ -337,8 +332,8 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, SYNC_USER)] == 1 } def "PBS cookie sync call when privacy regulation match and rejecting should exclude bidders URLs"() { @@ -577,8 +572,8 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Response shouldn't contain warnings" assert !response.warnings @@ -624,7 +619,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 and: "Should add a warning when in debug mode" assert response.warnings.contains("GPP string invalid: Unable to decode '$invalidGpp'".toString()) @@ -741,10 +736,10 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 and: "General alert metric shouldn't be updated" - !metrics[ALERT_GENERAL] + !metrics[MetricsUtil.General.alert()] where: regsGpp << [null, "", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] @@ -784,7 +779,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 } def "PBS cookie sync call when privacy module contain invalid code should include proper responded with bidders URLs"() { @@ -944,7 +939,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) @@ -1135,7 +1130,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(setuidRequest, SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 } def "PBS setuid request when bidder restriction by activities should reject bidders with status code invalidStatusCode and update disallowed metrics"() { @@ -1169,8 +1164,8 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(setuidRequest, SYNC_USER)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(setuidRequest, SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, SYNC_USER)] == 1 } def "PBS setuid when default activity setting set to false should reject bidders with status code invalidStatusCode"() { @@ -1337,7 +1332,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(setuidRequest, SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 where: gppSid | conditionGppSid @@ -1601,8 +1596,8 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(setuidRequest, SYNC_USER)] == 1 - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) @@ -1648,7 +1643,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(setuidRequest, SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 } def "PBS setuid request when request have different gpp consent but match and rejecting should reject bidders with status code invalidStatusCode"() { @@ -1770,10 +1765,10 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(setuidRequest, SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 and: "General alert metric shouldn't be updated" - !metrics[ALERT_GENERAL] + !metrics[MetricsUtil.General.alert()] where: regsGpp << [null, "", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] @@ -1816,7 +1811,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 } def "PBS setuid request call when privacy module contain invalid code should respond with valid bidders UIDs cookies"() { @@ -1991,7 +1986,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) @@ -2200,7 +2195,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = prebidServerService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -2259,7 +2254,7 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = prebidServerService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(setuidRequest, SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -2314,8 +2309,8 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = prebidServerService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, SYNC_USER)] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) @@ -2423,12 +2418,12 @@ class GppSyncUserActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = prebidServerService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(cookieSyncRequest, SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(SYNC_USER)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, SYNC_USER)] == 1 and: "Metrics processed across activities should be updated" - assert metrics[GEO_LOCATION_REQUESTS] == 1 - assert metrics[GEO_LOCATION_SUCCESSFUL] == 1 + assert metrics[MetricsUtil.General.geolocationRequests()] == 1 + assert metrics[MetricsUtil.General.geolocationSuccessful()] == 1 cleanup: "Stop and remove pbs container" pbsServiceFactory.removeContainer(pbsConfig) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitEidsActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitEidsActivitiesSpec.groovy index 3c6472b3d99..caff2c858fd 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitEidsActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitEidsActivitiesSpec.groovy @@ -1,5 +1,6 @@ package org.prebid.server.functional.tests.privacy.gpp +import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.config.AccountGppConfig import org.prebid.server.functional.model.config.ActivityConfig import org.prebid.server.functional.model.config.EqualityValueRule @@ -22,6 +23,7 @@ import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.model.request.auction.RegsExt import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.tests.privacy.PrivacyBaseSpec +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.gpp.v1.UsCaV1Consent import org.prebid.server.functional.util.privacy.gpp.v1.UsCoV1Consent @@ -54,11 +56,6 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.privacy.Metric.ACCOUNT_PROCESSED_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.PROCESSED_ACTIVITY_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ADAPTER_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_REQUEST_DISALLOWED_COUNT import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.CONSENT import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NOT_APPLICABLE import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NO_CONSENT @@ -104,13 +101,13 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(TRANSMIT_EIDS, Activity.defaultActivity), new AllowActivities().tap { transmitEidsKebabCase = Activity.defaultActivity }, - new AllowActivities().tap { transmitEidsSnakeCase = Activity.defaultActivity },] + new AllowActivities().tap { transmitEidsSnakeCase = Activity.defaultActivity }] } def "PBS auction call when transmit EIDS activities is rejecting requests should remove EIDS fields in request and update disallowed metrics"() { @@ -138,9 +135,9 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(TRANSMIT_EIDS, Activity.getDefaultActivity([ActivityRule.getDefaultActivityRule(Condition.baseCondition, false)])), @@ -292,8 +289,8 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 where: regsGppSid | conditionGppSid @@ -339,9 +336,9 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 } def "PBS auction should process rule when device.geo doesn't intersection"() { @@ -380,8 +377,8 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 where: deviceGeo | conditionGeo @@ -431,9 +428,9 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 where: deviceGeo | conditionGeo @@ -476,8 +473,8 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 } def "PBS auction should disallowed rule when regs.ext.gpc intersection with condition.gpc"() { @@ -520,9 +517,9 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 } def "PBS auction should process rule when header gpc doesn't intersection with condition.gpc"() { @@ -560,8 +557,8 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 } def "PBS auction should disallowed rule when header gpc intersection with condition.gpc"() { @@ -603,9 +600,9 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 } def "PBS auction call when privacy regulation match and rejecting should remove EIDS fields in request"() { @@ -887,9 +884,9 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) @@ -937,8 +934,8 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 } def "PBS auction call when request have different gpp consent but match and rejecting should remove EIDS fields in request"() { @@ -1056,11 +1053,11 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 and: "General alert metric shouldn't be updated" - !metrics[ALERT_GENERAL] + !metrics[MetricsUtil.General.alert()] where: regsGpp << [null, "", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] @@ -1099,7 +1096,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 } def "PBS auction call when privacy module contain invalid property should respond with an error"() { @@ -1265,7 +1262,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Generic bidder request should have data in EIDS fields" def genericBidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -1469,7 +1466,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp call when transmit EIDS activities is rejecting request should remove EIDS fields field in active request and update disallowed metrics"() { @@ -1509,8 +1506,8 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 } def "PBS amp call when default activity setting set to false should remove EIDS fields from request"() { @@ -1702,8 +1699,8 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 } def "PBS amp should allowed rule when gpc header doesn't intersection with condition.gpc"() { @@ -1745,7 +1742,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp call when privacy regulation match and rejecting should remove EIDS fields in request"() { @@ -2057,8 +2054,8 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Response should not contain any warnings" assert !response.ext.warnings @@ -2115,7 +2112,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 and: "Should add a warning when in debug mode" assert response.ext.warnings[PREBID]?.message.contains("GPP string invalid: Unable to decode '$invalidGpp'".toString()) @@ -2266,10 +2263,10 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 and: "General alert metric shouldn't be updated" - !metrics[ALERT_GENERAL] + !metrics[MetricsUtil.General.alert()] where: regsGpp << [null, ""] @@ -2366,7 +2363,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 } def "PBS amp call when privacy module contain invalid property should respond with an error"() { @@ -2567,7 +2564,7 @@ class GppTransmitEidsActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Generic bidder request should have data in EIDS fields" def genericBidderRequest = bidder.getBidderRequest(ampStoredRequest.id) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitPreciseGeoActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitPreciseGeoActivitiesSpec.groovy index da9dd38561f..22a694e81b6 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitPreciseGeoActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitPreciseGeoActivitiesSpec.groovy @@ -1,5 +1,6 @@ package org.prebid.server.functional.tests.privacy.gpp +import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.config.AccountGppConfig import org.prebid.server.functional.model.config.ActivityConfig import org.prebid.server.functional.model.config.EqualityValueRule @@ -21,6 +22,7 @@ import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.model.request.auction.RegsExt import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.tests.privacy.PrivacyBaseSpec +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.gpp.v1.UsCaV1Consent import org.prebid.server.functional.util.privacy.gpp.v1.UsCoV1Consent @@ -33,6 +35,7 @@ import org.prebid.server.functional.util.privacy.gpp.v2.UsNatV2Consent import java.time.Instant import static io.netty.handler.codec.http.HttpResponseStatus.UNAUTHORIZED +import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.config.LogicalRestrictedRule.LogicalOperation.AND import static org.prebid.server.functional.model.config.LogicalRestrictedRule.LogicalOperation.OR import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_BELOW_13 @@ -53,11 +56,6 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.privacy.Metric.ACCOUNT_PROCESSED_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.PROCESSED_ACTIVITY_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ADAPTER_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_REQUEST_DISALLOWED_COUNT import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.CONSENT import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NOT_APPLICABLE import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NO_CONSENT @@ -127,8 +125,8 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(accountId)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(TRANSMIT_PRECISE_GEO, Activity.defaultActivity), @@ -186,9 +184,9 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(TRANSMIT_PRECISE_GEO, Activity.getDefaultActivity([ActivityRule.getDefaultActivityRule(Condition.baseCondition, false)])), @@ -436,8 +434,8 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(accountId)] == 1 where: regsGppSid | conditionGppSid @@ -506,9 +504,9 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 } def "PBS auction should process rule when device.geo doesn't intersection"() { @@ -573,8 +571,8 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(accountId)] == 1 where: deviceGeo | conditionGeo @@ -645,8 +643,8 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(accountId)] == 1 } def "PBS auction should disallowed rule when device.geo intersection"() { @@ -715,9 +713,9 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 where: geoCountry | geoRegion | conditionGeo @@ -783,8 +781,8 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(accountId)] == 1 } def "PBS auction should disallowed rule when regs.ext.gpc intersection with condition.gpc"() { @@ -851,9 +849,9 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 } def "PBS auction should process rule when header gpc doesn't intersection with condition.gpc"() { @@ -913,8 +911,8 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(accountId)] == 1 } def "PBS auction should process rule when header gpc intersection with condition.gpc"() { @@ -978,9 +976,9 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 } def "PBS auction call when privacy regulation match and rejecting should round lat/lon data to 2 digits"() { @@ -1434,7 +1432,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 } def "PBS auction call when privacy module contain invalid code should respond with an error"() { @@ -1671,7 +1669,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) @@ -1921,7 +1919,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp call with bidder rejected in activities should round lat/lon data to 2 digits and update disallowed metrics"() { @@ -1985,8 +1983,8 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 } def "PBS amp call when default activity setting set to false should round lat/lon data to 2 digits"() { @@ -2269,7 +2267,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp should disallow rule when header gpc intersection with condition.gpc"() { @@ -2339,8 +2337,8 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_PRECISE_GEO)] == 1 } def "PBS amp call when privacy regulation match and rejecting should round lat/lon data to 2 digits"() { @@ -2774,7 +2772,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 } def "PBS amp call when privacy module contain invalid code should respond with an error"() { @@ -3046,7 +3044,7 @@ class GppTransmitPreciseGeoActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitTidActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitTidActivitiesSpec.groovy index f91df7acd50..f406ace618d 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitTidActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitTidActivitiesSpec.groovy @@ -1,5 +1,6 @@ package org.prebid.server.functional.tests.privacy.gpp +import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.Activity @@ -8,16 +9,12 @@ import org.prebid.server.functional.model.request.auction.AllowActivities import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Condition import org.prebid.server.functional.model.request.auction.Source +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.tests.privacy.PrivacyBaseSpec import org.prebid.server.functional.util.PBSUtils import java.time.Instant -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.ACCOUNT_PROCESSED_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ADAPTER_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.PROCESSED_ACTIVITY_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_REQUEST_DISALLOWED_COUNT import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_TID import static org.prebid.server.functional.model.request.auction.TraceLevel.VERBOSE @@ -56,8 +53,8 @@ class GppTransmitTidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_TID)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_TID)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(accountId)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(TRANSMIT_TID, Activity.defaultActivity), @@ -224,9 +221,9 @@ class GppTransmitTidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_TID)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_TID)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_TID)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_TID)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_TID)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_TID)] == 1 } def "PBS auction should remove bidRequest.(source/imp[0].ext).tid and don't change schain in request when ext.prebid.createTids=#createTid and defaultAction=false and schain specified in request"() { @@ -426,7 +423,7 @@ class GppTransmitTidActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_TID)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp should generate id for bidRequest.(source/imp[0].ext).tid when ext.prebid.createTids=true and transmit activity allowed"() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitUfpdActivitiesSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitUfpdActivitiesSpec.groovy index 74cdcdce28b..47e7481d236 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitUfpdActivitiesSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/gpp/GppTransmitUfpdActivitiesSpec.groovy @@ -27,6 +27,7 @@ import org.prebid.server.functional.model.request.auction.Geo import org.prebid.server.functional.model.request.auction.RegsExt import org.prebid.server.functional.service.PrebidServerException import org.prebid.server.functional.tests.privacy.PrivacyBaseSpec +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.gpp.v1.UsCaV1Consent import org.prebid.server.functional.util.privacy.gpp.v1.UsCoV1Consent @@ -40,6 +41,7 @@ import org.prebid.server.functional.util.privacy.gpp.v2.UsNatV2Consent import java.time.Instant import static io.netty.handler.codec.http.HttpResponseStatus.UNAUTHORIZED +import static org.prebid.server.functional.model.bidder.BidderName.GENERIC import static org.prebid.server.functional.model.config.LogicalRestrictedRule.LogicalOperation.AND import static org.prebid.server.functional.model.config.LogicalRestrictedRule.LogicalOperation.OR import static org.prebid.server.functional.model.config.UsNationalPrivacySection.CHILD_CONSENTS_BELOW_13 @@ -60,11 +62,6 @@ import static org.prebid.server.functional.model.config.UsNationalPrivacySection import static org.prebid.server.functional.model.config.UsNationalPrivacySection.SHARING_NOTICE import static org.prebid.server.functional.model.pricefloors.Country.CAN import static org.prebid.server.functional.model.pricefloors.Country.USA -import static org.prebid.server.functional.model.privacy.Metric.ACCOUNT_PROCESSED_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.PROCESSED_ACTIVITY_RULES_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ADAPTER_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_REQUEST_DISALLOWED_COUNT import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.CONSENT import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NOT_APPLICABLE import static org.prebid.server.functional.model.privacy.gpp.GppDataActivity.NO_CONSENT @@ -129,8 +126,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(TRANSMIT_UFPD, Activity.defaultActivity), @@ -179,9 +176,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 where: "Activities fields name in different case" activities << [AllowActivities.getDefaultAllowActivities(TRANSMIT_UFPD, Activity.getDefaultActivity([ActivityRule.getDefaultActivityRule(Condition.baseCondition, false)])), @@ -402,8 +399,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 where: regsGppSid | conditionGppSid @@ -464,9 +461,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 } def "PBS auction should process rule when device.geo doesn't intersection"() { @@ -524,8 +521,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 where: deviceGeo | conditionGeo @@ -590,9 +587,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 where: deviceGeo | conditionGeo @@ -654,8 +651,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 } def "PBS auction should disallowed rule when regs.ext.gpc intersection with condition.gpc"() { @@ -713,9 +710,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 } def "PBS auction should process rule when header gpc doesn't intersection with condition.gpc"() { @@ -772,8 +769,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 } def "PBS auction should disallowed rule when header gpc intersection with condition.gpc"() { @@ -830,9 +827,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 } def "PBS auction call when privacy regulation match and rejecting should remove UFPD fields in request"() { @@ -1322,9 +1319,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Logs should contain error" def logs = activityPbsService.getLogsByTime(startTime) @@ -1392,8 +1389,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 } def "PBS auction call when request have different gpp consent but match and rejecting should remove UFPD fields in request"() { @@ -1566,11 +1563,11 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ACCOUNT_PROCESSED_RULES_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.Privacy.accountProcessedRulesCount(bidRequest.accountId)] == 1 and: "General alert metric shouldn't be updated" - !metrics[ALERT_GENERAL] + !metrics[MetricsUtil.General.alert()] where: regsGpp << [null, "", new UsNatV1Consent.Builder().build(), new UsNatV1Consent.Builder().setGpc(false).build()] @@ -1627,9 +1624,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Generic bidder request should have data in EIDS fields" assert bidderRequest.user.eids == bidRequest.user.eids - and: "Metrics for disallowed activities should be updated" + and: "Alerts.general metrics should be populated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 } def "PBS auction call when privacy module contain invalid property should respond with an error"() { @@ -1826,9 +1823,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Response should not contain any errors" assert !response.ext.errors - and: "Metrics for disallowed activities should be updated" + and: "Alerts.general metrics should be populated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Generic bidder request should have data in UFPD fields" def bidderRequest = bidder.getBidderRequest(bidRequest.id) @@ -2086,7 +2083,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp call when transmit UFPD activities is rejecting request should remove UFPD fields field in active request and update disallowed metrics"() { @@ -2141,8 +2138,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 } def "PBS amp call when default activity setting set to false should remove UFPD fields from request"() { @@ -2399,8 +2396,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 } def "PBS amp should allowed rule when gpc header doesn't intersection with condition.gpc"() { @@ -2461,7 +2458,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 } def "PBS amp call when privacy regulation match and rejecting should remove UFPD fields in request"() { @@ -2936,8 +2933,8 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Response should not contain any warnings" assert !response.ext.warnings @@ -3014,7 +3011,7 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 and: "Should add a warning when in debug mode" assert response.ext.warnings[PREBID]?.message.contains("GPP string invalid: Unable to decode '$invalidGpp'".toString()) @@ -3218,10 +3215,10 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[PROCESSED_ACTIVITY_RULES_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestProcessedActivityCount()] == 1 and: "General alert metric shouldn't be updated" - !metrics[ALERT_GENERAL] + !metrics[MetricsUtil.General.alert()] where: regsGpp << [null, ""] @@ -3354,9 +3351,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Generic bidder request should have data in EIDS fields" assert bidderRequest.user.eids == ampStoredRequest.user.eids - and: "Metrics for disallowed activities should be updated" + and: "Alerts.general metrics should be populated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 } def "PBS amp call when privacy module contain invalid property should respond with an error"() { @@ -3588,9 +3585,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Response should contain consent_string error" assert response.ext.errors[PREBID].message == ["Amp request parameter consent_string has invalid format: $gppConsent"] - and: "Metrics for disallowed activities should be updated" + and: "Alerts.general metrics should be populated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[ALERT_GENERAL] == 1 + assert metrics[MetricsUtil.General.alert()] == 1 and: "Generic bidder request should have data in UFPD fields" def bidderRequest = bidder.getBidderRequest(ampStoredRequest.id) @@ -3851,9 +3848,9 @@ class GppTransmitUfpdActivitiesSpec extends PrivacyBaseSpec { and: "Metrics for disallowed activities should be updated" def metrics = activityPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(accountId, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(GENERIC, TRANSMIT_UFPD)] == 1 where: eid << [new PurposeEid(activityTransition: false), diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/lmt/LmtSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/lmt/LmtSpec.groovy index ffbd958a508..3a24386addd 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/lmt/LmtSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/lmt/LmtSpec.groovy @@ -1,16 +1,15 @@ package org.prebid.server.functional.tests.privacy.lmt +import org.prebid.server.functional.model.bidder.BidderName import org.prebid.server.functional.model.db.StoredRequest import org.prebid.server.functional.model.request.amp.AmpRequest import org.prebid.server.functional.model.request.auction.BidRequest import org.prebid.server.functional.model.request.auction.Device import org.prebid.server.functional.model.request.auction.DeviceExt import org.prebid.server.functional.tests.privacy.PrivacyBaseSpec +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ACCOUNT_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_ADAPTER_DISALLOWED_COUNT -import static org.prebid.server.functional.model.privacy.Metric.TEMPLATE_REQUEST_DISALLOWED_COUNT import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_EIDS import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_PRECISE_GEO import static org.prebid.server.functional.model.request.auction.ActivityType.TRANSMIT_UFPD @@ -391,15 +390,15 @@ class LmtSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 } def "PBS auction should mask device and user fields for auction request and emit metrics when device.lm = 1 was passed and trace basic"() { @@ -461,17 +460,17 @@ class LmtSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 and: "Account metrics shouldn't be populated" - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] } def "PBS auction shouldn't mask device and user fields for auction request when device.lm = 0 was passed"() { @@ -523,15 +522,15 @@ class LmtSpec extends PrivacyBaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(bidRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(bidRequest.accountId, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] } def "PBS amp should mask device and user fields for auction request when device.lm = 1 was passed"() { @@ -597,15 +596,15 @@ class LmtSpec extends PrivacyBaseSpec { and: "Metrics processed across activities should be updated" def metrics = defaultPbsService.sendCollectedMetricsRequest() - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_ACCOUNT_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] == 1 - assert metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(ampStoredRequest.accountId, TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(ampStoredRequest.accountId, TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.accountDisallowedActivityCount(ampStoredRequest.accountId, TRANSMIT_PRECISE_GEO)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] == 1 + assert metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] == 1 } def "PBS amp shouldn't mask device and user fields for auction request when device.lm = 0 was passed"() { @@ -662,12 +661,12 @@ class LmtSpec extends PrivacyBaseSpec { and: "Metrics processed across activities shouldn't be updated" def metrics = privacyPbsService.sendCollectedMetricsRequest() - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_ADAPTER_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_UFPD)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_EIDS)] - assert !metrics[TEMPLATE_REQUEST_DISALLOWED_COUNT.getValue(ampStoredRequest, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.adapterDisallowedActivityCount(BidderName.GENERIC, TRANSMIT_PRECISE_GEO)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_UFPD)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_EIDS)] + assert !metrics[MetricsUtil.Privacy.requestDisallowedActivityCount(TRANSMIT_PRECISE_GEO)] } private static getRandomAtts() { diff --git a/src/test/groovy/org/prebid/server/functional/tests/privacy/tcf/TcfGeneralSpec.groovy b/src/test/groovy/org/prebid/server/functional/tests/privacy/tcf/TcfGeneralSpec.groovy index 4892e19fc37..8ad562656d1 100644 --- a/src/test/groovy/org/prebid/server/functional/tests/privacy/tcf/TcfGeneralSpec.groovy +++ b/src/test/groovy/org/prebid/server/functional/tests/privacy/tcf/TcfGeneralSpec.groovy @@ -7,6 +7,7 @@ import org.prebid.server.functional.model.config.PurposeConfig import org.prebid.server.functional.model.privacy.EnforcementRequirement import org.prebid.server.functional.model.response.auction.NoBidResponse import org.prebid.server.functional.service.PrebidServerService +import org.prebid.server.functional.util.MetricsUtil import org.prebid.server.functional.util.PBSUtils import org.prebid.server.functional.util.privacy.TcfConsent import org.prebid.server.functional.util.privacy.TcfUtils @@ -22,7 +23,6 @@ class TcfGeneralSpec extends TcfBaseSpec { private final static ZonedDateTime TCF_2_3_ENFORCEMENT_DATE = ZonedDateTime.parse("2026-03-01T00:00:00Z") private final static Map STRICT_DISCLOSED_VENDOR_TREATMENT_CONFIG = TCF_BASE_CONFIG + ["gdpr.strict-disclosed-vendors-treatment": 'true'] - private final static TCF_NO_DISCLOSED_VENDORS_METRIC = 'privacy.tcf.no-disclosed-vendors' private final static DISCLOSED_VENDORS_MESSAGE = 'Invalid TCF string: `disclosedVendors` list is empty.' private static PrebidServerService pbsWithoutGvlVendorsWithStrictDvTreatment @@ -69,7 +69,7 @@ class TcfGeneralSpec extends TcfBaseSpec { and: "PBS shouldn't emit no disclosed vendors metric" def metrics = pbsWithoutGvlVendorsWithStrictDvTreatment.sendCollectedMetricsRequest() - assert !metrics[TCF_NO_DISCLOSED_VENDORS_METRIC] + assert !metrics[MetricsUtil.Privacy.noDisclosedVendors()] and: "PBS should send bid request to bidder" assert bidder.getBidderRequests(bidRequest.id).size() == 1 @@ -106,7 +106,7 @@ class TcfGeneralSpec extends TcfBaseSpec { and: "PBS shouldn't emit no disclosed vendors metric" def metrics = pbsWithMultipleGvlListsWithStrictDvTreatment.sendCollectedMetricsRequest() - assert !metrics[TCF_NO_DISCLOSED_VENDORS_METRIC] + assert !metrics[MetricsUtil.Privacy.noDisclosedVendors()] and: "PBS should send bid request to bidder" assert bidder.getBidderRequests(bidRequest.id).size() == 1 @@ -144,7 +144,7 @@ class TcfGeneralSpec extends TcfBaseSpec { and: "PBS shouldn't emit no disclosed vendors metric" def metrics = pbsWithoutGvlVendorsWithStrictDvTreatment.sendCollectedMetricsRequest() - assert !metrics[TCF_NO_DISCLOSED_VENDORS_METRIC] + assert !metrics[MetricsUtil.Privacy.noDisclosedVendors()] and: "PBS should send bid request to bidder" assert bidder.getBidderRequests(bidRequest.id).size() == 1 @@ -185,7 +185,7 @@ class TcfGeneralSpec extends TcfBaseSpec { and: "PBS shouldn't emit no disclosed vendors metric" def metrics = pbsWithMultipleGvlListsWithStrictDvTreatment.sendCollectedMetricsRequest() - assert !metrics[TCF_NO_DISCLOSED_VENDORS_METRIC] + assert !metrics[MetricsUtil.Privacy.noDisclosedVendors()] and: "PBS should send bid request to bidder" assert bidder.getBidderRequests(bidRequest.id).size() == 1 @@ -226,7 +226,7 @@ class TcfGeneralSpec extends TcfBaseSpec { and: "PBS should emit no disclosed vendors metric" def metrics = pbsWithoutGvlVendorsWithStrictDvTreatment.sendCollectedMetricsRequest() - assert metrics[TCF_NO_DISCLOSED_VENDORS_METRIC] == 1 + assert metrics[MetricsUtil.Privacy.noDisclosedVendors()] == 1 and: "PBS should not send bid request to bidder" assert !bidder.getBidderRequests(bidRequest.id) @@ -267,7 +267,7 @@ class TcfGeneralSpec extends TcfBaseSpec { and: "PBS should emit no disclosed vendors metric" def metrics = pbsWithMultipleGvlListsWithStrictDvTreatment.sendCollectedMetricsRequest() - assert metrics[TCF_NO_DISCLOSED_VENDORS_METRIC] == 1 + assert metrics[MetricsUtil.Privacy.noDisclosedVendors()] == 1 and: "PBS should not send bid request to bidder" assert !bidder.getBidderRequests(bidRequest.id) @@ -417,7 +417,7 @@ class TcfGeneralSpec extends TcfBaseSpec { and: "PBS should emit no disclosed vendors metric" def metrics = pbsService.sendCollectedMetricsRequest() - assert metrics[TCF_NO_DISCLOSED_VENDORS_METRIC] == 1 + assert metrics[MetricsUtil.Privacy.noDisclosedVendors()] == 1 where: pbsService | serviceName diff --git a/src/test/groovy/org/prebid/server/functional/util/MetricsUtil.groovy b/src/test/groovy/org/prebid/server/functional/util/MetricsUtil.groovy new file mode 100644 index 00000000000..2c7215aee80 --- /dev/null +++ b/src/test/groovy/org/prebid/server/functional/util/MetricsUtil.groovy @@ -0,0 +1,410 @@ +package org.prebid.server.functional.util + +import org.prebid.server.functional.model.ChannelType +import org.prebid.server.functional.model.bidder.BidderName +import org.prebid.server.functional.model.config.ModuleName +import org.prebid.server.functional.model.config.Stage +import org.prebid.server.functional.model.request.auction.ActivityType + +class MetricsUtil { + + static class General { + + static String alert() { + 'alerts.general' + } + + static String impsRequested() { + 'imps_requested' + } + + static String impsDropped() { + 'imps_dropped' + } + + static String debugRequests() { + 'debug_requests' + } + + static String floorsFetchFailure() { + 'price-floors.fetch.failure' + } + + static String storedRequestFound() { + 'stored_requests_found' + } + + static String geolocationRequests() { + 'geolocation_requests' + } + + static String geolocationFail() { + 'geolocation_fail' + } + + static String geolocationSuccessful() { + 'geolocation_successful' + } + + static String requestOk(ChannelType channel) { + "requests.ok.openrtb2-${channel.value}" + } + } + + static class Module { + + static String call(ModuleName name, Stage stage) { + getBasicModuleMetric(name, stage, 'call') + } + + static String noop(ModuleName name, Stage stage) { + getBasicModuleMetric(name, stage, 'success.noop') + } + + static String update(ModuleName name, Stage stage) { + getBasicModuleMetric(name, stage, 'success.update') + } + + static String noInvocation(ModuleName name, Stage stage) { + getBasicModuleMetric(name, stage, 'success.no-invocation') + } + + static String executionError(ModuleName name, Stage stage) { + getBasicModuleMetric(name, stage, 'execution-error') + } + + private static String getBasicModuleMetric(ModuleName name, Stage stage, String suffix) { + "modules.module.${name.code}.stage.${stage.metricValue}.hook.${name.code}-${stage.value}-hook.${suffix}" + } + } + + static class Cache { + + static String requestsOk() { + 'prebid_cache.requests.ok' + } + + static String creativeSizeJson() { + 'prebid_cache.creative_size.json' + } + + static String creativeSizeXml() { + 'prebid_cache.creative_size.xml' + } + + static String creativeTtlJson() { + 'prebid_cache.creative_ttl.json' + } + + static String creativeTtlXml() { + 'prebid_cache.creative_ttl.xml' + } + + static String accountCreativeSizeJson(String accountId) { + accountMetric(accountId, "creative_size.json") + } + + static String accountCreativeSizeXml(String accountId) { + accountMetric(accountId, "creative_size.xml") + } + + static String accountCreativeTtlJson(String accountId) { + accountMetric(accountId, "creative_ttl.json") + } + + static String accountCreativeTtlXml(String accountId) { + accountMetric(accountId, "creative_ttl.xml") + } + + static String accountRequestsOk(String accountId) { + accountMetric(accountId, "requests.ok") + } + + static String creativeSizeText(ModuleName name) { + moduleStorageMetric(name, "entry_size.text") + } + + static String creativeTtlText(ModuleName name) { + moduleStorageMetric(name, "entry_ttl.text") + } + + static String readOk(ModuleName name) { + moduleStorageMetric(name, "read.ok") + } + + static String readErr(ModuleName name) { + moduleStorageMetric(name, "read.err") + } + + static String writeOk(ModuleName name) { + moduleStorageMetric(name, "write.ok") + } + + static String writeErr(ModuleName name) { + moduleStorageMetric(name, "write.err") + } + + static String vtrackCreativeSizeXml() { + vtrackMetric("creative_size.xml") + } + + static String vtrackCreativeTtlXml() { + vtrackMetric("creative_ttl.xml") + } + + static String vtrackWriteOk() { + vtrackMetric("write.ok") + } + + static String vtrackWriteErr() { + vtrackMetric("write.err") + } + + static String vtrackReadOk() { + vtrackMetric("read.ok") + } + + static String vtrackReadErr() { + vtrackMetric("read.err") + } + + private static String accountMetric(String accountId, String suffix) { + "account.${accountId}.prebid_cache.${suffix}" + } + + private static String moduleStorageMetric(ModuleName name, String suffix) { + "prebid_cache.module_storage.${name.code}.${suffix}" + } + + private static String vtrackMetric(String suffix) { + "prebid_cache.vtrack.${suffix}" + } + } + + static class Account { + + static String invalidConfigFloors(String accountId) { + "alerts.account_config.${accountId}.price-floors" + } + + static String requestType(String accountId, ChannelType channel) { + baseMetric(accountId, "requests.type.openrtb2-${channel.value}") + } + + static String debugRequests(String accountId) { + baseMetric(accountId, "debug_requests") + } + + static String cacheVtrackCreativeSizeXml(String accountId) { + baseMetric(accountId, "prebid_cache.vtrack.creative_size.xml") + } + + static String cacheVtrackCreativeTtlXml(String accountId) { + baseMetric(accountId, "prebid_cache.vtrack.creative_ttl.xml") + } + + static String cacheVtrackWriteOk(String accountId) { + baseMetric(accountId, "prebid_cache.vtrack.write.ok") + } + + static String cacheVtrackWriteErr(String accountId) { + baseMetric(accountId, "prebid_cache.vtrack.write.err") + } + + static String profilesLimitExceeded(String accountId) { + baseMetric(accountId, "profiles.limit_exceeded") + } + + static String profilesMissing(String accountId) { + baseMetric(accountId, "profiles.missing") + } + + static String rejectedInvalidAccount(String accountId) { + baseMetric(accountId, "requests.rejected.invalid-account") + } + + static String requests(String accountId) { + baseMetric(accountId, "requests") + } + + static String buyerUidScrubbed(String accountId, BidderName bidder) { + adapterMetric(accountId, bidder, "requests.buyeruid_scrubbed") + } + + static String bidsReceived(String accountId, BidderName bidder) { + adapterMetric(accountId, bidder, "bids_received") + } + + static String prices(String accountId, BidderName bidder) { + adapterMetric(accountId, bidder, "prices") + } + + static String requestTime(String accountId, BidderName bidder) { + adapterMetric(accountId, bidder, "request_time") + } + + static String requestsGotBids(String accountId, BidderName bidder) { + adapterMetric(accountId, bidder, "requests.gotbids") + } + + static String validationSizeWarn(String accountId) { + baseMetric(accountId, "response.validation.size.warn") + } + + static String validationSizeError(String accountId) { + baseMetric(accountId, "response.validation.size.err") + } + + static String validationSecureWarn(String accountId) { + baseMetric(accountId, "response.validation.secure.warn") + } + + static String validationSecureError(String accountId) { + baseMetric(accountId, "response.validation.secure.err") + } + + private static String adapterMetric(String accountId, BidderName bidder, String suffix) { + baseMetric(accountId, "adapter.${bidder.value}.${suffix}") + } + + private static String baseMetric(String accountId, String suffix) { + "account.${accountId}.${suffix}" + } + } + + static class Adapter { + + private static String request(BidderName adapter, String suffix) { + metric(adapter, 'requests', suffix) + } + + static String validationSeat(BidderName bidder) { + response(bidder, 'validation.seat') + } + + static String requestType(BidderName bidder, ChannelType channel) { + request(bidder, "type.openrtb2-${channel.value}") + } + + static String buyerUidScrubbed(BidderName bidder) { + request(bidder, 'buyeruid_scrubbed') + } + + static String validationSizeWarn(BidderName bidder) { + response(bidder, 'validation.size.warn') + } + + static String validationSizeError(BidderName bidder) { + response(bidder, 'validation.size.err') + } + + static String validationSecureWarn(BidderName bidder) { + response(bidder, 'validation.secure.warn') + } + + static String bidValidation(BidderName bidder) { + request(bidder, 'bid_validation') + } + + static String validationSecureError(BidderName bidder) { + response(bidder, 'validation.secure.err') + } + + private static String response(BidderName adapter, String suffix) { + metric(adapter, 'response', suffix) + } + + private static String metric(BidderName adapter, String type, String suffix) { + "adapter.${adapter.value}.${type}.${suffix}" + } + } + + static class Privacy { + + static String noDisclosedVendors() { + 'privacy.tcf.no-disclosed-vendors' + } + + static String tcfVendorListMissing(Integer version) { + tcfMetric(version, 'vendorlist.missing') + } + + static String tcfInGeo(Integer version) { + tcfMetric(version, 'in-geo') + } + + static String tcfOutGeo(Integer version) { + tcfMetric(version, 'out-geo') + } + + static String requestProcessedActivityCount() { + processedRulesMetric('requests') + } + + static String requestDisallowedActivityCount(ActivityType activity) { + activityMetric('requests', activity) + } + + static String adapterDisallowedActivityCount(BidderName bidder, ActivityType activity) { + activityMetric("adapter.${bidder.value}", activity) + } + + static String accountDisallowedActivityCount(String accountId, ActivityType activity) { + activityMetric("account.${accountId}", activity) + } + + static String accountProcessedRulesCount(String accountId) { + processedRulesMetric("account.${accountId}") + } + + private static String activityMetric(String prefix, ActivityType activity) { + "${prefix}.activity.${activity.metricValue}.disallowed.count" + } + + private static String processedRulesMetric(String prefix) { + "${prefix}.activity.processedrules.count" + } + + private static String tcfMetric(Integer version, String suffix) { + "privacy.tcf.v${version}.${suffix}" + } + } + + static class CookieSync { + + static String tcfBlocked(BidderName adapter) { + cookieBaseMetric(adapter, 'tcf.blocked') + } + + static String filtered(BidderName adapter) { + cookieBaseMetric(adapter, 'filtered') + } + + private static String cookieBaseMetric(BidderName adapter, String suffix) { + "cookie_sync.${adapter.value}.${suffix}" + } + } + + static class UserSync { + + static String sizeBlocked(BidderName adapter) { + userSyncBaseMetric(adapter, 'sizeblocked') + } + + static String sets(BidderName adapter) { + userSyncBaseMetric(adapter, 'sets') + } + + static String tcfBlocked(BidderName adapter) { + userSyncBaseMetric(adapter, 'tcf.blocked') + } + + static String sizedOut(BidderName adapter) { + userSyncBaseMetric(adapter, 'sizedout') + } + + private static String userSyncBaseMetric(BidderName adapter, String suffix) { + "usersync.${adapter.value}.${suffix}" + } + } +}