Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: Price floors max rules dimensions #3646

Conversation

marki1an
Copy link
Collaborator

@marki1an marki1an commented Dec 20, 2024

🔧 Type of changes

  • new bid adapter
  • bid adapter update
  • new feature
  • new analytics adapter
  • new module
  • module update
  • bugfix
  • documentation
  • configuration
  • dependency update
  • tech debt (test coverage, refactorings, etc.)

✨ What's the context?

What's the context for the changes?

🧠 Rationale behind the change

Why did you choose to make these changes? Were there any trade-offs you had to consider?

🔎 New Bid Adapter Checklist

  • verify email contact works
  • NO fully dynamic hostnames
  • geographic host parameters are NOT required
  • direct use of HTTP is prohibited - implement an existing Bidder interface that will do all the job
  • if the ORTB is just forwarded to the endpoint, use the generic adapter - define the new adapter as the alias of the generic adapter
  • cover an adapter configuration with an integration test

🧪 Test plan

How do you know the changes are safe to ship to production?

🏎 Quality check

  • Are your changes following our code style guidelines?
  • Are there any breaking changes in your code?
  • Does your test coverage exceed 90%?
  • Are there any erroneous console logs, debuggers or leftover code in your changes?

@marki1an marki1an added the tests Functional or other tests label Dec 20, 2024
@marki1an marki1an self-assigned this Dec 20, 2024
Copy link
Collaborator

@osulzhenko osulzhenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add test cases that cover the following:

  • request-level max-schema-dims config cannot be passed in the request; it must be specified as part of the account config (i.e., ignore ext.prebid.floors.max-schema-dims).
  • default value for max-schema-dims is 3.
  • What happens if both fetch.max-schema-dims and max-schema-dims are set with different values? Which one takes priority?

@@ -2046,6 +2046,91 @@ class PriceFloorsFetchingSpec extends PriceFloorsBaseSpec {
}
}

def "PBS should validate fetch.max-schema-dims from account config"() {
given: "Default BidRequest"
def bidRequest = BidRequest.getDefaultBidRequest(APP)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also why APP?

Comment on lines 21 to 26
import spock.lang.IgnoreRest

import static org.mockserver.model.HttpStatusCode.BAD_REQUEST_400
import static org.prebid.server.functional.model.Currency.USD
import static org.prebid.server.functional.model.bidder.BidderName.GENERIC
import static org.prebid.server.functional.model.pricefloors.DeviceType.PHONE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

invalid imports

Comment on lines 569 to 570
["Failed to parse price floors from request, with a reason: " +
"Price floor rules number 2 exceeded its maximum number 1"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the proper way to configure tests. For any external viewer, it will be hard to understand why it is set to 2 and why we are using 1. A person would be forced to look at the code and into PriceFloorSchema.groovy for the request. This is not right. We should replace 2 with priceFloorSchema.fields.size and 1 with priceFloorSchema.fields.size - 1 (as example). Same for others

PBSUtils.randomNegativeNumber | null
}

def "PBS should validate price-floor.max-schema-dims from account config"() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PBS should validate price-floor.max-schema-dims from account config and not reject entire auction same for others

Copy link
Collaborator

@osulzhenko osulzhenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please add some privacy methods for these counts:

foo.ext.prebid.floors.data.modelGroups[0].values.size()
boo.ext.prebid.floors.data.modelGroups[0].schema.fields.size()

assert response.ext?.errors[PREBID]*.message ==
["Failed to parse price floors from request, with a reason: " +
"Price floor rules number ${ampStoredRequest.ext.prebid.floors.data.modelGroups[0].values.keySet().size()} " +
"exceeded its maximum number 1"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace 1 with maxRules value. Same for others. Also maybe we can use ${ampStoredRequest.ext.prebid.floors.data.modelGroups[0].values.size()}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can't just replace with maxRules, since

maxRules            | maxRulesSnakeCase
        1           | null
        null        | 1

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's then make it constant

def "PBS shouldn't emit errors when request schema.fields than floor-config.max-schema-dims"() {
given: "Bid request with schema 2 fields"
def bidRequest = bidRequestWithFloors.tap {
ext.prebid.floors.maxSchemaDims = PBSUtils.randomNumber
Copy link
Collaborator

@osulzhenko osulzhenko Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it can be flaky, pls add:
ext.prebid.floors.maxSchemaDims = PBSUtils.getRandomNumber(2) 2 as example here

Comment on lines 696 to 697
"'$BASIC_FETCH_URL$accountId', account = $accountId with a reason : Price floor schema dimensions 2 " +
"exceeded its maximum number 1")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Price floor schema dimensions ${getSchemaSize(bidRequest)}

assert response.ext?.errors[PREBID]*.message ==
["Failed to parse price floors from request, with a reason: " +
"Price floor rules number ${ampStoredRequest.ext.prebid.floors.data.modelGroups[0].values.keySet().size()} " +
"exceeded its maximum number 1"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's then make it constant

Comment on lines 768 to 769
config.auction.priceFloors.maxSchemaDims = 2
config.auction.priceFloors.fetch.maxSchemaDims = 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        config.auction.priceFloors.maxSchemaDims = getSchemaSize(bidRequest)
        config.auction.priceFloors.fetch.maxSchemaDims = getSchemaSize(bidRequest) - 1

@osulzhenko osulzhenko merged commit 4097c12 into price-floors-max-rules-dimensions Jan 8, 2025
@osulzhenko osulzhenko deleted the tests/price-floors-max-rules-dimensions branch January 8, 2025 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Functional or other tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants