Skip to content

Commit

Permalink
minor refactoring (#104)
Browse files Browse the repository at this point in the history
Co-authored-by: tomas mccandless <[email protected]>
  • Loading branch information
tomnis and tomas mccandless authored Aug 21, 2023
1 parent 2f20156 commit fcb5235
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
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
}
}

0 comments on commit fcb5235

Please sign in to comment.