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

minor refactoring to support different threshold arbiters #104

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ WARP_CORE_INFLUX_PORT=8086
# Versions
MYSQL_VERSION=8.0.30
INFLUX_VERSION=1.5.2
GRAFANA_VERSION=5.0.2
GRAFANA_VERSION=8.2.6
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class ResponseTimeArbiter extends ArbiterLike with CorePersistenceAware {
*/
override def vote[T: TestExecutionRowLikeType](ballot: Ballot, testExecution: T): Option[Throwable] = {
val testId: String = this.persistenceUtils.getMethodSignature(testExecution)
val threshold: Duration = testExecution.responseTimeRequirement.seconds
val threshold: Duration = this.getThreshold(testExecution)

val responseTime: Duration = Duration.ofNanos(TimeUtils.toNanos(testExecution.responseTime, TimeUnit.SECONDS))
val responseTime: Duration = this.getResponseTime(testExecution)

if (threshold.isPositive && responseTime > threshold) {
Option(new RequirementViolationException(
Expand All @@ -43,4 +43,27 @@ class ResponseTimeArbiter extends ArbiterLike with CorePersistenceAware {
None
}
}


/**
* Gets response time from the test execution. Subclasses may have a different notion of where to obtain response time.
*
* @param testExecution [[TestExecutionRowLikeType]] we are voting on.
* @return test response time as a [[Duration]].
*/
def getResponseTime[T: TestExecutionRowLikeType](testExecution: T): Duration = {
TimeUtils.toNanos(testExecution.responseTime, TimeUnit.SECONDS).nanoseconds
}


/**
* Gets test response time threshold from the test execution. Subclasses may have a different notion of where to obtain
* a threshold. For example, [[SpikeFilterSettings]].
*
* @param testExecution [[TestExecutionRowLikeType]] we are voting on.
* @return test response time threshold as a [[Duration]].
*/
def getThreshold[T: TestExecutionRowLikeType](testExecution: T): Duration = {
testExecution.responseTimeRequirement.seconds
}
}