-
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
Merged
osulzhenko
merged 7 commits into
influxdb-metrics-fix
from
add-functional-tests-for-influx
Dec 2, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
53e9599
Add tests for influx db
marki1an 3504d22
Improving tests for influxDb
marki1an 2d0a8e9
Updating pom with influx DB
marki1an 3fc9391
Merge remote-tracking branch 'origin/influxdb-metrics-fix' into add-f…
marki1an 34a2b3c
Update after review
marki1an aa507fc
Update after review
marki1an 8ecb203
minor update
osulzhenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
6 changes: 6 additions & 0 deletions
6
src/test/groovy/org/prebid/server/functional/model/response/influx/InfluxResponse.groovy
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package org.prebid.server.functional.model.response.influx | ||
|
|
||
| class InfluxResponse { | ||
|
|
||
| List<InfluxResult> results | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/test/groovy/org/prebid/server/functional/model/response/influx/InfluxResult.groovy
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package org.prebid.server.functional.model.response.influx | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty | ||
|
|
||
| class InfluxResult { | ||
|
|
||
| @JsonProperty("statement_id") | ||
| Integer statementId | ||
| List<Series> series | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/test/groovy/org/prebid/server/functional/model/response/influx/Series.groovy
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package org.prebid.server.functional.model.response.influx | ||
|
|
||
| class Series { | ||
|
|
||
| String name | ||
| Tags tags | ||
| List<String> columns | ||
| List<List<String>> values | ||
| } |
6 changes: 6 additions & 0 deletions
6
src/test/groovy/org/prebid/server/functional/model/response/influx/Tags.groovy
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package org.prebid.server.functional.model.response.influx | ||
|
|
||
| class Tags { | ||
|
|
||
| String measurement | ||
| } |
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
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
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
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
78 changes: 78 additions & 0 deletions
78
src/test/groovy/org/prebid/server/functional/tests/InfluxDBSpec.groovy
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| package org.prebid.server.functional.tests | ||
|
|
||
| import org.prebid.server.functional.model.AccountStatus | ||
| import org.prebid.server.functional.model.config.AccountConfig | ||
| import org.prebid.server.functional.model.db.Account | ||
| import org.prebid.server.functional.model.request.auction.BidRequest | ||
| import org.prebid.server.functional.service.PrebidServerException | ||
| import org.prebid.server.functional.service.PrebidServerService | ||
|
|
||
| import static io.netty.handler.codec.http.HttpResponseStatus.UNAUTHORIZED | ||
| import static org.prebid.server.functional.testcontainers.Dependencies.influxdbContainer | ||
|
|
||
| class InfluxDBSpec extends BaseSpec { | ||
|
|
||
| private static final String ACCOUNT_REJECTED_METRIC = "influx.metric.account.%s.requests.rejected.invalid-account" | ||
|
|
||
| private static final Map<String, String> PBS_CONFIG_WITH_INFLUX_AND_ENFORCE_VALIDATION_ACCOUNTANT = [ | ||
| "metrics.influxdb.enabled" : "true", | ||
| "metrics.influxdb.prefix" : "influx.metric.", | ||
| "metrics.influxdb.host" : influxdbContainer.getNetworkAliases().get(0), | ||
| "metrics.influxdb.port" : influxdbContainer.getExposedPorts().get(0) as String, | ||
| "metrics.influxdb.protocol" : "http", | ||
| "metrics.influxdb.database" : influxdbContainer.database as String, | ||
| "metrics.influxdb.auth" : "${influxdbContainer.username}:${influxdbContainer.password}" as String, | ||
| "metrics.influxdb.interval" : "1", | ||
| "metrics.influxdb.connectTimeout": "5000", | ||
| "metrics.influxdb.readTimeout" : "100", | ||
| "settings.enforce-valid-account": true as String] | ||
|
|
||
| private static final PrebidServerService pbsServiceWithEnforceValidAccount | ||
| = pbsServiceFactory.getService(PBS_CONFIG_WITH_INFLUX_AND_ENFORCE_VALIDATION_ACCOUNTANT) | ||
|
|
||
| def cleanupSpec() { | ||
| pbsServiceFactory.removeContainer(PBS_CONFIG_WITH_INFLUX_AND_ENFORCE_VALIDATION_ACCOUNTANT) | ||
| } | ||
|
|
||
| def "PBS should reject request with error and metrics when inactive account"() { | ||
| given: "Default basic 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) | ||
|
|
||
| when: "PBS processes auction request" | ||
| pbsServiceWithEnforceValidAccount.sendAuctionRequest(bidRequest) | ||
|
|
||
| then: "PBS should reject the entire auction" | ||
| def exception = thrown(PrebidServerException) | ||
| assert exception.statusCode == UNAUTHORIZED.code() | ||
| assert exception.responseBody == "Account $bidRequest.accountId is inactive" | ||
|
|
||
| and: "PBS wait until get metric" | ||
| assert pbsServiceWithEnforceValidAccount.isContainMetricByValue(ACCOUNT_REJECTED_METRIC.formatted(bidRequest.accountId)) | ||
|
|
||
| and: "PBS metrics populated correctly" | ||
| def influxMetricsRequest = pbsServiceWithEnforceValidAccount.sendInfluxMetricsRequest() | ||
| assert influxMetricsRequest[ACCOUNT_REJECTED_METRIC.formatted(bidRequest.accountId)] == 1 | ||
| } | ||
|
|
||
| def "PBS shouldn't reject request with error and metrics when active account"() { | ||
| given: "Default basic 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.ACTIVE)) | ||
| accountDao.save(account) | ||
|
|
||
| when: "PBS processes auction request" | ||
| def response = pbsServiceWithEnforceValidAccount.sendAuctionRequest(bidRequest) | ||
|
|
||
| then: "Bid response should contain seatBid" | ||
| assert response.seatbid.size() == 1 | ||
|
|
||
| and: "PBs shouldn't emit metric" | ||
| assert !pbsServiceWithEnforceValidAccount.isContainMetricByValue(ACCOUNT_REJECTED_METRIC.formatted(bidRequest.accountId)) | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.