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

Update matrix file each time a matrix changes while polling #533

Merged
merged 2 commits into from
Mar 29, 2019
Merged
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
14 changes: 8 additions & 6 deletions test_runner/src/main/kotlin/ftl/run/TestRunner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,14 @@ object TestRunner {
/** Synchronously poll all matrix ids until they complete. Returns true if test run passed. **/
private fun pollMatrices(matrices: MatrixMap, args: IArgs) {
println("PollMatrices")
val map = matrices.map
val poll = matrices.map.values.filter {
MatrixState.inProgress(it.state)
}

val stopwatch = StopWatch().start()
poll.forEach {
val matrixId = it.matrixId
val completedMatrix = pollMatrix(matrixId, stopwatch, args)

map[matrixId]?.update(completedMatrix)
pollMatrix(matrixId, stopwatch, args, matrices)
}
println()

Expand All @@ -280,7 +277,7 @@ object TestRunner {
//
// Port of MonitorTestExecutionProgress
// gcloud-cli/googlecloudsdk/api_lib/firebase/test/matrix_ops.py
private fun pollMatrix(matrixId: String, stopwatch: StopWatch, args: IArgs): TestMatrix {
private fun pollMatrix(matrixId: String, stopwatch: StopWatch, args: IArgs, matrices: MatrixMap) {
var lastState = ""
var lastError = ""
var progress = listOf<String>()
Expand Down Expand Up @@ -336,14 +333,19 @@ object TestRunner {
puts(lastState)
}

// Update the matrix file if the matrix has changed.
val changed = matrices.map[matrixId]?.update(refreshedMatrix) ?: false
if (changed) {
updateMatrixFile(matrices, args)
}

// GetTestMatrix is not designed to handle many requests per second.
// Sleep 15s to avoid overloading the system.
Utils.sleep(15)
}

// Print final matrix state with timestamp. May be many minutes after the 'Done.' progress message.
puts(refreshedMatrix.state)
return refreshedMatrix
}

// used to update and poll the results from an async run
Expand Down