-
Notifications
You must be signed in to change notification settings - Fork 224
Test: Add Influx db coverage #4284
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: Add Influx db coverage #4284
Conversation
…unctional-tests-for-influx
| .withUsername("prebid") | ||
| .withUsername("prebid") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate
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
| "metrics.influxdb.database" : PREBID_DATABASE, | ||
| "metrics.influxdb.auth" : "prebid:prebid", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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
| private static final PrebidServerService pbsServiceWithEnforceValidAccount | ||
| = pbsServiceFactory.getService(["settings.enforce-valid-account": true as String]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls add cleanupSpec
| private static final Closure<String> REJECT_INVALID_ACCOUNT_METRIC = { accountId -> | ||
| "influx.metric.account.${accountId}.requests.rejected.invalid-account" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a simple, straightforward metrics check; simple formatting will be enough
| 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 | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actual
| PBSUtils.waitUntil({ | ||
| !pbsServiceWithEnforceValidAccount.sendInfluxMetricsRequest() | ||
| .containsKey(REJECT_INVALID_ACCOUNT_METRIC(bidRequest.accountId) as String) | ||
| }) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert isContainDbMetricsByValue
def influxMetricsRequest = pbsServiceWithEnforceValidAccount.sendInfluxMetricsRequest()
assert influxMetricsRequest[REJECT_INVALID_ACCOUNT_METRIC(bidRequest.accountId) as String] == 1
|
|
|
||
| Map<String, Number> sendInfluxMetricsRequest() { | ||
| def response = given(influxRequestSpecification) | ||
| .queryParams(["db": "prebid", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"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", | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty space
🔧 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