Skip to content

Commit 5dfdfca

Browse files
committed
Retry on any errors.
1 parent a7fecfb commit 5dfdfca

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tests/src/test/scala/common/RunCliCmd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ trait RunCliCmd extends Matchers {
9696
/** Retries cmd on network error exit. */
9797
private def retry(i: Int, N: Int, cmd: () => RunResult): RunResult = {
9898
val rr = cmd()
99-
if (rr.exitCode == NETWORK_ERROR_EXIT && i < N) {
99+
if (rr.exitCode != SUCCESS_EXIT && i < N) {
100100
Thread.sleep(1.second.toMillis)
101101
println(s"command will retry to due to network error: $rr")
102102
retry(i + 1, N, cmd)

tests/src/test/scala/org/apache/openwhisk/common/RunCliCmdTests.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ class RunCliCmdTests extends FlatSpec with RunCliCmd with BeforeAndAfterEach {
7474
cmdCount shouldBe 1
7575
}
7676

77-
it should "not retry commands if failure is not retriable" in {
78-
Seq(MISUSE_EXIT, ERROR_EXIT, SUCCESS_EXIT).foreach { code =>
77+
it should "retry commands if any failure is happen" in {
78+
Seq(MISUSE_EXIT, ERROR_EXIT).foreach { code =>
7979
cmdCount = 0
8080

8181
rr = Some(TestRunResult(code))
8282
noException shouldBe thrownBy {
8383
cli(Seq.empty, expectedExitCode = DONTCARE_EXIT, retriesOnNetworkError = 3)
8484
}
8585

86-
cmdCount shouldBe 1
86+
cmdCount shouldBe 4
8787
}
8888
}
8989

0 commit comments

Comments
 (0)