This is an automated email from the ASF dual-hosted git repository.
style95 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new 4a69be20c Retry on any errors. (#5280)
4a69be20c is described below
commit 4a69be20cda806680d181666c8126333b31c90ca
Author: Dominic Kim <[email protected]>
AuthorDate: Fri Jul 15 14:29:34 2022 +0900
Retry on any errors. (#5280)
* Retry on any errors.
* Change the variable name.
---
tests/src/test/scala/common/RunCliCmd.scala | 8 ++++----
.../scala/org/apache/openwhisk/common/RunCliCmdTests.scala | 10 +++++-----
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/tests/src/test/scala/common/RunCliCmd.scala
b/tests/src/test/scala/common/RunCliCmd.scala
index 51b25724e..9a31e3765 100644
--- a/tests/src/test/scala/common/RunCliCmd.scala
+++ b/tests/src/test/scala/common/RunCliCmd.scala
@@ -66,8 +66,8 @@ trait RunCliCmd extends Matchers {
stdinFile: Option[File] = None,
showCmd: Boolean = false,
hideFromOutput: Seq[String] = Seq.empty,
- retriesOnNetworkError: Int = 3): RunResult = {
- require(retriesOnNetworkError >= 0, "retry count on network error must not
be negative")
+ retriesOnError: Int = 3): RunResult = {
+ require(retriesOnError >= 0, "retry count on network error must not be
negative")
val args = baseCommand
if (verbose) args += "--verbose"
@@ -79,7 +79,7 @@ trait RunCliCmd extends Matchers {
if (showCmd) println(args.mkString(" "))
val rr =
- retry(0, retriesOnNetworkError, () => runCmd(DONTCARE_EXIT, workingDir,
sys.env ++ env, stdinFile, args.toSeq))
+ retry(0, retriesOnError, () => runCmd(DONTCARE_EXIT, workingDir, sys.env
++ env, stdinFile, args.toSeq))
withClue(hideStr(reportFailure(args, expectedExitCode, rr).toString(),
hideFromOutput)) {
if (expectedExitCode != TestUtils.DONTCARE_EXIT) {
@@ -96,7 +96,7 @@ trait RunCliCmd extends Matchers {
/** Retries cmd on network error exit. */
private def retry(i: Int, N: Int, cmd: () => RunResult): RunResult = {
val rr = cmd()
- if (rr.exitCode == NETWORK_ERROR_EXIT && i < N) {
+ if (rr.exitCode != SUCCESS_EXIT && i < N) {
Thread.sleep(1.second.toMillis)
println(s"command will retry to due to network error: $rr")
retry(i + 1, N, cmd)
diff --git
a/tests/src/test/scala/org/apache/openwhisk/common/RunCliCmdTests.scala
b/tests/src/test/scala/org/apache/openwhisk/common/RunCliCmdTests.scala
index bbcab377a..c4f2bc423 100644
--- a/tests/src/test/scala/org/apache/openwhisk/common/RunCliCmdTests.scala
+++ b/tests/src/test/scala/org/apache/openwhisk/common/RunCliCmdTests.scala
@@ -68,22 +68,22 @@ class RunCliCmdTests extends FlatSpec with RunCliCmd with
BeforeAndAfterEach {
it should "not retry commands if retry is disabled" in {
rr = Some(TestRunResult(NETWORK_ERROR_EXIT))
noException shouldBe thrownBy {
- cli(Seq.empty, expectedExitCode = ANY_ERROR_EXIT, retriesOnNetworkError
= 0)
+ cli(Seq.empty, expectedExitCode = ANY_ERROR_EXIT, retriesOnError = 0)
}
cmdCount shouldBe 1
}
- it should "not retry commands if failure is not retriable" in {
- Seq(MISUSE_EXIT, ERROR_EXIT, SUCCESS_EXIT).foreach { code =>
+ it should "retry commands if any failure is happen" in {
+ Seq(MISUSE_EXIT, ERROR_EXIT).foreach { code =>
cmdCount = 0
rr = Some(TestRunResult(code))
noException shouldBe thrownBy {
- cli(Seq.empty, expectedExitCode = DONTCARE_EXIT, retriesOnNetworkError
= 3)
+ cli(Seq.empty, expectedExitCode = DONTCARE_EXIT, retriesOnError = 3)
}
- cmdCount shouldBe 1
+ cmdCount shouldBe 4
}
}