Test: Add Influx db coverage#4284
Merged
osulzhenko merged 7 commits intoinfluxdb-metrics-fixfrom Dec 2, 2025
Merged
Conversation
…unctional-tests-for-influx
osulzhenko
requested changes
Nov 28, 2025
Comment on lines
39
to
40
| .withUsername("prebid") | ||
| .withUsername("prebid") |
src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy
Show resolved
Hide resolved
src/test/groovy/org/prebid/server/functional/testcontainers/Dependencies.groovy
Show resolved
Hide resolved
Comment on lines
112
to
113
| "metrics.influxdb.database" : PREBID_DATABASE, | ||
| "metrics.influxdb.auth" : "prebid:prebid", |
Collaborator
There was a problem hiding this comment.
"metrics.influxdb.database" : influx.database,
"metrics.influxdb.auth" : "${influx.username}:${influx.password}",
src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy
Show resolved
Hide resolved
Comment on lines
15
to
16
| private static final PrebidServerService pbsServiceWithEnforceValidAccount | ||
| = pbsServiceFactory.getService(["settings.enforce-valid-account": true as String]) |
Comment on lines
17
to
19
| private static final Closure<String> REJECT_INVALID_ACCOUNT_METRIC = { accountId -> | ||
| "influx.metric.account.${accountId}.requests.rejected.invalid-account" | ||
| } |
Collaborator
There was a problem hiding this comment.
It's a simple, straightforward metrics check; simple formatting will be enough
Comment on lines
22
to
30
| given: "Inactive account id" | ||
| def accountId = PBSUtils.randomNumber | ||
| def account = new Account(uuid: accountId, config: new AccountConfig(status: AccountStatus.INACTIVE)) | ||
| accountDao.save(account) | ||
|
|
||
| and: "Default basic BidRequest with inactive account id" | ||
| def bidRequest = BidRequest.defaultBidRequest.tap { | ||
| site.publisher.id = accountId | ||
| } |
Collaborator
There was a problem hiding this comment.
same for other
given: "BidRequest with inactive account id"
def bidRequest = BidRequest.defaultBidRequest
and: "Inactive account id"
def account = new Account(uuid: bidRequest.accountId, config: new AccountConfig(status: AccountStatus.INACTIVE))
accountDao.save(account)
Comment on lines
67
to
71
| PBSUtils.waitUntil({ | ||
| !pbsServiceWithEnforceValidAccount.sendInfluxMetricsRequest() | ||
| .containsKey(REJECT_INVALID_ACCOUNT_METRIC(bidRequest.accountId) as String) | ||
| }) | ||
| } |
Collaborator
There was a problem hiding this comment.
what if we make it like in logs:
Boolean isContainLogsByValue(String value) {
try {
PBSUtils.waitUntil({ getPbsLogsByValue(value) != null })
true
} catch (IllegalStateException ignored) {
false
}
}
| .containsKey(REJECT_INVALID_ACCOUNT_METRIC(bidRequest.accountId) as String) | ||
| }) | ||
| def influxMetricsRequest = pbsServiceWithEnforceValidAccount.sendInfluxMetricsRequest() | ||
| assert influxMetricsRequest[REJECT_INVALID_ACCOUNT_METRIC(bidRequest.accountId) as String] == 1 |
Collaborator
There was a problem hiding this comment.
assert isContainDbMetricsByValue
def influxMetricsRequest = pbsServiceWithEnforceValidAccount.sendInfluxMetricsRequest()
assert influxMetricsRequest[REJECT_INVALID_ACCOUNT_METRIC(bidRequest.accountId) as String] == 1
|
osulzhenko
requested changes
Dec 2, 2025
|
|
||
| Map<String, Number> sendInfluxMetricsRequest() { | ||
| def response = given(influxRequestSpecification) | ||
| .queryParams(["db": "prebid", |
Collaborator
There was a problem hiding this comment.
"db": influxdbContainer.getDatabase(),
src/test/groovy/org/prebid/server/functional/service/PrebidServerService.groovy
Show resolved
Hide resolved
| "metrics.influxdb.interval" : "1", | ||
| "metrics.influxdb.connectTimeout": "5000", | ||
| "metrics.influxdb.readTimeout" : "100", | ||
|
|
osulzhenko
approved these changes
Dec 2, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔧 Type of changes
✨ What's the context?
Test cases for open source issue #4248
🧠 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
🧪 Test plan
How do you know the changes are safe to ship to production?
🏎 Quality check