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

Add progress bar when uploading #403

Merged
merged 1 commit into from
Nov 29, 2018
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
4 changes: 3 additions & 1 deletion release_notes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
## v4.1 (unreleased)
- `app`, `test`, and `xctestrun-file` now support `~`, environment variables, and globs (`*`, `**`) when resolving paths. [#386](https://github.com/TestArmada/flank/pull/386)
- Update `flank android run` to support `--app`, `--test`, `--test-targets`, `--use-orchestrator` and `--no-use-orchestrator`.
- Add `smartFlankGcsPath` to shard iOS and Android tests by time using historical run data. The amount of shards used is set by `testShards`.
- Add `smartFlankGcsPath` to shard iOS and Android tests by time using historical run data. The amount of shards used is set by `testShards`. [#385](https://github.com/TestArmada/flank/pull/385)
- Fix parsing empty testcase [#402](https://github.com/TestArmada/flank/pull/402)
- Add progress bar when uploading files.

## v4.0.0

Expand Down
9 changes: 9 additions & 0 deletions test_runner/src/main/kotlin/ftl/gc/GcStorage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import ftl.config.FtlConstants.GCS_PREFIX
import ftl.reports.xml.model.JUnitTestResult
import ftl.reports.xml.parseAllSuitesXml
import ftl.reports.xml.xmlToString
import ftl.util.ProgressBar
import ftl.util.Utils.fatalError
import ftl.util.Utils.join
import java.io.File
Expand Down Expand Up @@ -54,10 +55,14 @@ object GcStorage {

val fileBlob = BlobInfo.newBuilder(bucket, name).build()

val progress = ProgressBar()
try {
progress.start("Uploading smart flank XML")
storage.create(fileBlob, testResult.xmlToString().toByteArray())
} catch (e: Exception) {
fatalError(e)
} finally {
progress.stop()
}
}

Expand Down Expand Up @@ -98,10 +103,14 @@ object GcStorage {
// 404 Not Found error when rootGcsBucket does not exist
val fileBlob = BlobInfo.newBuilder(rootGcsBucket, join(runGcsPath, fileName)).build()

val progress = ProgressBar()
try {
progress.start("Uploading $fileName")
storage.create(fileBlob, fileBytes)
} catch (e: Exception) {
fatalError(e)
} finally {
progress.stop()
}

return gcsFilePath
Expand Down
1 change: 1 addition & 0 deletions test_runner/src/main/kotlin/ftl/shard/Shard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ object Shard {
val allTests = testsToRun.size
val cacheHit = allTests - cacheMiss
val cachePercent = cacheHit.toDouble() / allTests * 100.0
println()
println(" Smart Flank cache hit: ${cachePercent.roundToInt()}% ($cacheHit / $allTests)")
println(" Shard times: " + shards.joinToString(", ") { "${it.time.roundToInt()}s" } + "\n")

Expand Down
26 changes: 26 additions & 0 deletions test_runner/src/main/kotlin/ftl/util/ProgressBar.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package ftl.util

import java.util.Timer
import java.util.TimerTask

class ProgressBar {
private val task = ProgressBarTask()
private val timer = Timer(true)

fun start(msg: String) {
print(" $msg ")
timer.scheduleAtFixedRate(task, 0, 10_000)
}

fun stop() {
println()
timer.cancel()
task.cancel()
}
}

private class ProgressBarTask : TimerTask() {
override fun run() {
print(".")
}
}
25 changes: 25 additions & 0 deletions test_runner/src/test/kotlin/ftl/util/ProgressBarTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package ftl.util

import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
import org.junit.contrib.java.lang.system.SystemOutRule

class ProgressBarTest {

@Rule
@JvmField
val systemOutRule: SystemOutRule = SystemOutRule().enableLog().muteForSuccessfulTests()

@Test
fun progress_start_stop() {
val progress = ProgressBar()

progress.start("hi")
Thread.sleep(300)
assertThat(systemOutRule.log).isEqualTo(" hi .")

progress.stop()
assertThat(systemOutRule.log).isEqualTo(" hi .\n")
}
}