Skip to content

Commit

Permalink
fix after review
Browse files Browse the repository at this point in the history
  • Loading branch information
mtuchkova committed Nov 11, 2021
1 parent 352d56a commit 05e35f5
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
5 changes: 0 additions & 5 deletions src/test/groovy/org/prebid/server/functional/AmpSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ 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.service.PrebidServerService
import org.prebid.server.functional.util.PBSUtils
import spock.lang.Shared
import spock.lang.Unroll

Expand Down Expand Up @@ -145,8 +144,4 @@ class AmpSpec extends BaseSpec {
AmpRequest.defaultAmpRequest || "valid AMP request"
new AmpRequest() || "invalid AMP request"
}

private static int getRandomTimeout() {
PBSUtils.getRandomNumber(MIN_TIMEOUT, MAX_TIMEOUT)
}
}
10 changes: 5 additions & 5 deletions src/test/groovy/org/prebid/server/functional/AuctionSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import static org.prebid.server.functional.util.SystemProperties.PBS_VERSION

class AuctionSpec extends BaseSpec {

private static final int MAX_TIMEOUT = 5000
private static final int DEFAULT_TIMEOUT = PBSUtils.getRandomNumber(1000, MAX_TIMEOUT)
private static final int DEFAULT_TIMEOUT = getRandomTimeout()
private static final String PBS_VERSION_HEADER = "pbs-java/$PBS_VERSION"

@Shared
PrebidServerService prebidServerService = pbsServiceFactory.getService(["auction.max-timeout-ms" : MAX_TIMEOUT as String,
"auction.default-timeout-ms": DEFAULT_TIMEOUT as String])
Expand Down Expand Up @@ -42,7 +42,7 @@ class AuctionSpec extends BaseSpec {
}

and: "Default stored request with timeout"
def timeout = PBSUtils.getRandomNumber(0, MAX_TIMEOUT)
def timeout = getRandomTimeout()
def storedRequestModel = BidRequest.defaultStoredRequest.tap {
tmax = timeout
}
Expand All @@ -62,7 +62,7 @@ class AuctionSpec extends BaseSpec {
@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 timeout = getRandomTimeout()
def bidRequest = BidRequest.defaultBidRequest.tap {
tmax = timeout
ext.prebid.storedRequest = new PrebidStoredRequest(id: PBSUtils.randomNumber.toString())
Expand All @@ -85,7 +85,7 @@ class AuctionSpec extends BaseSpec {
assert bidderRequest.tmax == timeout as Long

where:
tmaxStoredRequest << [null, PBSUtils.getRandomNumber(0, MAX_TIMEOUT)]
tmaxStoredRequest << [null, getRandomTimeout()]
}

@Unroll
Expand Down
5 changes: 5 additions & 0 deletions src/test/groovy/org/prebid/server/functional/BaseSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.prebid.server.functional.testcontainers.PbsServiceFactory
import org.prebid.server.functional.testcontainers.scaffolding.Bidder
import org.prebid.server.functional.testcontainers.scaffolding.PrebidCache
import org.prebid.server.functional.util.ObjectMapperWrapper
import org.prebid.server.functional.util.PBSUtils
import spock.lang.Specification

import static org.prebid.server.functional.testcontainers.Dependencies.mysqlContainer
Expand Down Expand Up @@ -48,4 +49,8 @@ abstract class BaseSpec extends Specification {
repository.removeAllDatabaseData()
pbsServiceFactory.stopContainers()
}

protected static int getRandomTimeout() {
PBSUtils.getRandomNumber(MIN_TIMEOUT, MAX_TIMEOUT)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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"
// Using minimal allowed time for timeout (1ms) to get timeout error.
def pbsService = pbsServiceFactory.getService(["cookie-sync.default-timeout-ms": "1"])

and: "Default CookieSyncRequest with account"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class EventSpec extends BaseSpec {

def "PBS should return an error for event request when the timeout time is exceeded"() {
given: "PBS with timeout configuration"
// Using minimal allowed time for timeout (1ms) to get timeout error.
def pbsService = pbsServiceFactory.getService(["event.default-timeout-ms": "1"])

and: "Default EventRequest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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"
// Using minimal allowed time for timeout (1ms) to get timeout error.
def pbsService = pbsServiceFactory.getService(["setuid.default-timeout-ms": "1"])

and: "Default setuid request with account"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class VtrackSpec extends BaseSpec {

def "PBS should return an error for vtrack request when the timeout time is exceeded"() {
given: "PBS with timeout configuration"
// Using minimal allowed time for timeout (1ms) to get timeout error.
def pbsService = pbsServiceFactory.getService(["vtrack.default-timeout-ms": "1"])

and: "Default VtrackRequest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class PrebidServerService {
if (uids) {
return mapper.decode(new String(Base64.urlDecoder.decode(uids)), UidsCookie)
} else {
throw new IllegalStateException()
throw new IllegalStateException("uids cookie is missing in response")
}
}

Expand Down

0 comments on commit 05e35f5

Please sign in to comment.