-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
mtuchkova
committed
Oct 25, 2021
1 parent
9fe1d87
commit 954706e
Showing
18 changed files
with
316 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
src/test/groovy/org/prebid/server/functional/AuctionSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
package org.prebid.server.functional | ||
|
||
import org.prebid.server.functional.model.db.StoredRequest | ||
import org.prebid.server.functional.model.request.auction.BidRequest | ||
import org.prebid.server.functional.model.request.auction.StoredRequestExt | ||
import org.prebid.server.functional.service.PrebidServerService | ||
import org.prebid.server.functional.util.PBSUtils | ||
import spock.lang.Shared | ||
import spock.lang.Unroll | ||
|
||
class AuctionSpec extends BaseSpec { | ||
|
||
private static final int MAX_TIMEOUT = 5000 | ||
private static final int DEFAULT_TIMEOUT = PBSUtils.getRandomNumber(1000, MAX_TIMEOUT) | ||
|
||
@Shared | ||
PrebidServerService prebidServerService = pbsServiceFactory.getService(["auction.max-timeout-ms" : MAX_TIMEOUT as String, | ||
"auction.default-timeout-ms": DEFAULT_TIMEOUT as String]) | ||
|
||
def "PBS should apply timeout from stored request when it's not specified in the auction request"() { | ||
given: "Default basic BidRequest with generic bidder" | ||
def bidRequest = BidRequest.defaultBidRequest.tap { | ||
tmax = null | ||
ext.prebid.storedRequest = new StoredRequestExt(id: PBSUtils.randomNumber.toString()) | ||
} | ||
|
||
and: "Default stored request with timeout" | ||
def timeout = PBSUtils.getRandomNumber(0, MAX_TIMEOUT) | ||
def storedRequestModel = BidRequest.defaultStoredRequest.tap { | ||
tmax = timeout | ||
} | ||
|
||
and: "Save storedRequest into DB" | ||
def storedRequest = StoredRequest.getAuctionDbStoredRequest(bidRequest, storedRequestModel) | ||
storedRequestDao.save(storedRequest) | ||
|
||
when: "PBS processes auction request" | ||
prebidServerService.sendAuctionRequest(bidRequest) | ||
|
||
then: "Bidder request should contain timeout from the stored request" | ||
def bidderRequest = bidder.getBidderRequest(bidRequest.id) | ||
assert bidderRequest.tmax == timeout as Long | ||
} | ||
|
||
@Unroll | ||
def "PBS should prefer timeout from the auction request when stored request timeout is #tmax"() { | ||
given: "Default basic BidRequest with generic bidder" | ||
def timeout = PBSUtils.getRandomNumber(0, MAX_TIMEOUT) | ||
def bidRequest = BidRequest.defaultBidRequest.tap { | ||
tmax = timeout | ||
ext.prebid.storedRequest = new StoredRequestExt(id: PBSUtils.randomNumber.toString()) | ||
} | ||
|
||
and: "Default stored request" | ||
def storedRequestModel = BidRequest.defaultStoredRequest.tap { | ||
it.tmax = tmaxStoredRequest | ||
} | ||
|
||
and: "Save storedRequest into DB" | ||
def storedRequest = StoredRequest.getAuctionDbStoredRequest(bidRequest, storedRequestModel) | ||
storedRequestDao.save(storedRequest) | ||
|
||
when: "PBS processes auction request" | ||
prebidServerService.sendAuctionRequest(bidRequest) | ||
|
||
then: "Bidder request should contain timeout from the request" | ||
def bidderRequest = bidder.getBidderRequest(bidRequest.id) | ||
assert bidderRequest.tmax == timeout as Long | ||
|
||
where: | ||
tmaxStoredRequest << [null, PBSUtils.getRandomNumber(0, MAX_TIMEOUT)] | ||
} | ||
|
||
@Unroll | ||
def "PBS should honor max timeout from the settings for auction request"() { | ||
given: "Default basic BidRequest with generic bidder" | ||
def bidRequest = BidRequest.defaultBidRequest.tap { | ||
tmax = autcionRequestTimeout | ||
ext.prebid.storedRequest = new StoredRequestExt(id: PBSUtils.randomNumber.toString()) | ||
} | ||
|
||
and: "Default stored request" | ||
def storedRequest = BidRequest.defaultStoredRequest.tap { | ||
it.tmax = storedRequestTimeout | ||
} | ||
|
||
and: "Save storedRequest into DB" | ||
def storedRequestModel = StoredRequest.getAuctionDbStoredRequest(bidRequest, storedRequest) | ||
storedRequestDao.save(storedRequestModel) | ||
|
||
when: "PBS processes auction request" | ||
prebidServerService.sendAuctionRequest(bidRequest) | ||
|
||
then: "Bidder request timeout should correspond to the maximum from the settings" | ||
def bidderRequest = bidder.getBidderRequest(bidRequest.id) | ||
assert bidderRequest.tmax == MAX_TIMEOUT as Long | ||
|
||
where: | ||
autcionRequestTimeout || storedRequestTimeout | ||
MAX_TIMEOUT + 1 || null | ||
null || MAX_TIMEOUT + 1 | ||
MAX_TIMEOUT + 1 || MAX_TIMEOUT + 1 | ||
} | ||
|
||
def "PBS should honor default timeout for auction request"() { | ||
given: "Default basic BidRequest without timeout" | ||
def bidRequest = BidRequest.defaultBidRequest.tap { | ||
tmax = null | ||
ext.prebid.storedRequest = new StoredRequestExt(id: PBSUtils.randomNumber.toString()) | ||
} | ||
|
||
and: "Default stored request without timeout" | ||
def storedRequest = BidRequest.defaultStoredRequest.tap { | ||
it.tmax = null | ||
} | ||
|
||
and: "Save storedRequest into DB" | ||
def storedRequestModel = StoredRequest.getAuctionDbStoredRequest(bidRequest, storedRequest) | ||
storedRequestDao.save(storedRequestModel) | ||
|
||
when: "PBS processes auction request" | ||
prebidServerService.sendAuctionRequest(bidRequest) | ||
|
||
then: "Bidder request timeout should correspond to the maximum from the settings" | ||
def bidderRequest = bidder.getBidderRequest(bidRequest.id) | ||
assert bidderRequest.tmax == DEFAULT_TIMEOUT as Long | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/test/groovy/org/prebid/server/functional/CookieSyncSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.prebid.server.functional | ||
|
||
import org.prebid.server.functional.model.UidsCookie | ||
import org.prebid.server.functional.model.db.Account | ||
import org.prebid.server.functional.model.request.cookiesync.CookieSyncRequest | ||
import org.prebid.server.functional.service.PrebidServerException | ||
import org.prebid.server.functional.util.PBSUtils | ||
import spock.lang.PendingFeature | ||
|
||
class CookieSyncSpec extends BaseSpec { | ||
|
||
@PendingFeature | ||
def "PBS should return an error for cookie_sync request when the timeout time is exceeded"() { | ||
given: "PBS with timeout configuration" | ||
def pbsService = pbsServiceFactory.getService(["cookie-sync.default-timeout-ms": "1"]) | ||
|
||
and: "Default CookieSyncRequest with account" | ||
def cookieSyncRequest = CookieSyncRequest.defaultCookieSyncRequest | ||
cookieSyncRequest.account = PBSUtils.randomNumber.toString() | ||
def uidsCookie = UidsCookie.defaultUidsCookie | ||
|
||
and: "Account in the DB" | ||
def account = new Account(uuid: cookieSyncRequest.account, eventsEnabled: true) | ||
accountDao.save(account) | ||
|
||
when: "PBS processes cookie sync request" | ||
pbsService.sendCookieSyncRequest(cookieSyncRequest, uidsCookie) | ||
|
||
then: "Request should fail with error" | ||
def exception = thrown(PrebidServerException) | ||
assert exception.statusCode == 500 | ||
assert exception.responseBody.contains("Timed out while executing SQL query") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/test/groovy/org/prebid/server/functional/EventSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.prebid.server.functional | ||
|
||
import org.prebid.server.functional.model.db.Account | ||
import org.prebid.server.functional.model.request.event.EventRequest | ||
import org.prebid.server.functional.service.PrebidServerException | ||
|
||
class EventSpec extends BaseSpec { | ||
|
||
def "PBS should return an error for event request when the timeout time is exceeded"() { | ||
given: "PBS with timeout configuration" | ||
def pbsService = pbsServiceFactory.getService(["event.default-timeout-ms": "1"]) | ||
|
||
and: "Default EventRequest" | ||
def eventRequest = EventRequest.defaultEventRequest | ||
|
||
and: "Account in the DB" | ||
def account = new Account(uuid: eventRequest.accountId, eventsEnabled: true) | ||
accountDao.save(account) | ||
|
||
when: "PBS processes event request" | ||
pbsService.sendEventRequest(eventRequest) | ||
|
||
then: "Request should fail with error" | ||
def exception = thrown(PrebidServerException) | ||
assert exception.statusCode == 500 | ||
assert exception.responseBody.contains("Timed out while executing SQL query") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/test/groovy/org/prebid/server/functional/SetuidSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.prebid.server.functional | ||
|
||
import org.prebid.server.functional.model.UidsCookie | ||
import org.prebid.server.functional.model.db.Account | ||
import org.prebid.server.functional.model.request.setuid.SetuidRequest | ||
import org.prebid.server.functional.service.PrebidServerException | ||
import org.prebid.server.functional.util.PBSUtils | ||
import spock.lang.PendingFeature | ||
|
||
class SetuidSpec extends BaseSpec { | ||
|
||
@PendingFeature | ||
def "PBS should return an error for setuid request when the timeout time is exceeded"() { | ||
given: "PBS with timeout configuration" | ||
def pbsService = pbsServiceFactory.getService(["setuid.default-timeout-ms": "1"]) | ||
|
||
and: "Default setuid request with account" | ||
def request = SetuidRequest.defaultSetuidRequest | ||
def uidsCookie = UidsCookie.defaultUidsCookie | ||
request.account = PBSUtils.randomNumber.toString() | ||
|
||
and: "Account in the DB" | ||
def account = new Account(uuid: request.account, eventsEnabled: true) | ||
accountDao.save(account) | ||
|
||
when: "PBS processes setuid request" | ||
pbsService.sendSetUidRequest(request, uidsCookie) | ||
|
||
then: "Request should fail with error" | ||
def exception = thrown(PrebidServerException) | ||
assert exception.statusCode == 500 | ||
assert exception.responseBody.contains("Timed out while executing SQL query") | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/test/groovy/org/prebid/server/functional/VtrackSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.prebid.server.functional | ||
|
||
import org.prebid.server.functional.model.request.vtrack.VtrackRequest | ||
import org.prebid.server.functional.model.request.vtrack.xml.Vast | ||
import org.prebid.server.functional.service.PrebidServerException | ||
import org.prebid.server.functional.util.PBSUtils | ||
|
||
class VtrackSpec extends BaseSpec { | ||
|
||
def "PBS should return an error for vtrack request when the timeout time is exceeded"() { | ||
given: "PBS with timeout configuration" | ||
def pbsService = pbsServiceFactory.getService(["vtrack.default-timeout-ms": "1"]) | ||
|
||
and: "Default VtrackRequest" | ||
def payload = PBSUtils.randomNumber.toString() | ||
def request = VtrackRequest.getDefaultVtrackRequest(mapper.encodeXml(Vast.getDefaultVastModel(payload))) | ||
def accountId = PBSUtils.randomNumber.toString() | ||
|
||
when: "PBS processes vtrack request" | ||
pbsService.sendVtrackRequest(request, accountId) | ||
|
||
then: "Request should fail with error" | ||
def exception = thrown(PrebidServerException) | ||
assert exception.statusCode == 500 | ||
assert exception.responseBody.contains("Timed out while executing SQL query") | ||
} | ||
} |
Oops, something went wrong.