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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ private Future<Account> wrapFailure(Throwable exception, String accountId, HttpR
if (exception instanceof UnauthorizedAccountException) {
return Future.failedFuture(exception);
} else if (exception instanceof PreBidException) {
unknownAccountLogger.warn(accountErrorMessage(exception.getMessage(), httpRequest), 100);
unknownAccountLogger.warn(accountErrorMessage(exception.getMessage(), httpRequest), logSamplingRate);
} else {
metrics.updateAccountRequestRejectedByFailedFetch(accountId);
logger.warn("Error occurred while fetching account: {}", exception.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ import groovy.transform.ToString
@ToString
enum Endpoint {

OPENRTB2_AUCTION("/openrtb2/auction"),
OPENRTB2_AMP("/openrtb2/amp"),
OPENRTB2_VIDEO("/openrtb2/video"),
AUCTION("/openrtb2/auction"),
AMP("/openrtb2/amp"),
VIDEO("/openrtb2/video"),
COOKIE_SYNC("/cookie_sync"),
SETUID("/setuid"),
BIDDER_PARAMS("/bidders/params"),
EVENT("/event"),
GETUIDS("/getuids"),
INFO_BIDDERS("/info/bidders"),
OPTOUT("/optout"),
CURRENCY_RATES("/currency/rates"),
HTTP_INTERACTION("/logging/httpinteraction"),
COLLECTED_METRICS("/collected-metrics"),
PROMETHEUS_METRICS ("/metrics"),
INFLUX_DB("/query"),
STATUS("/status"),
VTRACK("/vtrack")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ import org.prebid.server.functional.model.ModuleName
class ExecutionPlan {

List<AbTest> abTests
Map<Endpoint, EndpointExecutionPlan> endpoints
Map<HookHttpEndpoint, EndpointExecutionPlan> endpoints

static ExecutionPlan getSingleEndpointExecutionPlan(Endpoint endpoint, ModuleName moduleName, List<Stage> stage) {
static ExecutionPlan getSingleEndpointExecutionPlan(HookHttpEndpoint endpoint, ModuleName moduleName, List<Stage> stage) {
new ExecutionPlan(endpoints: [(endpoint): EndpointExecutionPlan.getModuleEndpointExecutionPlan(moduleName, stage)])
}

static ExecutionPlan getSingleEndpointExecutionPlan(Endpoint endpoint, Map<Stage, List<ModuleName>> modulesStages) {
static ExecutionPlan getSingleEndpointExecutionPlan(HookHttpEndpoint endpoint, Map<Stage, List<ModuleName>> modulesStages) {
new ExecutionPlan(endpoints: [(endpoint): EndpointExecutionPlan.getModulesEndpointExecutionPlan(modulesStages)])
}

List<String> getListOfModuleCodes() {
endpoints.values().stages*.values().groups.hookSequence.moduleCode.flatten() as List<String>
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.prebid.server.functional.model.config

import com.fasterxml.jackson.annotation.JsonValue
import groovy.transform.ToString

@ToString
enum HookHttpEndpoint {

AUCTION("/openrtb2/auction"),
AUCTION_GET("GET /openrtb2/auction"),
AUCTION_POST("POST /openrtb2/auction"),

AMP("/openrtb2/amp"),
AMP_GET("GET /openrtb2/amp"),
AMP_POST("POST /openrtb2/amp"),

VIDEO("/openrtb2/video"),
VIDEO_GET("GET /openrtb2/video"),
VIDEO_POST("POST /openrtb2/video"),

@JsonValue
final String value

HookHttpEndpoint(String value) {
this.value = value
}

@Override
String toString() {
value
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,26 @@ import java.time.format.DateTimeFormatter

import static io.restassured.RestAssured.given
import static java.time.ZoneOffset.UTC
import static org.prebid.server.functional.model.config.Endpoint.AMP
import static org.prebid.server.functional.model.config.Endpoint.AUCTION
import static org.prebid.server.functional.model.config.Endpoint.BIDDER_PARAMS
import static org.prebid.server.functional.model.config.Endpoint.COLLECTED_METRICS
import static org.prebid.server.functional.model.config.Endpoint.COOKIE_SYNC
import static org.prebid.server.functional.model.config.Endpoint.CURRENCY_RATES
import static org.prebid.server.functional.model.config.Endpoint.EVENT
import static org.prebid.server.functional.model.config.Endpoint.GETUIDS
import static org.prebid.server.functional.model.config.Endpoint.HTTP_INTERACTION
import static org.prebid.server.functional.model.config.Endpoint.INFLUX_DB
import static org.prebid.server.functional.model.config.Endpoint.INFO_BIDDERS
import static org.prebid.server.functional.model.config.Endpoint.PROMETHEUS_METRICS
import static org.prebid.server.functional.model.config.Endpoint.SETUID
import static org.prebid.server.functional.model.config.Endpoint.STATUS
import static org.prebid.server.functional.model.config.Endpoint.VTRACK
import static org.prebid.server.functional.testcontainers.Dependencies.influxdbContainer


class PrebidServerService implements ObjectMapperWrapper {

static final String AUCTION_ENDPOINT = "/openrtb2/auction"
static final String AMP_ENDPOINT = "/openrtb2/amp"
static final String COOKIE_SYNC_ENDPOINT = "/cookie_sync"
static final String SET_UID_ENDPOINT = "/setuid"
static final String GET_UIDS_ENDPOINT = "/getuids"
static final String EVENT_ENDPOINT = "/event"
static final String VTRACK_ENDPOINT = "/vtrack"
static final String STATUS_ENDPOINT = "/status"
static final String INFO_BIDDERS_ENDPOINT = "/info/bidders"
static final String BIDDERS_PARAMS_ENDPOINT = "/bidders/params"
static final String CURRENCY_RATES_ENDPOINT = "/currency/rates"
static final String HTTP_INTERACTION_ENDPOINT = "/logging/httpinteraction"
static final String COLLECTED_METRICS_ENDPOINT = "/collected-metrics"
static final String PROMETHEUS_METRICS_ENDPOINT = "/metrics"
static final String INFLUX_DB_ENDPOINT = "/query"
static final String UIDS_COOKIE_NAME = "uids"

private final PrebidServerContainer pbsContainer
Expand Down Expand Up @@ -190,7 +190,7 @@ class PrebidServerService implements ObjectMapperWrapper {
.cookies(cookies)
.queryParams(toMap(request))
.headers(header)
.get(SET_UID_ENDPOINT)
.get(SETUID.value)

checkResponseStatusCode(response)

Expand All @@ -206,7 +206,7 @@ class PrebidServerService implements ObjectMapperWrapper {
def uidsCookieAsEncodedJson = Base64.urlEncoder.encodeToString(uidsCookieAsJson.bytes)

def response = given(requestSpecification).cookie(UIDS_COOKIE_NAME, uidsCookieAsEncodedJson)
.get(GET_UIDS_ENDPOINT)
.get(GETUIDS.value)

checkResponseStatusCode(response)
decode(response.body.asString(), GetuidResponse)
Expand All @@ -215,7 +215,7 @@ class PrebidServerService implements ObjectMapperWrapper {
byte[] sendEventRequest(EventRequest eventRequest, Map<String, String> headers = [:]) {
def response = given(requestSpecification).headers(headers)
.queryParams(toMap(eventRequest))
.get(EVENT_ENDPOINT)
.get(EVENT.value)

checkResponseStatusCode(response)
response.body.asByteArray()
Expand All @@ -224,7 +224,7 @@ class PrebidServerService implements ObjectMapperWrapper {
PrebidCacheResponse sendPostVtrackRequest(VtrackRequest request, String account) {
def response = given(requestSpecification).queryParams(["a": account])
.body(request)
.post(VTRACK_ENDPOINT)
.post(VTRACK.value)

checkResponseStatusCode(response)
decode(response.body.asString(), PrebidCacheResponse)
Expand All @@ -233,65 +233,65 @@ class PrebidServerService implements ObjectMapperWrapper {
TransferValue sendGetVtrackRequest(Map<String, Object> parameters) {
def response = given(requestSpecification)
.queryParams(parameters)
.get(VTRACK_ENDPOINT)
.get(VTRACK.value)

checkResponseStatusCode(response)
decode(response.body.asString(), TransferValue)
}

StatusResponse sendStatusRequest() {
def response = given(requestSpecification).get(STATUS_ENDPOINT)
def response = given(requestSpecification).get(STATUS.value)

checkResponseStatusCode(response)
decode(response.body.asString(), StatusResponse)
}

String sendInfoBiddersRequest() {
def response = given(requestSpecification).get(INFO_BIDDERS_ENDPOINT)
def response = given(requestSpecification).get(INFO_BIDDERS.value)

checkResponseStatusCode(response)
response.body().asString()
}

List<String> sendInfoBiddersRequest(Map<String, String> queryParam) {
def response = given(requestSpecification).queryParams(queryParam).get(INFO_BIDDERS_ENDPOINT)
def response = given(requestSpecification).queryParams(queryParam).get(INFO_BIDDERS.value)

checkResponseStatusCode(response)
decode(response.asString(), new TypeReference<List<String>>() {})
}

BidderInfoResponse sendBidderInfoRequest(BidderName bidderName) {

def response = given(requestSpecification).get("$INFO_BIDDERS_ENDPOINT/$bidderName.value")
def response = given(requestSpecification).get("${INFO_BIDDERS.value}/$bidderName.value")

checkResponseStatusCode(response)
decode(response.body.asString(), BidderInfoResponse)
}

BiddersParamsResponse sendBiddersParamsRequest() {
def response = given(requestSpecification).get(BIDDERS_PARAMS_ENDPOINT)
def response = given(requestSpecification).get(BIDDER_PARAMS.value)

checkResponseStatusCode(response)
decode(response.body.asString(), BiddersParamsResponse)
}

CurrencyRatesResponse sendCurrencyRatesRequest() {
def response = given(adminRequestSpecification).get(CURRENCY_RATES_ENDPOINT)
def response = given(adminRequestSpecification).get(CURRENCY_RATES.value)

checkResponseStatusCode(response)
decode(response.body.asString(), CurrencyRatesResponse)
}

String sendLoggingHttpInteractionRequest(HttpInteractionRequest httpInteractionRequest) {
def response = given(adminRequestSpecification).queryParams(toMap(httpInteractionRequest))
.get(HTTP_INTERACTION_ENDPOINT)
.get(HTTP_INTERACTION.value)

checkResponseStatusCode(response)
response.body().asString()
}

Map<String, Number> sendCollectedMetricsRequest() {
def response = given(adminRequestSpecification).get(COLLECTED_METRICS_ENDPOINT)
def response = given(adminRequestSpecification).get(COLLECTED_METRICS.value)

checkResponseStatusCode(response)
decode(response.asString(), new TypeReference<Map<String, Number>>() {})
Expand All @@ -301,14 +301,14 @@ class PrebidServerService implements ObjectMapperWrapper {
def response = given(influxRequestSpecification)
.queryParams(["db": influxdbContainer.getDatabase(),
"q" : "SELECT COUNT(count) FROM /.*/ WHERE count >= 1 GROUP BY \"measurement\""])
.get(INFLUX_DB_ENDPOINT)
.get(INFLUX_DB.value)

checkResponseStatusCode(response)
collectInToMap(decode(response.getBody().asString(), InfluxResponse))
}

String sendPrometheusMetricsRequest() {
def response = given(prometheusRequestSpecification).get(PROMETHEUS_METRICS_ENDPOINT)
def response = given(prometheusRequestSpecification).get(PROMETHEUS_METRICS.value)

checkResponseStatusCode(response)
response.body().asString()
Expand All @@ -324,7 +324,7 @@ class PrebidServerService implements ObjectMapperWrapper {

given(requestSpecification).headers(headers)
.body(payload)
.post(AUCTION_ENDPOINT)
.post(AUCTION.value)
}

private Response postCookieSync(CookieSyncRequest cookieSyncRequest,
Expand Down Expand Up @@ -355,7 +355,7 @@ class PrebidServerService implements ObjectMapperWrapper {
requestSpecification.headers(headers)
}

requestSpecification.post(COOKIE_SYNC_ENDPOINT)
requestSpecification.post(COOKIE_SYNC.value)
}

private Response getAmp(AmpRequest ampRequest,
Expand All @@ -369,7 +369,7 @@ class PrebidServerService implements ObjectMapperWrapper {

given(requestSpecification).headers(headers)
.queryParams(map)
.get(AMP_ENDPOINT)
.get(AMP.value)
}

private void checkResponseStatusCode(Response response, int statusCode = 200) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.testcontainers.containers.GenericContainer
import org.testcontainers.containers.wait.strategy.Wait
import org.testcontainers.images.builder.Transferable

import static org.prebid.server.functional.model.config.Endpoint.STATUS
import static org.prebid.server.functional.testcontainers.PbsConfig.DEFAULT_ENV

class PrebidServerContainer extends GenericContainer<PrebidServerContainer> {
Expand All @@ -29,7 +30,7 @@ class PrebidServerContainer extends GenericContainer<PrebidServerContainer> {
withExposedPorts(PORT, DEBUG_PORT, ADMIN_PORT, PROMETHEUS_PORT)
withFixedPorts()
withStartupAttempts(3)
waitingFor(Wait.forHttp("/status")
waitingFor(Wait.forHttp(STATUS.value)
.forPort(PORT)
.forStatusCode(200))
withDebug()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import static org.prebid.server.functional.model.bidder.BidderName.ALIAS
import static org.prebid.server.functional.model.bidder.BidderName.APPNEXUS
import static org.prebid.server.functional.model.bidder.BidderName.GENERIC
import static org.prebid.server.functional.model.bidder.BidderName.GENERIC_CAMEL_CASE
import static org.prebid.server.functional.model.config.Endpoint.AUCTION
import static org.prebid.server.functional.model.response.auction.ErrorType.PREBID
import static org.prebid.server.functional.model.response.cookiesync.UserSyncInfo.Type.REDIRECT
import static org.prebid.server.functional.testcontainers.Dependencies.networkServiceContainer
Expand Down Expand Up @@ -329,7 +330,7 @@ class AuctionSpec extends BaseSpec {

then: "BidderRequest should contain endpoint in ext.prebid.server.endpoint instead of ext.prebid.pbs.endpoint"
def bidderRequest = bidder.getBidderRequest(bidRequest.id)
assert bidderRequest?.ext?.prebid?.server?.endpoint == "/openrtb2/auction"
assert bidderRequest?.ext?.prebid?.server?.endpoint == AUCTION.value
assert !bidderRequest?.ext?.prebid?.pbs?.endpoint

and: "BidderRequest shouldn't populate fields"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.prebid.server.functional.tests
import org.prebid.server.functional.model.bidder.AppNexus
import org.prebid.server.functional.model.bidder.BidderName
import org.prebid.server.functional.model.bidder.Generic
import org.prebid.server.functional.model.config.Endpoint
import org.prebid.server.functional.model.db.Account
import org.prebid.server.functional.model.db.StoredImp
import org.prebid.server.functional.model.db.StoredRequest
Expand Down Expand Up @@ -145,7 +146,7 @@ class BidderParamsSpec extends BaseSpec {
then: "vast xml is modified"
def prebidCacheRequest = prebidCache.getXmlRecordedRequestsBody(payload)
assert prebidCacheRequest.size() == 1
assert prebidCacheRequest.first().contains("/event?t=imp&b=${request.puts[0].bidid}&a=$accountId&bidder=${request.puts[0].bidder}")
assert prebidCacheRequest.first().contains("${Endpoint.EVENT}?t=imp&b=${request.puts[0].bidid}&a=$accountId&bidder=${request.puts[0].bidder}")

cleanup: "Stop and remove pbs container"
pbsServiceFactory.removeContainer(pbsConfig)
Expand Down Expand Up @@ -177,7 +178,7 @@ class BidderParamsSpec extends BaseSpec {
then: "vast xml is not modified"
def prebidCacheRequest = prebidCache.getXmlRecordedRequestsBody(payload)
assert prebidCacheRequest.size() == 1
assert !prebidCacheRequest.first().contains("/event?t=imp&b=${request.puts[0].bidid}&a=$accountId&bidder=${request.puts[0].bidder}")
assert !prebidCacheRequest.first().contains("${Endpoint.EVENT}?t=imp&b=${request.puts[0].bidid}&a=$accountId&bidder=${request.puts[0].bidder}")

cleanup: "Stop and remove pbs container"
pbsServiceFactory.removeContainer(pbsConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.prebid.server.functional.model.config.AccountCacheConfig
import org.prebid.server.functional.model.config.AccountConfig
import org.prebid.server.functional.model.config.AccountEventsConfig
import org.prebid.server.functional.model.config.AccountVtrackConfig
import org.prebid.server.functional.model.config.Endpoint
import org.prebid.server.functional.model.db.Account
import org.prebid.server.functional.model.request.vtrack.VtrackRequest
import org.prebid.server.functional.model.request.vtrack.xml.Vast
Expand Down Expand Up @@ -89,7 +90,7 @@ class CacheVtrackSpec extends BaseSpec {
then: "Vast xml is modified"
def prebidCacheRequest = prebidCache.getXmlRecordedRequestsBody(payload)
assert prebidCacheRequest.size() == 1
assert prebidCacheRequest[0].contains("/event?t=imp&b=${request.puts[0].bidid}&a=$accountId&bidder=${request.puts[0].bidder}")
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()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.prebid.server.functional.tests

import org.prebid.server.functional.model.UidsCookie
import org.prebid.server.functional.model.config.Endpoint
import org.prebid.server.functional.model.db.StoredRequest
import org.prebid.server.functional.model.mock.services.httpsettings.HttpAccountsResponse
import org.prebid.server.functional.model.request.amp.AmpRequest
Expand Down Expand Up @@ -282,7 +283,7 @@ class HttpSettingsSpec extends BaseSpec {

and: "VastXml that was send to PrebidCache must contain event url"
def prebidCacheRequest = prebidCache.getXmlRecordedRequestsBody(payload)[0]
assert prebidCacheRequest.contains("/event?t=imp&b=${request.puts[0].bidid}&a=$accountId&bidder=${request.puts[0].bidder}")
assert prebidCacheRequest.contains("${Endpoint.EVENT}?t=imp&b=${request.puts[0].bidid}&a=$accountId&bidder=${request.puts[0].bidder}")
}

def "PBS should take account information from http data source on vtrack request when rfc3986 enabled"() {
Expand All @@ -307,7 +308,7 @@ class HttpSettingsSpec extends BaseSpec {

and: "VastXml that was send to PrebidCache must contain event url"
def prebidCacheRequest = prebidCache.getXmlRecordedRequestsBody(payload)[0]
assert prebidCacheRequest.contains("/event?t=imp&b=${request.puts[0].bidid}&a=$accountId&bidder=${request.puts[0].bidder}")
assert prebidCacheRequest.contains("${Endpoint.EVENT}?t=imp&b=${request.puts[0].bidid}&a=$accountId&bidder=${request.puts[0].bidder}")
}

def "PBS should return error if account settings isn't found"() {
Expand Down
Loading