Skip to content

Commit

Permalink
Fix issue with connection for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
osulzhenko committed Jan 27, 2025
1 parent 89d68f2 commit aa3d6f3
Show file tree
Hide file tree
Showing 9 changed files with 246 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import org.prebid.server.functional.testcontainers.scaffolding.PrebidCache
import org.prebid.server.functional.testcontainers.scaffolding.VendorList
import org.prebid.server.functional.util.ObjectMapperWrapper
import org.prebid.server.functional.util.PBSUtils
import spock.lang.Shared
import spock.lang.Specification

import static java.math.RoundingMode.DOWN
Expand All @@ -43,9 +44,11 @@ abstract class BaseSpec extends Specification implements ObjectMapperWrapper {
protected static final Map<String, String> GENERIC_ALIAS_CONFIG = ["adapters.generic.aliases.alias.enabled" : "true",
"adapters.generic.aliases.alias.endpoint": "$networkServiceContainer.rootUri/auction".toString()]

protected final PrebidServerService defaultPbsService = pbsServiceFactory.getService([:])
@Shared
protected static PrebidServerService defaultPbsService

def setupSpec() {
defaultPbsService = pbsServiceFactory.getService([:])
prebidCache.setResponse()
bidder.setResponse()
vendorList.setResponse()
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ 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.PBSUtils
import spock.lang.Shared

import static org.prebid.server.functional.model.ModuleName.PB_RESPONSE_CORRECTION
import static org.prebid.server.functional.model.config.Endpoint.OPENRTB2_AUCTION
Expand Down Expand Up @@ -48,8 +49,20 @@ class AbTestingModuleSpec extends ModuleBaseSpec {
private final static Map<String, String> MULTI_MODULE_CONFIG = getResponseCorrectionConfig() + getOrtb2BlockingSettings() +
['hooks.host-execution-plan': null]

private final static PrebidServerService ortbModulePbsService = pbsServiceFactory.getService(getOrtb2BlockingSettings())
private final static PrebidServerService pbsServiceWithMultipleModules = pbsServiceFactory.getService(MULTI_MODULE_CONFIG)
@Shared
private static PrebidServerService ortbModulePbsService
@Shared
private static PrebidServerService pbsServiceWithMultipleModules

def setupSpec() {
ortbModulePbsService = pbsServiceFactory.getService(getOrtb2BlockingSettings())
pbsServiceWithMultipleModules = pbsServiceFactory.getService(MULTI_MODULE_CONFIG)
}

def cleanupSpec() {
pbsServiceFactory.removeContainer(getOrtb2BlockingSettings())
pbsServiceFactory.removeContainer(MULTI_MODULE_CONFIG)
}

def "PBS shouldn't apply a/b test config when config of ab test is disabled"() {
given: "Default bid request with verbose trace"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.PrebidServerService
import org.prebid.server.functional.util.PBSUtils
import spock.lang.Shared

import static org.prebid.server.functional.model.ModuleName.ORTB2_BLOCKING
import static org.prebid.server.functional.model.ModuleName.PB_RICHMEDIA_FILTER
Expand Down Expand Up @@ -45,8 +46,20 @@ class GeneralModuleSpec extends ModuleBaseSpec {
getOrtb2BlockingSettings() +
['hooks.host-execution-plan': encode(ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, MODULES_STAGES))]

private final static PrebidServerService pbsServiceWithMultipleModule = pbsServiceFactory.getService(MULTI_MODULE_CONFIG + DISABLED_INVOKE_CONFIG)
private final static PrebidServerService pbsServiceWithMultipleModuleWithRequireInvoke = pbsServiceFactory.getService(MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG)
@Shared
private static PrebidServerService pbsServiceWithMultipleModule
@Shared
private static PrebidServerService pbsServiceWithMultipleModuleWithRequireInvoke

def setupSpec() {
pbsServiceWithMultipleModule = pbsServiceFactory.getService(MULTI_MODULE_CONFIG + DISABLED_INVOKE_CONFIG)
pbsServiceWithMultipleModuleWithRequireInvoke = pbsServiceFactory.getService(MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG)
}

def cleanupSpec() {
pbsServiceFactory.removeContainer(MULTI_MODULE_CONFIG + DISABLED_INVOKE_CONFIG)
pbsServiceFactory.removeContainer(MULTI_MODULE_CONFIG + ENABLED_INVOKE_CONFIG)
}

def "PBS should call all modules and traces response when account config is empty and require-config-to-invoke is disabled"() {
given: "Default bid request with verbose trace"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.prebid.server.functional.model.response.auction.ModuleActivityName
import org.prebid.server.functional.service.PrebidServerService
import org.prebid.server.functional.tests.module.ModuleBaseSpec
import org.prebid.server.functional.util.PBSUtils
import spock.lang.Shared

import static org.prebid.server.functional.model.ModuleName.ORTB2_BLOCKING
import static org.prebid.server.functional.model.ModuleName.PB_RICHMEDIA_FILTER
Expand All @@ -30,7 +31,16 @@ import static org.prebid.server.functional.model.response.auction.ErrorType.PREB

class AnalyticsTagsModuleSpec extends ModuleBaseSpec {

private final PrebidServerService pbsServiceWithEnabledOrtb2Blocking = pbsServiceFactory.getService(ortb2BlockingSettings)
@Shared
private static PrebidServerService pbsServiceWithEnabledOrtb2Blocking

def setupSpec() {
pbsServiceWithEnabledOrtb2Blocking = pbsServiceFactory.getService(ortb2BlockingSettings)
}

def cleanupSpec() {
pbsServiceFactory.removeContainer(ortb2BlockingSettings)
}

def "PBS should include analytics tag for ortb2-blocking module in response when request and account allow client details"() {
given: "Default account with module config"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import org.prebid.server.functional.model.response.auction.SeatBid
import org.prebid.server.functional.service.PrebidServerService
import org.prebid.server.functional.tests.module.ModuleBaseSpec
import org.prebid.server.functional.util.PBSUtils
import spock.lang.Shared

import static org.prebid.server.functional.model.ModuleName.ORTB2_BLOCKING
import static org.prebid.server.functional.model.bidder.BidderName.ALIAS
Expand All @@ -59,9 +60,19 @@ class Ortb2BlockingSpec extends ModuleBaseSpec {
private static final String WILDCARD = '*'
private static final Map IX_CONFIG = ["adapters.ix.enabled" : "true",
"adapters.ix.endpoint": "$networkServiceContainer.rootUri/auction".toString()]
private static final Map PBS_CONFIG = getOrtb2BlockingSettings() + IX_CONFIG +
['adapter-defaults.ortb.multiformat-supported': 'false']

private final PrebidServerService pbsServiceWithEnabledOrtb2Blocking = pbsServiceFactory.getService(ortb2BlockingSettings + IX_CONFIG +
['adapter-defaults.ortb.multiformat-supported': 'false'])
@Shared
private static PrebidServerService pbsServiceWithEnabledOrtb2Blocking

def setupSpec() {
pbsServiceWithEnabledOrtb2Blocking = pbsServiceFactory.getService(PBS_CONFIG)
}

def cleanupSpec() {
pbsServiceFactory.removeContainer(PBS_CONFIG)
}

def "PBS should send original array ortb2 attribute to bidder when enforce blocking is disabled"() {
given: "Default bid request with proper ortb attribute"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.prebid.server.functional.model.request.auction.OperationState
import org.prebid.server.functional.service.PrebidServerService
import org.prebid.server.functional.tests.module.ModuleBaseSpec
import org.prebid.server.functional.util.PBSUtils
import spock.lang.Shared

import static org.prebid.server.functional.model.request.auction.DistributionChannel.APP
import static org.prebid.server.functional.model.request.auction.OperationState.YES
Expand All @@ -27,7 +28,16 @@ class PbRequestCorrectionSpec extends ModuleBaseSpec {
private static final String ANDROID = "android"
private static final String IOS = "IOS"

private PrebidServerService pbsServiceWithRequestCorrectionModule = pbsServiceFactory.getService(requestCorrectionSettings)
@Shared
private static PrebidServerService pbsServiceWithRequestCorrectionModule

def setupSpec() {
pbsServiceWithRequestCorrectionModule = pbsServiceFactory.getService(requestCorrectionSettings)
}

def cleanupSpec() {
pbsServiceFactory.removeContainer(requestCorrectionSettings)
}

def "PBS should remove positive instl from imps for android app when request correction is enabled for account"() {
given: "Android APP bid request with version lover then version threshold"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.prebid.server.functional.model.response.auction.Prebid
import org.prebid.server.functional.service.PrebidServerService
import org.prebid.server.functional.tests.module.ModuleBaseSpec
import org.prebid.server.functional.util.PBSUtils
import spock.lang.Shared

import java.time.Instant

Expand All @@ -32,12 +33,22 @@ import static org.prebid.server.functional.model.response.auction.MediaType.VIDE

class ResponseCorrectionSpec extends ModuleBaseSpec {

private final PrebidServerService pbsServiceWithResponseCorrectionModule = pbsServiceFactory.getService(
["adapter-defaults.modifying-vast-xml-allowed": "false",
"adapters.generic.modifying-vast-xml-allowed": "false"] +
responseCorrectionConfig)

private final static int OPTIMAL_MAX_LENGTH = 20
private static final Map PBS_CONFIG = ["adapter-defaults.modifying-vast-xml-allowed": "false",
"adapters.generic.modifying-vast-xml-allowed": "false"] +
getResponseCorrectionConfig()

@Shared
private static PrebidServerService pbsServiceWithResponseCorrectionModule

def setupSpec() {
pbsServiceWithResponseCorrectionModule = pbsServiceFactory.getService(PBS_CONFIG)
}

def cleanupSpec() {
pbsServiceFactory.removeContainer(PBS_CONFIG)
}


def "PBS shouldn't modify response when in account correction module disabled"() {
given: "Start up time"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,28 @@ class RichMediaFilterSpec extends ModuleBaseSpec {

private static final String PATTERN_NAME = PBSUtils.randomString
private static final String PATTERN_NAME_ACCOUNT = PBSUtils.randomString
private final PrebidServerService pbsServiceWithEnabledMediaFilter = pbsServiceFactory.getService(getRichMediaFilterSettings(PATTERN_NAME))
private final PrebidServerService pbsServiceWithEnabledMediaFilterAndDifferentCaseStrategy = pbsServiceFactory.getService(
(getRichMediaFilterSettings(PATTERN_NAME) + ["hooks.host-execution-plan": encode(ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, PB_RICHMEDIA_FILTER, [ALL_PROCESSED_BID_RESPONSES]).tap {
private static final Map<String, String> DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG = getRichMediaFilterSettings(PATTERN_NAME, false)
private static final Map<String, String> SPECIFIC_PATTERN_NAME_CONFIG = getRichMediaFilterSettings(PATTERN_NAME)
private static final Map<String, String> SNAKE_SPECIFIC_PATTERN_NAME_CONFIG = (getRichMediaFilterSettings(PATTERN_NAME) +
["hooks.host-execution-plan": encode(ExecutionPlan.getSingleEndpointExecutionPlan(OPENRTB2_AUCTION, PB_RICHMEDIA_FILTER, [ALL_PROCESSED_BID_RESPONSES]).tap {
endpoints.values().first().stages.values().first().groups.first.hookSequenceSnakeCase = [new HookId(moduleCodeSnakeCase: PB_RICHMEDIA_FILTER.code, hookImplCodeSnakeCase: "${PB_RICHMEDIA_FILTER.code}-${ALL_PROCESSED_BID_RESPONSES.value}-hook")]
})])
.collectEntries { key, value -> [(key.toString()): value.toString()] })
private final PrebidServerService pbsServiceWithDisabledMediaFilter = pbsServiceFactory.getService(getRichMediaFilterSettings(PATTERN_NAME, false))
})]).collectEntries { key, value -> [(key.toString()): value.toString()] }

private static PrebidServerService pbsServiceWithDisabledMediaFilter
private static PrebidServerService pbsServiceWithEnabledMediaFilter
private static PrebidServerService pbsServiceWithEnabledMediaFilterAndDifferentCaseStrategy

def setupSpec() {
pbsServiceWithDisabledMediaFilter = pbsServiceFactory.getService(DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG)
pbsServiceWithEnabledMediaFilter = pbsServiceFactory.getService(SPECIFIC_PATTERN_NAME_CONFIG)
pbsServiceWithEnabledMediaFilterAndDifferentCaseStrategy = pbsServiceFactory.getService(SNAKE_SPECIFIC_PATTERN_NAME_CONFIG)
}

def cleanupSpec() {
pbsServiceFactory.removeContainer(DISABLED_FILTER_SPECIFIC_PATTERN_NAME_CONFIG)
pbsServiceFactory.removeContainer(SPECIFIC_PATTERN_NAME_CONFIG)
pbsServiceFactory.removeContainer(SNAKE_SPECIFIC_PATTERN_NAME_CONFIG)
}

def "PBS should process request without rich media module when host config have empty settings"() {
given: "Prebid server with empty settings for module"
Expand Down

0 comments on commit aa3d6f3

Please sign in to comment.