You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by md...@apache.org on 2018/07/03 20:20:46 UTC
[incubator-openwhisk] branch master updated (be89eb7 -> f604672)
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git.
from be89eb7 Allow ElasticSearchClient to retrieve hit count. (#3794)
new 654ec5c Remove swift tests.
new d7e5417 Rename test suite.
new 80d1cf7 Delete really dated sequence schema related tests.
new 0e05f6b Remove reference to wsk CLI class Wsk.
new a75d063 More cleanup of BaseRunWsk, and some redundant methods.
new a4ac8f7 Remove return statements.
new c63a4f5 Scala-isms and more code cleanup.
new 583862d Remove unnecessary dependency injection and flatten type hiearchy some more.
new 6f358fe Remove RunWskAdminCmd trait.
new 07c5c90 Move a trait and singleton around.
new ce185af Rename trait and file.
new 38c3679 Renaming, no intended semantic change.
new 663440d Remove burried ActorSystem which turned into several instances for every instantiated instance of the Rest 'wsk'.
new 34fc4b0 Re-introduce cli bindings.
new ed435e7 Remove return statements.
new 49e89cb Add back utility method used downstream, with deprecation notice issued in logs.
new 722f4c5 Allow wsk CLI path to be overriden.
new 474d2e5 Allow for commands to on network error. Add test for run cmd with retry.
new f604672 Change import to be fully qualified.
The 19 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
tests/dat/actions/seq_echo_word_count.json | 25 --
tests/dat/actions/seq_type_2.json | 33 ---
.../apigw/healthtests/ApiGwEndToEndTests.scala | 12 +-
.../apigw/healthtests/ApiGwRestEndToEndTests.scala | 13 +-
tests/src/test/scala/common/RunCliCmd.scala | 147 +++++++++
.../common/{Wsk.scala => WskCliOperations.scala} | 292 +++++-------------
.../common/{BaseWsk.scala => WskOperations.scala} | 151 +++++-----
tests/src/test/scala/common/WskTestHelpers.scala | 72 +++--
.../{WskRest.scala => WskRestOperations.scala} | 327 ++++++++++-----------
tests/src/test/scala/ha/ShootComponentsTests.scala | 4 +-
tests/src/test/scala/limits/ThrottleTests.scala | 17 +-
tests/src/test/scala/services/HeadersTests.scala | 4 +-
.../test/scala/system/basic/WskActionTests.scala | 12 +-
.../scala/system/basic/WskActivationTests.scala | 4 +-
.../scala/system/basic/WskBasicJavaTests.scala | 4 +-
.../scala/system/basic/WskBasicNode6Tests.scala | 4 +-
.../system/basic/WskBasicNodeDefaultTests.scala | 4 +-
.../scala/system/basic/WskBasicPythonTests.scala | 4 +-
.../scala/system/basic/WskBasicSwift3Tests.scala | 4 +-
.../scala/system/basic/WskConductorTests.scala | 4 +-
.../test/scala/system/basic/WskConsoleTests.scala | 4 +-
.../test/scala/system/basic/WskPackageTests.scala | 4 +-
.../scala/system/basic/WskRestActionTests.scala | 12 +-
.../system/basic/WskRestActivationTests.scala | 7 +-
.../scala/system/basic/WskRestBasicJavaTests.scala | 8 +-
.../system/basic/WskRestBasicNode6Tests.scala | 7 +-
.../system/basic/WskRestBasicNode8Tests.scala | 7 +-
.../basic/WskRestBasicNodeDefaultTests.scala | 7 +-
.../system/basic/WskRestBasicPythonTests.scala | 7 +-
.../system/basic/WskRestBasicSwift311Tests.scala | 7 +-
.../system/basic/WskRestBasicSwift41Tests.scala | 7 +-
.../scala/system/basic/WskRestBasicTests.scala | 10 +-
.../scala/system/basic/WskRestConductorTests.scala | 7 +-
.../scala/system/basic/WskRestPackageTests.scala | 8 +-
.../test/scala/system/basic/WskRestRuleTests.scala | 11 +-
.../scala/system/basic/WskRestSequenceTests.scala | 4 +-
.../system/basic/WskRestUnicodeJavaTests.scala | 7 +-
.../system/basic/WskRestUnicodeNode6Tests.scala | 7 +-
.../system/basic/WskRestUnicodeNode8Tests.scala | 7 +-
.../system/basic/WskRestUnicodePython2Tests.scala | 10 +-
.../system/basic/WskRestUnicodePython3Tests.scala | 10 +-
.../system/basic/WskRestUnicodeSwift311Tests.scala | 10 +-
.../system/basic/WskRestUnicodeSwift41Tests.scala | 8 +-
.../src/test/scala/system/basic/WskRuleTests.scala | 4 +-
.../test/scala/system/basic/WskSequenceTests.scala | 4 +-
.../test/scala/system/basic/WskUnicodeTests.scala | 4 +-
.../test/scala/system/rest/ActionSchemaTests.scala | 20 +-
.../test/scala/whisk/common/RunCliCmdTests.scala | 90 ++++++
.../test/scala/whisk/common/UserEventTests.scala | 4 +-
.../scala/whisk/core/admin/WskAdminTests.scala | 31 +-
.../test/ApiGwRestRoutemgmtActionTests.scala | 4 +-
.../actions/test/ApiGwRoutemgmtActionTests.scala | 23 +-
.../whisk/core/cli/test/ApiGwRestBasicTests.scala | 2 +-
.../scala/whisk/core/cli/test/ApiGwRestTests.scala | 10 +-
.../scala/whisk/core/cli/test/BaseApiGwTests.scala | 4 +-
.../core/cli/test/SequenceMigrationTests.scala | 137 ---------
.../scala/whisk/core/cli/test/Swift311Tests.scala | 65 ----
.../core/cli/test/WskActionSequenceTests.scala | 6 +-
.../whisk/core/cli/test/WskEntitlementTests.scala | 4 +-
.../core/cli/test/WskRestActionSequenceTests.scala | 8 +-
.../core/cli/test/WskRestBasicUsageTests.scala | 11 +-
.../core/cli/test/WskRestEntitlementTests.scala | 9 +-
.../core/cli/test/WskRestWebActionsTests.scala | 8 +-
.../whisk/core/cli/test/WskWebActionsTests.scala | 10 +-
.../core/database/test/CacheConcurrencyTests.scala | 13 +-
.../whisk/core/limits/ActionLimitsTests.scala | 8 +-
.../whisk/core/limits/MaxActionDurationTests.scala | 8 +-
67 files changed, 836 insertions(+), 964 deletions(-)
delete mode 100644 tests/dat/actions/seq_echo_word_count.json
delete mode 100644 tests/dat/actions/seq_type_2.json
create mode 100644 tests/src/test/scala/common/RunCliCmd.scala
rename tests/src/test/scala/common/{Wsk.scala => WskCliOperations.scala} (79%)
rename tests/src/test/scala/common/{BaseWsk.scala => WskOperations.scala} (77%)
rename tests/src/test/scala/common/rest/{WskRest.scala => WskRestOperations.scala} (87%)
create mode 100644 tests/src/test/scala/whisk/common/RunCliCmdTests.scala
delete mode 100644 tests/src/test/scala/whisk/core/cli/test/SequenceMigrationTests.scala
delete mode 100644 tests/src/test/scala/whisk/core/cli/test/Swift311Tests.scala
[incubator-openwhisk] 06/19: Remove return statements.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit a4ac8f75a6303c751e9d0517be47aa2549c4269a
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Fri Jun 8 15:14:42 2018 -0400
Remove return statements.
---
.../scala/apigw/healthtests/ApiGwEndToEndTests.scala | 6 ++----
.../apigw/healthtests/ApiGwRestEndToEndTests.scala | 4 ++--
tests/src/test/scala/common/rest/WskRest.scala | 15 +++++++--------
.../actions/test/ApiGwRoutemgmtActionTests.scala | 19 +++++++++----------
.../scala/whisk/core/cli/test/ApiGwRestTests.scala | 2 +-
5 files changed, 21 insertions(+), 25 deletions(-)
diff --git a/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala b/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala
index 8995c7a..1b0f5e0 100644
--- a/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala
+++ b/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala
@@ -98,12 +98,10 @@ abstract class ApiGwEndToEndTests
val bw = new BufferedWriter(new FileWriter(swaggerfile))
bw.write(rr.stdout)
bw.close()
- return swaggerfile
+ swaggerfile
}
- def getSwaggerApiUrl(rr: RunResult): String = {
- return rr.stdout.split("\n")(1)
- }
+ def getSwaggerApiUrl(rr: RunResult): String = rr.stdout.split("\n")(1)
behavior of "Wsk api"
diff --git a/tests/src/test/scala/apigw/healthtests/ApiGwRestEndToEndTests.scala b/tests/src/test/scala/apigw/healthtests/ApiGwRestEndToEndTests.scala
index 279da3c..2f92185 100644
--- a/tests/src/test/scala/apigw/healthtests/ApiGwRestEndToEndTests.scala
+++ b/tests/src/test/scala/apigw/healthtests/ApiGwRestEndToEndTests.scala
@@ -83,11 +83,11 @@ class ApiGwRestEndToEndTests extends ApiGwEndToEndTests {
val apidoc = RestResult.getFieldJsObject(apiValue, "apidoc")
bw.write(apidoc.toString())
bw.close()
- return swaggerfile
+ swaggerfile
}
override def getSwaggerApiUrl(rr: RunResult): String = {
val apiResultRest = rr.asInstanceOf[RestResult]
- return apiResultRest.getField("gwApiUrl") + "/path"
+ apiResultRest.getField("gwApiUrl") + "/path"
}
}
diff --git a/tests/src/test/scala/common/rest/WskRest.scala b/tests/src/test/scala/common/rest/WskRest.scala
index b981013..a4cc09f 100644
--- a/tests/src/test/scala/common/rest/WskRest.scala
+++ b/tests/src/test/scala/common/rest/WskRest.scala
@@ -1201,14 +1201,13 @@ class WskRestApi extends RunWskRestCmd with BaseApi {
Map("spaceguid" -> wp.authKey.split(":")(0).toJson)
}
- val rr = invokeAction(
+ invokeAction(
name = "apimgmt/deleteApi",
parameters = parms,
blocking = true,
result = true,
web = true,
expectedExitCode = expectedExitCode)(wp)
- return rr
}
}
@@ -1244,7 +1243,7 @@ class RunWskRestCmd() extends FlatSpec with Matchers with ScalaFutures with WskA
}
def getNamePath(noun: String, name: String)(implicit wp: WskProps): Path = {
- return Path(s"$basePath/namespaces/${wp.namespace}/$noun/$name")
+ Path(s"$basePath/namespaces/${wp.namespace}/$noun/$name")
}
def getExt(filePath: String)(implicit wp: WskProps) = {
@@ -1441,9 +1440,9 @@ object RestResult {
}
def convertStausCodeToExitCode(statusCode: StatusCode, blocking: Boolean = false): Int = {
- if ((statusCode == OK) || (!blocking && (statusCode == Accepted)))
- return 0
- if (statusCode.intValue < BadRequest.intValue) statusCode.intValue else statusCode.intValue - codeConversion
+ if ((statusCode == OK) || (!blocking && (statusCode == Accepted))) 0
+ else if (statusCode.intValue < BadRequest.intValue) statusCode.intValue
+ else statusCode.intValue - codeConversion
}
def convertHttpResponseToStderr(respData: String): String = {
@@ -1499,8 +1498,8 @@ class ApiAction(var name: String,
var backendMethod: String = "POST",
var backendUrl: String,
var authkey: String) {
- def toJson(): JsObject = {
- return JsObject(
+ def toJson() = {
+ JsObject(
"name" -> name.toJson,
"namespace" -> namespace.toJson,
"backendMethod" -> backendMethod.toJson,
diff --git a/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala b/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala
index 57449e6..b283af5 100644
--- a/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala
+++ b/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala
@@ -99,7 +99,7 @@ abstract class ApiGwRoutemgmtActionTests
case e: Exception =>
JsArray.empty
}
- return apiJsArray.elements
+ apiJsArray.elements
}
def createApi(namespace: Option[String] = Some("_"),
@@ -155,13 +155,12 @@ abstract class ApiGwRoutemgmtActionTests
} getOrElse Map[String, JsValue]()
}
- val rr = wsk.action.invoke(
+ wsk.action.invoke(
name = "apimgmt/createApi",
parameters = parm,
blocking = true,
result = true,
expectedExitCode = expectedExitCode)(wskprops)
- return rr
}
def deleteApi(namespace: Option[String] = Some("_"),
@@ -202,13 +201,12 @@ abstract class ApiGwRoutemgmtActionTests
} getOrElse Map[String, JsValue]()
}
- val rr = wsk.action.invoke(
+ wsk.action.invoke(
name = "apimgmt/deleteApi",
parameters = parms,
blocking = true,
result = true,
expectedExitCode = expectedExitCode)(wskprops)
- return rr
}
def apiMatch(apiarr: Vector[JsValue],
@@ -256,7 +254,8 @@ abstract class ApiGwRoutemgmtActionTests
}
}
}
- return matches
+
+ matches
}
def actionMatch(jsAction: JsObject, action: ApiAction): Boolean = {
@@ -265,10 +264,10 @@ abstract class ApiGwRoutemgmtActionTests
System.out.println(
"actionMatch: namespace " + jsAction.fields("namespace").convertTo[String] + "; namespace " + action.namespace)
System.out.println("actionMatch: action " + jsAction.fields("action").convertTo[String] + "; action " + action.name)
- val matches = jsAction.fields("url").convertTo[String] == action.backendUrl &&
- jsAction.fields("namespace").convertTo[String] == action.namespace &&
- jsAction.fields("action").convertTo[String] == action.name
- return matches
+
+ jsAction.fields("url").convertTo[String] == action.backendUrl &&
+ jsAction.fields("namespace").convertTo[String] == action.namespace &&
+ jsAction.fields("action").convertTo[String] == action.name
}
behavior of "API Gateway apimgmt action parameter validation"
diff --git a/tests/src/test/scala/whisk/core/cli/test/ApiGwRestTests.scala b/tests/src/test/scala/whisk/core/cli/test/ApiGwRestTests.scala
index 43a95be..b118e81 100644
--- a/tests/src/test/scala/whisk/core/cli/test/ApiGwRestTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/ApiGwRestTests.scala
@@ -249,7 +249,7 @@ class ApiGwRestTests extends ApiGwRestBasicTests with RestUtil {
def getSwaggerApiUrl(rr: RunResult): String = {
val apiResultRest = rr.asInstanceOf[RestResult]
- return apiResultRest.getField("gwApiUrl") + "/path"
+ apiResultRest.getField("gwApiUrl") + "/path"
}
def getParametersFromJson(rr: RunResult, pathName: String): Vector[JsObject] = {
[incubator-openwhisk] 18/19: Allow for commands to on network
error. Add test for run cmd with retry.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit 474d2e584b158326a554d6475f4f1ea6befcb247
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Sun Jun 17 11:58:52 2018 -0400
Allow for commands to on network error. Add test for run cmd with retry.
---
tests/src/test/scala/common/RunCliCmd.scala | 32 +++++---
.../test/scala/whisk/common/RunCliCmdTests.scala | 90 ++++++++++++++++++++++
2 files changed, 113 insertions(+), 9 deletions(-)
diff --git a/tests/src/test/scala/common/RunCliCmd.scala b/tests/src/test/scala/common/RunCliCmd.scala
index a7c0c24..682e7c6 100644
--- a/tests/src/test/scala/common/RunCliCmd.scala
+++ b/tests/src/test/scala/common/RunCliCmd.scala
@@ -23,7 +23,6 @@ import scala.collection.JavaConversions.mapAsJavaMap
import scala.collection.mutable.Buffer
import org.scalatest.Matchers
import TestUtils._
-import whisk.utils.retry
import scala.concurrent.duration._
import scala.collection.mutable
@@ -35,6 +34,24 @@ trait RunCliCmd extends Matchers {
def baseCommand: Buffer[String]
/**
+ * Delegates execution of the command to an underlying implementation.
+ *
+ * @param expectedExitCode the expected exit code
+ * @param dir the working directory
+ * @param env an environment for the command
+ * @param fileStdin argument file to redirect to stdin (optional)
+ * @param params parameters to pass on the command line
+ * @return an instance of RunResult
+ */
+ def runCmd(expectedExitCode: Int,
+ dir: File,
+ env: Map[String, String],
+ fileStdin: Option[File],
+ params: Seq[String]): RunResult = {
+ TestUtils.runCmd(expectedExitCode, dir, TestUtils.logger, env, fileStdin.getOrElse(null), params: _*)
+ }
+
+ /**
* Runs a command wsk [params] where the arguments come in as a sequence.
*
* @return RunResult which contains stdout, stderr, exit code
@@ -48,20 +65,16 @@ trait RunCliCmd extends Matchers {
showCmd: Boolean = false,
hideFromOutput: Seq[String] = Seq(),
retriesOnNetworkError: Int = 3): RunResult = {
+ require(retriesOnNetworkError >= 0, "retry count on network error must not be negative")
+
val args = baseCommand
if (verbose) args += "--verbose"
if (showCmd) println(args.mkString(" ") + " " + params.mkString(" "))
+
val rr = retry(
0,
retriesOnNetworkError,
- () =>
- TestUtils.runCmd(
- DONTCARE_EXIT,
- workingDir,
- TestUtils.logger,
- sys.env ++ env,
- stdinFile.getOrElse(null),
- args ++ params: _*))
+ () => runCmd(DONTCARE_EXIT, workingDir, sys.env ++ env, stdinFile, args ++ params))
withClue(hideStr(reportFailure(args ++ params, expectedExitCode, rr).toString(), hideFromOutput)) {
if (expectedExitCode != TestUtils.DONTCARE_EXIT) {
@@ -83,6 +96,7 @@ trait RunCliCmd extends Matchers {
println(s"command will retry to due to network error: $rr")
retry(i + 1, N, cmd)
} else rr
+ }
/**
* Takes a string and a list of sensitive strings. Any sensistive string found in
diff --git a/tests/src/test/scala/whisk/common/RunCliCmdTests.scala b/tests/src/test/scala/whisk/common/RunCliCmdTests.scala
new file mode 100644
index 0000000..548aa06
--- /dev/null
+++ b/tests/src/test/scala/whisk/common/RunCliCmdTests.scala
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package whisk.common
+
+import java.io.File
+
+import org.junit.runner.RunWith
+import org.scalatest.{BeforeAndAfterEach, FlatSpec}
+import org.scalatest.junit.JUnitRunner
+import common.RunCliCmd
+import common.TestUtils._
+
+import scala.collection.mutable.Buffer
+
+@RunWith(classOf[JUnitRunner])
+class RunCliCmdTests extends FlatSpec with RunCliCmd with BeforeAndAfterEach {
+
+ case class TestRunResult(code: Int) extends RunResult(code, "", "")
+ val defaultRR = TestRunResult(0)
+
+ override def baseCommand = Buffer.empty
+
+ override def runCmd(expectedExitCode: Int,
+ dir: File,
+ env: Map[String, String],
+ fileStdin: Option[File],
+ params: Seq[String]): RunResult = {
+ cmdCount += 1
+ rr.getOrElse(defaultRR)
+ }
+
+ override def beforeEach() = {
+ rr = None
+ cmdCount = 0
+ }
+
+ var rr: Option[TestRunResult] = None // optional run result override per test
+ var cmdCount = 0
+
+ it should "retry commands that experience network errors" in {
+ Seq(ANY_ERROR_EXIT, DONTCARE_EXIT, NETWORK_ERROR_EXIT).foreach { code =>
+ cmdCount = 0
+
+ rr = Some(TestRunResult(NETWORK_ERROR_EXIT))
+ noException shouldBe thrownBy {
+ cli(Seq.empty, expectedExitCode = code)
+ }
+
+ cmdCount shouldBe 3 + 1
+ }
+ }
+
+ 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)
+ }
+
+ cmdCount shouldBe 1
+ }
+
+ it should "not retry commands if failure is not retriable" in {
+ Seq(MISUSE_EXIT, ERROR_EXIT, SUCCESS_EXIT).foreach { code =>
+ cmdCount = 0
+
+ rr = Some(TestRunResult(code))
+ noException shouldBe thrownBy {
+ cli(Seq.empty, expectedExitCode = DONTCARE_EXIT, retriesOnNetworkError = 3)
+ }
+
+ cmdCount shouldBe 1
+ }
+ }
+
+}
[incubator-openwhisk] 09/19: Remove RunWskAdminCmd trait.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit 6f358fecd24ddd7099d91f49fe6b537c24ba3fa4
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Fri Jun 8 16:28:43 2018 -0400
Remove RunWskAdminCmd trait.
---
tests/src/test/scala/common/Wsk.scala | 13 +++++------
tests/src/test/scala/common/WskTestHelpers.scala | 4 ++--
tests/src/test/scala/limits/ThrottleTests.scala | 10 ++------
.../scala/whisk/core/admin/WskAdminTests.scala | 27 ++++++----------------
4 files changed, 17 insertions(+), 37 deletions(-)
diff --git a/tests/src/test/scala/common/Wsk.scala b/tests/src/test/scala/common/Wsk.scala
index 4d1f3ce..1d40ba3 100644
--- a/tests/src/test/scala/common/Wsk.scala
+++ b/tests/src/test/scala/common/Wsk.scala
@@ -23,11 +23,11 @@ import scala.collection.JavaConversions.mapAsJavaMap
import scala.collection.mutable.Buffer
import scala.language.postfixOps
import scala.util.Try
-
import org.scalatest.Matchers
-
import TestUtils._
+import scala.collection.mutable
+
trait HasActivation {
/**
@@ -160,6 +160,10 @@ trait RunWskCmd extends Matchers {
}
object WskAdmin {
+ val wskadmin = new RunWskCmd {
+ override def baseCommand: mutable.Buffer[String] = WskAdmin.baseCommand
+ }
+
private val binDir = WhiskProperties.getFileRelativeToWhiskHome("bin")
private val binaryName = "wskadmin"
@@ -175,7 +179,6 @@ object WskAdmin {
}
def listKeys(namespace: String, pick: Integer = 1): List[(String, String)] = {
- val wskadmin = new RunWskAdminCmd {}
wskadmin
.cli(Seq("user", "list", namespace, "--pick", pick.toString))
.stdout
@@ -185,7 +188,3 @@ object WskAdmin {
.toList
}
}
-
-trait RunWskAdminCmd extends RunWskCmd {
- override def baseCommand = WskAdmin.baseCommand
-}
diff --git a/tests/src/test/scala/common/WskTestHelpers.scala b/tests/src/test/scala/common/WskTestHelpers.scala
index 3afa610..e889a22 100644
--- a/tests/src/test/scala/common/WskTestHelpers.scala
+++ b/tests/src/test/scala/common/WskTestHelpers.scala
@@ -277,12 +277,12 @@ trait WskTestHelpers extends Matchers {
}
def getAdditionalTestSubject(newUser: String): WskProps = {
- val wskadmin = new RunWskAdminCmd {}
+ import WskAdmin.wskadmin
WskProps(namespace = newUser, authKey = wskadmin.cli(Seq("user", "create", newUser)).stdout.trim)
}
def disposeAdditionalTestSubject(subject: String, expectedExitCode: Int = SUCCESS_EXIT): Unit = {
- val wskadmin = new RunWskAdminCmd {}
+ import WskAdmin.wskadmin
withClue(s"failed to delete temporary subject $subject") {
wskadmin.cli(Seq("user", "delete", subject), expectedExitCode).stdout should include("Subject deleted")
}
diff --git a/tests/src/test/scala/limits/ThrottleTests.scala b/tests/src/test/scala/limits/ThrottleTests.scala
index f132995..bc5da1e 100644
--- a/tests/src/test/scala/limits/ThrottleTests.scala
+++ b/tests/src/test/scala/limits/ThrottleTests.scala
@@ -31,15 +31,10 @@ import org.scalatest.FlatSpec
import org.scalatest.Matchers
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.junit.JUnitRunner
-import common.RunWskAdminCmd
-import common.TestHelpers
-import common.TestUtils
+import common._
import common.TestUtils._
-import common.WhiskProperties
import common.rest.WskRest
-import common.WskActorSystem
-import common.WskProps
-import common.WskTestHelpers
+import WskAdmin.wskadmin
import spray.json._
import spray.json.DefaultJsonProtocol._
import whisk.http.Messages._
@@ -306,7 +301,6 @@ class NamespaceSpecificThrottleTests
val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
- val wskadmin = new RunWskAdminCmd {}
val wsk = new WskRest
def sanitizeNamespaces(namespaces: Seq[String], expectedExitCode: Int = SUCCESS_EXIT): Unit = {
diff --git a/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala b/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala
index c76dff9..e5bcff3 100644
--- a/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala
+++ b/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala
@@ -17,28 +17,22 @@
package whisk.core.admin
-import scala.concurrent.duration.DurationInt
-
+import common.WskAdmin.wskadmin
+import common.{TestHelpers, TestUtils, WskAdmin, WskProps}
+import common.rest.WskRest
import org.junit.runner.RunWith
-import org.scalatest.Matchers
+import org.scalatest.{BeforeAndAfterAll, Matchers}
import org.scalatest.junit.JUnitRunner
-import org.scalatest.BeforeAndAfterAll
-
-import common.RunWskAdminCmd
+import whisk.core.entity.{BasicAuthenticationAuthKey, Subject}
import common.TestHelpers
-import common.rest.WskRest
-import common.WskAdmin
-import common.WskProps
-import whisk.core.entity.BasicAuthenticationAuthKey
-import whisk.core.entity.Subject
-import common.TestUtils
+
+import scala.concurrent.duration.DurationInt
import scala.util.Try
@RunWith(classOf[JUnitRunner])
class WskAdminTests extends TestHelpers with Matchers with BeforeAndAfterAll {
override def beforeAll() = {
- val wskadmin = new RunWskAdminCmd {}
val testSpaces = Seq("testspace", "testspace1", "testspace2")
testSpaces.foreach(testspace => {
Try {
@@ -60,7 +54,6 @@ class WskAdminTests extends TestHelpers with Matchers with BeforeAndAfterAll {
}
it should "CRD a subject" in {
- val wskadmin = new RunWskAdminCmd {}
val auth = BasicAuthenticationAuthKey()
val subject = Subject().asString
try {
@@ -103,7 +96,6 @@ class WskAdminTests extends TestHelpers with Matchers with BeforeAndAfterAll {
}
it should "list all namespaces for a subject" in {
- val wskadmin = new RunWskAdminCmd {}
val auth = BasicAuthenticationAuthKey()
val subject = Subject().asString
try {
@@ -122,7 +114,6 @@ class WskAdminTests extends TestHelpers with Matchers with BeforeAndAfterAll {
}
it should "verify guest account installed correctly" in {
- val wskadmin = new RunWskAdminCmd {}
implicit val wskprops = WskProps()
val wsk = new WskRest
val ns = wsk.namespace.whois()
@@ -130,7 +121,6 @@ class WskAdminTests extends TestHelpers with Matchers with BeforeAndAfterAll {
}
it should "block and unblock a user respectively" in {
- val wskadmin = new RunWskAdminCmd {}
val auth = BasicAuthenticationAuthKey()
val subject1 = Subject().asString
val subject2 = Subject().asString
@@ -170,7 +160,6 @@ class WskAdminTests extends TestHelpers with Matchers with BeforeAndAfterAll {
}
it should "block and unblock should accept more than a single subject" in {
- val wskadmin = new RunWskAdminCmd {}
val subject1 = Subject().asString
val subject2 = Subject().asString
try {
@@ -196,7 +185,6 @@ class WskAdminTests extends TestHelpers with Matchers with BeforeAndAfterAll {
}
it should "not allow edits on a blocked subject" in {
- val wskadmin = new RunWskAdminCmd {}
val subject = Subject().asString
try {
// initially create the subject
@@ -217,7 +205,6 @@ class WskAdminTests extends TestHelpers with Matchers with BeforeAndAfterAll {
}
it should "adjust throttles for namespace" in {
- val wskadmin = new RunWskAdminCmd {}
val subject = Subject().asString
try {
// set some limits
[incubator-openwhisk] 04/19: Remove reference to wsk CLI class Wsk.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit 0e05f6b2cb7e6c7b4ad26c6ef719732062fddaa6
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Fri Jun 8 11:25:39 2018 -0400
Remove reference to wsk CLI class Wsk.
---
tests/src/test/scala/common/Wsk.scala | 937 +--------------------
tests/src/test/scala/common/rest/WskRest.scala | 3 +-
.../test/scala/system/basic/WskActionTests.scala | 9 +-
3 files changed, 8 insertions(+), 941 deletions(-)
diff --git a/tests/src/test/scala/common/Wsk.scala b/tests/src/test/scala/common/Wsk.scala
index a335f03..af59e19 100644
--- a/tests/src/test/scala/common/Wsk.scala
+++ b/tests/src/test/scala/common/Wsk.scala
@@ -18,148 +18,13 @@
package common
import java.io.File
-import java.time.Instant
-
-import scala.Left
-import scala.Right
import scala.collection.JavaConversions.mapAsJavaMap
+
import scala.collection.mutable.Buffer
-import scala.concurrent.duration.Duration
-import scala.concurrent.duration.DurationInt
import scala.language.postfixOps
-import scala.util.Failure
-import scala.util.Success
import scala.util.Try
import TestUtils._
-import spray.json.JsObject
-import spray.json.JsValue
-import whisk.core.entity.ByteSize
-import whisk.utils.retry
-
-/**
- * Provide Scala bindings for the whisk CLI.
- *
- * Each of the top level CLI commands is a "noun" class that extends one
- * of several traits that are common to the whisk collections and corresponds
- * to one of the top level CLI nouns.
- *
- * Each of the "noun" classes mixes in the RunWskCmd trait which runs arbitrary
- * wsk commands and returns the results. Optionally RunWskCmd can validate the exit
- * code matched a desired value.
- *
- * The various collections support one or more of these as common traits:
- * list, get, delete, and sanitize.
- * Sanitize is akin to delete but accepts a failure because entity may not
- * exit. Additionally, some of the nouns define custom commands.
- *
- * All of the commands define default values that are either optional
- * or omitted in the common case. This makes for a compact implementation
- * instead of using a Builder pattern.
- *
- * An implicit WskProps instance is required for all of CLI commands. This
- * type provides the authentication key for the API as well as the namespace.
- * It also sets the apihost and apiversion explicitly to avoid ambiguity with
- * a local property file if it exists.
- */
-class Wsk() extends RunWskCmd with BaseWsk {
- override implicit val action = new WskAction
- override implicit val trigger = new WskTrigger
- override implicit val rule = new WskRule
- override implicit val activation = new WskActivation
- override implicit val pkg = new WskPackage
- override implicit val namespace = new WskNamespace
- override implicit val api = new WskApi
-}
-
-trait ListOrGetFromCollectionCLI extends BaseListOrGetFromCollection {
- self: RunWskCmd =>
-
- /**
- * List entities in collection.
- *
- * @param namespace (optional) if specified must be fully qualified namespace
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def list(namespace: Option[String] = None,
- limit: Option[Int] = None,
- nameSort: Option[Boolean] = None,
- expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- val params = Seq(noun, "list", resolve(namespace), "--auth", wp.authKey) ++ {
- limit map { l =>
- Seq("--limit", l.toString)
- } getOrElse Seq()
- } ++ {
- nameSort map { n =>
- Seq("--name-sort")
- } getOrElse Seq()
- }
- cli(wp.overrides ++ params, expectedExitCode)
- }
-
- /**
- * Gets entity from collection.
- *
- * @param name either a fully qualified name or a simple entity name
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def get(name: String,
- expectedExitCode: Int = SUCCESS_EXIT,
- summary: Boolean = false,
- fieldFilter: Option[String] = None,
- url: Option[Boolean] = None,
- save: Option[Boolean] = None,
- saveAs: Option[String] = None)(implicit wp: WskProps): RunResult = {
-
- val params = Seq(noun, "get", "--auth", wp.authKey) ++
- Seq(fqn(name)) ++ { if (summary) Seq("--summary") else Seq() } ++ {
- fieldFilter map { f =>
- Seq(f)
- } getOrElse Seq()
- } ++ {
- url map { u =>
- Seq("--url")
- } getOrElse Seq()
- } ++ {
- save map { s =>
- Seq("--save")
- } getOrElse Seq()
- } ++ {
- saveAs map { s =>
- Seq("--save-as", s)
- } getOrElse Seq()
- }
-
- cli(wp.overrides ++ params, expectedExitCode)
- }
-}
-
-trait DeleteFromCollectionCLI extends BaseDeleteFromCollection {
- self: RunWskCmd =>
-
- /**
- * Deletes entity from collection.
- *
- * @param name either a fully qualified name or a simple entity name
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def delete(name: String, expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- cli(wp.overrides ++ Seq(noun, "delete", "--auth", wp.authKey, fqn(name)), expectedExitCode)
- }
-
- /**
- * Deletes entity from collection but does not assert that the command succeeds.
- * Use this if deleting an entity that may not exist and it is OK if it does not.
- *
- * @param name either a fully qualified name or a simple entity name
- */
- override def sanitize(name: String)(implicit wp: WskProps): RunResult = {
- delete(name, DONTCARE_EXIT)
- }
-}
trait HasActivation {
@@ -217,808 +82,12 @@ trait HasActivation {
}
}
-class WskAction()
- extends RunWskCmd
- with ListOrGetFromCollectionCLI
- with DeleteFromCollectionCLI
- with HasActivation
- with BaseAction {
-
- override protected val noun = "action"
-
- /**
- * Creates action. Parameters mirror those available in the CLI.
- *
- * @param name either a fully qualified name or a simple entity name
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def create(
- name: String,
- artifact: Option[String],
- kind: Option[String] = None, // one of docker, copy, sequence or none for autoselect else an explicit type
- main: Option[String] = None,
- docker: Option[String] = None,
- parameters: Map[String, JsValue] = Map(),
- annotations: Map[String, JsValue] = Map(),
- parameterFile: Option[String] = None,
- annotationFile: Option[String] = None,
- timeout: Option[Duration] = None,
- memory: Option[ByteSize] = None,
- logsize: Option[ByteSize] = None,
- shared: Option[Boolean] = None,
- update: Boolean = false,
- web: Option[String] = None,
- websecure: Option[String] = None,
- expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- val params = Seq(noun, if (!update) "create" else "update", "--auth", wp.authKey, fqn(name)) ++ {
- artifact map { Seq(_) } getOrElse Seq()
- } ++ {
- kind map { k =>
- if (k == "sequence" || k == "copy" || k == "native") Seq(s"--$k")
- else Seq("--kind", k)
- } getOrElse Seq()
- } ++ {
- main.toSeq flatMap { p =>
- Seq("--main", p)
- }
- } ++ {
- docker.toSeq flatMap { p =>
- Seq("--docker", p)
- }
- } ++ {
- parameters flatMap { p =>
- Seq("-p", p._1, p._2.compactPrint)
- }
- } ++ {
- annotations flatMap { p =>
- Seq("-a", p._1, p._2.compactPrint)
- }
- } ++ {
- parameterFile map { pf =>
- Seq("-P", pf)
- } getOrElse Seq()
- } ++ {
- annotationFile map { af =>
- Seq("-A", af)
- } getOrElse Seq()
- } ++ {
- timeout map { t =>
- Seq("-t", t.toMillis.toString)
- } getOrElse Seq()
- } ++ {
- memory map { m =>
- Seq("-m", m.toMB.toString)
- } getOrElse Seq()
- } ++ {
- logsize map { l =>
- Seq("-l", l.toMB.toString)
- } getOrElse Seq()
- } ++ {
- shared map { s =>
- Seq("--shared", if (s) "yes" else "no")
- } getOrElse Seq()
- } ++ {
- web map { w =>
- Seq("--web", w)
- } getOrElse Seq()
- } ++ {
- websecure map { ws =>
- Seq("--web-secure", ws)
- } getOrElse Seq()
- }
- cli(wp.overrides ++ params, expectedExitCode)
- }
-
- /**
- * Invokes action. Parameters mirror those available in the CLI.
- *
- * @param name either a fully qualified name or a simple entity name
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def invoke(name: String,
- parameters: Map[String, JsValue] = Map(),
- parameterFile: Option[String] = None,
- blocking: Boolean = false,
- result: Boolean = false,
- expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- val params = Seq(noun, "invoke", "--auth", wp.authKey, fqn(name)) ++ {
- parameters flatMap { p =>
- Seq("-p", p._1, p._2.compactPrint)
- }
- } ++ {
- parameterFile map { pf =>
- Seq("-P", pf)
- } getOrElse Seq()
- } ++ { if (blocking) Seq("--blocking") else Seq() } ++ { if (result) Seq("--result") else Seq() }
- cli(wp.overrides ++ params, expectedExitCode)
- }
-}
-
-class WskTrigger()
- extends RunWskCmd
- with ListOrGetFromCollectionCLI
- with DeleteFromCollectionCLI
- with HasActivation
- with BaseTrigger {
-
- override protected val noun = "trigger"
-
- /**
- * Creates trigger. Parameters mirror those available in the CLI.
- *
- * @param name either a fully qualified name or a simple entity name
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def create(name: String,
- parameters: Map[String, JsValue] = Map(),
- annotations: Map[String, JsValue] = Map(),
- parameterFile: Option[String] = None,
- annotationFile: Option[String] = None,
- feed: Option[String] = None,
- shared: Option[Boolean] = None,
- update: Boolean = false,
- expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- val params = Seq(noun, if (!update) "create" else "update", "--auth", wp.authKey, fqn(name)) ++ {
- feed map { f =>
- Seq("--feed", fqn(f))
- } getOrElse Seq()
- } ++ {
- parameters flatMap { p =>
- Seq("-p", p._1, p._2.compactPrint)
- }
- } ++ {
- annotations flatMap { p =>
- Seq("-a", p._1, p._2.compactPrint)
- }
- } ++ {
- parameterFile map { pf =>
- Seq("-P", pf)
- } getOrElse Seq()
- } ++ {
- annotationFile map { af =>
- Seq("-A", af)
- } getOrElse Seq()
- } ++ {
- shared map { s =>
- Seq("--shared", if (s) "yes" else "no")
- } getOrElse Seq()
- }
- cli(wp.overrides ++ params, expectedExitCode)
- }
-
- /**
- * Fires trigger. Parameters mirror those available in the CLI.
- *
- * @param name either a fully qualified name or a simple entity name
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def fire(name: String,
- parameters: Map[String, JsValue] = Map(),
- parameterFile: Option[String] = None,
- expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- val params = Seq(noun, "fire", "--auth", wp.authKey, fqn(name)) ++ {
- parameters flatMap { p =>
- Seq("-p", p._1, p._2.compactPrint)
- }
- } ++ {
- parameterFile map { pf =>
- Seq("-P", pf)
- } getOrElse Seq()
- }
- cli(wp.overrides ++ params, expectedExitCode)
- }
-}
-
-class WskRule()
- extends RunWskCmd
- with ListOrGetFromCollectionCLI
- with DeleteFromCollectionCLI
- with WaitFor
- with BaseRule {
-
- override protected val noun = "rule"
-
- /**
- * Creates rule. Parameters mirror those available in the CLI.
- *
- * @param name either a fully qualified name or a simple entity name
- * @param trigger must be a simple name
- * @param action must be a simple name
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def create(name: String,
- trigger: String,
- action: String,
- annotations: Map[String, JsValue] = Map(),
- shared: Option[Boolean] = None,
- update: Boolean = false,
- expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- val params = Seq(noun, if (!update) "create" else "update", "--auth", wp.authKey, fqn(name), (trigger), (action)) ++ {
- annotations flatMap { p =>
- Seq("-a", p._1, p._2.compactPrint)
- }
- } ++ {
- shared map { s =>
- Seq("--shared", if (s) "yes" else "no")
- } getOrElse Seq()
- }
- cli(wp.overrides ++ params, expectedExitCode)
- }
-
- /**
- * Deletes rule.
- *
- * @param name either a fully qualified name or a simple entity name
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def delete(name: String, expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- super.delete(name, expectedExitCode)
- }
-
- /**
- * Enables rule.
- *
- * @param name either a fully qualified name or a simple entity name
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def enable(name: String, expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- cli(wp.overrides ++ Seq(noun, "enable", "--auth", wp.authKey, fqn(name)), expectedExitCode)
- }
-
- /**
- * Disables rule.
- *
- * @param name either a fully qualified name or a simple entity name
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def disable(name: String, expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- cli(wp.overrides ++ Seq(noun, "disable", "--auth", wp.authKey, fqn(name)), expectedExitCode)
- }
-
- /**
- * Checks state of rule.
- *
- * @param name either a fully qualified name or a simple entity name
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def state(name: String, expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- cli(wp.overrides ++ Seq(noun, "status", "--auth", wp.authKey, fqn(name)), expectedExitCode)
- }
-}
-
-class WskActivation() extends RunWskCmd with HasActivation with WaitFor with BaseActivation {
-
- protected val noun = "activation"
-
- /**
- * Activation polling console.
- *
- * @param duration exits console after duration
- * @param since (optional) time travels back to activation since given duration
- * @param actionName (optional) name of entity to filter activation records on.
- */
- override def console(duration: Duration,
- since: Option[Duration] = None,
- expectedExitCode: Int = SUCCESS_EXIT,
- actionName: Option[String] = None)(implicit wp: WskProps): RunResult = {
- val params = Seq(noun, "poll") ++ {
- actionName map { name =>
- Seq(name)
- } getOrElse Seq()
- } ++ Seq("--auth", wp.authKey, "--exit", duration.toSeconds.toString) ++ {
- since map { s =>
- Seq("--since-seconds", s.toSeconds.toString)
- } getOrElse Seq()
- }
- cli(wp.overrides ++ params, expectedExitCode)
- }
-
- /**
- * Lists activations.
- *
- * @param filter (optional) if define, must be a simple entity name
- * @param limit (optional) the maximum number of activation to return
- * @param since (optional) only the activations since this timestamp are included
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- def list(filter: Option[String] = None,
- limit: Option[Int] = None,
- since: Option[Instant] = None,
- expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- val params = Seq(noun, "list", "--auth", wp.authKey) ++ { filter map { Seq(_) } getOrElse Seq() } ++ {
- limit map { l =>
- Seq("--limit", l.toString)
- } getOrElse Seq()
- } ++ {
- since map { i =>
- Seq("--since", i.toEpochMilli.toString)
- } getOrElse Seq()
- }
- cli(wp.overrides ++ params, expectedExitCode)
- }
-
- /**
- * Parses result of WskActivation.list to extract sequence of activation ids.
- *
- * @param rr run result, should be from WhiskActivation.list otherwise behavior is undefined
- * @return sequence of activations
- */
- def ids(rr: RunResult): Seq[String] = {
- rr.stdout.split("\n") filter {
- // remove empty lines the header
- s =>
- s.nonEmpty && s != "activations"
- } map {
- // split into (id, name)
- _.split(" ")(0)
- }
- }
-
- /**
- * Gets activation by id.
- *
- * @param activationId the activation id
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- * @param last retrieves latest acitvation
- */
- override def get(activationId: Option[String] = None,
- expectedExitCode: Int = SUCCESS_EXIT,
- fieldFilter: Option[String] = None,
- last: Option[Boolean] = None,
- summary: Option[Boolean] = None)(implicit wp: WskProps): RunResult = {
- val params = {
- activationId map { a =>
- Seq(a)
- } getOrElse Seq()
- } ++ {
- fieldFilter map { f =>
- Seq(f)
- } getOrElse Seq()
- } ++ {
- last map { l =>
- Seq("--last")
- } getOrElse Seq()
- } ++ {
- summary map { s =>
- Seq("--summary")
- } getOrElse Seq()
- }
- cli(wp.overrides ++ Seq(noun, "get", "--auth", wp.authKey) ++ params, expectedExitCode)
- }
-
- /**
- * Gets activation logs by id.
- *
- * @param activationId the activation id
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- * @param last retrieves latest acitvation
- */
- override def logs(activationId: Option[String] = None,
- expectedExitCode: Int = SUCCESS_EXIT,
- last: Option[Boolean] = None)(implicit wp: WskProps): RunResult = {
- val params = {
- activationId map { a =>
- Seq(a)
- } getOrElse Seq()
- } ++ {
- last map { l =>
- Seq("--last")
- } getOrElse Seq()
- }
- cli(wp.overrides ++ Seq(noun, "logs", "--auth", wp.authKey) ++ params, expectedExitCode)
- }
-
- /**
- * Gets activation result by id.
- *
- * @param activationId the activation id
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- * @param last retrieves latest acitvation
- */
- override def result(activationId: Option[String] = None,
- expectedExitCode: Int = SUCCESS_EXIT,
- last: Option[Boolean] = None)(implicit wp: WskProps): RunResult = {
- val params = {
- activationId map { a =>
- Seq(a)
- } getOrElse Seq()
- } ++ {
- last map { l =>
- Seq("--last")
- } getOrElse Seq()
- }
- cli(wp.overrides ++ Seq(noun, "result", "--auth", wp.authKey) ++ params, expectedExitCode)
- }
-
- /**
- * Polls activations list for at least N activations. The activations
- * are optionally filtered for the given entity. Will return as soon as
- * N activations are found. If after retry budget is exhausted, N activations
- * are still not present, will return a partial result. Hence caller must
- * check length of the result and not assume it is >= N.
- *
- * @param N the number of activations desired
- * @param entity the name of the entity to filter from activation list
- * @param limit the maximum number of entities to list (if entity name is not unique use Some(0))
- * @param since (optional) only the activations since this timestamp are included
- * @param retries the maximum retries (total timeout is retries + 1 seconds)
- * @return activation ids found, caller must check length of sequence
- */
- override def pollFor(N: Int,
- entity: Option[String],
- limit: Option[Int] = None,
- since: Option[Instant] = None,
- retries: Int = 10,
- pollPeriod: Duration = 1.second)(implicit wp: WskProps): Seq[String] = {
- Try {
- retry({
- val result = ids(list(filter = entity, limit = limit, since = since))
- if (result.length >= N) result else throw PartialResult(result)
- }, retries, waitBeforeRetry = Some(pollPeriod))
- } match {
- case Success(ids) => ids
- case Failure(PartialResult(ids)) => ids
- case _ => Seq()
- }
- }
-
- /**
- * Polls for an activation matching the given id. If found
- * return Right(activation) else Left(result of running CLI command).
- *
- * @return either Left(error message) or Right(activation as JsObject)
- */
- override def waitForActivation(activationId: String,
- initialWait: Duration = 1 second,
- pollPeriod: Duration = 1 second,
- totalWait: Duration = 30 seconds)(implicit wp: WskProps): Either[String, JsObject] = {
- val activation = waitfor(
- () => {
- val result =
- cli(wp.overrides ++ Seq(noun, "get", activationId, "--auth", wp.authKey), expectedExitCode = DONTCARE_EXIT)
- if (result.exitCode == NOT_FOUND) {
- null
- } else if (result.exitCode == SUCCESS_EXIT) {
- Right(result.stdout)
- } else Left(s"$result")
- },
- initialWait,
- pollPeriod,
- totalWait)
-
- Option(activation) map {
- case Right(stdout) =>
- Try {
- // strip first line and convert the rest to JsObject
- assert(stdout.startsWith("ok: got activation"))
- parseJsonString(stdout)
- } map {
- Right(_)
- } getOrElse Left(s"cannot parse activation from '$stdout'")
- case Left(error) => Left(error)
- } getOrElse Left(s"$activationId not found")
- }
-
- /** Used in polling for activations to record partial results from retry poll. */
- private case class PartialResult(ids: Seq[String]) extends Throwable
-}
-
-class WskNamespace() extends RunWskCmd with FullyQualifiedNames with BaseNamespace {
-
- protected val noun = "namespace"
-
- /**
- * Lists available namespaces for whisk key.
- *
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def list(expectedExitCode: Int = SUCCESS_EXIT, nameSort: Option[Boolean] = None)(
- implicit wp: WskProps): RunResult = {
- val params = Seq(noun, "list", "--auth", wp.authKey) ++ {
- nameSort map { n =>
- Seq("--name-sort")
- } getOrElse Seq()
- }
- cli(wp.overrides ++ params, expectedExitCode)
- }
-
- /**
- * Looks up namespace for whisk props.
- *
- * @param wskprops instance of WskProps with an auth key to lookup
- * @return namespace as string
- */
- override def whois()(implicit wskprops: WskProps): String = {
- // the invariant that list() returns a conforming result is enforced in a test in WskRestBasicTests
- val ns = list().stdout.lines.toSeq.last.trim
- assert(ns != "_") // this is not permitted
- ns
- }
-
- /**
- * Gets entities in namespace.
- *
- * @param namespace (optional) if specified must be fully qualified namespace
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- def get(namespace: Option[String] = None, expectedExitCode: Int, nameSort: Option[Boolean] = None)(
- implicit wp: WskProps): RunResult = {
- val params = {
- nameSort map { n =>
- Seq("--name-sort")
- } getOrElse Seq()
- }
- cli(wp.overrides ++ Seq(noun, "get", resolve(namespace), "--auth", wp.authKey) ++ params, expectedExitCode)
- }
-}
-
-class WskPackage() extends RunWskCmd with ListOrGetFromCollectionCLI with DeleteFromCollectionCLI with BasePackage {
- override protected val noun = "package"
-
- /**
- * Creates package. Parameters mirror those available in the CLI.
- *
- * @param name either a fully qualified name or a simple entity name
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def create(name: String,
- parameters: Map[String, JsValue] = Map(),
- annotations: Map[String, JsValue] = Map(),
- parameterFile: Option[String] = None,
- annotationFile: Option[String] = None,
- shared: Option[Boolean] = None,
- update: Boolean = false,
- expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- val params = Seq(noun, if (!update) "create" else "update", "--auth", wp.authKey, fqn(name)) ++ {
- parameters flatMap { p =>
- Seq("-p", p._1, p._2.compactPrint)
- }
- } ++ {
- annotations flatMap { p =>
- Seq("-a", p._1, p._2.compactPrint)
- }
- } ++ {
- parameterFile map { pf =>
- Seq("-P", pf)
- } getOrElse Seq()
- } ++ {
- annotationFile map { af =>
- Seq("-A", af)
- } getOrElse Seq()
- } ++ {
- shared map { s =>
- Seq("--shared", if (s) "yes" else "no")
- } getOrElse Seq()
- }
- cli(wp.overrides ++ params, expectedExitCode)
- }
-
- /**
- * Binds package. Parameters mirror those available in the CLI.
- *
- * @param name either a fully qualified name or a simple entity name
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def bind(provider: String,
- name: String,
- parameters: Map[String, JsValue] = Map(),
- annotations: Map[String, JsValue] = Map(),
- expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- val params = Seq(noun, "bind", "--auth", wp.authKey, fqn(provider), fqn(name)) ++ {
- parameters flatMap { p =>
- Seq("-p", p._1, p._2.compactPrint)
- }
- } ++ {
- annotations flatMap { p =>
- Seq("-a", p._1, p._2.compactPrint)
- }
- }
- cli(wp.overrides ++ params, expectedExitCode)
- }
-}
-
-class WskApi() extends RunWskCmd with BaseApi {
- protected val noun = "api"
-
- /**
- * Creates and API endpoint. Parameters mirror those available in the CLI.
- *
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def create(basepath: Option[String] = None,
- relpath: Option[String] = None,
- operation: Option[String] = None,
- action: Option[String] = None,
- apiname: Option[String] = None,
- swagger: Option[String] = None,
- responsetype: Option[String] = None,
- expectedExitCode: Int = SUCCESS_EXIT,
- cliCfgFile: Option[String] = None)(implicit wp: WskProps): RunResult = {
- val params = Seq(noun, "create", "--auth", wp.authKey) ++ {
- basepath map { b =>
- Seq(b)
- } getOrElse Seq()
- } ++ {
- relpath map { r =>
- Seq(r)
- } getOrElse Seq()
- } ++ {
- operation map { o =>
- Seq(o)
- } getOrElse Seq()
- } ++ {
- action map { aa =>
- Seq(aa)
- } getOrElse Seq()
- } ++ {
- apiname map { a =>
- Seq("--apiname", a)
- } getOrElse Seq()
- } ++ {
- swagger map { s =>
- Seq("--config-file", s)
- } getOrElse Seq()
- } ++ {
- responsetype map { t =>
- Seq("--response-type", t)
- } getOrElse Seq()
- }
- cli(
- wp.overrides ++ params,
- expectedExitCode,
- showCmd = true,
- env = Map("WSK_CONFIG_FILE" -> cliCfgFile.getOrElse("")))
- }
-
- /**
- * Retrieve a list of API endpoints. Parameters mirror those available in the CLI.
- *
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def list(basepathOrApiName: Option[String] = None,
- relpath: Option[String] = None,
- operation: Option[String] = None,
- limit: Option[Int] = None,
- since: Option[Instant] = None,
- full: Option[Boolean] = None,
- nameSort: Option[Boolean] = None,
- expectedExitCode: Int = SUCCESS_EXIT,
- cliCfgFile: Option[String] = None)(implicit wp: WskProps): RunResult = {
- val params = Seq(noun, "list", "--auth", wp.authKey) ++ {
- basepathOrApiName map { b =>
- Seq(b)
- } getOrElse Seq()
- } ++ {
- relpath map { r =>
- Seq(r)
- } getOrElse Seq()
- } ++ {
- operation map { o =>
- Seq(o)
- } getOrElse Seq()
- } ++ {
- limit map { l =>
- Seq("--limit", l.toString)
- } getOrElse Seq()
- } ++ {
- since map { i =>
- Seq("--since", i.toEpochMilli.toString)
- } getOrElse Seq()
- } ++ {
- full map { r =>
- Seq("--full")
- } getOrElse Seq()
- } ++ {
- nameSort map { n =>
- Seq("--name-sort")
- } getOrElse Seq()
- }
- cli(
- wp.overrides ++ params,
- expectedExitCode,
- showCmd = true,
- env = Map("WSK_CONFIG_FILE" -> cliCfgFile.getOrElse("")))
- }
-
- /**
- * Retieves an API's configuration. Parameters mirror those available in the CLI.
- * Runs a command wsk [params] where the arguments come in as a sequence.
- *
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def get(basepathOrApiName: Option[String] = None,
- full: Option[Boolean] = None,
- expectedExitCode: Int = SUCCESS_EXIT,
- cliCfgFile: Option[String] = None,
- format: Option[String] = None)(implicit wp: WskProps): RunResult = {
- val params = Seq(noun, "get", "--auth", wp.authKey) ++ {
- basepathOrApiName map { b =>
- Seq(b)
- } getOrElse Seq()
- } ++ {
- full map { f =>
- if (f) Seq("--full") else Seq()
- } getOrElse Seq()
- } ++ {
- format map { ft =>
- Seq("--format", ft)
- } getOrElse Seq()
- }
- cli(
- wp.overrides ++ params,
- expectedExitCode,
- showCmd = true,
- env = Map("WSK_CONFIG_FILE" -> cliCfgFile.getOrElse("")))
- }
-
- /**
- * Delete an entire API or a subset of API endpoints. Parameters mirror those available in the CLI.
- *
- * @param expectedExitCode (optional) the expected exit code for the command
- * if the code is anything but DONTCARE_EXIT, assert the code is as expected
- */
- override def delete(basepathOrApiName: String,
- relpath: Option[String] = None,
- operation: Option[String] = None,
- expectedExitCode: Int = SUCCESS_EXIT,
- cliCfgFile: Option[String] = None)(implicit wp: WskProps): RunResult = {
- val params = Seq(noun, "delete", "--auth", wp.authKey, basepathOrApiName) ++ {
- relpath map { r =>
- Seq(r)
- } getOrElse Seq()
- } ++ {
- operation map { o =>
- Seq(o)
- } getOrElse Seq()
- }
- cli(
- wp.overrides ++ params,
- expectedExitCode,
- showCmd = true,
- env = Map("WSK_CONFIG_FILE" -> cliCfgFile.getOrElse("")))
- }
-}
-
-object Wsk {
- private val binaryName = "wsk"
- private val cliPath = if (WhiskProperties.useCLIDownload) getDownloadedGoCLIPath else WhiskProperties.getCLIPath
-
- assert((new File(cliPath)).exists, s"did not find $cliPath")
-
- /** What is the path to a downloaded CLI? **/
- private def getDownloadedGoCLIPath = {
- s"${System.getProperty("user.home")}${File.separator}.local${File.separator}bin${File.separator}${binaryName}"
- }
-
- def baseCommand = Buffer(cliPath)
-}
-
trait RunWskCmd extends BaseRunWsk {
/**
- * The base command to run.
+ * The base command to run. This returns a new mutable buffer, intended for building the rest of the command line.
*/
- def baseCommand = Wsk.baseCommand
+ def baseCommand: Buffer[String]
/**
* Runs a command wsk [params] where the arguments come in as a sequence.
diff --git a/tests/src/test/scala/common/rest/WskRest.scala b/tests/src/test/scala/common/rest/WskRest.scala
index 395047e..19e093e 100644
--- a/tests/src/test/scala/common/rest/WskRest.scala
+++ b/tests/src/test/scala/common/rest/WskRest.scala
@@ -61,7 +61,6 @@ import common._
import common.BaseDeleteFromCollection
import common.BaseListOrGetFromCollection
import common.HasActivation
-import common.RunWskCmd
import common.TestUtils.SUCCESS_EXIT
import common.TestUtils.ANY_ERROR_EXIT
import common.TestUtils.DONTCARE_EXIT
@@ -1213,7 +1212,7 @@ class WskRestApi extends RunWskRestCmd with BaseApi {
}
}
-class RunWskRestCmd() extends FlatSpec with RunWskCmd with Matchers with ScalaFutures with WskActorSystem {
+class RunWskRestCmd() extends FlatSpec with Matchers with ScalaFutures with WskActorSystem {
implicit val config = PatienceConfig(100 seconds, 15 milliseconds)
implicit val materializer = ActorMaterializer()
diff --git a/tests/src/test/scala/system/basic/WskActionTests.scala b/tests/src/test/scala/system/basic/WskActionTests.scala
index 31cc186..db9af72 100644
--- a/tests/src/test/scala/system/basic/WskActionTests.scala
+++ b/tests/src/test/scala/system/basic/WskActionTests.scala
@@ -19,15 +19,14 @@ package system.basic
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-
import common.ActivationResult
import common.JsHelpers
import common.TestHelpers
import common.TestUtils
import common.BaseWsk
-import common.Wsk
import common.WskProps
import common.WskTestHelpers
+import common.rest.WskRest
import spray.json._
import spray.json.DefaultJsonProtocol._
@@ -139,8 +138,8 @@ abstract class WskActionTests extends TestHelpers with WskTestHelpers with JsHel
action.create(copiedActionName, Some(origActionName), Some("copy"))
}
- val copiedAction = getJSONFromResponse(wsk.action.get(copiedActionName).stdout, wsk.isInstanceOf[Wsk])
- val origAction = getJSONFromResponse(wsk.action.get(copiedActionName).stdout, wsk.isInstanceOf[Wsk])
+ val copiedAction = getJSONFromResponse(wsk.action.get(copiedActionName).stdout, !wsk.isInstanceOf[WskRest])
+ val origAction = getJSONFromResponse(wsk.action.get(copiedActionName).stdout, !wsk.isInstanceOf[WskRest])
copiedAction.fields("annotations") shouldBe origAction.fields("annotations")
copiedAction.fields("parameters") shouldBe origAction.fields("parameters")
@@ -179,7 +178,7 @@ abstract class WskActionTests extends TestHelpers with WskTestHelpers with JsHel
action.create(copiedName, Some(origName), Some("copy"), parameters = copiedParams, annotations = copiedAnnots)
}
- val copiedAction = getJSONFromResponse(wsk.action.get(copiedName).stdout, wsk.isInstanceOf[Wsk])
+ val copiedAction = getJSONFromResponse(wsk.action.get(copiedName).stdout, !wsk.isInstanceOf[WskRest])
// CLI does not guarantee order of annotations and parameters so do a diff to compare the values
copiedAction.fields("parameters").convertTo[Seq[JsObject]] diff resParams shouldBe List()
[incubator-openwhisk] 19/19: Change import to be fully qualified.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit f6046721acd801ea1777cb5cb040dfaa6922a18e
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Wed Jun 27 15:28:52 2018 -0400
Change import to be fully qualified.
---
tests/src/test/scala/limits/ThrottleTests.scala | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/src/test/scala/limits/ThrottleTests.scala b/tests/src/test/scala/limits/ThrottleTests.scala
index 72358f6..4c4bb18 100644
--- a/tests/src/test/scala/limits/ThrottleTests.scala
+++ b/tests/src/test/scala/limits/ThrottleTests.scala
@@ -34,7 +34,7 @@ import org.scalatest.junit.JUnitRunner
import common._
import common.TestUtils._
import common.rest.WskRestOperations
-import WskAdmin.wskadmin
+import common.WskAdmin.wskadmin
import spray.json._
import spray.json.DefaultJsonProtocol._
import whisk.http.Messages._
[incubator-openwhisk] 11/19: Rename trait and file.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit ce185af833b040aaab827bf3a98b9da336008b92
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Fri Jun 8 21:10:21 2018 -0400
Rename trait and file.
---
tests/src/test/scala/common/{Wsk.scala => CliCommand.scala} | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/src/test/scala/common/Wsk.scala b/tests/src/test/scala/common/CliCommand.scala
similarity index 98%
rename from tests/src/test/scala/common/Wsk.scala
rename to tests/src/test/scala/common/CliCommand.scala
index 473e175..44c9dcf 100644
--- a/tests/src/test/scala/common/Wsk.scala
+++ b/tests/src/test/scala/common/CliCommand.scala
@@ -26,7 +26,7 @@ import TestUtils._
import scala.collection.mutable
-trait RunWskCmd extends Matchers {
+trait CliCommand extends Matchers {
/**
* The base command to run. This returns a new mutable buffer, intended for building the rest of the command line.
@@ -102,7 +102,7 @@ trait RunWskCmd extends Matchers {
}
object WskAdmin {
- val wskadmin = new RunWskCmd {
+ val wskadmin = new CliCommand {
override def baseCommand: mutable.Buffer[String] = WskAdmin.baseCommand
}
[incubator-openwhisk] 15/19: Remove return statements.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit ed435e73248d2da2ca576e8113312002b7186b86
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Sat Jun 9 00:21:12 2018 -0400
Remove return statements.
---
tests/src/test/scala/common/WskCliOperations.scala | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/tests/src/test/scala/common/WskCliOperations.scala b/tests/src/test/scala/common/WskCliOperations.scala
index da3fcbc..2137ad8 100644
--- a/tests/src/test/scala/common/WskCliOperations.scala
+++ b/tests/src/test/scala/common/WskCliOperations.scala
@@ -35,7 +35,6 @@ import spray.json.JsObject
import spray.json.JsValue
import whisk.core.entity.ByteSize
import whisk.utils.retry
-import common._
import FullyQualifiedNames.fqn
import FullyQualifiedNames.resolve
@@ -65,7 +64,7 @@ import FullyQualifiedNames.resolve
* It also sets the apihost and apiversion explicitly to avoid ambiguity with
* a local property file if it exists.
*/
-class Wsk extends WskOperations {
+class Wsk extends WskOperations with RunWskCliCmd {
override implicit val action = new CliActionOperations
override implicit val trigger = new CliTriggerOperations
override implicit val rule = new CliRuleOperations
@@ -75,7 +74,7 @@ class Wsk extends WskOperations {
override implicit val api = new CliGatewayOperations
}
-trait CliListOrGetFromCollectionOperations extends ListOrGetFromCollectionOperations with RunWskCliCommand {
+trait CliListOrGetFromCollectionOperations extends ListOrGetFromCollectionOperations with RunWskCliCmd {
/**
* List entities in collection.
@@ -138,7 +137,7 @@ trait CliListOrGetFromCollectionOperations extends ListOrGetFromCollectionOperat
}
}
-trait CliDeleteFromCollectionOperations extends DeleteFromCollectionOperations with RunWskCliCommand {
+trait CliDeleteFromCollectionOperations extends DeleteFromCollectionOperations with RunWskCliCmd {
/**
* Deletes entity from collection.
@@ -437,7 +436,7 @@ class CliRuleOperations
}
}
-class CliActivationOperations extends ActivationOperations with RunWskCliCommand with HasActivation with WaitFor {
+class CliActivationOperations extends ActivationOperations with RunWskCliCmd with HasActivation with WaitFor {
protected val noun = "activation"
@@ -658,7 +657,7 @@ class CliActivationOperations extends ActivationOperations with RunWskCliCommand
private case class PartialResult(ids: Seq[String]) extends Throwable
}
-class CliNamespaceOperations extends CliDeleteFromCollectionOperations with NamespaceOperations with RunWskCliCommand {
+class CliNamespaceOperations extends CliDeleteFromCollectionOperations with NamespaceOperations with RunWskCliCmd {
protected val noun = "namespace"
@@ -779,7 +778,7 @@ class CliPackageOperations
}
}
-class CliGatewayOperations extends GatewayOperations with RunWskCliCommand {
+class CliGatewayOperations extends GatewayOperations with RunWskCliCmd {
protected val noun = "api"
/**
@@ -944,7 +943,7 @@ class CliGatewayOperations extends GatewayOperations with RunWskCliCommand {
}
}
-trait RunWskCliCommand extends RunCliCmd {
+trait RunWskCliCmd extends RunCliCmd {
private val binaryName = "wsk"
private val cliPath = if (WhiskProperties.useCLIDownload) getDownloadedGoCLIPath else WhiskProperties.getCLIPath
[incubator-openwhisk] 03/19: Delete really dated sequence schema
related tests.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit 80d1cf77acda0e18005be62769946db02ab81227
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Fri Jun 8 10:42:13 2018 -0400
Delete really dated sequence schema related tests.
---
tests/dat/actions/seq_echo_word_count.json | 25 ----
tests/dat/actions/seq_type_2.json | 33 -----
.../core/cli/test/SequenceMigrationTests.scala | 137 ---------------------
3 files changed, 195 deletions(-)
diff --git a/tests/dat/actions/seq_echo_word_count.json b/tests/dat/actions/seq_echo_word_count.json
deleted file mode 100644
index 984058b..0000000
--- a/tests/dat/actions/seq_echo_word_count.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "annotations": [],
- "exec": {
- "binary": false,
- "code": "/**\n * Invokes a sequence of actions, piping the output of each to the input of the next.\n *\n * @param _actions An array of action names to invoke.\n * @param <everything else> Passed as input to the first action.\n */\nfunction main(msg) {\n // The actions to invoke sequentially.\n var actions = msg['_actions'];\n\n if (typeof actions === 'string') {\n try {\n actions = JSON.parse(actions);\n } catch (e) {\n return whisk.e [...]
- "kind": "nodejs:6"
- },
- "limits": {
- "logs": 10,
- "memory": 256,
- "timeout": 60000
- },
- "name": "seq_echo_word_count",
- "parameters": [
- {
- "key": "_actions",
- "value": [
- "/_/echo",
- "/_/word_count"
- ]
- }
- ],
- "publish": false,
- "version": "0.0.1"
-}
diff --git a/tests/dat/actions/seq_type_2.json b/tests/dat/actions/seq_type_2.json
deleted file mode 100644
index 69495ee..0000000
--- a/tests/dat/actions/seq_type_2.json
+++ /dev/null
@@ -1,33 +0,0 @@
-{
- "annotations": [
- {
- "key": "exec",
- "value": "sequence"
- }
- ],
- "exec": {
- "code": "\n/**\n * Invokes a sequence of actions, piping the output of each to the input of the next.\n *\n * @param _actions An array of action names to invoke.\n * @param <everything else> Passed as input to the first action.\n */\nfunction main(msg) {\n // The actions to invoke sequentially.\n var actions = msg['_actions'];\n\n if (typeof actions === 'string') {\n try {\n actions = JSON.parse(actions);\n } catch (e) {\n return whisk [...]
- "components": [
- "/_/echo",
- "/_/word_count"
- ],
- "kind": "sequence"
- },
- "limits": {
- "logs": 10,
- "memory": 256,
- "timeout": 60000
- },
- "name": "seq_type_2",
- "parameters": [
- {
- "key": "_actions",
- "value": [
- "/_/echo",
- "/_/word_count"
- ]
- }
- ],
- "publish": false,
- "version": "0.0.1"
-}
\ No newline at end of file
diff --git a/tests/src/test/scala/whisk/core/cli/test/SequenceMigrationTests.scala b/tests/src/test/scala/whisk/core/cli/test/SequenceMigrationTests.scala
deleted file mode 100644
index bdf604e..0000000
--- a/tests/src/test/scala/whisk/core/cli/test/SequenceMigrationTests.scala
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package whisk.core.cli.test
-
-import java.util.Date
-
-import scala.concurrent.duration.DurationInt
-import scala.language.postfixOps
-
-import org.junit.runner.RunWith
-import org.scalatest.BeforeAndAfter
-import org.scalatest.junit.JUnitRunner
-
-import akka.stream.ActorMaterializer
-import common.TestHelpers
-import common.TestUtils
-import common.rest.WskRest
-import common.WskProps
-import common.WskTestHelpers
-import spray.json._
-import spray.json.DefaultJsonProtocol.StringJsonFormat
-import whisk.core.database.test.DbUtils
-import whisk.core.entity._
-import whisk.core.entity.test.ExecHelpers
-
-/**
- * Tests that "old-style" sequences can be invoked
- */
-@RunWith(classOf[JUnitRunner])
-class SequenceMigrationTests extends TestHelpers with BeforeAndAfter with DbUtils with ExecHelpers with WskTestHelpers {
-
- implicit val matzerializer = ActorMaterializer()
- implicit val wskprops = WskProps()
- val wsk = new WskRest
- // handle on the entity datastore
- val entityStore = WhiskEntityStore.datastore()
- val namespace = wsk.namespace.whois()
- val allowedActionDuration = 120 seconds
-
- override protected def withFixture(test: NoArgTest) = {
- assume(!isMemoryStore(entityStore))
- super.withFixture(test)
- }
-
- behavior of "Sequence Migration"
-
- it should "check default namespace '_' is preserved in WhiskAction of old style sequence" in {
- // read json file and add the appropriate namespace
- val seqJsonFile = "seq_type_2.json"
- val jsonFile = TestUtils.getTestActionFilename(seqJsonFile)
- val source = scala.io.Source.fromFile(jsonFile)
- val jsonString = try source.mkString
- finally source.close()
- val entityJson = jsonString.parseJson.asJsObject
- // add default namespace (i.e., user) to the json object
- val entityJsonWithNamespace = JsObject(entityJson.fields + ("namespace" -> JsString(namespace)))
- val wskEntity = entityJsonWithNamespace.convertTo[WhiskAction]
- wskEntity.exec match {
- case SequenceExec(components) =>
- // check '_' is preserved
- components.size shouldBe 2
- assert(components.forall { _.path.namespace.contains('_') }, "default namespace lost")
- case _ => assert(false)
- }
- }
-
- it should "invoke an old-style (kind sequence) sequence and get the result" in {
- val seqName = "seq_type_2"
- testOldStyleSequence(seqName, s"$seqName.json")
- }
-
- it should "not display code from an old sequence on action get" in {
- // install sequence in db
- val seqName = "seq_type_2"
- installActionInDb(s"$seqName.json")
- val stdout = wsk.action.get(seqName).stdout
- stdout.contains("code") shouldBe false
- }
-
- /**
- * helper function that tests old style sequence based on two actions echo and word_count
- * @param seqName the name of the sequence
- * @param seqFileName the name of the json file that contains the whisk action associated with the sequence
- */
- private def testOldStyleSequence(seqName: String, seqFileName: String) = {
- // create entities to insert in the entity store
- val echo = "echo.json"
- val wc = "word_count.json"
- val entities = Seq(echo, wc, seqFileName)
- for (entity <- entities) {
- installActionInDb(entity)
- }
- // invoke sequence
- val now = "it is now " + new Date()
- val run = wsk.action.invoke(seqName, Map("payload" -> now.mkString("\n").toJson))
- withActivation(wsk.activation, run, totalWait = allowedActionDuration) { activation =>
- val result = activation.response.result.get
- result.fields.get("count") shouldBe Some(JsNumber(now.split(" ").size))
- }
- }
-
- /**
- * helper function that takes a json file containing a whisk action (minus the namespace), adds namespace and installs in db
- */
- private def installActionInDb(actionJson: String) = {
- // read json file and add the appropriate namespace
- val jsonFile = TestUtils.getTestActionFilename(actionJson)
- val source = scala.io.Source.fromFile(jsonFile)
- val jsonString = try source.mkString
- finally source.close()
- val entityJson = jsonString.parseJson.asJsObject
- // add default namespace (i.e., user) to the json object
- val entityJsonWithNamespace = JsObject(entityJson.fields + ("namespace" -> JsString(namespace)))
- val wskEntity = entityJsonWithNamespace.convertTo[WhiskAction]
- implicit val tid = transid() // needed for put db below
- put(entityStore, wskEntity)
- }
-
- after {
- cleanup() // cleanup entities from db
- }
-}
[incubator-openwhisk] 07/19: Scala-isms and more code cleanup.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit c63a4f53274002bb9de8c59c7e0735049358bd67
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Fri Jun 8 16:06:08 2018 -0400
Scala-isms and more code cleanup.
---
tests/src/test/scala/common/rest/WskRest.scala | 198 ++++++++++++-------------
1 file changed, 94 insertions(+), 104 deletions(-)
diff --git a/tests/src/test/scala/common/rest/WskRest.scala b/tests/src/test/scala/common/rest/WskRest.scala
index a4cc09f..a4d7ac6 100644
--- a/tests/src/test/scala/common/rest/WskRest.scala
+++ b/tests/src/test/scala/common/rest/WskRest.scala
@@ -72,7 +72,6 @@ import common.WskProps
import whisk.core.entity.ByteSize
import whisk.utils.retry
import javax.net.ssl._
-
import com.typesafe.sslconfig.akka.AkkaSSLConfig
import java.nio.charset.StandardCharsets
import java.security.KeyStore
@@ -89,11 +88,11 @@ object SSL {
lazy val httpsConfig = loadConfigOrThrow[HttpsConfig]("whisk.controller.https")
- def keyManagers(clientAuth: Boolean) = {
+ def keyManagers(clientAuth: Boolean): Array[KeyManager] = {
if (clientAuth)
keyManagersForClientAuth
else
- Array[KeyManager]()
+ Array.empty
}
def keyManagersForClientAuth: Array[KeyManager] = {
@@ -110,7 +109,7 @@ object SSL {
class IgnoreX509TrustManager extends X509TrustManager {
def checkClientTrusted(chain: Array[X509Certificate], authType: String) = ()
def checkServerTrusted(chain: Array[X509Certificate], authType: String) = ()
- def getAcceptedIssuers = Array[X509Certificate]()
+ def getAcceptedIssuers: Array[X509Certificate] = Array.empty
}
val context = SSLContext.getInstance("TLS")
@@ -177,11 +176,9 @@ trait ListOrGetFromCollectionRest extends BaseListOrGetFromCollection {
else Path(s"$basePath/namespaces/$nspace/$noun/$name/")
} getOrElse Path(s"$basePath/namespaces/${wp.namespace}/$noun")
- val paramMap = Map[String, String]() ++ { Map("skip" -> "0", "docs" -> true.toString) } ++ {
- limit map { l =>
- Map("limit" -> l.toString)
- } getOrElse Map[String, String]()
- }
+ val paramMap: Map[String, String] = Map("skip" -> "0", "docs" -> true.toString) ++
+ limit.map(l => Map("limit" -> l.toString)).getOrElse(Map.empty)
+
val resp = requestEntity(GET, entPath, paramMap)
val r = new RestResult(resp.status, getRespData(resp))
validateStatusCode(expectedExitCode, r.statusCode.intValue)
@@ -283,8 +280,8 @@ class WskRestAction
kind: Option[String] = None, // one of docker, copy, sequence or none for autoselect else an explicit type
main: Option[String] = None,
docker: Option[String] = None,
- parameters: Map[String, JsValue] = Map(),
- annotations: Map[String, JsValue] = Map(),
+ parameters: Map[String, JsValue] = Map.empty,
+ annotations: Map[String, JsValue] = Map.empty,
parameterFile: Option[String] = None,
annotationFile: Option[String] = None,
timeout: Option[Duration] = None,
@@ -375,11 +372,11 @@ class WskRestAction
val exec = execByKind ++ {
main map { m =>
Map("main" -> m.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
} ++ {
docker map { d =>
Map("kind" -> "blackbox".toJson, "image" -> d.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
}
val bodyHead = Map("name" -> name.toJson, "namespace" -> namespace.toJson)
@@ -405,37 +402,37 @@ class WskRestAction
case Some(k) if (k == "sequence" || k == "native") => {
Map("exec" -> exec.toJson)
}
- case _ => Map[String, JsValue]()
+ case _ => Map.empty
}
} ++ {
shared map { s =>
Map("publish" -> s.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
} ++ {
if (inputParams.size > 0) {
Map("parameters" -> params.toJson)
- } else Map[String, JsValue]()
+ } else Map.empty
} ++ {
if (inputAnnos.size > 0) {
Map("annotations" -> inputAnnos.toJson)
- } else Map[String, JsValue]()
+ } else Map.empty
}
} else {
bodyHead ++ Map("exec" -> exec.toJson, "parameters" -> params.toJson, "annotations" -> annos.toJson)
}
- val limits = Map[String, JsValue]() ++ {
+ val limits: Map[String, JsValue] = {
timeout map { t =>
Map("timeout" -> t.toMillis.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
} ++ {
logsize map { log =>
Map("logs" -> log.toMB.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
} ++ {
memory map { m =>
Map("memory" -> m.toMB.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
}
val bodyContent =
@@ -453,7 +450,7 @@ class WskRestAction
}
override def invoke(name: String,
- parameters: Map[String, JsValue] = Map(),
+ parameters: Map[String, JsValue] = Map.empty,
parameterFile: Option[String] = None,
blocking: Boolean = false,
result: Boolean = false,
@@ -479,8 +476,8 @@ class WskRestTrigger
* if the code is anything but DONTCARE_EXIT, assert the code is as expected
*/
override def create(name: String,
- parameters: Map[String, JsValue] = Map(),
- annotations: Map[String, JsValue] = Map(),
+ parameters: Map[String, JsValue] = Map.empty,
+ annotations: Map[String, JsValue] = Map.empty,
parameterFile: Option[String] = None,
annotationFile: Option[String] = None,
feed: Option[String] = None,
@@ -531,7 +528,7 @@ class WskRestTrigger
"triggerName" -> s"/$ns/$triggerName".toJson,
"authKey" -> s"${wp.authKey}".toJson)
body = body ++ parameters
- val resp = requestEntity(POST, path, paramMap, Some(body.toJson.toString()))
+ val resp = requestEntity(POST, path, paramMap, Some(body.toJson.toString))
val resultInvoke = new RestResult(resp.status, getRespData(resp))
if ((expectedExitCode != DONTCARE_EXIT) && (expectedExitCode != ANY_ERROR_EXIT))
expectedExitCode shouldBe resultInvoke.statusCode.intValue
@@ -557,7 +554,7 @@ class WskRestTrigger
* if the code is anything but DONTCARE_EXIT, assert the code is as expected
*/
override def fire(name: String,
- parameters: Map[String, JsValue] = Map(),
+ parameters: Map[String, JsValue] = Map.empty,
parameterFile: Option[String] = None,
expectedExitCode: Int = Accepted.intValue)(implicit wp: WskProps): RestResult = {
val path = getNamePath(noun, name)
@@ -567,7 +564,7 @@ class WskRestTrigger
} getOrElse parameters
val resp =
if (params.size == 0) requestEntity(POST, path)
- else requestEntity(POST, path, body = Some(params.toJson.toString()))
+ else requestEntity(POST, path, body = Some(params.toJson.toString))
new RestResult(resp.status.intValue, getRespData(resp))
}
}
@@ -593,7 +590,7 @@ class WskRestRule
override def create(name: String,
trigger: String,
action: String,
- annotations: Map[String, JsValue] = Map(),
+ annotations: Map[String, JsValue] = Map.empty,
shared: Option[Boolean] = None,
update: Boolean = false,
expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RestResult = {
@@ -702,15 +699,15 @@ class WskRestActivation extends RunWskRestCmd with HasActivationRest with WaitFo
var paramMap = Map("skip" -> "0", "docs" -> docs.toString) ++ {
limit map { l =>
Map("limit" -> l.toString)
- } getOrElse Map[String, String]()
+ } getOrElse Map.empty
} ++ {
filter map { f =>
Map("name" -> f.toString)
- } getOrElse Map[String, String]()
+ } getOrElse Map.empty
} ++ {
since map { s =>
- Map("since" -> s.toEpochMilli().toString)
- } getOrElse Map[String, String]()
+ Map("since" -> s.toEpochMilli.toString)
+ } getOrElse Map.empty
}
val resp = requestEntity(GET, entityPath, paramMap)
new RestResult(resp.status, getRespData(resp))
@@ -723,10 +720,7 @@ class WskRestActivation extends RunWskRestCmd with HasActivationRest with WaitFo
* @return sequence of activations
*/
def idsActivation(rr: RestResult): Seq[String] = {
- val list = rr.getBodyListJsObject()
- var result = Seq[String]()
- list.foreach((obj: JsObject) => result = result :+ (RestResult.getField(obj, "activationId").toString))
- result
+ rr.getBodyListJsObject.map(r => RestResult.getField(r, "activationId").toString)
}
/**
@@ -787,7 +781,7 @@ class WskRestActivation extends RunWskRestCmd with HasActivationRest with WaitFo
} match {
case Success(ids) => ids
case Failure(PartialResult(ids)) => ids
- case _ => Seq()
+ case _ => Seq.empty
}
}
@@ -898,7 +892,7 @@ class WskRestNamespace extends RunWskRestCmd with BaseNamespace {
*/
override def whois()(implicit wskprops: WskProps): String = {
val ns = list().getBodyListString
- if (ns.size > 0) ns(0).toString() else ""
+ if (ns.size > 0) ns(0).toString else ""
}
}
@@ -918,8 +912,8 @@ class WskRestPackage
* if the code is anything but DONTCARE_EXIT, assert the code is as expected
*/
override def create(name: String,
- parameters: Map[String, JsValue] = Map(),
- annotations: Map[String, JsValue] = Map(),
+ parameters: Map[String, JsValue] = Map.empty,
+ annotations: Map[String, JsValue] = Map.empty,
parameterFile: Option[String] = None,
annotationFile: Option[String] = None,
shared: Option[Boolean] = None,
@@ -967,8 +961,8 @@ class WskRestPackage
*/
override def bind(provider: String,
name: String,
- parameters: Map[String, JsValue] = Map(),
- annotations: Map[String, JsValue] = Map(),
+ parameters: Map[String, JsValue] = Map.empty,
+ annotations: Map[String, JsValue] = Map.empty,
expectedExitCode: Int = OK.intValue)(implicit wp: WskProps): RestResult = {
val params = convertMapIntoKeyValue(parameters)
val annos = convertMapIntoKeyValue(annotations)
@@ -1011,39 +1005,37 @@ class WskRestApi extends RunWskRestCmd with BaseApi {
val actionAuthKey = wp.authKey
val testaction = Some(
new ApiAction(name = actionName, namespace = ns, backendUrl = actionUrl, authkey = actionAuthKey))
- val parms = Map[String, JsValue]() ++ { Map("namespace" -> ns.toJson) } ++ {
+ val parms = Map("namespace" -> ns.toJson) ++ {
basepath map { b =>
Map("gatewayBasePath" -> b.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
} ++ {
relpath map { r =>
Map("gatewayPath" -> r.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
} ++ {
operation map { o =>
Map("gatewayMethod" -> o.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
} ++ {
apiname map { an =>
Map("apiName" -> an.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
} ++ {
testaction map { a =>
Map("action" -> a.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
} ++ {
swagger map { s =>
val swaggerFile = FileUtils.readFileToString(new File(s), StandardCharsets.UTF_8)
Map("swagger" -> swaggerFile.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
}
val spaceguid = if (wp.authKey.contains(":")) wp.authKey.split(":")(0) else wp.authKey
val parm = Map[String, JsValue]("apidoc" -> JsObject(parms)) ++ {
- responsetype map { r =>
- Map("responsetype" -> r.toJson)
- } getOrElse Map[String, JsValue]()
+ responsetype.map(r => Map("responsetype" -> r.toJson)).getOrElse(Map.empty)
} ++ {
Map("accesstoken" -> wp.authKey.toJson)
} ++ {
@@ -1062,20 +1054,18 @@ class WskRestApi extends RunWskRestCmd with BaseApi {
swagger match {
case Some(swaggerFile) => {
var file = ""
- val fileName = swaggerFile.toString()
+ val fileName = swaggerFile.toString
try {
file = FileUtils.readFileToString(new File(fileName), StandardCharsets.UTF_8)
} catch {
case e: Throwable =>
return new RestResult(
NotFound,
- JsObject("error" -> s"Error reading swagger file '$fileName'".toJson).toString())
+ JsObject("error" -> s"Error reading swagger file '$fileName'".toJson).toString)
}
val parms = Map("namespace" -> s"${wp.namespace}".toJson, "swagger" -> file.toJson)
val parm = Map[String, JsValue]("apidoc" -> JsObject(parms)) ++ {
- responsetype map { r =>
- Map("responsetype" -> r.toJson)
- } getOrElse Map[String, JsValue]()
+ responsetype.map(r => Map("responsetype" -> r.toJson)).getOrElse(Map.empty)
} ++ {
Map("accesstoken" -> wp.authKey.toJson)
} ++ {
@@ -1114,32 +1104,31 @@ class WskRestApi extends RunWskRestCmd with BaseApi {
expectedExitCode: Int = SUCCESS_EXIT,
cliCfgFile: Option[String] = None)(implicit wp: WskProps): RestResult = {
- val parms = Map[String, JsValue]() ++ {
+ val parms = {
basepathOrApiName map { b =>
Map("basepath" -> b.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
} ++ {
relpath map { r =>
Map("relpath" -> r.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
} ++ {
operation map { o =>
Map("operation" -> o.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
} ++ {
Map("accesstoken" -> wp.authKey.toJson)
} ++ {
Map("spaceguid" -> wp.authKey.split(":")(0).toJson)
}
- val rr = invokeAction(
+ invokeAction(
name = "apimgmt/getApi",
parameters = parms,
blocking = true,
result = true,
web = true,
expectedExitCode = OK.intValue)(wp)
- rr
}
/**
@@ -1154,24 +1143,23 @@ class WskRestApi extends RunWskRestCmd with BaseApi {
expectedExitCode: Int = SUCCESS_EXIT,
cliCfgFile: Option[String] = None,
format: Option[String] = None)(implicit wp: WskProps): RestResult = {
- val parms = Map[String, JsValue]() ++ {
+ val parms = {
basepathOrApiName map { b =>
Map("basepath" -> b.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
} ++ {
Map("accesstoken" -> wp.authKey.toJson)
} ++ {
Map("spaceguid" -> wp.authKey.split(":")(0).toJson)
}
- val result = invokeAction(
+ invokeAction(
name = "apimgmt/getApi",
parameters = parms,
blocking = true,
result = true,
web = true,
expectedExitCode = OK.intValue)(wp)
- result
}
/**
@@ -1185,16 +1173,14 @@ class WskRestApi extends RunWskRestCmd with BaseApi {
operation: Option[String] = None,
expectedExitCode: Int = SUCCESS_EXIT,
cliCfgFile: Option[String] = None)(implicit wp: WskProps): RestResult = {
- val parms = Map[String, JsValue]() ++ {
- Map("basepath" -> basepathOrApiName.toJson)
- } ++ {
+ val parms = Map("basepath" -> basepathOrApiName.toJson) ++ {
relpath map { r =>
Map("relpath" -> r.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
} ++ {
operation map { o =>
Map("operation" -> o.toJson)
- } getOrElse Map[String, JsValue]()
+ } getOrElse Map.empty
} ++ {
Map("accesstoken" -> wp.authKey.toJson)
} ++ {
@@ -1222,8 +1208,8 @@ class RunWskRestCmd() extends FlatSpec with Matchers with ScalaFutures with WskA
val basePath = Path("/api/v1")
val systemNamespace = "whisk.system"
- val sslConfig = AkkaSSLConfig().mapSettings { s =>
- s.withHostnameVerifierClass(classOf[AcceptAllHostNameVerifier].asInstanceOf[Class[HostnameVerifier]])
+ val sslConfig = AkkaSSLConfig().mapSettings {
+ _.withHostnameVerifierClass(classOf[AcceptAllHostNameVerifier].asInstanceOf[Class[HostnameVerifier]])
}
val connectionContext = new HttpsConnectionContext(SSL.nonValidatingContext(), Some(sslConfig))
@@ -1231,11 +1217,10 @@ class RunWskRestCmd() extends FlatSpec with Matchers with ScalaFutures with WskA
def isStatusCodeExpected(expectedExitCode: Int, statusCode: Int): Boolean = {
if ((expectedExitCode != DONTCARE_EXIT) && (expectedExitCode != ANY_ERROR_EXIT))
statusCode == expectedExitCode
- else
- true
+ else true
}
- def validateStatusCode(expectedExitCode: Int, statusCode: Int) = {
+ def validateStatusCode(expectedExitCode: Int, statusCode: Int): Unit = {
if ((expectedExitCode != DONTCARE_EXIT) && (expectedExitCode != ANY_ERROR_EXIT))
if (!isStatusCodeExpected(expectedExitCode, statusCode)) {
statusCode shouldBe expectedExitCode
@@ -1248,12 +1233,14 @@ class RunWskRestCmd() extends FlatSpec with Matchers with ScalaFutures with WskA
def getExt(filePath: String)(implicit wp: WskProps) = {
val sep = "."
- if (filePath.contains(sep)) filePath.substring(filePath.lastIndexOf(sep), filePath.length())
+ if (filePath.contains(sep)) filePath.substring(filePath.lastIndexOf(sep), filePath.length)
else ""
}
- def requestEntity(method: HttpMethod, path: Path, params: Map[String, String] = Map(), body: Option[String] = None)(
- implicit wp: WskProps): HttpResponse = {
+ def requestEntity(method: HttpMethod,
+ path: Path,
+ params: Map[String, String] = Map.empty,
+ body: Option[String] = None)(implicit wp: WskProps): HttpResponse = {
val creds = getBasicHttpCredentials(wp)
@@ -1286,18 +1273,18 @@ class RunWskRestCmd() extends FlatSpec with Matchers with ScalaFutures with WskA
}
}
- def getParamsAnnos(parameters: Map[String, JsValue] = Map(),
- annotations: Map[String, JsValue] = Map(),
+ def getParamsAnnos(parameters: Map[String, JsValue] = Map.empty,
+ annotations: Map[String, JsValue] = Map.empty,
parameterFile: Option[String] = None,
annotationFile: Option[String] = None,
feed: Option[String] = None,
web: Option[String] = None): (Array[JsValue], Array[JsValue]) = {
- val params = parameterFile map { pf =>
- convertStringIntoKeyValue(pf)
- } getOrElse convertMapIntoKeyValue(parameters)
- val annos = annotationFile map { af =>
- convertStringIntoKeyValue(af, feed, web)
- } getOrElse convertMapIntoKeyValue(annotations, feed, web)
+ val params = parameterFile.map(convertStringIntoKeyValue(_)).getOrElse(convertMapIntoKeyValue(parameters))
+
+ val annos = annotationFile
+ .map(convertStringIntoKeyValue(_, feed, web))
+ .getOrElse(convertMapIntoKeyValue(annotations, feed, web))
+
(params, annos)
}
@@ -1312,16 +1299,17 @@ class RunWskRestCmd() extends FlatSpec with Matchers with ScalaFutures with WskA
def convertMapIntoKeyValue(params: Map[String, JsValue],
feed: Option[String] = None,
web: Option[String] = None,
- oldParams: List[JsObject] = List[JsObject]()): Array[JsValue] = {
+ oldParams: List[JsObject] = List.empty): Array[JsValue] = {
val newParams =
params
.map { case (key, value) => JsObject("key" -> key.toJson, "value" -> value) } ++ feed.map(f =>
JsObject("key" -> "feed".toJson, "value" -> f.toJson))
- val paramsList =
+ val paramsList = {
if (newParams.nonEmpty) newParams
- else
- oldParams
+ else oldParams
+ }
+
val webOpt = web.map {
case "true" | "yes" =>
Seq(
@@ -1339,16 +1327,18 @@ class RunWskRestCmd() extends FlatSpec with Matchers with ScalaFutures with WskA
JsObject("key" -> "raw-http".toJson, "value" -> true.toJson),
JsObject("key" -> "final".toJson, "value" -> true.toJson))
case _ =>
- Seq()
+ Seq.empty
}
- (webOpt map { web =>
- paramsList ++ web
- } getOrElse paramsList).toArray
+
+ webOpt
+ .map(paramsList ++ _)
+ .getOrElse(paramsList)
+ .toArray
}
def entityName(name: String)(implicit wp: WskProps) = {
val sep = "/"
- if (name.startsWith(sep)) name.substring(name.indexOf(sep, name.indexOf(sep) + 1) + 1, name.length())
+ if (name.startsWith(sep)) name.substring(name.indexOf(sep, name.indexOf(sep) + 1) + 1, name.length)
else name
}
@@ -1390,7 +1380,7 @@ class RunWskRestCmd() extends FlatSpec with Matchers with ScalaFutures with WskA
}
def invokeAction(name: String,
- parameters: Map[String, JsValue] = Map(),
+ parameters: Map[String, JsValue] = Map.empty,
parameterFile: Option[String] = None,
blocking: Boolean = false,
result: Boolean = false,
@@ -1403,19 +1393,19 @@ class RunWskRestCmd() extends FlatSpec with Matchers with ScalaFutures with WskA
val paramMap = Map("blocking" -> blocking.toString, "result" -> result.toString)
val input = parameterFile map { pf =>
Some(FileUtils.readFileToString(new File(pf), StandardCharsets.UTF_8))
- } getOrElse Some(parameters.toJson.toString())
+ } getOrElse Some(parameters.toJson.toString)
val resp = requestEntity(POST, path, paramMap, input)
- val r = new RestResult(resp.status.intValue, getRespData(resp), blocking)
+ val rr = new RestResult(resp.status.intValue, getRespData(resp), blocking)
// If the statusCode does not not equal to expectedExitCode, it is acceptable that the statusCode
// equals to 200 for the case that either blocking or result is set to true.
- if (!isStatusCodeExpected(expectedExitCode, r.statusCode.intValue)) {
+ if (!isStatusCodeExpected(expectedExitCode, rr.statusCode.intValue)) {
if (blocking || result) {
- validateStatusCode(OK.intValue, r.statusCode.intValue)
+ validateStatusCode(OK.intValue, rr.statusCode.intValue)
} else {
- r.statusCode.intValue shouldBe expectedExitCode
+ rr.statusCode.intValue shouldBe expectedExitCode
}
}
- r
+ rr
}
}
[incubator-openwhisk] 10/19: Move a trait and singleton around.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit 07c5c90acb4059835102a01cb7c026d321a661bb
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Fri Jun 8 16:31:48 2018 -0400
Move a trait and singleton around.
---
tests/src/test/scala/common/BaseWsk.scala | 92 +++++++++++++++---------
tests/src/test/scala/common/Wsk.scala | 58 ---------------
tests/src/test/scala/common/WskTestHelpers.scala | 33 +++++++++
3 files changed, 91 insertions(+), 92 deletions(-)
diff --git a/tests/src/test/scala/common/BaseWsk.scala b/tests/src/test/scala/common/BaseWsk.scala
index 53325e5..90e9ffa 100644
--- a/tests/src/test/scala/common/BaseWsk.scala
+++ b/tests/src/test/scala/common/BaseWsk.scala
@@ -25,11 +25,12 @@ import java.time.Instant
import scala.concurrent.duration.DurationInt
import scala.concurrent.duration.Duration
import scala.language.postfixOps
-
import TestUtils._
import spray.json._
import whisk.core.entity.ByteSize
+import scala.util.Try
+
case class WskProps(
authKey: String = WhiskProperties.readAuthKey(WhiskProperties.getAuthFileForTesting),
cert: String =
@@ -86,6 +87,62 @@ trait WaitFor {
}
}
+trait HasActivation {
+
+ /**
+ * Extracts activation id from invoke (action or trigger) or activation get
+ */
+ def extractActivationId(result: RunResult): Option[String] = {
+ Try {
+ // try to interpret the run result as the result of an invoke
+ extractActivationIdFromInvoke(result) getOrElse extractActivationIdFromActivation(result).get
+ } toOption
+ }
+
+ /**
+ * Extracts activation id from 'wsk activation get' run result
+ */
+ private def extractActivationIdFromActivation(result: RunResult): Option[String] = {
+ Try {
+ // a characteristic string that comes right before the activationId
+ val idPrefix = "ok: got activation "
+ val output = if (result.exitCode != SUCCESS_EXIT) result.stderr else result.stdout
+ assert(output.contains(idPrefix), output)
+ extractActivationId(idPrefix, output).get
+ } toOption
+ }
+
+ /**
+ * Extracts activation id from 'wsk action invoke' or 'wsk trigger invoke'
+ */
+ private def extractActivationIdFromInvoke(result: RunResult): Option[String] = {
+ Try {
+ val output = if (result.exitCode != SUCCESS_EXIT) result.stderr else result.stdout
+ assert(output.contains("ok: invoked") || output.contains("ok: triggered"), output)
+ // a characteristic string that comes right before the activationId
+ val idPrefix = "with id "
+ extractActivationId(idPrefix, output).get
+ } toOption
+ }
+
+ /**
+ * Extracts activation id preceded by a prefix (idPrefix) from a string (output)
+ *
+ * @param idPrefix the prefix of the activation id
+ * @param output the string to be used in the extraction
+ * @return an option containing the id as a string or None if the extraction failed for any reason
+ */
+ private def extractActivationId(idPrefix: String, output: String): Option[String] = {
+ Try {
+ val start = output.indexOf(idPrefix) + idPrefix.length
+ var end = start
+ assert(start > 0)
+ while (end < output.length && output.charAt(end) != '\n') end = end + 1
+ output.substring(start, end) // a uuid
+ } toOption
+ }
+}
+
trait BaseWsk {
val action: BaseAction
val trigger: BaseTrigger
@@ -104,39 +161,6 @@ trait BaseWsk {
}
}
-object FullyQualifiedNames {
-
- /**
- * Fully qualifies the name of an entity with its namespace.
- * If the name already starts with the PATHSEP character, then
- * it already is fully qualified. Otherwise (package name or
- * basic entity name) it is prefixed with the namespace. The
- * namespace is derived from the implicit whisk properties.
- *
- * @param name to fully qualify iff it is not already fully qualified
- * @param wp whisk properties
- * @return name if it is fully qualified else a name fully qualified for a namespace
- */
- def fqn(name: String)(implicit wp: WskProps) = {
- val sep = "/" // Namespace.PATHSEP
- if (name.startsWith(sep) || name.count(_ == sep(0)) == 2) name
- else s"$sep${wp.namespace}$sep$name"
- }
-
- /**
- * Resolves a namespace. If argument is defined, it takes precedence.
- * else resolve to namespace in implicit WskProps.
- *
- * @param namespace an optional namespace
- * @param wp whisk properties
- * @return resolved namespace
- */
- def resolve(namespace: Option[String])(implicit wp: WskProps) = {
- val sep = "/" // Namespace.PATHSEP
- namespace getOrElse s"$sep${wp.namespace}"
- }
-}
-
trait BaseListOrGetFromCollection {
protected val noun: String
diff --git a/tests/src/test/scala/common/Wsk.scala b/tests/src/test/scala/common/Wsk.scala
index 1d40ba3..473e175 100644
--- a/tests/src/test/scala/common/Wsk.scala
+++ b/tests/src/test/scala/common/Wsk.scala
@@ -21,69 +21,11 @@ import java.io.File
import scala.collection.JavaConversions.mapAsJavaMap
import scala.collection.mutable.Buffer
-import scala.language.postfixOps
-import scala.util.Try
import org.scalatest.Matchers
import TestUtils._
import scala.collection.mutable
-trait HasActivation {
-
- /**
- * Extracts activation id from invoke (action or trigger) or activation get
- */
- def extractActivationId(result: RunResult): Option[String] = {
- Try {
- // try to interpret the run result as the result of an invoke
- extractActivationIdFromInvoke(result) getOrElse extractActivationIdFromActivation(result).get
- } toOption
- }
-
- /**
- * Extracts activation id from 'wsk activation get' run result
- */
- private def extractActivationIdFromActivation(result: RunResult): Option[String] = {
- Try {
- // a characteristic string that comes right before the activationId
- val idPrefix = "ok: got activation "
- val output = if (result.exitCode != SUCCESS_EXIT) result.stderr else result.stdout
- assert(output.contains(idPrefix), output)
- extractActivationId(idPrefix, output).get
- } toOption
- }
-
- /**
- * Extracts activation id from 'wsk action invoke' or 'wsk trigger invoke'
- */
- private def extractActivationIdFromInvoke(result: RunResult): Option[String] = {
- Try {
- val output = if (result.exitCode != SUCCESS_EXIT) result.stderr else result.stdout
- assert(output.contains("ok: invoked") || output.contains("ok: triggered"), output)
- // a characteristic string that comes right before the activationId
- val idPrefix = "with id "
- extractActivationId(idPrefix, output).get
- } toOption
- }
-
- /**
- * Extracts activation id preceded by a prefix (idPrefix) from a string (output)
- *
- * @param idPrefix the prefix of the activation id
- * @param output the string to be used in the extraction
- * @return an option containing the id as a string or None if the extraction failed for any reason
- */
- private def extractActivationId(idPrefix: String, output: String): Option[String] = {
- Try {
- val start = output.indexOf(idPrefix) + idPrefix.length
- var end = start
- assert(start > 0)
- while (end < output.length && output.charAt(end) != '\n') end = end + 1
- output.substring(start, end) // a uuid
- } toOption
- }
-}
-
trait RunWskCmd extends Matchers {
/**
diff --git a/tests/src/test/scala/common/WskTestHelpers.scala b/tests/src/test/scala/common/WskTestHelpers.scala
index e889a22..0008784 100644
--- a/tests/src/test/scala/common/WskTestHelpers.scala
+++ b/tests/src/test/scala/common/WskTestHelpers.scala
@@ -35,6 +35,39 @@ import TestUtils.SUCCESS_EXIT
import TestUtils.CONFLICT
import akka.http.scaladsl.model.StatusCodes
+object FullyQualifiedNames {
+
+ /**
+ * Fully qualifies the name of an entity with its namespace.
+ * If the name already starts with the PATHSEP character, then
+ * it already is fully qualified. Otherwise (package name or
+ * basic entity name) it is prefixed with the namespace. The
+ * namespace is derived from the implicit whisk properties.
+ *
+ * @param name to fully qualify iff it is not already fully qualified
+ * @param wp whisk properties
+ * @return name if it is fully qualified else a name fully qualified for a namespace
+ */
+ def fqn(name: String)(implicit wp: WskProps) = {
+ val sep = "/" // Namespace.PATHSEP
+ if (name.startsWith(sep) || name.count(_ == sep(0)) == 2) name
+ else s"$sep${wp.namespace}$sep$name"
+ }
+
+ /**
+ * Resolves a namespace. If argument is defined, it takes precedence.
+ * else resolve to namespace in implicit WskProps.
+ *
+ * @param namespace an optional namespace
+ * @param wp whisk properties
+ * @return resolved namespace
+ */
+ def resolve(namespace: Option[String])(implicit wp: WskProps) = {
+ val sep = "/" // Namespace.PATHSEP
+ namespace getOrElse s"$sep${wp.namespace}"
+ }
+}
+
/**
* An arbitrary response of a whisk action. Includes the result as a JsObject as the
* structure of "result" is not defined.
[incubator-openwhisk] 05/19: More cleanup of BaseRunWsk,
and some redundant methods.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit a75d063640480892b3398da9b7b73795707c6979
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Fri Jun 8 11:38:37 2018 -0400
More cleanup of BaseRunWsk, and some redundant methods.
---
tests/src/test/scala/common/BaseWsk.scala | 52 +++++++---------------
tests/src/test/scala/common/Wsk.scala | 22 ++++++++-
tests/src/test/scala/common/WskTestHelpers.scala | 8 ----
tests/src/test/scala/common/rest/WskRest.scala | 2 +-
.../test/scala/system/basic/WskActionTests.scala | 7 ++-
.../scala/system/basic/WskRestActionTests.scala | 2 +-
.../test/scala/system/basic/WskRestRuleTests.scala | 4 +-
7 files changed, 44 insertions(+), 53 deletions(-)
diff --git a/tests/src/test/scala/common/BaseWsk.scala b/tests/src/test/scala/common/BaseWsk.scala
index 8a1611a..d91c578 100644
--- a/tests/src/test/scala/common/BaseWsk.scala
+++ b/tests/src/test/scala/common/BaseWsk.scala
@@ -23,10 +23,8 @@ import java.io.FileWriter
import java.time.Instant
import scala.concurrent.duration.DurationInt
-import scala.collection.mutable.Buffer
import scala.concurrent.duration.Duration
import scala.language.postfixOps
-import org.scalatest.Matchers
import TestUtils._
import spray.json._
@@ -88,6 +86,16 @@ trait WaitFor {
}
}
+trait BaseRunWsk {
+ /*
+ * Utility function to return a JSON object from the CLI output that returns
+ * an optional a status line following by the JSON data
+ */
+ def parseJsonString(jsonStr: String): JsObject = {
+ jsonStr.substring(jsonStr.indexOf("\n") + 1).parseJson.asJsObject // Skip optional status line before parsing
+ }
+}
+
trait BaseWsk extends BaseRunWsk {
val action: BaseAction
val trigger: BaseTrigger
@@ -185,7 +193,7 @@ trait BaseDeleteFromCollection extends FullyQualifiedNames {
def sanitize(name: String)(implicit wp: WskProps): RunResult
}
-trait BaseAction extends BaseRunWsk with BaseDeleteFromCollection with BaseListOrGetFromCollection {
+trait BaseAction extends BaseDeleteFromCollection with BaseListOrGetFromCollection {
def create(name: String,
artifact: Option[String],
@@ -213,7 +221,7 @@ trait BaseAction extends BaseRunWsk with BaseDeleteFromCollection with BaseListO
expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult
}
-trait BasePackage extends BaseRunWsk with BaseDeleteFromCollection with BaseListOrGetFromCollection {
+trait BasePackage extends BaseDeleteFromCollection with BaseListOrGetFromCollection {
def create(name: String,
parameters: Map[String, JsValue] = Map(),
@@ -231,7 +239,7 @@ trait BasePackage extends BaseRunWsk with BaseDeleteFromCollection with BaseList
expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult
}
-trait BaseTrigger extends BaseRunWsk with BaseDeleteFromCollection with BaseListOrGetFromCollection {
+trait BaseTrigger extends BaseDeleteFromCollection with BaseListOrGetFromCollection {
def create(name: String,
parameters: Map[String, JsValue] = Map(),
@@ -249,7 +257,7 @@ trait BaseTrigger extends BaseRunWsk with BaseDeleteFromCollection with BaseList
expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult
}
-trait BaseRule extends BaseRunWsk with BaseDeleteFromCollection with BaseListOrGetFromCollection {
+trait BaseRule extends BaseDeleteFromCollection with BaseListOrGetFromCollection {
def create(name: String,
trigger: String,
@@ -266,7 +274,7 @@ trait BaseRule extends BaseRunWsk with BaseDeleteFromCollection with BaseListOrG
def state(name: String, expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult
}
-trait BaseActivation extends BaseRunWsk {
+trait BaseActivation {
def extractActivationId(result: RunResult): Option[String]
@@ -298,14 +306,14 @@ trait BaseActivation extends BaseRunWsk {
implicit wp: WskProps): RunResult
}
-trait BaseNamespace extends BaseRunWsk {
+trait BaseNamespace {
def list(expectedExitCode: Int = SUCCESS_EXIT, nameSort: Option[Boolean] = None)(implicit wp: WskProps): RunResult
def whois()(implicit wskprops: WskProps): String
}
-trait BaseApi extends BaseRunWsk {
+trait BaseApi {
def create(basepath: Option[String] = None,
relpath: Option[String] = None,
@@ -339,29 +347,3 @@ trait BaseApi extends BaseRunWsk {
expectedExitCode: Int = SUCCESS_EXIT,
cliCfgFile: Option[String] = None)(implicit wp: WskProps): RunResult
}
-
-trait BaseRunWsk extends Matchers {
-
- // Takes a string and a list of sensitive strings. Any sensistive string found in
- // the target string will be replaced with "XXXXX", returning the processed string
- def hideStr(str: String, hideThese: Seq[String]): String = {
- // Iterate through each string to hide, replacing it in the target string (str)
- hideThese.fold(str)((updatedStr, replaceThis) => updatedStr.replace(replaceThis, "XXXXX"))
- }
-
- /*
- * Utility function to return a JSON object from the CLI output that returns
- * an optional a status line following by the JSON data
- */
- def parseJsonString(jsonStr: String): JsObject = {
- jsonStr.substring(jsonStr.indexOf("\n") + 1).parseJson.asJsObject // Skip optional status line before parsing
- }
-
- def reportFailure(args: Buffer[String], ec: Integer, rr: RunResult) = {
- val s = new StringBuilder()
- s.append(args.mkString(" ") + "\n")
- if (rr.stdout.nonEmpty) s.append(rr.stdout + "\n")
- if (rr.stderr.nonEmpty) s.append(rr.stderr)
- s.append("exit code:")
- }
-}
diff --git a/tests/src/test/scala/common/Wsk.scala b/tests/src/test/scala/common/Wsk.scala
index af59e19..4d1f3ce 100644
--- a/tests/src/test/scala/common/Wsk.scala
+++ b/tests/src/test/scala/common/Wsk.scala
@@ -18,12 +18,14 @@
package common
import java.io.File
-import scala.collection.JavaConversions.mapAsJavaMap
+import scala.collection.JavaConversions.mapAsJavaMap
import scala.collection.mutable.Buffer
import scala.language.postfixOps
import scala.util.Try
+import org.scalatest.Matchers
+
import TestUtils._
trait HasActivation {
@@ -82,7 +84,7 @@ trait HasActivation {
}
}
-trait RunWskCmd extends BaseRunWsk {
+trait RunWskCmd extends Matchers {
/**
* The base command to run. This returns a new mutable buffer, intended for building the rest of the command line.
@@ -138,6 +140,22 @@ trait RunWskCmd extends BaseRunWsk {
println(s"command will retry to due to network error: $rr")
retry(i + 1, N, cmd)
} else rr
+
+ /**
+ * Takes a string and a list of sensitive strings. Any sensistive string found in
+ * the target string will be replaced with "XXXXX", returning the processed string.
+ */
+ private def hideStr(str: String, hideThese: Seq[String]): String = {
+ // Iterate through each string to hide, replacing it in the target string (str)
+ hideThese.fold(str)((updatedStr, replaceThis) => updatedStr.replace(replaceThis, "XXXXX"))
+ }
+
+ private def reportFailure(args: Buffer[String], ec: Integer, rr: RunResult) = {
+ val s = new StringBuilder()
+ s.append(args.mkString(" ") + "\n")
+ if (rr.stdout.nonEmpty) s.append(rr.stdout + "\n")
+ if (rr.stderr.nonEmpty) s.append(rr.stderr)
+ s.append("exit code:")
}
}
diff --git a/tests/src/test/scala/common/WskTestHelpers.scala b/tests/src/test/scala/common/WskTestHelpers.scala
index 098d5cc..3afa610 100644
--- a/tests/src/test/scala/common/WskTestHelpers.scala
+++ b/tests/src/test/scala/common/WskTestHelpers.scala
@@ -276,14 +276,6 @@ trait WskTestHelpers extends Matchers {
}
}
- def removeCLIHeader(response: String): String = {
- if (response.contains("\n")) response.substring(response.indexOf("\n")) else response
- }
-
- def getJSONFromResponse(response: String, isCli: Boolean = false): JsObject = {
- if (isCli) removeCLIHeader(response).parseJson.asJsObject else response.parseJson.asJsObject
- }
-
def getAdditionalTestSubject(newUser: String): WskProps = {
val wskadmin = new RunWskAdminCmd {}
WskProps(namespace = newUser, authKey = wskadmin.cli(Seq("user", "create", newUser)).stdout.trim)
diff --git a/tests/src/test/scala/common/rest/WskRest.scala b/tests/src/test/scala/common/rest/WskRest.scala
index 19e093e..b981013 100644
--- a/tests/src/test/scala/common/rest/WskRest.scala
+++ b/tests/src/test/scala/common/rest/WskRest.scala
@@ -23,8 +23,8 @@ import java.util.Base64
import java.security.cert.X509Certificate
import org.apache.commons.io.FileUtils
-import org.scalatest.Matchers
import org.scalatest.FlatSpec
+import org.scalatest.Matchers
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.time.Span.convertDurationToSpan
diff --git a/tests/src/test/scala/system/basic/WskActionTests.scala b/tests/src/test/scala/system/basic/WskActionTests.scala
index db9af72..bee8170 100644
--- a/tests/src/test/scala/system/basic/WskActionTests.scala
+++ b/tests/src/test/scala/system/basic/WskActionTests.scala
@@ -26,7 +26,6 @@ import common.TestUtils
import common.BaseWsk
import common.WskProps
import common.WskTestHelpers
-import common.rest.WskRest
import spray.json._
import spray.json.DefaultJsonProtocol._
@@ -138,8 +137,8 @@ abstract class WskActionTests extends TestHelpers with WskTestHelpers with JsHel
action.create(copiedActionName, Some(origActionName), Some("copy"))
}
- val copiedAction = getJSONFromResponse(wsk.action.get(copiedActionName).stdout, !wsk.isInstanceOf[WskRest])
- val origAction = getJSONFromResponse(wsk.action.get(copiedActionName).stdout, !wsk.isInstanceOf[WskRest])
+ val copiedAction = wsk.parseJsonString(wsk.action.get(copiedActionName).stdout)
+ val origAction = wsk.parseJsonString(wsk.action.get(copiedActionName).stdout)
copiedAction.fields("annotations") shouldBe origAction.fields("annotations")
copiedAction.fields("parameters") shouldBe origAction.fields("parameters")
@@ -178,7 +177,7 @@ abstract class WskActionTests extends TestHelpers with WskTestHelpers with JsHel
action.create(copiedName, Some(origName), Some("copy"), parameters = copiedParams, annotations = copiedAnnots)
}
- val copiedAction = getJSONFromResponse(wsk.action.get(copiedName).stdout, !wsk.isInstanceOf[WskRest])
+ val copiedAction = wsk.parseJsonString(wsk.action.get(copiedName).stdout)
// CLI does not guarantee order of annotations and parameters so do a diff to compare the values
copiedAction.fields("parameters").convertTo[Seq[JsObject]] diff resParams shouldBe List()
diff --git a/tests/src/test/scala/system/basic/WskRestActionTests.scala b/tests/src/test/scala/system/basic/WskRestActionTests.scala
index dbafbcd..de2bd2d 100644
--- a/tests/src/test/scala/system/basic/WskRestActionTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestActionTests.scala
@@ -35,6 +35,6 @@ class WskRestActionTests extends WskActionTests {
action.create(name, Some(TestUtils.getTestActionFilename("empty.js")))
}
val rr = wsk.action.get(name)
- getJSONFromResponse(rr.stdout, false).getFieldPath("exec", "code") shouldBe Some(JsString(""))
+ wsk.parseJsonString(rr.stdout).getFieldPath("exec", "code") shouldBe Some(JsString(""))
}
}
diff --git a/tests/src/test/scala/system/basic/WskRestRuleTests.scala b/tests/src/test/scala/system/basic/WskRestRuleTests.scala
index 8b07374..d281a6b 100644
--- a/tests/src/test/scala/system/basic/WskRestRuleTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestRuleTests.scala
@@ -71,8 +71,8 @@ class WskRestRuleTests extends WskRuleTests {
retry({
val createStdout = wsk.rule.create(ruleName, trigger, actionName, update = true).stdout
val getStdout = wsk.rule.get(ruleName).stdout
- getJSONFromResponse(createStdout, false).fields.get("status") shouldBe status
- getJSONFromResponse(getStdout, false).fields.get("status") shouldBe status
+ wsk.parseJsonString(createStdout).fields.get("status") shouldBe status
+ wsk.parseJsonString(getStdout).fields.get("status") shouldBe status
}, 10, Some(1.second))
}
}
[incubator-openwhisk] 02/19: Rename test suite.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit d7e54174c53692199ea10df153abe9111729dd2b
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Fri Jun 8 10:33:35 2018 -0400
Rename test suite.
---
.../test/scala/whisk/core/cli/test/WskRestActionSequenceTests.scala | 2 +-
.../src/test/scala/whisk/core/cli/test/WskRestBasicUsageTests.scala | 6 +++---
.../test/scala/whisk/core/cli/test/WskRestEntitlementTests.scala | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskRestActionSequenceTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskRestActionSequenceTests.scala
index f8cec3e..a96eb9e 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskRestActionSequenceTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskRestActionSequenceTests.scala
@@ -27,7 +27,7 @@ import common.TestUtils.RunResult
@RunWith(classOf[JUnitRunner])
class WskRestActionSequenceTests extends WskActionSequenceTests {
- override lazy val wsk: common.rest.WskRest = new WskRest
+ override lazy val wsk = new WskRest
override def verifyActionSequence(action: RunResult, name: String, compValue: JsArray, kindValue: JsString): Unit = {
val actionResultRest = action.asInstanceOf[RestResult]
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskRestBasicUsageTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskRestBasicUsageTests.scala
index c625c2d..823abbf 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskRestBasicUsageTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskRestBasicUsageTests.scala
@@ -50,12 +50,12 @@ import whisk.http.Messages
@RunWith(classOf[JUnitRunner])
class WskRestBasicUsageTests extends TestHelpers with WskTestHelpers {
- implicit val wskprops: common.WskProps = WskProps()
- val wsk: common.rest.WskRest = new WskRest
+ implicit val wskprops = WskProps()
+ val wsk = new WskRest
val defaultAction: Some[String] = Some(TestUtils.getTestActionFilename("hello.js"))
val usrAgentHeaderRegEx: String = """\bUser-Agent\b": \[\s+"OpenWhisk\-CLI/1.\d+.*"""
- behavior of "Wsk CLI usage"
+ behavior of "Wsk API basic usage"
it should "allow a 3 part Fully Qualified Name (FQN) without a leading '/'" in withAssetCleaner(wskprops) {
(wp, assetHelper) =>
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskRestEntitlementTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskRestEntitlementTests.scala
index 200782d..7395922 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskRestEntitlementTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskRestEntitlementTests.scala
@@ -30,7 +30,7 @@ import common.TestUtils.RunResult
@RunWith(classOf[JUnitRunner])
class WskRestEntitlementTests extends WskEntitlementTests {
- override lazy val wsk: common.rest.WskRest = new WskRest
+ override lazy val wsk = new WskRest
override lazy val forbiddenCode = Forbidden.intValue
override lazy val timeoutCode = BadGateway.intValue
override lazy val notFoundCode = NotFound.intValue
[incubator-openwhisk] 01/19: Remove swift tests.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit 654ec5cb5ee535170e918202cb950addb5d3a2c7
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Fri Jun 8 10:33:13 2018 -0400
Remove swift tests.
---
.../scala/whisk/core/cli/test/Swift311Tests.scala | 65 ----------------------
1 file changed, 65 deletions(-)
diff --git a/tests/src/test/scala/whisk/core/cli/test/Swift311Tests.scala b/tests/src/test/scala/whisk/core/cli/test/Swift311Tests.scala
deleted file mode 100644
index a7e6eeb..0000000
--- a/tests/src/test/scala/whisk/core/cli/test/Swift311Tests.scala
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package whisk.core.cli.test
-
-import scala.concurrent.duration.DurationInt
-import org.junit.runner.RunWith
-import org.scalatest.Matchers
-import org.scalatest.junit.JUnitRunner
-import common.TestHelpers
-import common.TestUtils
-import common.rest.WskRest
-import common.WskProps
-import common.WskTestHelpers
-import spray.json.DefaultJsonProtocol._
-import spray.json._
-
-@RunWith(classOf[JUnitRunner])
-class Swift311Tests extends TestHelpers with WskTestHelpers with Matchers {
-
- implicit val wskprops = WskProps()
- val wsk = new WskRest
- val activationPollDuration = 2.minutes
- val defaultJsAction = Some(TestUtils.getTestActionFilename("hello.js"))
-
- lazy val runtimeContainer = "swift:3.1.1"
-
- behavior of "Swift Actions"
-
- /**
- * Test the Swift "hello world" demo sequence
- */
- it should "invoke a swift action" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
- val name = "helloSwift"
- assetHelper.withCleaner(wsk.action, name) { (action, _) =>
- action.create(name, Some(TestUtils.getTestActionFilename("hello.swift")), kind = Some(runtimeContainer))
- }
-
- withActivation(wsk.activation, wsk.action.invoke(name), totalWait = activationPollDuration) {
- _.response.result.get.toString should include("Hello stranger!")
- }
-
- withActivation(
- wsk.activation,
- wsk.action.invoke(name, Map("name" -> "Sir".toJson)),
- totalWait = activationPollDuration) {
- _.response.result.get.toString should include("Hello Sir!")
- }
- }
-
-}
[incubator-openwhisk] 13/19: Remove burried ActorSystem which
turned into several instances for every instantiated instance of the Rest
'wsk'.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit 663440da35baf4b066add3e5fae70cfc0557a1d3
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Fri Jun 8 23:07:06 2018 -0400
Remove burried ActorSystem which turned into several instances for every instantiated instance of the Rest 'wsk'.
---
.../apigw/healthtests/ApiGwEndToEndTests.scala | 2 +-
.../apigw/healthtests/ApiGwRestEndToEndTests.scala | 7 +--
.../common/{CommandLine.scala => RunCliCmd.scala} | 4 +-
.../test/scala/common/rest/WskRestOperations.scala | 53 +++++++++++-----------
tests/src/test/scala/limits/ThrottleTests.scala | 1 +
.../scala/system/basic/WskRestActionTests.scala | 10 ++--
.../system/basic/WskRestActivationTests.scala | 5 +-
.../scala/system/basic/WskRestBasicJavaTests.scala | 6 +--
.../system/basic/WskRestBasicNode6Tests.scala | 5 +-
.../system/basic/WskRestBasicNode8Tests.scala | 5 +-
.../basic/WskRestBasicNodeDefaultTests.scala | 5 +-
.../system/basic/WskRestBasicPythonTests.scala | 5 +-
.../system/basic/WskRestBasicSwift311Tests.scala | 5 +-
.../system/basic/WskRestBasicSwift41Tests.scala | 5 +-
.../scala/system/basic/WskRestBasicTests.scala | 8 ++--
.../scala/system/basic/WskRestConductorTests.scala | 5 +-
.../scala/system/basic/WskRestPackageTests.scala | 8 ++--
.../test/scala/system/basic/WskRestRuleTests.scala | 5 +-
.../system/basic/WskRestUnicodeJavaTests.scala | 5 +-
.../system/basic/WskRestUnicodeNode6Tests.scala | 5 +-
.../system/basic/WskRestUnicodeNode8Tests.scala | 5 +-
.../system/basic/WskRestUnicodePython2Tests.scala | 8 ++--
.../system/basic/WskRestUnicodePython3Tests.scala | 8 ++--
.../system/basic/WskRestUnicodeSwift311Tests.scala | 8 ++--
.../system/basic/WskRestUnicodeSwift41Tests.scala | 6 +--
.../test/scala/system/rest/ActionSchemaTests.scala | 16 +++----
.../scala/whisk/core/admin/WskAdminTests.scala | 4 +-
.../whisk/core/cli/test/ApiGwRestBasicTests.scala | 2 +-
.../scala/whisk/core/cli/test/ApiGwRestTests.scala | 4 +-
.../core/cli/test/WskActionSequenceTests.scala | 2 +-
.../core/cli/test/WskRestActionSequenceTests.scala | 4 +-
.../core/cli/test/WskRestBasicUsageTests.scala | 3 +-
.../core/cli/test/WskRestEntitlementTests.scala | 5 +-
.../core/cli/test/WskRestWebActionsTests.scala | 6 +--
.../whisk/core/cli/test/WskWebActionsTests.scala | 8 ++--
.../core/database/test/CacheConcurrencyTests.scala | 9 +---
.../whisk/core/limits/ActionLimitsTests.scala | 4 +-
.../whisk/core/limits/MaxActionDurationTests.scala | 4 +-
38 files changed, 135 insertions(+), 125 deletions(-)
diff --git a/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala b/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala
index 59821e7..957909b 100644
--- a/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala
+++ b/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala
@@ -55,7 +55,7 @@ abstract class ApiGwEndToEndTests
implicit val wskprops: common.WskProps = WskProps()
val wsk: WskOperations
- val namespace: String = wsk.namespace.whois()
+ lazy val namespace: String = wsk.namespace.whois()
val createCode: Int
// Custom CLI properties file
diff --git a/tests/src/test/scala/apigw/healthtests/ApiGwRestEndToEndTests.scala b/tests/src/test/scala/apigw/healthtests/ApiGwRestEndToEndTests.scala
index abb82e0..577a566 100644
--- a/tests/src/test/scala/apigw/healthtests/ApiGwRestEndToEndTests.scala
+++ b/tests/src/test/scala/apigw/healthtests/ApiGwRestEndToEndTests.scala
@@ -29,12 +29,13 @@ import org.scalatest.junit.JUnitRunner
import common.TestUtils._
import common.rest.WskRestOperations
import common.rest.RestResult
+import common.WskActorSystem
@RunWith(classOf[JUnitRunner])
-class ApiGwRestEndToEndTests extends ApiGwEndToEndTests {
+class ApiGwRestEndToEndTests extends ApiGwEndToEndTests with WskActorSystem {
- override lazy val wsk: common.rest.WskRestOperations = new WskRestOperations
- override val createCode: Int = OK.intValue
+ override lazy val wsk = new WskRestOperations
+ override val createCode = OK.intValue
override def verifyAPICreated(rr: RunResult): Unit = {
val apiResultRest = rr.asInstanceOf[RestResult]
diff --git a/tests/src/test/scala/common/CommandLine.scala b/tests/src/test/scala/common/RunCliCmd.scala
similarity index 98%
rename from tests/src/test/scala/common/CommandLine.scala
rename to tests/src/test/scala/common/RunCliCmd.scala
index 55e451d..a13ee9d 100644
--- a/tests/src/test/scala/common/CommandLine.scala
+++ b/tests/src/test/scala/common/RunCliCmd.scala
@@ -26,7 +26,7 @@ import TestUtils._
import scala.collection.mutable
-trait CommandLine extends Matchers {
+trait RunCliCmd extends Matchers {
/**
* The base command to run. This returns a new mutable buffer, intended for building the rest of the command line.
@@ -102,7 +102,7 @@ trait CommandLine extends Matchers {
}
object WskAdmin {
- val wskadmin = new CommandLine {
+ val wskadmin = new RunCliCmd {
override def baseCommand: mutable.Buffer[String] = WskAdmin.baseCommand
}
diff --git a/tests/src/test/scala/common/rest/WskRestOperations.scala b/tests/src/test/scala/common/rest/WskRestOperations.scala
index b3d42c1..f12d477 100644
--- a/tests/src/test/scala/common/rest/WskRestOperations.scala
+++ b/tests/src/test/scala/common/rest/WskRestOperations.scala
@@ -23,7 +23,6 @@ import java.util.Base64
import java.security.cert.X509Certificate
import org.apache.commons.io.FileUtils
-import org.scalatest.FlatSpec
import org.scalatest.Matchers
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.time.Span.convertDurationToSpan
@@ -67,7 +66,6 @@ import common.TestUtils.DONTCARE_EXIT
import common.TestUtils.RunResult
import common.WaitFor
import common.WhiskProperties
-import common.WskActorSystem
import common.WskProps
import whisk.core.entity.ByteSize
import whisk.utils.retry
@@ -145,7 +143,7 @@ object HttpConnection {
}
}
-class WskRestOperations() extends RunWskRestCmd with WskOperations {
+class WskRestOperations(implicit actorSytem: ActorSystem) extends WskOperations {
override implicit val action = new RestActionOperations
override implicit val trigger = new RestTriggerOperations
override implicit val rule = new RestRuleOperations
@@ -155,7 +153,7 @@ class WskRestOperations() extends RunWskRestCmd with WskOperations {
override implicit val api = new RestGatewayOperations
}
-trait RestListOrGetFromCollectionOperations extends RunWskRestCmd with ListOrGetFromCollectionOperations {
+trait RestListOrGetFromCollectionOperations extends ListOrGetFromCollectionOperations with RunRestCmd {
import FullyQualifiedNames.resolve
/**
@@ -208,7 +206,7 @@ trait RestListOrGetFromCollectionOperations extends RunWskRestCmd with ListOrGet
}
}
-trait RestDeleteFromCollectionOperations extends RunWskRestCmd with DeleteFromCollectionOperations {
+trait RestDeleteFromCollectionOperations extends DeleteFromCollectionOperations with RunRestCmd {
/**
* Deletes entity from collection.
@@ -257,9 +255,8 @@ trait RestActivation extends HasActivation {
}
}
-class RestActionOperations
- extends RunWskRestCmd
- with RestListOrGetFromCollectionOperations
+class RestActionOperations(implicit val actorSystem: ActorSystem)
+ extends RestListOrGetFromCollectionOperations
with RestDeleteFromCollectionOperations
with RestActivation
with ActionOperations {
@@ -458,9 +455,8 @@ class RestActionOperations
}
}
-class RestTriggerOperations
- extends RunWskRestCmd
- with RestListOrGetFromCollectionOperations
+class RestTriggerOperations(implicit val actorSystem: ActorSystem)
+ extends RestListOrGetFromCollectionOperations
with RestDeleteFromCollectionOperations
with RestActivation
with TriggerOperations {
@@ -568,9 +564,8 @@ class RestTriggerOperations
}
}
-class RestRuleOperations
- extends RunWskRestCmd
- with RestListOrGetFromCollectionOperations
+class RestRuleOperations(implicit val actorSystem: ActorSystem)
+ extends RestListOrGetFromCollectionOperations
with RestDeleteFromCollectionOperations
with WaitFor
with RuleOperations {
@@ -652,7 +647,11 @@ class RestRuleOperations
}
}
-class RestActivationOperations extends RunWskRestCmd with RestActivation with WaitFor with ActivationOperations {
+class RestActivationOperations(implicit val actorSystem: ActorSystem)
+ extends ActivationOperations
+ with RunRestCmd
+ with RestActivation
+ with WaitFor {
protected val noun = "activations"
@@ -695,7 +694,7 @@ class RestActivationOperations extends RunWskRestCmd with RestActivation with Wa
docs: Boolean = true,
expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RestResult = {
val entityPath = Path(s"${basePath}/namespaces/${wp.namespace}/$noun")
- var paramMap = Map("skip" -> "0", "docs" -> docs.toString) ++ {
+ val paramMap = Map("skip" -> "0", "docs" -> docs.toString) ++ {
limit map { l =>
Map("limit" -> l.toString)
} getOrElse Map.empty
@@ -864,7 +863,7 @@ class RestActivationOperations extends RunWskRestCmd with RestActivation with Wa
private case class PartialResult(ids: Seq[String]) extends Throwable
}
-class RestNamespaceOperations extends RunWskRestCmd with NamespaceOperations {
+class RestNamespaceOperations(implicit val actorSystem: ActorSystem) extends NamespaceOperations with RunRestCmd {
protected val noun = "namespaces"
@@ -895,9 +894,8 @@ class RestNamespaceOperations extends RunWskRestCmd with NamespaceOperations {
}
}
-class RestPackageOperations
- extends RunWskRestCmd
- with RestListOrGetFromCollectionOperations
+class RestPackageOperations(implicit val actorSystem: ActorSystem)
+ extends RestListOrGetFromCollectionOperations
with RestDeleteFromCollectionOperations
with PackageOperations {
@@ -979,7 +977,7 @@ class RestPackageOperations
}
-class RestGatewayOperations extends RunWskRestCmd with GatewayOperations {
+class RestGatewayOperations(implicit val actorSystem: ActorSystem) extends GatewayOperations with RunRestCmd {
protected val noun = "apis"
/**
@@ -1196,10 +1194,8 @@ class RestGatewayOperations extends RunWskRestCmd with GatewayOperations {
}
}
-class RunWskRestCmd() extends FlatSpec with Matchers with ScalaFutures with WskActorSystem {
+trait RunRestCmd extends Matchers with ScalaFutures {
- implicit val config = PatienceConfig(100 seconds, 15 milliseconds)
- implicit val materializer = ActorMaterializer()
val protocol = loadConfigOrThrow[String]("whisk.controller.protocol")
val idleTimeout = 90 seconds
val queueSize = 10
@@ -1207,11 +1203,16 @@ class RunWskRestCmd() extends FlatSpec with Matchers with ScalaFutures with WskA
val basePath = Path("/api/v1")
val systemNamespace = "whisk.system"
- val sslConfig = AkkaSSLConfig().mapSettings {
+ implicit val config = PatienceConfig(100 seconds, 15 milliseconds)
+ implicit val actorSystem: ActorSystem
+ lazy implicit val executionContext = actorSystem.dispatcher
+ lazy implicit val materializer = ActorMaterializer()
+
+ lazy val sslConfig = AkkaSSLConfig().mapSettings {
_.withHostnameVerifierClass(classOf[AcceptAllHostNameVerifier].asInstanceOf[Class[HostnameVerifier]])
}
- val connectionContext = new HttpsConnectionContext(SSL.nonValidatingContext(), Some(sslConfig))
+ lazy val connectionContext = new HttpsConnectionContext(SSL.nonValidatingContext(), Some(sslConfig))
def isStatusCodeExpected(expectedExitCode: Int, statusCode: Int): Boolean = {
if ((expectedExitCode != DONTCARE_EXIT) && (expectedExitCode != ANY_ERROR_EXIT))
diff --git a/tests/src/test/scala/limits/ThrottleTests.scala b/tests/src/test/scala/limits/ThrottleTests.scala
index ae01309..72358f6 100644
--- a/tests/src/test/scala/limits/ThrottleTests.scala
+++ b/tests/src/test/scala/limits/ThrottleTests.scala
@@ -295,6 +295,7 @@ class NamespaceSpecificThrottleTests
extends FlatSpec
with TestHelpers
with WskTestHelpers
+ with WskActorSystem
with Matchers
with BeforeAndAfterAll
with LocalHelper {
diff --git a/tests/src/test/scala/system/basic/WskRestActionTests.scala b/tests/src/test/scala/system/basic/WskRestActionTests.scala
index 1f46628..be41abf 100644
--- a/tests/src/test/scala/system/basic/WskRestActionTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestActionTests.scala
@@ -17,17 +17,15 @@
package system.basic
+import common.{TestUtils, WskActorSystem}
+import common.rest.WskRestOperations
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-
-import common.rest.WskRestOperations
-import common.TestUtils
-
import spray.json._
@RunWith(classOf[JUnitRunner])
-class WskRestActionTests extends WskActionTests {
- override val wsk: WskRestOperations = new WskRestOperations
+class WskRestActionTests extends WskActionTests with WskActorSystem {
+ override val wsk = new WskRestOperations
it should "create an action with an empty file" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
val name = "empty"
diff --git a/tests/src/test/scala/system/basic/WskRestActivationTests.scala b/tests/src/test/scala/system/basic/WskRestActivationTests.scala
index c7f7897..86cd831 100644
--- a/tests/src/test/scala/system/basic/WskRestActivationTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestActivationTests.scala
@@ -21,8 +21,9 @@ import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import common.rest.WskRestOperations
+import common.WskActorSystem
@RunWith(classOf[JUnitRunner])
-class WskRestActivationTests extends WskActivationTests {
- override val wsk: WskRestOperations = new WskRestOperations
+class WskRestActivationTests extends WskActivationTests with WskActorSystem {
+ override val wsk = new WskRestOperations
}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicJavaTests.scala b/tests/src/test/scala/system/basic/WskRestBasicJavaTests.scala
index 5cc5126..4567be2 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicJavaTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicJavaTests.scala
@@ -18,11 +18,11 @@
package system.basic
import common.rest.WskRestOperations
-
+import common.WskActorSystem
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
-class WskRestBasicJavaTests extends WskBasicJavaTests {
- override val wsk: common.rest.WskRestOperations = new WskRestOperations
+class WskRestBasicJavaTests extends WskBasicJavaTests with WskActorSystem {
+ override val wsk = new WskRestOperations
}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicNode6Tests.scala b/tests/src/test/scala/system/basic/WskRestBasicNode6Tests.scala
index 792b13d..8eb0cd6 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicNode6Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicNode6Tests.scala
@@ -18,11 +18,12 @@
package system.basic
import common.rest.WskRestOperations
+import common.WskActorSystem
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
-class WskRestBasicNode6Tests extends WskBasicNode6Tests {
- override val wsk: common.rest.WskRestOperations = new WskRestOperations
+class WskRestBasicNode6Tests extends WskBasicNode6Tests with WskActorSystem {
+ override val wsk = new WskRestOperations
}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicNode8Tests.scala b/tests/src/test/scala/system/basic/WskRestBasicNode8Tests.scala
index 3b69b74..ca1ee84 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicNode8Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicNode8Tests.scala
@@ -18,11 +18,12 @@
package system.basic
import common.rest.WskRestOperations
+import common.WskActorSystem
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
-class WskRestBasicNode8Tests extends WskBasicNode8Tests {
- override val wsk: common.rest.WskRestOperations = new WskRestOperations
+class WskRestBasicNode8Tests extends WskBasicNode8Tests with WskActorSystem {
+ override val wsk = new WskRestOperations
}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicNodeDefaultTests.scala b/tests/src/test/scala/system/basic/WskRestBasicNodeDefaultTests.scala
index 367aa9c..ed5b3dd 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicNodeDefaultTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicNodeDefaultTests.scala
@@ -18,11 +18,12 @@
package system.basic
import common.rest.WskRestOperations
+import common.WskActorSystem
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
-class WskRestBasicNodeDefaultTests extends WskBasicNodeDefaultTests {
- override val wsk: common.rest.WskRestOperations = new WskRestOperations
+class WskRestBasicNodeDefaultTests extends WskBasicNodeDefaultTests with WskActorSystem {
+ override val wsk = new WskRestOperations
}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicPythonTests.scala b/tests/src/test/scala/system/basic/WskRestBasicPythonTests.scala
index d6242f1..8a65b9c 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicPythonTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicPythonTests.scala
@@ -18,11 +18,12 @@
package system.basic
import common.rest.WskRestOperations
+import common.WskActorSystem
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
-class WskRestBasicPythonTests extends WskBasicPythonTests {
- override val wsk: common.rest.WskRestOperations = new WskRestOperations
+class WskRestBasicPythonTests extends WskBasicPythonTests with WskActorSystem {
+ override val wsk = new WskRestOperations
}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicSwift311Tests.scala b/tests/src/test/scala/system/basic/WskRestBasicSwift311Tests.scala
index 46e3935..92161b0 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicSwift311Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicSwift311Tests.scala
@@ -18,12 +18,13 @@
package system.basic
import common.rest.WskRestOperations
+import common.WskActorSystem
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
-class WskRestBasicSwift311Tests extends WskBasicSwift3Tests {
- override val wsk: common.rest.WskRestOperations = new WskRestOperations
+class WskRestBasicSwift311Tests extends WskBasicSwift3Tests with WskActorSystem {
+ override val wsk = new WskRestOperations
override lazy val actionKind = "swift:3.1.1"
}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicSwift41Tests.scala b/tests/src/test/scala/system/basic/WskRestBasicSwift41Tests.scala
index 0222020..c6a7908 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicSwift41Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicSwift41Tests.scala
@@ -18,13 +18,14 @@
package system.basic
import common.rest.WskRestOperations
+import common.WskActorSystem
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
-class WskRestBasicSwift41Tests extends WskBasicSwift3Tests {
- override val wsk: common.rest.WskRestOperations = new WskRestOperations
+class WskRestBasicSwift41Tests extends WskBasicSwift3Tests with WskActorSystem {
+ override val wsk = new WskRestOperations
override lazy val actionKind = "swift:4.1"
}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicTests.scala b/tests/src/test/scala/system/basic/WskRestBasicTests.scala
index 3042205..d8a54d3 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicTests.scala
@@ -36,15 +36,17 @@ import common.rest.WskRestOperations
import common.rest.RestResult
import common.WskProps
import common.WskTestHelpers
+import common.WskActorSystem
+
import spray.json._
import spray.json.DefaultJsonProtocol._
import whisk.http.Messages
@RunWith(classOf[JUnitRunner])
-class WskRestBasicTests extends TestHelpers with WskTestHelpers {
+class WskRestBasicTests extends TestHelpers with WskTestHelpers with WskActorSystem {
- implicit val wskprops: common.WskProps = WskProps()
- val wsk: common.rest.WskRestOperations = new WskRestOperations
+ implicit val wskprops = WskProps()
+ val wsk = new WskRestOperations
val defaultAction: Some[String] = Some(TestUtils.getTestActionFilename("hello.js"))
/**
diff --git a/tests/src/test/scala/system/basic/WskRestConductorTests.scala b/tests/src/test/scala/system/basic/WskRestConductorTests.scala
index 7a0757b..a739bed 100644
--- a/tests/src/test/scala/system/basic/WskRestConductorTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestConductorTests.scala
@@ -21,8 +21,9 @@ import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import common.rest.WskRestOperations
+import common.WskActorSystem
@RunWith(classOf[JUnitRunner])
-class WskRestConductorTests extends WskConductorTests {
- override val wsk: WskRestOperations = new WskRestOperations
+class WskRestConductorTests extends WskConductorTests with WskActorSystem {
+ override val wsk = new WskRestOperations
}
diff --git a/tests/src/test/scala/system/basic/WskRestPackageTests.scala b/tests/src/test/scala/system/basic/WskRestPackageTests.scala
index 1751f06..d0d6d51 100644
--- a/tests/src/test/scala/system/basic/WskRestPackageTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestPackageTests.scala
@@ -17,11 +17,13 @@
package system.basic
+import common.WskActorSystem
+import common.rest.WskRestOperations
+
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-import common.rest.WskRestOperations
@RunWith(classOf[JUnitRunner])
-class WskRestPackageTests extends WskPackageTests {
- override val wsk: WskRestOperations = new WskRestOperations
+class WskRestPackageTests extends WskPackageTests with WskActorSystem {
+ override val wsk = new WskRestOperations
}
diff --git a/tests/src/test/scala/system/basic/WskRestRuleTests.scala b/tests/src/test/scala/system/basic/WskRestRuleTests.scala
index 7ba4ed7..ac00ab4 100644
--- a/tests/src/test/scala/system/basic/WskRestRuleTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestRuleTests.scala
@@ -23,6 +23,7 @@ import org.scalatest.junit.JUnitRunner
import common.TestUtils.RunResult
import common.rest.WskRestOperations
import common.rest.RestResult
+import common.WskActorSystem
import whisk.utils.retry
@@ -32,8 +33,8 @@ import spray.json._
import spray.json.DefaultJsonProtocol._
@RunWith(classOf[JUnitRunner])
-class WskRestRuleTests extends WskRuleTests {
- override val wsk: common.rest.WskRestOperations = new WskRestOperations
+class WskRestRuleTests extends WskRuleTests with WskActorSystem {
+ override val wsk = new WskRestOperations
override def verifyRuleList(ruleListResult: RunResult,
ruleNameEnable: String,
diff --git a/tests/src/test/scala/system/basic/WskRestUnicodeJavaTests.scala b/tests/src/test/scala/system/basic/WskRestUnicodeJavaTests.scala
index 6b27621..bb9ddb7 100644
--- a/tests/src/test/scala/system/basic/WskRestUnicodeJavaTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestUnicodeJavaTests.scala
@@ -23,11 +23,12 @@ import org.scalatest.junit.JUnitRunner
import common.JsHelpers
import common.WskTestHelpers
import common.rest.WskRestOperations
+import common.WskActorSystem
@RunWith(classOf[JUnitRunner])
-class WskRestUnicodeJavaTests extends WskUnicodeTests with WskTestHelpers with JsHelpers {
+class WskRestUnicodeJavaTests extends WskUnicodeTests with WskTestHelpers with WskActorSystem with JsHelpers {
- override val wsk: common.rest.WskRestOperations = new WskRestOperations
+ override val wsk = new WskRestOperations
override lazy val actionKind = "java"
override lazy val actionSource = "unicode.jar"
diff --git a/tests/src/test/scala/system/basic/WskRestUnicodeNode6Tests.scala b/tests/src/test/scala/system/basic/WskRestUnicodeNode6Tests.scala
index 182dcec..c20de9d 100644
--- a/tests/src/test/scala/system/basic/WskRestUnicodeNode6Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestUnicodeNode6Tests.scala
@@ -23,11 +23,12 @@ import org.scalatest.junit.JUnitRunner
import common.JsHelpers
import common.WskTestHelpers
import common.rest.WskRestOperations
+import common.WskActorSystem
@RunWith(classOf[JUnitRunner])
-class WskRestUnicodeNode6Tests extends WskUnicodeTests with WskTestHelpers with JsHelpers {
+class WskRestUnicodeNode6Tests extends WskUnicodeTests with WskTestHelpers with WskActorSystem with JsHelpers {
- override val wsk: common.rest.WskRestOperations = new WskRestOperations
+ override val wsk = new WskRestOperations
override lazy val actionKind = "nodejs:6"
override lazy val actionSource = "unicode.js"
diff --git a/tests/src/test/scala/system/basic/WskRestUnicodeNode8Tests.scala b/tests/src/test/scala/system/basic/WskRestUnicodeNode8Tests.scala
index 35a7f29..c788757 100644
--- a/tests/src/test/scala/system/basic/WskRestUnicodeNode8Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestUnicodeNode8Tests.scala
@@ -23,11 +23,12 @@ import org.scalatest.junit.JUnitRunner
import common.JsHelpers
import common.WskTestHelpers
import common.rest.WskRestOperations
+import common.WskActorSystem
@RunWith(classOf[JUnitRunner])
-class WskRestUnicodeNode8Tests extends WskUnicodeTests with WskTestHelpers with JsHelpers {
+class WskRestUnicodeNode8Tests extends WskUnicodeTests with WskTestHelpers with WskActorSystem with JsHelpers {
- override val wsk: common.rest.WskRestOperations = new WskRestOperations
+ override val wsk = new WskRestOperations
override lazy val actionKind = "nodejs:8"
override lazy val actionSource = "unicode.js"
diff --git a/tests/src/test/scala/system/basic/WskRestUnicodePython2Tests.scala b/tests/src/test/scala/system/basic/WskRestUnicodePython2Tests.scala
index a67e151..0d58ca1 100644
--- a/tests/src/test/scala/system/basic/WskRestUnicodePython2Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestUnicodePython2Tests.scala
@@ -19,15 +19,13 @@ package system.basic
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-
-import common.JsHelpers
-import common.WskTestHelpers
+import common.{JsHelpers, WskActorSystem, WskTestHelpers}
import common.rest.WskRestOperations
@RunWith(classOf[JUnitRunner])
-class WskRestUnicodePython2Tests extends WskUnicodeTests with WskTestHelpers with JsHelpers {
+class WskRestUnicodePython2Tests extends WskUnicodeTests with WskTestHelpers with WskActorSystem with JsHelpers {
- override val wsk: common.rest.WskRestOperations = new WskRestOperations
+ override val wsk = new WskRestOperations
override lazy val actionKind = "python:2"
override lazy val actionSource = "unicode2.py"
diff --git a/tests/src/test/scala/system/basic/WskRestUnicodePython3Tests.scala b/tests/src/test/scala/system/basic/WskRestUnicodePython3Tests.scala
index 6d74598..287baff 100644
--- a/tests/src/test/scala/system/basic/WskRestUnicodePython3Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestUnicodePython3Tests.scala
@@ -19,15 +19,13 @@ package system.basic
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-
-import common.JsHelpers
-import common.WskTestHelpers
+import common.{JsHelpers, WskActorSystem, WskTestHelpers}
import common.rest.WskRestOperations
@RunWith(classOf[JUnitRunner])
-class WskRestUnicodePython3Tests extends WskUnicodeTests with WskTestHelpers with JsHelpers {
+class WskRestUnicodePython3Tests extends WskUnicodeTests with WskTestHelpers with WskActorSystem with JsHelpers {
- override val wsk: common.rest.WskRestOperations = new WskRestOperations
+ override val wsk = new WskRestOperations
override lazy val actionKind = "python:3"
override lazy val actionSource = "unicode3.py"
diff --git a/tests/src/test/scala/system/basic/WskRestUnicodeSwift311Tests.scala b/tests/src/test/scala/system/basic/WskRestUnicodeSwift311Tests.scala
index 3b1e5d9..68a7928 100644
--- a/tests/src/test/scala/system/basic/WskRestUnicodeSwift311Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestUnicodeSwift311Tests.scala
@@ -19,15 +19,13 @@ package system.basic
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-
-import common.JsHelpers
-import common.WskTestHelpers
+import common.{JsHelpers, WskActorSystem, WskTestHelpers}
import common.rest.WskRestOperations
@RunWith(classOf[JUnitRunner])
-class WskRestUnicodeSwift311Tests extends WskUnicodeTests with WskTestHelpers with JsHelpers {
+class WskRestUnicodeSwift311Tests extends WskUnicodeTests with WskTestHelpers with WskActorSystem with JsHelpers {
- override val wsk: common.rest.WskRestOperations = new WskRestOperations
+ override val wsk = new WskRestOperations
override lazy val actionKind = "swift:3.1.1"
override lazy val actionSource = "unicode.swift"
diff --git a/tests/src/test/scala/system/basic/WskRestUnicodeSwift41Tests.scala b/tests/src/test/scala/system/basic/WskRestUnicodeSwift41Tests.scala
index cd62237..51577c1 100644
--- a/tests/src/test/scala/system/basic/WskRestUnicodeSwift41Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestUnicodeSwift41Tests.scala
@@ -17,15 +17,15 @@
package system.basic
-import common.{JsHelpers, WskTestHelpers}
+import common.{JsHelpers, WskActorSystem, WskTestHelpers}
import common.rest.WskRestOperations
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
-class WskRestUnicodeSwift41Tests extends WskUnicodeTests with WskTestHelpers with JsHelpers {
+class WskRestUnicodeSwift41Tests extends WskUnicodeTests with WskTestHelpers with WskActorSystem with JsHelpers {
- override val wsk: common.rest.WskRestOperations = new WskRestOperations
+ override val wsk = new WskRestOperations
override lazy val actionKind = "swift:4.1"
override lazy val actionSource = "unicode.swift"
diff --git a/tests/src/test/scala/system/rest/ActionSchemaTests.scala b/tests/src/test/scala/system/rest/ActionSchemaTests.scala
index 7c6356e..a22fccd 100644
--- a/tests/src/test/scala/system/rest/ActionSchemaTests.scala
+++ b/tests/src/test/scala/system/rest/ActionSchemaTests.scala
@@ -19,26 +19,26 @@ package system.rest
import scala.util.Success
import scala.util.Try
-
import org.junit.runner.RunWith
import org.scalatest.FlatSpec
import org.scalatest.Matchers
import org.scalatest.junit.JUnitRunner
-
import com.jayway.restassured.RestAssured
-
-import common.TestUtils
-import common.WhiskProperties
+import common._
import common.rest.WskRestOperations
-import common.WskProps
-import common.WskTestHelpers
import spray.json._
/**
* Basic tests of API calls for actions
*/
@RunWith(classOf[JUnitRunner])
-class ActionSchemaTests extends FlatSpec with Matchers with RestUtil with JsonSchema with WskTestHelpers {
+class ActionSchemaTests
+ extends FlatSpec
+ with Matchers
+ with RestUtil
+ with JsonSchema
+ with WskTestHelpers
+ with WskActorSystem {
implicit val wskprops = WskProps()
val wsk = new WskRestOperations
diff --git a/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala b/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala
index 7251e1a..7342f3e 100644
--- a/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala
+++ b/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala
@@ -18,7 +18,7 @@
package whisk.core.admin
import common.WskAdmin.wskadmin
-import common.{TestHelpers, TestUtils, WskAdmin, WskProps}
+import common._
import common.rest.WskRestOperations
import org.junit.runner.RunWith
import org.scalatest.{BeforeAndAfterAll, Matchers}
@@ -30,7 +30,7 @@ import scala.concurrent.duration.DurationInt
import scala.util.Try
@RunWith(classOf[JUnitRunner])
-class WskAdminTests extends TestHelpers with Matchers with BeforeAndAfterAll {
+class WskAdminTests extends TestHelpers with WskActorSystem with Matchers with BeforeAndAfterAll {
override def beforeAll() = {
val testSpaces = Seq("testspace", "testspace1", "testspace2")
diff --git a/tests/src/test/scala/whisk/core/cli/test/ApiGwRestBasicTests.scala b/tests/src/test/scala/whisk/core/cli/test/ApiGwRestBasicTests.scala
index b520951..f599675 100644
--- a/tests/src/test/scala/whisk/core/cli/test/ApiGwRestBasicTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/ApiGwRestBasicTests.scala
@@ -36,7 +36,7 @@ import common.WskProps
@RunWith(classOf[JUnitRunner])
abstract class ApiGwRestBasicTests extends BaseApiGwTests {
- val clinamespace = wsk.namespace.whois()
+ lazy val clinamespace = wsk.namespace.whois()
val createCode: Int
def verifyBadCommands(rr: RunResult, badpath: String): Unit = {
diff --git a/tests/src/test/scala/whisk/core/cli/test/ApiGwRestTests.scala b/tests/src/test/scala/whisk/core/cli/test/ApiGwRestTests.scala
index dcb9104..7a2447c 100644
--- a/tests/src/test/scala/whisk/core/cli/test/ApiGwRestTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/ApiGwRestTests.scala
@@ -25,7 +25,7 @@ import spray.json._
import common.rest.WskRestOperations
import common.rest.RestResult
import common.TestUtils.{RunResult, _}
-import common.TestUtils
+import common.{TestUtils, WskActorSystem}
import system.rest.RestUtil
import java.io.File
@@ -33,7 +33,7 @@ import java.io.File
* Tests for testing the CLI "api" subcommand. Most of these tests require a deployed backend.
*/
@RunWith(classOf[JUnitRunner])
-class ApiGwRestTests extends ApiGwRestBasicTests with RestUtil {
+class ApiGwRestTests extends ApiGwRestBasicTests with RestUtil with WskActorSystem {
override lazy val wsk = new WskRestOperations
override lazy val createCode = OK.intValue
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskActionSequenceTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskActionSequenceTests.scala
index 05aff02..5c9705e 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskActionSequenceTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskActionSequenceTests.scala
@@ -38,7 +38,7 @@ abstract class WskActionSequenceTests extends TestHelpers with WskTestHelpers {
implicit val wskprops = WskProps()
val wsk: WskOperations
val defaultNamespace = EntityPath.DEFAULT.asString
- val namespace = wsk.namespace.whois()
+ lazy val namespace = wsk.namespace.whois()
behavior of "Wsk Action Sequence"
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskRestActionSequenceTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskRestActionSequenceTests.scala
index 955f9a3..0cc21ed 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskRestActionSequenceTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskRestActionSequenceTests.scala
@@ -20,13 +20,13 @@ package whisk.core.cli.test
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import spray.json._
-
import common.rest.WskRestOperations
import common.rest.RestResult
import common.TestUtils.RunResult
+import common.WskActorSystem
@RunWith(classOf[JUnitRunner])
-class WskRestActionSequenceTests extends WskActionSequenceTests {
+class WskRestActionSequenceTests extends WskActionSequenceTests with WskActorSystem {
override lazy val wsk = new WskRestOperations
override def verifyActionSequence(action: RunResult, name: String, compValue: JsArray, kindValue: JsString): Unit = {
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskRestBasicUsageTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskRestBasicUsageTests.scala
index c248ae1..03d2035 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskRestBasicUsageTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskRestBasicUsageTests.scala
@@ -36,6 +36,7 @@ import common.TestUtils._
import common.WhiskProperties
import common.WskProps
import common.WskTestHelpers
+import common.WskActorSystem
import common.rest.WskRestOperations
import spray.json.DefaultJsonProtocol._
import spray.json._
@@ -48,7 +49,7 @@ import whisk.http.Messages
* Tests for basic CLI usage. Some of these tests require a deployed backend.
*/
@RunWith(classOf[JUnitRunner])
-class WskRestBasicUsageTests extends TestHelpers with WskTestHelpers {
+class WskRestBasicUsageTests extends TestHelpers with WskTestHelpers with WskActorSystem {
implicit val wskprops = WskProps()
val wsk = new WskRestOperations
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskRestEntitlementTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskRestEntitlementTests.scala
index c017e5f..ccbc167 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskRestEntitlementTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskRestEntitlementTests.scala
@@ -20,16 +20,15 @@ package whisk.core.cli.test
import akka.http.scaladsl.model.StatusCodes.BadGateway
import akka.http.scaladsl.model.StatusCodes.Forbidden
import akka.http.scaladsl.model.StatusCodes.NotFound
-
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-
import common.rest.WskRestOperations
import common.rest.RestResult
import common.TestUtils.RunResult
+import common.WskActorSystem
@RunWith(classOf[JUnitRunner])
-class WskRestEntitlementTests extends WskEntitlementTests {
+class WskRestEntitlementTests extends WskEntitlementTests with WskActorSystem {
override lazy val wsk = new WskRestOperations
override lazy val forbiddenCode = Forbidden.intValue
override lazy val timeoutCode = BadGateway.intValue
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskRestWebActionsTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskRestWebActionsTests.scala
index 517258e..52c7583 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskRestWebActionsTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskRestWebActionsTests.scala
@@ -17,12 +17,12 @@
package whisk.core.cli.test
+import common.WskActorSystem
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-
import common.rest.WskRestOperations
@RunWith(classOf[JUnitRunner])
-class WskRestWebActionsTests extends WskWebActionsTests {
- override lazy val wsk: common.rest.WskRestOperations = new WskRestOperations
+class WskRestWebActionsTests extends WskWebActionsTests with WskActorSystem {
+ override lazy val wsk = new WskRestOperations
}
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
index a3b4f08..6abf672 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
@@ -48,9 +48,9 @@ import whisk.core.entity.Subject
abstract class WskWebActionsTests extends TestHelpers with WskTestHelpers with RestUtil with BeforeAndAfterAll {
val MAX_URL_LENGTH = 8192 // 8K matching nginx default
- val wsk: WskOperations
private implicit val wskprops = WskProps()
- val namespace = wsk.namespace.whois()
+ val wsk: WskOperations
+ lazy val namespace = wsk.namespace.whois()
protected val testRoutePath: String = "/api/v1/web"
@@ -313,7 +313,7 @@ abstract class WskWebActionsTests extends TestHelpers with WskTestHelpers with R
private val subdomainRegex = Seq.fill(WhiskProperties.getPartsInVanitySubdomain)("[a-zA-Z0-9]+").mkString("-")
- private val (vanitySubdomain, vanityNamespace, makeTestSubject) = {
+ private lazy val (vanitySubdomain, vanityNamespace, makeTestSubject) = {
if (namespace.matches(subdomainRegex)) {
(namespace, namespace, false)
} else {
@@ -322,7 +322,7 @@ abstract class WskWebActionsTests extends TestHelpers with WskTestHelpers with R
}
}
- private val wskPropsForSubdomainTest = if (makeTestSubject) {
+ private lazy val wskPropsForSubdomainTest = if (makeTestSubject) {
getAdditionalTestSubject(vanityNamespace) // create new subject for the test
} else {
WskProps()
diff --git a/tests/src/test/scala/whisk/core/database/test/CacheConcurrencyTests.scala b/tests/src/test/scala/whisk/core/database/test/CacheConcurrencyTests.scala
index eadac08..ec5a3e6 100644
--- a/tests/src/test/scala/whisk/core/database/test/CacheConcurrencyTests.scala
+++ b/tests/src/test/scala/whisk/core/database/test/CacheConcurrencyTests.scala
@@ -20,25 +20,20 @@ package whisk.core.database.test
import scala.collection.parallel._
import scala.concurrent.duration.DurationInt
import scala.concurrent.forkjoin.ForkJoinPool
-
import org.junit.runner.RunWith
import org.scalatest.BeforeAndAfterEach
import org.scalatest.FlatSpec
import org.scalatest.junit.JUnitRunner
-
import akka.http.scaladsl.model.StatusCodes.NotFound
import common.TestUtils._
-import common.TestUtils
-import common.WhiskProperties
-import common.WskProps
-import common.WskTestHelpers
+import common._
import common.rest.WskRestOperations
import spray.json.JsString
import whisk.common.TransactionId
import whisk.utils.retry
@RunWith(classOf[JUnitRunner])
-class CacheConcurrencyTests extends FlatSpec with WskTestHelpers with BeforeAndAfterEach {
+class CacheConcurrencyTests extends FlatSpec with WskTestHelpers with WskActorSystem with BeforeAndAfterEach {
println(s"Running tests on # proc: ${Runtime.getRuntime.availableProcessors()}")
diff --git a/tests/src/test/scala/whisk/core/limits/ActionLimitsTests.scala b/tests/src/test/scala/whisk/core/limits/ActionLimitsTests.scala
index 5962fdc..9580d2d 100644
--- a/tests/src/test/scala/whisk/core/limits/ActionLimitsTests.scala
+++ b/tests/src/test/scala/whisk/core/limits/ActionLimitsTests.scala
@@ -35,6 +35,8 @@ import common.WhiskProperties
import common.rest.WskRestOperations
import common.WskProps
import common.WskTestHelpers
+import common.WskActorSystem
+
import spray.json._
import spray.json.DefaultJsonProtocol._
import whisk.core.entity.{ActivationEntityLimit, ActivationResponse, ByteSize, Exec, LogLimit, MemoryLimit, TimeLimit}
@@ -42,7 +44,7 @@ import whisk.core.entity.size._
import whisk.http.Messages
@RunWith(classOf[JUnitRunner])
-class ActionLimitsTests extends TestHelpers with WskTestHelpers {
+class ActionLimitsTests extends TestHelpers with WskTestHelpers with WskActorSystem {
implicit val wskprops = WskProps()
val wsk = new WskRestOperations
diff --git a/tests/src/test/scala/whisk/core/limits/MaxActionDurationTests.scala b/tests/src/test/scala/whisk/core/limits/MaxActionDurationTests.scala
index 95a0cbd..1a854f1 100644
--- a/tests/src/test/scala/whisk/core/limits/MaxActionDurationTests.scala
+++ b/tests/src/test/scala/whisk/core/limits/MaxActionDurationTests.scala
@@ -27,6 +27,8 @@ import common.TestUtils
import common.rest.WskRestOperations
import common.WskProps
import common.WskTestHelpers
+import common.WskActorSystem
+
import whisk.core.entity._
import spray.json.DefaultJsonProtocol._
import spray.json._
@@ -38,7 +40,7 @@ import org.scalatest.tagobjects.Slow
* Tests for action duration limits. These tests require a deployed backend.
*/
@RunWith(classOf[JUnitRunner])
-class MaxActionDurationTests extends TestHelpers with WskTestHelpers {
+class MaxActionDurationTests extends TestHelpers with WskTestHelpers with WskActorSystem {
implicit val wskprops = WskProps()
val wsk = new WskRestOperations
[incubator-openwhisk] 17/19: Allow wsk CLI path to be overriden.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit 722f4c542ccb70adbdda6f4b04817daa8f71560f
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Sat Jun 9 11:55:38 2018 -0400
Allow wsk CLI path to be overriden.
---
tests/src/test/scala/common/RunCliCmd.scala | 3 +-
tests/src/test/scala/common/WskCliOperations.scala | 112 +++++++++++----------
2 files changed, 63 insertions(+), 52 deletions(-)
diff --git a/tests/src/test/scala/common/RunCliCmd.scala b/tests/src/test/scala/common/RunCliCmd.scala
index a13ee9d..a7c0c24 100644
--- a/tests/src/test/scala/common/RunCliCmd.scala
+++ b/tests/src/test/scala/common/RunCliCmd.scala
@@ -23,7 +23,8 @@ import scala.collection.JavaConversions.mapAsJavaMap
import scala.collection.mutable.Buffer
import org.scalatest.Matchers
import TestUtils._
-
+import whisk.utils.retry
+import scala.concurrent.duration._
import scala.collection.mutable
trait RunCliCmd extends Matchers {
diff --git a/tests/src/test/scala/common/WskCliOperations.scala b/tests/src/test/scala/common/WskCliOperations.scala
index 2137ad8..d0a0c5f 100644
--- a/tests/src/test/scala/common/WskCliOperations.scala
+++ b/tests/src/test/scala/common/WskCliOperations.scala
@@ -46,12 +46,13 @@ import FullyQualifiedNames.resolve
* of several traits that are common to the whisk collections and corresponds
* to one of the top level CLI nouns.
*
- * Each of the "noun" classes mixes in the RunWskCmd trait which runs arbitrary
- * wsk commands and returns the results. Optionally RunWskCmd can validate the exit
+ * Each of the "noun" classes mixes in the RunCliCmd trait which runs arbitrary
+ * wsk commands and returns the results. Optionally RunCliCmd can validate the exit
* code matched a desired value.
*
* The various collections support one or more of these as common traits:
* list, get, delete, and sanitize.
+ *
* Sanitize is akin to delete but accepts a failure because entity may not
* exit. Additionally, some of the nouns define custom commands.
*
@@ -64,17 +65,26 @@ import FullyQualifiedNames.resolve
* It also sets the apihost and apiversion explicitly to avoid ambiguity with
* a local property file if it exists.
*/
-class Wsk extends WskOperations with RunWskCliCmd {
- override implicit val action = new CliActionOperations
- override implicit val trigger = new CliTriggerOperations
- override implicit val rule = new CliRuleOperations
- override implicit val activation = new CliActivationOperations
- override implicit val pkg = new CliPackageOperations
- override implicit val namespace = new CliNamespaceOperations
- override implicit val api = new CliGatewayOperations
+class Wsk(cliPath: String = Wsk.defaultCliPath) extends WskOperations with RunCliCmd {
+
+ assert({
+ val f = new File(cliPath)
+ f.exists && f.isFile && f.canExecute
+ }, s"did not find $cliPath")
+
+ override def baseCommand = Buffer(cliPath)
+
+ override implicit val action = new CliActionOperations(this)
+ override implicit val trigger = new CliTriggerOperations(this)
+ override implicit val rule = new CliRuleOperations(this)
+ override implicit val activation = new CliActivationOperations(this)
+ override implicit val pkg = new CliPackageOperations(this)
+ override implicit val namespace = new CliNamespaceOperations(this)
+ override implicit val api = new CliGatewayOperations(this)
}
-trait CliListOrGetFromCollectionOperations extends ListOrGetFromCollectionOperations with RunWskCliCmd {
+trait CliListOrGetFromCollectionOperations extends ListOrGetFromCollectionOperations {
+ val wsk: RunCliCmd
/**
* List entities in collection.
@@ -96,7 +106,7 @@ trait CliListOrGetFromCollectionOperations extends ListOrGetFromCollectionOperat
Seq("--name-sort")
} getOrElse Seq()
}
- cli(wp.overrides ++ params, expectedExitCode)
+ wsk.cli(wp.overrides ++ params, expectedExitCode)
}
/**
@@ -133,11 +143,12 @@ trait CliListOrGetFromCollectionOperations extends ListOrGetFromCollectionOperat
} getOrElse Seq()
}
- cli(wp.overrides ++ params, expectedExitCode)
+ wsk.cli(wp.overrides ++ params, expectedExitCode)
}
}
-trait CliDeleteFromCollectionOperations extends DeleteFromCollectionOperations with RunWskCliCmd {
+trait CliDeleteFromCollectionOperations extends DeleteFromCollectionOperations {
+ val wsk: RunCliCmd
/**
* Deletes entity from collection.
@@ -147,7 +158,7 @@ trait CliDeleteFromCollectionOperations extends DeleteFromCollectionOperations w
* if the code is anything but DONTCARE_EXIT, assert the code is as expected
*/
override def delete(name: String, expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- cli(wp.overrides ++ Seq(noun, "delete", "--auth", wp.authKey, fqn(name)), expectedExitCode)
+ wsk.cli(wp.overrides ++ Seq(noun, "delete", "--auth", wp.authKey, fqn(name)), expectedExitCode)
}
/**
@@ -161,7 +172,7 @@ trait CliDeleteFromCollectionOperations extends DeleteFromCollectionOperations w
}
}
-class CliActionOperations
+class CliActionOperations(override val wsk: RunCliCmd)
extends CliListOrGetFromCollectionOperations
with CliDeleteFromCollectionOperations
with HasActivation
@@ -250,7 +261,7 @@ class CliActionOperations
Seq("--web-secure", ws)
} getOrElse Seq()
}
- cli(wp.overrides ++ params, expectedExitCode)
+ wsk.cli(wp.overrides ++ params, expectedExitCode)
}
/**
@@ -275,11 +286,11 @@ class CliActionOperations
Seq("-P", pf)
} getOrElse Seq()
} ++ { if (blocking) Seq("--blocking") else Seq() } ++ { if (result) Seq("--result") else Seq() }
- cli(wp.overrides ++ params, expectedExitCode)
+ wsk.cli(wp.overrides ++ params, expectedExitCode)
}
}
-class CliTriggerOperations
+class CliTriggerOperations(override val wsk: RunCliCmd)
extends CliListOrGetFromCollectionOperations
with CliDeleteFromCollectionOperations
with HasActivation
@@ -328,7 +339,7 @@ class CliTriggerOperations
Seq("--shared", if (s) "yes" else "no")
} getOrElse Seq()
}
- cli(wp.overrides ++ params, expectedExitCode)
+ wsk.cli(wp.overrides ++ params, expectedExitCode)
}
/**
@@ -351,11 +362,11 @@ class CliTriggerOperations
Seq("-P", pf)
} getOrElse Seq()
}
- cli(wp.overrides ++ params, expectedExitCode)
+ wsk.cli(wp.overrides ++ params, expectedExitCode)
}
}
-class CliRuleOperations
+class CliRuleOperations(override val wsk: RunCliCmd)
extends CliListOrGetFromCollectionOperations
with CliDeleteFromCollectionOperations
with WaitFor
@@ -388,7 +399,7 @@ class CliRuleOperations
Seq("--shared", if (s) "yes" else "no")
} getOrElse Seq()
}
- cli(wp.overrides ++ params, expectedExitCode)
+ wsk.cli(wp.overrides ++ params, expectedExitCode)
}
/**
@@ -410,7 +421,7 @@ class CliRuleOperations
* if the code is anything but DONTCARE_EXIT, assert the code is as expected
*/
override def enable(name: String, expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- cli(wp.overrides ++ Seq(noun, "enable", "--auth", wp.authKey, fqn(name)), expectedExitCode)
+ wsk.cli(wp.overrides ++ Seq(noun, "enable", "--auth", wp.authKey, fqn(name)), expectedExitCode)
}
/**
@@ -421,7 +432,7 @@ class CliRuleOperations
* if the code is anything but DONTCARE_EXIT, assert the code is as expected
*/
override def disable(name: String, expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- cli(wp.overrides ++ Seq(noun, "disable", "--auth", wp.authKey, fqn(name)), expectedExitCode)
+ wsk.cli(wp.overrides ++ Seq(noun, "disable", "--auth", wp.authKey, fqn(name)), expectedExitCode)
}
/**
@@ -432,11 +443,11 @@ class CliRuleOperations
* if the code is anything but DONTCARE_EXIT, assert the code is as expected
*/
override def state(name: String, expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
- cli(wp.overrides ++ Seq(noun, "status", "--auth", wp.authKey, fqn(name)), expectedExitCode)
+ wsk.cli(wp.overrides ++ Seq(noun, "status", "--auth", wp.authKey, fqn(name)), expectedExitCode)
}
}
-class CliActivationOperations extends ActivationOperations with RunWskCliCmd with HasActivation with WaitFor {
+class CliActivationOperations(val wsk: RunCliCmd) extends ActivationOperations with HasActivation with WaitFor {
protected val noun = "activation"
@@ -460,7 +471,7 @@ class CliActivationOperations extends ActivationOperations with RunWskCliCmd wit
Seq("--since-seconds", s.toSeconds.toString)
} getOrElse Seq()
}
- cli(wp.overrides ++ params, expectedExitCode)
+ wsk.cli(wp.overrides ++ params, expectedExitCode)
}
/**
@@ -485,7 +496,7 @@ class CliActivationOperations extends ActivationOperations with RunWskCliCmd wit
Seq("--since", i.toEpochMilli.toString)
} getOrElse Seq()
}
- cli(wp.overrides ++ params, expectedExitCode)
+ wsk.cli(wp.overrides ++ params, expectedExitCode)
}
/**
@@ -535,7 +546,7 @@ class CliActivationOperations extends ActivationOperations with RunWskCliCmd wit
Seq("--summary")
} getOrElse Seq()
}
- cli(wp.overrides ++ Seq(noun, "get", "--auth", wp.authKey) ++ params, expectedExitCode)
+ wsk.cli(wp.overrides ++ Seq(noun, "get", "--auth", wp.authKey) ++ params, expectedExitCode)
}
/**
@@ -558,7 +569,7 @@ class CliActivationOperations extends ActivationOperations with RunWskCliCmd wit
Seq("--last")
} getOrElse Seq()
}
- cli(wp.overrides ++ Seq(noun, "logs", "--auth", wp.authKey) ++ params, expectedExitCode)
+ wsk.cli(wp.overrides ++ Seq(noun, "logs", "--auth", wp.authKey) ++ params, expectedExitCode)
}
/**
@@ -581,7 +592,7 @@ class CliActivationOperations extends ActivationOperations with RunWskCliCmd wit
Seq("--last")
} getOrElse Seq()
}
- cli(wp.overrides ++ Seq(noun, "result", "--auth", wp.authKey) ++ params, expectedExitCode)
+ wsk.cli(wp.overrides ++ Seq(noun, "result", "--auth", wp.authKey) ++ params, expectedExitCode)
}
/**
@@ -629,7 +640,8 @@ class CliActivationOperations extends ActivationOperations with RunWskCliCmd wit
val activation = waitfor(
() => {
val result =
- cli(wp.overrides ++ Seq(noun, "get", activationId, "--auth", wp.authKey), expectedExitCode = DONTCARE_EXIT)
+ wsk
+ .cli(wp.overrides ++ Seq(noun, "get", activationId, "--auth", wp.authKey), expectedExitCode = DONTCARE_EXIT)
if (result.exitCode == NOT_FOUND) {
null
} else if (result.exitCode == SUCCESS_EXIT) {
@@ -657,7 +669,9 @@ class CliActivationOperations extends ActivationOperations with RunWskCliCmd wit
private case class PartialResult(ids: Seq[String]) extends Throwable
}
-class CliNamespaceOperations extends CliDeleteFromCollectionOperations with NamespaceOperations with RunWskCliCmd {
+class CliNamespaceOperations(override val wsk: RunCliCmd)
+ extends CliDeleteFromCollectionOperations
+ with NamespaceOperations {
protected val noun = "namespace"
@@ -674,7 +688,7 @@ class CliNamespaceOperations extends CliDeleteFromCollectionOperations with Name
Seq("--name-sort")
} getOrElse Seq()
}
- cli(wp.overrides ++ params, expectedExitCode)
+ wsk.cli(wp.overrides ++ params, expectedExitCode)
}
/**
@@ -704,11 +718,11 @@ class CliNamespaceOperations extends CliDeleteFromCollectionOperations with Name
Seq("--name-sort")
} getOrElse Seq()
}
- cli(wp.overrides ++ Seq(noun, "get", resolve(namespace), "--auth", wp.authKey) ++ params, expectedExitCode)
+ wsk.cli(wp.overrides ++ Seq(noun, "get", resolve(namespace), "--auth", wp.authKey) ++ params, expectedExitCode)
}
}
-class CliPackageOperations
+class CliPackageOperations(override val wsk: RunCliCmd)
extends CliListOrGetFromCollectionOperations
with CliDeleteFromCollectionOperations
with PackageOperations {
@@ -750,7 +764,7 @@ class CliPackageOperations
Seq("--shared", if (s) "yes" else "no")
} getOrElse Seq()
}
- cli(wp.overrides ++ params, expectedExitCode)
+ wsk.cli(wp.overrides ++ params, expectedExitCode)
}
/**
@@ -774,11 +788,11 @@ class CliPackageOperations
Seq("-a", p._1, p._2.compactPrint)
}
}
- cli(wp.overrides ++ params, expectedExitCode)
+ wsk.cli(wp.overrides ++ params, expectedExitCode)
}
}
-class CliGatewayOperations extends GatewayOperations with RunWskCliCmd {
+class CliGatewayOperations(val wsk: RunCliCmd) extends GatewayOperations {
protected val noun = "api"
/**
@@ -825,7 +839,7 @@ class CliGatewayOperations extends GatewayOperations with RunWskCliCmd {
Seq("--response-type", t)
} getOrElse Seq()
}
- cli(
+ wsk.cli(
wp.overrides ++ params,
expectedExitCode,
showCmd = true,
@@ -876,7 +890,7 @@ class CliGatewayOperations extends GatewayOperations with RunWskCliCmd {
Seq("--name-sort")
} getOrElse Seq()
}
- cli(
+ wsk.cli(
wp.overrides ++ params,
expectedExitCode,
showCmd = true,
@@ -908,7 +922,7 @@ class CliGatewayOperations extends GatewayOperations with RunWskCliCmd {
Seq("--format", ft)
} getOrElse Seq()
}
- cli(
+ wsk.cli(
wp.overrides ++ params,
expectedExitCode,
showCmd = true,
@@ -935,7 +949,7 @@ class CliGatewayOperations extends GatewayOperations with RunWskCliCmd {
Seq(o)
} getOrElse Seq()
}
- cli(
+ wsk.cli(
wp.overrides ++ params,
expectedExitCode,
showCmd = true,
@@ -943,16 +957,12 @@ class CliGatewayOperations extends GatewayOperations with RunWskCliCmd {
}
}
-trait RunWskCliCmd extends RunCliCmd {
- private val binaryName = "wsk"
- private val cliPath = if (WhiskProperties.useCLIDownload) getDownloadedGoCLIPath else WhiskProperties.getCLIPath
-
- assert((new File(cliPath)).exists, s"did not find $cliPath")
+object Wsk {
+ val binaryName = "wsk"
+ val defaultCliPath = if (WhiskProperties.useCLIDownload) getDownloadedGoCLIPath else WhiskProperties.getCLIPath
/** What is the path to a downloaded CLI? **/
private def getDownloadedGoCLIPath = {
s"${System.getProperty("user.home")}${File.separator}.local${File.separator}bin${File.separator}${binaryName}"
}
-
- def baseCommand = Buffer(cliPath)
}
[incubator-openwhisk] 14/19: Re-introduce cli bindings.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit 34fc4b08f07e4eb4144269fd9759a898365b2912
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Fri Jun 8 23:30:33 2018 -0400
Re-introduce cli bindings.
---
tests/src/test/scala/common/WskCliOperations.scala | 959 +++++++++++++++++++++
tests/src/test/scala/common/WskOperations.scala | 15 +-
2 files changed, 971 insertions(+), 3 deletions(-)
diff --git a/tests/src/test/scala/common/WskCliOperations.scala b/tests/src/test/scala/common/WskCliOperations.scala
new file mode 100644
index 0000000..da3fcbc
--- /dev/null
+++ b/tests/src/test/scala/common/WskCliOperations.scala
@@ -0,0 +1,959 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package common
+
+import java.io.File
+import java.time.Instant
+
+import scala.Left
+import scala.Right
+import scala.collection.mutable.Buffer
+import scala.concurrent.duration.Duration
+import scala.concurrent.duration.DurationInt
+import scala.language.postfixOps
+import scala.util.Failure
+import scala.util.Success
+import scala.util.Try
+
+import common.TestUtils._
+import spray.json.JsObject
+import spray.json.JsValue
+import whisk.core.entity.ByteSize
+import whisk.utils.retry
+import common._
+
+import FullyQualifiedNames.fqn
+import FullyQualifiedNames.resolve
+
+/**
+ * Provide Scala bindings for the whisk CLI.
+ *
+ * Each of the top level CLI commands is a "noun" class that extends one
+ * of several traits that are common to the whisk collections and corresponds
+ * to one of the top level CLI nouns.
+ *
+ * Each of the "noun" classes mixes in the RunWskCmd trait which runs arbitrary
+ * wsk commands and returns the results. Optionally RunWskCmd can validate the exit
+ * code matched a desired value.
+ *
+ * The various collections support one or more of these as common traits:
+ * list, get, delete, and sanitize.
+ * Sanitize is akin to delete but accepts a failure because entity may not
+ * exit. Additionally, some of the nouns define custom commands.
+ *
+ * All of the commands define default values that are either optional
+ * or omitted in the common case. This makes for a compact implementation
+ * instead of using a Builder pattern.
+ *
+ * An implicit WskProps instance is required for all of CLI commands. This
+ * type provides the authentication key for the API as well as the namespace.
+ * It also sets the apihost and apiversion explicitly to avoid ambiguity with
+ * a local property file if it exists.
+ */
+class Wsk extends WskOperations {
+ override implicit val action = new CliActionOperations
+ override implicit val trigger = new CliTriggerOperations
+ override implicit val rule = new CliRuleOperations
+ override implicit val activation = new CliActivationOperations
+ override implicit val pkg = new CliPackageOperations
+ override implicit val namespace = new CliNamespaceOperations
+ override implicit val api = new CliGatewayOperations
+}
+
+trait CliListOrGetFromCollectionOperations extends ListOrGetFromCollectionOperations with RunWskCliCommand {
+
+ /**
+ * List entities in collection.
+ *
+ * @param namespace (optional) if specified must be fully qualified namespace
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def list(namespace: Option[String] = None,
+ limit: Option[Int] = None,
+ nameSort: Option[Boolean] = None,
+ expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, "list", resolve(namespace), "--auth", wp.authKey) ++ {
+ limit map { l =>
+ Seq("--limit", l.toString)
+ } getOrElse Seq()
+ } ++ {
+ nameSort map { n =>
+ Seq("--name-sort")
+ } getOrElse Seq()
+ }
+ cli(wp.overrides ++ params, expectedExitCode)
+ }
+
+ /**
+ * Gets entity from collection.
+ *
+ * @param name either a fully qualified name or a simple entity name
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def get(name: String,
+ expectedExitCode: Int = SUCCESS_EXIT,
+ summary: Boolean = false,
+ fieldFilter: Option[String] = None,
+ url: Option[Boolean] = None,
+ save: Option[Boolean] = None,
+ saveAs: Option[String] = None)(implicit wp: WskProps): RunResult = {
+
+ val params = Seq(noun, "get", "--auth", wp.authKey) ++
+ Seq(fqn(name)) ++ { if (summary) Seq("--summary") else Seq() } ++ {
+ fieldFilter map { f =>
+ Seq(f)
+ } getOrElse Seq()
+ } ++ {
+ url map { u =>
+ Seq("--url")
+ } getOrElse Seq()
+ } ++ {
+ save map { s =>
+ Seq("--save")
+ } getOrElse Seq()
+ } ++ {
+ saveAs map { s =>
+ Seq("--save-as", s)
+ } getOrElse Seq()
+ }
+
+ cli(wp.overrides ++ params, expectedExitCode)
+ }
+}
+
+trait CliDeleteFromCollectionOperations extends DeleteFromCollectionOperations with RunWskCliCommand {
+
+ /**
+ * Deletes entity from collection.
+ *
+ * @param name either a fully qualified name or a simple entity name
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def delete(name: String, expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
+ cli(wp.overrides ++ Seq(noun, "delete", "--auth", wp.authKey, fqn(name)), expectedExitCode)
+ }
+
+ /**
+ * Deletes entity from collection but does not assert that the command succeeds.
+ * Use this if deleting an entity that may not exist and it is OK if it does not.
+ *
+ * @param name either a fully qualified name or a simple entity name
+ */
+ override def sanitize(name: String)(implicit wp: WskProps): RunResult = {
+ delete(name, DONTCARE_EXIT)
+ }
+}
+
+class CliActionOperations
+ extends CliListOrGetFromCollectionOperations
+ with CliDeleteFromCollectionOperations
+ with HasActivation
+ with ActionOperations {
+
+ override protected val noun = "action"
+
+ /**
+ * Creates action. Parameters mirror those available in the CLI.
+ *
+ * @param name either a fully qualified name or a simple entity name
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def create(
+ name: String,
+ artifact: Option[String],
+ kind: Option[String] = None, // one of docker, copy, sequence or none for autoselect else an explicit type
+ main: Option[String] = None,
+ docker: Option[String] = None,
+ parameters: Map[String, JsValue] = Map(),
+ annotations: Map[String, JsValue] = Map(),
+ parameterFile: Option[String] = None,
+ annotationFile: Option[String] = None,
+ timeout: Option[Duration] = None,
+ memory: Option[ByteSize] = None,
+ logsize: Option[ByteSize] = None,
+ shared: Option[Boolean] = None,
+ update: Boolean = false,
+ web: Option[String] = None,
+ websecure: Option[String] = None,
+ expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, if (!update) "create" else "update", "--auth", wp.authKey, fqn(name)) ++ {
+ artifact map { Seq(_) } getOrElse Seq()
+ } ++ {
+ kind map { k =>
+ if (k == "sequence" || k == "copy" || k == "native") Seq(s"--$k")
+ else Seq("--kind", k)
+ } getOrElse Seq()
+ } ++ {
+ main.toSeq flatMap { p =>
+ Seq("--main", p)
+ }
+ } ++ {
+ docker.toSeq flatMap { p =>
+ Seq("--docker", p)
+ }
+ } ++ {
+ parameters flatMap { p =>
+ Seq("-p", p._1, p._2.compactPrint)
+ }
+ } ++ {
+ annotations flatMap { p =>
+ Seq("-a", p._1, p._2.compactPrint)
+ }
+ } ++ {
+ parameterFile map { pf =>
+ Seq("-P", pf)
+ } getOrElse Seq()
+ } ++ {
+ annotationFile map { af =>
+ Seq("-A", af)
+ } getOrElse Seq()
+ } ++ {
+ timeout map { t =>
+ Seq("-t", t.toMillis.toString)
+ } getOrElse Seq()
+ } ++ {
+ memory map { m =>
+ Seq("-m", m.toMB.toString)
+ } getOrElse Seq()
+ } ++ {
+ logsize map { l =>
+ Seq("-l", l.toMB.toString)
+ } getOrElse Seq()
+ } ++ {
+ shared map { s =>
+ Seq("--shared", if (s) "yes" else "no")
+ } getOrElse Seq()
+ } ++ {
+ web map { w =>
+ Seq("--web", w)
+ } getOrElse Seq()
+ } ++ {
+ websecure map { ws =>
+ Seq("--web-secure", ws)
+ } getOrElse Seq()
+ }
+ cli(wp.overrides ++ params, expectedExitCode)
+ }
+
+ /**
+ * Invokes action. Parameters mirror those available in the CLI.
+ *
+ * @param name either a fully qualified name or a simple entity name
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def invoke(name: String,
+ parameters: Map[String, JsValue] = Map(),
+ parameterFile: Option[String] = None,
+ blocking: Boolean = false,
+ result: Boolean = false,
+ expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, "invoke", "--auth", wp.authKey, fqn(name)) ++ {
+ parameters flatMap { p =>
+ Seq("-p", p._1, p._2.compactPrint)
+ }
+ } ++ {
+ parameterFile map { pf =>
+ Seq("-P", pf)
+ } getOrElse Seq()
+ } ++ { if (blocking) Seq("--blocking") else Seq() } ++ { if (result) Seq("--result") else Seq() }
+ cli(wp.overrides ++ params, expectedExitCode)
+ }
+}
+
+class CliTriggerOperations
+ extends CliListOrGetFromCollectionOperations
+ with CliDeleteFromCollectionOperations
+ with HasActivation
+ with TriggerOperations {
+
+ override protected val noun = "trigger"
+
+ /**
+ * Creates trigger. Parameters mirror those available in the CLI.
+ *
+ * @param name either a fully qualified name or a simple entity name
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def create(name: String,
+ parameters: Map[String, JsValue] = Map(),
+ annotations: Map[String, JsValue] = Map(),
+ parameterFile: Option[String] = None,
+ annotationFile: Option[String] = None,
+ feed: Option[String] = None,
+ shared: Option[Boolean] = None,
+ update: Boolean = false,
+ expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, if (!update) "create" else "update", "--auth", wp.authKey, fqn(name)) ++ {
+ feed map { f =>
+ Seq("--feed", fqn(f))
+ } getOrElse Seq()
+ } ++ {
+ parameters flatMap { p =>
+ Seq("-p", p._1, p._2.compactPrint)
+ }
+ } ++ {
+ annotations flatMap { p =>
+ Seq("-a", p._1, p._2.compactPrint)
+ }
+ } ++ {
+ parameterFile map { pf =>
+ Seq("-P", pf)
+ } getOrElse Seq()
+ } ++ {
+ annotationFile map { af =>
+ Seq("-A", af)
+ } getOrElse Seq()
+ } ++ {
+ shared map { s =>
+ Seq("--shared", if (s) "yes" else "no")
+ } getOrElse Seq()
+ }
+ cli(wp.overrides ++ params, expectedExitCode)
+ }
+
+ /**
+ * Fires trigger. Parameters mirror those available in the CLI.
+ *
+ * @param name either a fully qualified name or a simple entity name
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def fire(name: String,
+ parameters: Map[String, JsValue] = Map(),
+ parameterFile: Option[String] = None,
+ expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, "fire", "--auth", wp.authKey, fqn(name)) ++ {
+ parameters flatMap { p =>
+ Seq("-p", p._1, p._2.compactPrint)
+ }
+ } ++ {
+ parameterFile map { pf =>
+ Seq("-P", pf)
+ } getOrElse Seq()
+ }
+ cli(wp.overrides ++ params, expectedExitCode)
+ }
+}
+
+class CliRuleOperations
+ extends CliListOrGetFromCollectionOperations
+ with CliDeleteFromCollectionOperations
+ with WaitFor
+ with RuleOperations {
+
+ override protected val noun = "rule"
+
+ /**
+ * Creates rule. Parameters mirror those available in the CLI.
+ *
+ * @param name either a fully qualified name or a simple entity name
+ * @param trigger must be a simple name
+ * @param action must be a simple name
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def create(name: String,
+ trigger: String,
+ action: String,
+ annotations: Map[String, JsValue] = Map(),
+ shared: Option[Boolean] = None,
+ update: Boolean = false,
+ expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, if (!update) "create" else "update", "--auth", wp.authKey, fqn(name), (trigger), (action)) ++ {
+ annotations flatMap { p =>
+ Seq("-a", p._1, p._2.compactPrint)
+ }
+ } ++ {
+ shared map { s =>
+ Seq("--shared", if (s) "yes" else "no")
+ } getOrElse Seq()
+ }
+ cli(wp.overrides ++ params, expectedExitCode)
+ }
+
+ /**
+ * Deletes rule.
+ *
+ * @param name either a fully qualified name or a simple entity name
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def delete(name: String, expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
+ super.delete(name, expectedExitCode)
+ }
+
+ /**
+ * Enables rule.
+ *
+ * @param name either a fully qualified name or a simple entity name
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def enable(name: String, expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
+ cli(wp.overrides ++ Seq(noun, "enable", "--auth", wp.authKey, fqn(name)), expectedExitCode)
+ }
+
+ /**
+ * Disables rule.
+ *
+ * @param name either a fully qualified name or a simple entity name
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def disable(name: String, expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
+ cli(wp.overrides ++ Seq(noun, "disable", "--auth", wp.authKey, fqn(name)), expectedExitCode)
+ }
+
+ /**
+ * Checks state of rule.
+ *
+ * @param name either a fully qualified name or a simple entity name
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def state(name: String, expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
+ cli(wp.overrides ++ Seq(noun, "status", "--auth", wp.authKey, fqn(name)), expectedExitCode)
+ }
+}
+
+class CliActivationOperations extends ActivationOperations with RunWskCliCommand with HasActivation with WaitFor {
+
+ protected val noun = "activation"
+
+ /**
+ * Activation polling console.
+ *
+ * @param duration exits console after duration
+ * @param since (optional) time travels back to activation since given duration
+ * @param actionName (optional) name of entity to filter activation records on.
+ */
+ override def console(duration: Duration,
+ since: Option[Duration] = None,
+ expectedExitCode: Int = SUCCESS_EXIT,
+ actionName: Option[String] = None)(implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, "poll") ++ {
+ actionName map { name =>
+ Seq(name)
+ } getOrElse Seq()
+ } ++ Seq("--auth", wp.authKey, "--exit", duration.toSeconds.toString) ++ {
+ since map { s =>
+ Seq("--since-seconds", s.toSeconds.toString)
+ } getOrElse Seq()
+ }
+ cli(wp.overrides ++ params, expectedExitCode)
+ }
+
+ /**
+ * Lists activations.
+ *
+ * @param filter (optional) if define, must be a simple entity name
+ * @param limit (optional) the maximum number of activation to return
+ * @param since (optional) only the activations since this timestamp are included
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ def list(filter: Option[String] = None,
+ limit: Option[Int] = None,
+ since: Option[Instant] = None,
+ expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, "list", "--auth", wp.authKey) ++ { filter map { Seq(_) } getOrElse Seq() } ++ {
+ limit map { l =>
+ Seq("--limit", l.toString)
+ } getOrElse Seq()
+ } ++ {
+ since map { i =>
+ Seq("--since", i.toEpochMilli.toString)
+ } getOrElse Seq()
+ }
+ cli(wp.overrides ++ params, expectedExitCode)
+ }
+
+ /**
+ * Parses result of WskActivation.list to extract sequence of activation ids.
+ *
+ * @param rr run result, should be from WhiskActivation.list otherwise behavior is undefined
+ * @return sequence of activations
+ */
+ def ids(rr: RunResult): Seq[String] = {
+ rr.stdout.split("\n") filter {
+ // remove empty lines the header
+ s =>
+ s.nonEmpty && s != "activations"
+ } map {
+ // split into (id, name)
+ _.split(" ")(0)
+ }
+ }
+
+ /**
+ * Gets activation by id.
+ *
+ * @param activationId the activation id
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ * @param last retrieves latest acitvation
+ */
+ override def get(activationId: Option[String] = None,
+ expectedExitCode: Int = SUCCESS_EXIT,
+ fieldFilter: Option[String] = None,
+ last: Option[Boolean] = None,
+ summary: Option[Boolean] = None)(implicit wp: WskProps): RunResult = {
+ val params = {
+ activationId map { a =>
+ Seq(a)
+ } getOrElse Seq()
+ } ++ {
+ fieldFilter map { f =>
+ Seq(f)
+ } getOrElse Seq()
+ } ++ {
+ last map { l =>
+ Seq("--last")
+ } getOrElse Seq()
+ } ++ {
+ summary map { s =>
+ Seq("--summary")
+ } getOrElse Seq()
+ }
+ cli(wp.overrides ++ Seq(noun, "get", "--auth", wp.authKey) ++ params, expectedExitCode)
+ }
+
+ /**
+ * Gets activation logs by id.
+ *
+ * @param activationId the activation id
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ * @param last retrieves latest acitvation
+ */
+ override def logs(activationId: Option[String] = None,
+ expectedExitCode: Int = SUCCESS_EXIT,
+ last: Option[Boolean] = None)(implicit wp: WskProps): RunResult = {
+ val params = {
+ activationId map { a =>
+ Seq(a)
+ } getOrElse Seq()
+ } ++ {
+ last map { l =>
+ Seq("--last")
+ } getOrElse Seq()
+ }
+ cli(wp.overrides ++ Seq(noun, "logs", "--auth", wp.authKey) ++ params, expectedExitCode)
+ }
+
+ /**
+ * Gets activation result by id.
+ *
+ * @param activationId the activation id
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ * @param last retrieves latest acitvation
+ */
+ override def result(activationId: Option[String] = None,
+ expectedExitCode: Int = SUCCESS_EXIT,
+ last: Option[Boolean] = None)(implicit wp: WskProps): RunResult = {
+ val params = {
+ activationId map { a =>
+ Seq(a)
+ } getOrElse Seq()
+ } ++ {
+ last map { l =>
+ Seq("--last")
+ } getOrElse Seq()
+ }
+ cli(wp.overrides ++ Seq(noun, "result", "--auth", wp.authKey) ++ params, expectedExitCode)
+ }
+
+ /**
+ * Polls activations list for at least N activations. The activations
+ * are optionally filtered for the given entity. Will return as soon as
+ * N activations are found. If after retry budget is exhausted, N activations
+ * are still not present, will return a partial result. Hence caller must
+ * check length of the result and not assume it is >= N.
+ *
+ * @param N the number of activations desired
+ * @param entity the name of the entity to filter from activation list
+ * @param limit the maximum number of entities to list (if entity name is not unique use Some(0))
+ * @param since (optional) only the activations since this timestamp are included
+ * @param retries the maximum retries (total timeout is retries + 1 seconds)
+ * @return activation ids found, caller must check length of sequence
+ */
+ override def pollFor(N: Int,
+ entity: Option[String],
+ limit: Option[Int] = None,
+ since: Option[Instant] = None,
+ retries: Int = 10,
+ pollPeriod: Duration = 1.second)(implicit wp: WskProps): Seq[String] = {
+ Try {
+ retry({
+ val result = ids(list(filter = entity, limit = limit, since = since))
+ if (result.length >= N) result else throw PartialResult(result)
+ }, retries, waitBeforeRetry = Some(pollPeriod))
+ } match {
+ case Success(ids) => ids
+ case Failure(PartialResult(ids)) => ids
+ case _ => Seq()
+ }
+ }
+
+ /**
+ * Polls for an activation matching the given id. If found
+ * return Right(activation) else Left(result of running CLI command).
+ *
+ * @return either Left(error message) or Right(activation as JsObject)
+ */
+ override def waitForActivation(activationId: String,
+ initialWait: Duration = 1 second,
+ pollPeriod: Duration = 1 second,
+ totalWait: Duration = 30 seconds)(implicit wp: WskProps): Either[String, JsObject] = {
+ val activation = waitfor(
+ () => {
+ val result =
+ cli(wp.overrides ++ Seq(noun, "get", activationId, "--auth", wp.authKey), expectedExitCode = DONTCARE_EXIT)
+ if (result.exitCode == NOT_FOUND) {
+ null
+ } else if (result.exitCode == SUCCESS_EXIT) {
+ Right(result.stdout)
+ } else Left(s"$result")
+ },
+ initialWait,
+ pollPeriod,
+ totalWait)
+
+ Option(activation) map {
+ case Right(stdout) =>
+ Try {
+ // strip first line and convert the rest to JsObject
+ assert(stdout.startsWith("ok: got activation"))
+ WskOperations.parseJsonString(stdout)
+ } map {
+ Right(_)
+ } getOrElse Left(s"cannot parse activation from '$stdout'")
+ case Left(error) => Left(error)
+ } getOrElse Left(s"$activationId not found")
+ }
+
+ /** Used in polling for activations to record partial results from retry poll. */
+ private case class PartialResult(ids: Seq[String]) extends Throwable
+}
+
+class CliNamespaceOperations extends CliDeleteFromCollectionOperations with NamespaceOperations with RunWskCliCommand {
+
+ protected val noun = "namespace"
+
+ /**
+ * Lists available namespaces for whisk key.
+ *
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def list(expectedExitCode: Int = SUCCESS_EXIT, nameSort: Option[Boolean] = None)(
+ implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, "list", "--auth", wp.authKey) ++ {
+ nameSort map { n =>
+ Seq("--name-sort")
+ } getOrElse Seq()
+ }
+ cli(wp.overrides ++ params, expectedExitCode)
+ }
+
+ /**
+ * Looks up namespace for whisk props.
+ *
+ * @param wskprops instance of WskProps with an auth key to lookup
+ * @return namespace as string
+ */
+ override def whois()(implicit wskprops: WskProps): String = {
+ // the invariant that list() returns a conforming result is enforced in WskRestBasicTests
+ val ns = list().stdout.lines.toSeq.last.trim
+ assert(ns != "_") // this is not permitted
+ ns
+ }
+
+ /**
+ * Gets entities in namespace.
+ *
+ * @param namespace (optional) if specified must be fully qualified namespace
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ def get(namespace: Option[String] = None, expectedExitCode: Int, nameSort: Option[Boolean] = None)(
+ implicit wp: WskProps): RunResult = {
+ val params = {
+ nameSort map { n =>
+ Seq("--name-sort")
+ } getOrElse Seq()
+ }
+ cli(wp.overrides ++ Seq(noun, "get", resolve(namespace), "--auth", wp.authKey) ++ params, expectedExitCode)
+ }
+}
+
+class CliPackageOperations
+ extends CliListOrGetFromCollectionOperations
+ with CliDeleteFromCollectionOperations
+ with PackageOperations {
+ override protected val noun = "package"
+
+ /**
+ * Creates package. Parameters mirror those available in the CLI.
+ *
+ * @param name either a fully qualified name or a simple entity name
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def create(name: String,
+ parameters: Map[String, JsValue] = Map(),
+ annotations: Map[String, JsValue] = Map(),
+ parameterFile: Option[String] = None,
+ annotationFile: Option[String] = None,
+ shared: Option[Boolean] = None,
+ update: Boolean = false,
+ expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, if (!update) "create" else "update", "--auth", wp.authKey, fqn(name)) ++ {
+ parameters flatMap { p =>
+ Seq("-p", p._1, p._2.compactPrint)
+ }
+ } ++ {
+ annotations flatMap { p =>
+ Seq("-a", p._1, p._2.compactPrint)
+ }
+ } ++ {
+ parameterFile map { pf =>
+ Seq("-P", pf)
+ } getOrElse Seq()
+ } ++ {
+ annotationFile map { af =>
+ Seq("-A", af)
+ } getOrElse Seq()
+ } ++ {
+ shared map { s =>
+ Seq("--shared", if (s) "yes" else "no")
+ } getOrElse Seq()
+ }
+ cli(wp.overrides ++ params, expectedExitCode)
+ }
+
+ /**
+ * Binds package. Parameters mirror those available in the CLI.
+ *
+ * @param name either a fully qualified name or a simple entity name
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def bind(provider: String,
+ name: String,
+ parameters: Map[String, JsValue] = Map(),
+ annotations: Map[String, JsValue] = Map(),
+ expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, "bind", "--auth", wp.authKey, fqn(provider), fqn(name)) ++ {
+ parameters flatMap { p =>
+ Seq("-p", p._1, p._2.compactPrint)
+ }
+ } ++ {
+ annotations flatMap { p =>
+ Seq("-a", p._1, p._2.compactPrint)
+ }
+ }
+ cli(wp.overrides ++ params, expectedExitCode)
+ }
+}
+
+class CliGatewayOperations extends GatewayOperations with RunWskCliCommand {
+ protected val noun = "api"
+
+ /**
+ * Creates and API endpoint. Parameters mirror those available in the CLI.
+ *
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def create(basepath: Option[String] = None,
+ relpath: Option[String] = None,
+ operation: Option[String] = None,
+ action: Option[String] = None,
+ apiname: Option[String] = None,
+ swagger: Option[String] = None,
+ responsetype: Option[String] = None,
+ expectedExitCode: Int = SUCCESS_EXIT,
+ cliCfgFile: Option[String] = None)(implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, "create", "--auth", wp.authKey) ++ {
+ basepath map { b =>
+ Seq(b)
+ } getOrElse Seq()
+ } ++ {
+ relpath map { r =>
+ Seq(r)
+ } getOrElse Seq()
+ } ++ {
+ operation map { o =>
+ Seq(o)
+ } getOrElse Seq()
+ } ++ {
+ action map { aa =>
+ Seq(aa)
+ } getOrElse Seq()
+ } ++ {
+ apiname map { a =>
+ Seq("--apiname", a)
+ } getOrElse Seq()
+ } ++ {
+ swagger map { s =>
+ Seq("--config-file", s)
+ } getOrElse Seq()
+ } ++ {
+ responsetype map { t =>
+ Seq("--response-type", t)
+ } getOrElse Seq()
+ }
+ cli(
+ wp.overrides ++ params,
+ expectedExitCode,
+ showCmd = true,
+ env = Map("WSK_CONFIG_FILE" -> cliCfgFile.getOrElse("")))
+ }
+
+ /**
+ * Retrieve a list of API endpoints. Parameters mirror those available in the CLI.
+ *
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def list(basepathOrApiName: Option[String] = None,
+ relpath: Option[String] = None,
+ operation: Option[String] = None,
+ limit: Option[Int] = None,
+ since: Option[Instant] = None,
+ full: Option[Boolean] = None,
+ nameSort: Option[Boolean] = None,
+ expectedExitCode: Int = SUCCESS_EXIT,
+ cliCfgFile: Option[String] = None)(implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, "list", "--auth", wp.authKey) ++ {
+ basepathOrApiName map { b =>
+ Seq(b)
+ } getOrElse Seq()
+ } ++ {
+ relpath map { r =>
+ Seq(r)
+ } getOrElse Seq()
+ } ++ {
+ operation map { o =>
+ Seq(o)
+ } getOrElse Seq()
+ } ++ {
+ limit map { l =>
+ Seq("--limit", l.toString)
+ } getOrElse Seq()
+ } ++ {
+ since map { i =>
+ Seq("--since", i.toEpochMilli.toString)
+ } getOrElse Seq()
+ } ++ {
+ full map { r =>
+ Seq("--full")
+ } getOrElse Seq()
+ } ++ {
+ nameSort map { n =>
+ Seq("--name-sort")
+ } getOrElse Seq()
+ }
+ cli(
+ wp.overrides ++ params,
+ expectedExitCode,
+ showCmd = true,
+ env = Map("WSK_CONFIG_FILE" -> cliCfgFile.getOrElse("")))
+ }
+
+ /**
+ * Retieves an API's configuration. Parameters mirror those available in the CLI.
+ * Runs a command wsk [params] where the arguments come in as a sequence.
+ *
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def get(basepathOrApiName: Option[String] = None,
+ full: Option[Boolean] = None,
+ expectedExitCode: Int = SUCCESS_EXIT,
+ cliCfgFile: Option[String] = None,
+ format: Option[String] = None)(implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, "get", "--auth", wp.authKey) ++ {
+ basepathOrApiName map { b =>
+ Seq(b)
+ } getOrElse Seq()
+ } ++ {
+ full map { f =>
+ if (f) Seq("--full") else Seq()
+ } getOrElse Seq()
+ } ++ {
+ format map { ft =>
+ Seq("--format", ft)
+ } getOrElse Seq()
+ }
+ cli(
+ wp.overrides ++ params,
+ expectedExitCode,
+ showCmd = true,
+ env = Map("WSK_CONFIG_FILE" -> cliCfgFile.getOrElse("")))
+ }
+
+ /**
+ * Delete an entire API or a subset of API endpoints. Parameters mirror those available in the CLI.
+ *
+ * @param expectedExitCode (optional) the expected exit code for the command
+ * if the code is anything but DONTCARE_EXIT, assert the code is as expected
+ */
+ override def delete(basepathOrApiName: String,
+ relpath: Option[String] = None,
+ operation: Option[String] = None,
+ expectedExitCode: Int = SUCCESS_EXIT,
+ cliCfgFile: Option[String] = None)(implicit wp: WskProps): RunResult = {
+ val params = Seq(noun, "delete", "--auth", wp.authKey, basepathOrApiName) ++ {
+ relpath map { r =>
+ Seq(r)
+ } getOrElse Seq()
+ } ++ {
+ operation map { o =>
+ Seq(o)
+ } getOrElse Seq()
+ }
+ cli(
+ wp.overrides ++ params,
+ expectedExitCode,
+ showCmd = true,
+ env = Map("WSK_CONFIG_FILE" -> cliCfgFile.getOrElse("")))
+ }
+}
+
+trait RunWskCliCommand extends RunCliCmd {
+ private val binaryName = "wsk"
+ private val cliPath = if (WhiskProperties.useCLIDownload) getDownloadedGoCLIPath else WhiskProperties.getCLIPath
+
+ assert((new File(cliPath)).exists, s"did not find $cliPath")
+
+ /** What is the path to a downloaded CLI? **/
+ private def getDownloadedGoCLIPath = {
+ s"${System.getProperty("user.home")}${File.separator}.local${File.separator}bin${File.separator}${binaryName}"
+ }
+
+ def baseCommand = Buffer(cliPath)
+}
diff --git a/tests/src/test/scala/common/WskOperations.scala b/tests/src/test/scala/common/WskOperations.scala
index 9aa1564..2597c59 100644
--- a/tests/src/test/scala/common/WskOperations.scala
+++ b/tests/src/test/scala/common/WskOperations.scala
@@ -152,9 +152,18 @@ trait WskOperations {
val namespace: NamespaceOperations
val api: GatewayOperations
- /*
- * Utility function to return a JSON object from the CLI output that returns
- * an optional a status line following by the JSON data
+ /**
+ * Utility function which strips the leading line if it ends in a newline (present when output is from
+ * wsk CLI) and parses the rest as a JSON object.
+ */
+ def parseJsonString(jsonStr: String): JsObject = WskOperations.parseJsonString(jsonStr)
+}
+
+object WskOperations {
+
+ /**
+ * Utility function which strips the leading line if it ends in a newline (present when output is from
+ * wsk CLI) and parses the rest as a JSON object.
*/
def parseJsonString(jsonStr: String): JsObject = {
jsonStr.substring(jsonStr.indexOf("\n") + 1).parseJson.asJsObject // Skip optional status line before parsing
[incubator-openwhisk] 12/19: Renaming, no intended semantic change.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit 38c3679b9a3495ba30177e1cb97042b33d3667c2
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Fri Jun 8 21:32:08 2018 -0400
Renaming, no intended semantic change.
---
.../apigw/healthtests/ApiGwEndToEndTests.scala | 4 +-
.../apigw/healthtests/ApiGwRestEndToEndTests.scala | 4 +-
.../common/{CliCommand.scala => CommandLine.scala} | 4 +-
.../common/{BaseWsk.scala => WskOperations.scala} | 34 +++++-----
tests/src/test/scala/common/WskTestHelpers.scala | 12 ++--
.../{WskRest.scala => WskRestOperations.scala} | 75 ++++++++++++----------
tests/src/test/scala/ha/ShootComponentsTests.scala | 4 +-
tests/src/test/scala/limits/ThrottleTests.scala | 6 +-
tests/src/test/scala/services/HeadersTests.scala | 4 +-
.../test/scala/system/basic/WskActionTests.scala | 4 +-
.../scala/system/basic/WskActivationTests.scala | 4 +-
.../scala/system/basic/WskBasicJavaTests.scala | 4 +-
.../scala/system/basic/WskBasicNode6Tests.scala | 4 +-
.../system/basic/WskBasicNodeDefaultTests.scala | 4 +-
.../scala/system/basic/WskBasicPythonTests.scala | 4 +-
.../scala/system/basic/WskBasicSwift3Tests.scala | 4 +-
.../scala/system/basic/WskConductorTests.scala | 4 +-
.../test/scala/system/basic/WskConsoleTests.scala | 4 +-
.../test/scala/system/basic/WskPackageTests.scala | 4 +-
.../scala/system/basic/WskRestActionTests.scala | 4 +-
.../system/basic/WskRestActivationTests.scala | 4 +-
.../scala/system/basic/WskRestBasicJavaTests.scala | 4 +-
.../system/basic/WskRestBasicNode6Tests.scala | 4 +-
.../system/basic/WskRestBasicNode8Tests.scala | 4 +-
.../basic/WskRestBasicNodeDefaultTests.scala | 4 +-
.../system/basic/WskRestBasicPythonTests.scala | 4 +-
.../system/basic/WskRestBasicSwift311Tests.scala | 4 +-
.../system/basic/WskRestBasicSwift41Tests.scala | 4 +-
.../scala/system/basic/WskRestBasicTests.scala | 4 +-
.../scala/system/basic/WskRestConductorTests.scala | 4 +-
.../scala/system/basic/WskRestPackageTests.scala | 4 +-
.../test/scala/system/basic/WskRestRuleTests.scala | 4 +-
.../scala/system/basic/WskRestSequenceTests.scala | 4 +-
.../system/basic/WskRestUnicodeJavaTests.scala | 4 +-
.../system/basic/WskRestUnicodeNode6Tests.scala | 4 +-
.../system/basic/WskRestUnicodeNode8Tests.scala | 4 +-
.../system/basic/WskRestUnicodePython2Tests.scala | 4 +-
.../system/basic/WskRestUnicodePython3Tests.scala | 4 +-
.../system/basic/WskRestUnicodeSwift311Tests.scala | 4 +-
.../system/basic/WskRestUnicodeSwift41Tests.scala | 4 +-
.../src/test/scala/system/basic/WskRuleTests.scala | 4 +-
.../test/scala/system/basic/WskSequenceTests.scala | 4 +-
.../test/scala/system/basic/WskUnicodeTests.scala | 4 +-
.../test/scala/system/rest/ActionSchemaTests.scala | 4 +-
.../test/scala/whisk/common/UserEventTests.scala | 4 +-
.../scala/whisk/core/admin/WskAdminTests.scala | 4 +-
.../test/ApiGwRestRoutemgmtActionTests.scala | 4 +-
.../actions/test/ApiGwRoutemgmtActionTests.scala | 4 +-
.../scala/whisk/core/cli/test/ApiGwRestTests.scala | 4 +-
.../scala/whisk/core/cli/test/BaseApiGwTests.scala | 4 +-
.../core/cli/test/WskActionSequenceTests.scala | 4 +-
.../whisk/core/cli/test/WskEntitlementTests.scala | 4 +-
.../core/cli/test/WskRestActionSequenceTests.scala | 4 +-
.../core/cli/test/WskRestBasicUsageTests.scala | 4 +-
.../core/cli/test/WskRestEntitlementTests.scala | 4 +-
.../core/cli/test/WskRestWebActionsTests.scala | 4 +-
.../whisk/core/cli/test/WskWebActionsTests.scala | 4 +-
.../core/database/test/CacheConcurrencyTests.scala | 4 +-
.../whisk/core/limits/ActionLimitsTests.scala | 4 +-
.../whisk/core/limits/MaxActionDurationTests.scala | 4 +-
60 files changed, 179 insertions(+), 172 deletions(-)
diff --git a/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala b/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala
index 1b0f5e0..59821e7 100644
--- a/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala
+++ b/tests/src/test/scala/apigw/healthtests/ApiGwEndToEndTests.scala
@@ -34,7 +34,7 @@ import com.jayway.restassured.RestAssured
import common.TestHelpers
import common.TestUtils
import common.TestUtils._
-import common.BaseWsk
+import common.WskOperations
import common.WskProps
import common.WskTestHelpers
import spray.json._
@@ -54,7 +54,7 @@ abstract class ApiGwEndToEndTests
with BeforeAndAfterAll {
implicit val wskprops: common.WskProps = WskProps()
- val wsk: BaseWsk
+ val wsk: WskOperations
val namespace: String = wsk.namespace.whois()
val createCode: Int
diff --git a/tests/src/test/scala/apigw/healthtests/ApiGwRestEndToEndTests.scala b/tests/src/test/scala/apigw/healthtests/ApiGwRestEndToEndTests.scala
index 2f92185..abb82e0 100644
--- a/tests/src/test/scala/apigw/healthtests/ApiGwRestEndToEndTests.scala
+++ b/tests/src/test/scala/apigw/healthtests/ApiGwRestEndToEndTests.scala
@@ -27,13 +27,13 @@ import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import common.TestUtils._
-import common.rest.WskRest
+import common.rest.WskRestOperations
import common.rest.RestResult
@RunWith(classOf[JUnitRunner])
class ApiGwRestEndToEndTests extends ApiGwEndToEndTests {
- override lazy val wsk: common.rest.WskRest = new WskRest
+ override lazy val wsk: common.rest.WskRestOperations = new WskRestOperations
override val createCode: Int = OK.intValue
override def verifyAPICreated(rr: RunResult): Unit = {
diff --git a/tests/src/test/scala/common/CliCommand.scala b/tests/src/test/scala/common/CommandLine.scala
similarity index 98%
rename from tests/src/test/scala/common/CliCommand.scala
rename to tests/src/test/scala/common/CommandLine.scala
index 44c9dcf..55e451d 100644
--- a/tests/src/test/scala/common/CliCommand.scala
+++ b/tests/src/test/scala/common/CommandLine.scala
@@ -26,7 +26,7 @@ import TestUtils._
import scala.collection.mutable
-trait CliCommand extends Matchers {
+trait CommandLine extends Matchers {
/**
* The base command to run. This returns a new mutable buffer, intended for building the rest of the command line.
@@ -102,7 +102,7 @@ trait CliCommand extends Matchers {
}
object WskAdmin {
- val wskadmin = new CliCommand {
+ val wskadmin = new CommandLine {
override def baseCommand: mutable.Buffer[String] = WskAdmin.baseCommand
}
diff --git a/tests/src/test/scala/common/BaseWsk.scala b/tests/src/test/scala/common/WskOperations.scala
similarity index 94%
rename from tests/src/test/scala/common/BaseWsk.scala
rename to tests/src/test/scala/common/WskOperations.scala
index 90e9ffa..9aa1564 100644
--- a/tests/src/test/scala/common/BaseWsk.scala
+++ b/tests/src/test/scala/common/WskOperations.scala
@@ -143,14 +143,14 @@ trait HasActivation {
}
}
-trait BaseWsk {
- val action: BaseAction
- val trigger: BaseTrigger
- val rule: BaseRule
- val activation: BaseActivation
- val pkg: BasePackage
- val namespace: BaseNamespace
- val api: BaseApi
+trait WskOperations {
+ val action: ActionOperations
+ val trigger: TriggerOperations
+ val rule: RuleOperations
+ val activation: ActivationOperations
+ val pkg: PackageOperations
+ val namespace: NamespaceOperations
+ val api: GatewayOperations
/*
* Utility function to return a JSON object from the CLI output that returns
@@ -161,7 +161,7 @@ trait BaseWsk {
}
}
-trait BaseListOrGetFromCollection {
+trait ListOrGetFromCollectionOperations {
protected val noun: String
@@ -193,7 +193,7 @@ trait BaseListOrGetFromCollection {
saveAs: Option[String] = None)(implicit wp: WskProps): RunResult
}
-trait BaseDeleteFromCollection {
+trait DeleteFromCollectionOperations {
protected val noun: String
@@ -215,7 +215,7 @@ trait BaseDeleteFromCollection {
def sanitize(name: String)(implicit wp: WskProps): RunResult
}
-trait BaseAction extends BaseDeleteFromCollection with BaseListOrGetFromCollection {
+trait ActionOperations extends DeleteFromCollectionOperations with ListOrGetFromCollectionOperations {
def create(name: String,
artifact: Option[String],
@@ -243,7 +243,7 @@ trait BaseAction extends BaseDeleteFromCollection with BaseListOrGetFromCollecti
expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult
}
-trait BasePackage extends BaseDeleteFromCollection with BaseListOrGetFromCollection {
+trait PackageOperations extends DeleteFromCollectionOperations with ListOrGetFromCollectionOperations {
def create(name: String,
parameters: Map[String, JsValue] = Map(),
@@ -261,7 +261,7 @@ trait BasePackage extends BaseDeleteFromCollection with BaseListOrGetFromCollect
expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult
}
-trait BaseTrigger extends BaseDeleteFromCollection with BaseListOrGetFromCollection {
+trait TriggerOperations extends DeleteFromCollectionOperations with ListOrGetFromCollectionOperations {
def create(name: String,
parameters: Map[String, JsValue] = Map(),
@@ -279,7 +279,7 @@ trait BaseTrigger extends BaseDeleteFromCollection with BaseListOrGetFromCollect
expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult
}
-trait BaseRule extends BaseDeleteFromCollection with BaseListOrGetFromCollection {
+trait RuleOperations extends DeleteFromCollectionOperations with ListOrGetFromCollectionOperations {
def create(name: String,
trigger: String,
@@ -296,7 +296,7 @@ trait BaseRule extends BaseDeleteFromCollection with BaseListOrGetFromCollection
def state(name: String, expectedExitCode: Int = SUCCESS_EXIT)(implicit wp: WskProps): RunResult
}
-trait BaseActivation {
+trait ActivationOperations {
def extractActivationId(result: RunResult): Option[String]
@@ -328,14 +328,14 @@ trait BaseActivation {
implicit wp: WskProps): RunResult
}
-trait BaseNamespace {
+trait NamespaceOperations {
def list(expectedExitCode: Int = SUCCESS_EXIT, nameSort: Option[Boolean] = None)(implicit wp: WskProps): RunResult
def whois()(implicit wskprops: WskProps): String
}
-trait BaseApi {
+trait GatewayOperations {
def create(basepath: Option[String] = None,
relpath: Option[String] = None,
diff --git a/tests/src/test/scala/common/WskTestHelpers.scala b/tests/src/test/scala/common/WskTestHelpers.scala
index 0008784..65d2f16 100644
--- a/tests/src/test/scala/common/WskTestHelpers.scala
+++ b/tests/src/test/scala/common/WskTestHelpers.scala
@@ -166,7 +166,7 @@ object RuleActivationResult extends DefaultJsonProtocol {
* completed, will delete them all.
*/
trait WskTestHelpers extends Matchers {
- type Assets = ListBuffer[(BaseDeleteFromCollection, String, Boolean)]
+ type Assets = ListBuffer[(DeleteFromCollectionOperations, String, Boolean)]
/**
* Helper to register an entity to delete once a test completes.
@@ -175,7 +175,7 @@ trait WskTestHelpers extends Matchers {
*
*/
class AssetCleaner(assetsToDeleteAfterTest: Assets, wskprops: WskProps) {
- def withCleaner[T <: BaseDeleteFromCollection](cli: T, name: String, confirmDelete: Boolean = true)(
+ def withCleaner[T <: DeleteFromCollectionOperations](cli: T, name: String, confirmDelete: Boolean = true)(
cmd: (T, String) => RunResult): RunResult = {
// sanitize (delete) if asset exists
cli.sanitize(name)(wskprops)
@@ -208,7 +208,7 @@ trait WskTestHelpers extends Matchers {
case (cli, n, delete) =>
n -> Try {
cli match {
- case _: BasePackage if delete =>
+ case _: PackageOperations if delete =>
// sanitize ignores the exit code, so we can inspect the actual result and retry accordingly
val rr = cli.sanitize(n)(wskprops)
rr.exitCode match {
@@ -239,7 +239,7 @@ trait WskTestHelpers extends Matchers {
* the activation to the post processor which then check for expected values.
*/
def withActivation(
- wsk: BaseActivation,
+ wsk: ActivationOperations,
run: RunResult,
initialWait: Duration = 1.second,
pollPeriod: Duration = 1.second,
@@ -257,7 +257,7 @@ trait WskTestHelpers extends Matchers {
* Polls activations until one matching id is found. If found, pass
* the activation to the post processor which then check for expected values.
*/
- def withActivation(wsk: BaseActivation,
+ def withActivation(wsk: ActivationOperations,
activationId: String,
initialWait: Duration,
pollPeriod: Duration,
@@ -273,7 +273,7 @@ trait WskTestHelpers extends Matchers {
}
}
}
- def withActivation(wsk: BaseActivation, activationId: String)(check: ActivationResult => Unit)(
+ def withActivation(wsk: ActivationOperations, activationId: String)(check: ActivationResult => Unit)(
implicit wskprops: WskProps): Unit = {
withActivation(wsk, activationId, 1.second, 1.second, 60.seconds)(check)
}
diff --git a/tests/src/test/scala/common/rest/WskRest.scala b/tests/src/test/scala/common/rest/WskRestOperations.scala
similarity index 96%
rename from tests/src/test/scala/common/rest/WskRest.scala
rename to tests/src/test/scala/common/rest/WskRestOperations.scala
index a209735..b3d42c1 100644
--- a/tests/src/test/scala/common/rest/WskRest.scala
+++ b/tests/src/test/scala/common/rest/WskRestOperations.scala
@@ -58,8 +58,8 @@ import akka.stream.ActorMaterializer
import spray.json._
import spray.json.DefaultJsonProtocol._
import common._
-import common.BaseDeleteFromCollection
-import common.BaseListOrGetFromCollection
+import common.DeleteFromCollectionOperations
+import common.ListOrGetFromCollectionOperations
import common.HasActivation
import common.TestUtils.SUCCESS_EXIT
import common.TestUtils.ANY_ERROR_EXIT
@@ -145,17 +145,17 @@ object HttpConnection {
}
}
-class WskRest() extends RunWskRestCmd with BaseWsk {
- override implicit val action = new WskRestAction
- override implicit val trigger = new WskRestTrigger
- override implicit val rule = new WskRestRule
- override implicit val activation = new WskRestActivation
- override implicit val pkg = new WskRestPackage
- override implicit val namespace = new WskRestNamespace
- override implicit val api = new WskRestApi
+class WskRestOperations() extends RunWskRestCmd with WskOperations {
+ override implicit val action = new RestActionOperations
+ override implicit val trigger = new RestTriggerOperations
+ override implicit val rule = new RestRuleOperations
+ override implicit val activation = new RestActivationOperations
+ override implicit val pkg = new RestPackageOperations
+ override implicit val namespace = new RestNamespaceOperations
+ override implicit val api = new RestGatewayOperations
}
-trait ListOrGetFromCollectionRest extends RunWskRestCmd with BaseListOrGetFromCollection {
+trait RestListOrGetFromCollectionOperations extends RunWskRestCmd with ListOrGetFromCollectionOperations {
import FullyQualifiedNames.resolve
/**
@@ -208,7 +208,7 @@ trait ListOrGetFromCollectionRest extends RunWskRestCmd with BaseListOrGetFromCo
}
}
-trait DeleteFromCollectionRest extends RunWskRestCmd with BaseDeleteFromCollection {
+trait RestDeleteFromCollectionOperations extends RunWskRestCmd with DeleteFromCollectionOperations {
/**
* Deletes entity from collection.
@@ -237,7 +237,7 @@ trait DeleteFromCollectionRest extends RunWskRestCmd with BaseDeleteFromCollecti
}
}
-trait HasActivationRest extends HasActivation {
+trait RestActivation extends HasActivation {
/**
* Extracts activation id from invoke (action or trigger) or activation get
@@ -257,12 +257,12 @@ trait HasActivationRest extends HasActivation {
}
}
-class WskRestAction
+class RestActionOperations
extends RunWskRestCmd
- with ListOrGetFromCollectionRest
- with DeleteFromCollectionRest
- with HasActivationRest
- with BaseAction {
+ with RestListOrGetFromCollectionOperations
+ with RestDeleteFromCollectionOperations
+ with RestActivation
+ with ActionOperations {
override protected val noun = "actions"
@@ -458,12 +458,12 @@ class WskRestAction
}
}
-class WskRestTrigger
+class RestTriggerOperations
extends RunWskRestCmd
- with ListOrGetFromCollectionRest
- with DeleteFromCollectionRest
- with HasActivationRest
- with BaseTrigger {
+ with RestListOrGetFromCollectionOperations
+ with RestDeleteFromCollectionOperations
+ with RestActivation
+ with TriggerOperations {
override protected val noun = "triggers"
@@ -568,12 +568,12 @@ class WskRestTrigger
}
}
-class WskRestRule
+class RestRuleOperations
extends RunWskRestCmd
- with ListOrGetFromCollectionRest
- with DeleteFromCollectionRest
+ with RestListOrGetFromCollectionOperations
+ with RestDeleteFromCollectionOperations
with WaitFor
- with BaseRule {
+ with RuleOperations {
override protected val noun = "rules"
@@ -652,7 +652,7 @@ class WskRestRule
}
}
-class WskRestActivation extends RunWskRestCmd with HasActivationRest with WaitFor with BaseActivation {
+class RestActivationOperations extends RunWskRestCmd with RestActivation with WaitFor with ActivationOperations {
protected val noun = "activations"
@@ -864,7 +864,7 @@ class WskRestActivation extends RunWskRestCmd with HasActivationRest with WaitFo
private case class PartialResult(ids: Seq[String]) extends Throwable
}
-class WskRestNamespace extends RunWskRestCmd with BaseNamespace {
+class RestNamespaceOperations extends RunWskRestCmd with NamespaceOperations {
protected val noun = "namespaces"
@@ -895,11 +895,11 @@ class WskRestNamespace extends RunWskRestCmd with BaseNamespace {
}
}
-class WskRestPackage
+class RestPackageOperations
extends RunWskRestCmd
- with ListOrGetFromCollectionRest
- with DeleteFromCollectionRest
- with BasePackage {
+ with RestListOrGetFromCollectionOperations
+ with RestDeleteFromCollectionOperations
+ with PackageOperations {
override protected val noun = "packages"
@@ -979,7 +979,7 @@ class WskRestPackage
}
-class WskRestApi extends RunWskRestCmd with BaseApi {
+class RestGatewayOperations extends RunWskRestCmd with GatewayOperations {
protected val noun = "apis"
/**
@@ -1386,15 +1386,21 @@ class RunWskRestCmd() extends FlatSpec with Matchers with ScalaFutures with WskA
web: Boolean = false,
expectedExitCode: Int = Accepted.intValue)(implicit wp: WskProps): RestResult = {
val (ns, actName) = this.getNamespaceEntityName(name)
+
val path =
if (web) Path(s"$basePath/web/$systemNamespace/$actName.http")
else Path(s"$basePath/namespaces/$ns/actions/$actName")
+
val paramMap = Map("blocking" -> blocking.toString, "result" -> result.toString)
+
val input = parameterFile map { pf =>
Some(FileUtils.readFileToString(new File(pf), StandardCharsets.UTF_8))
} getOrElse Some(parameters.toJson.toString)
+
val resp = requestEntity(POST, path, paramMap, input)
+
val rr = new RestResult(resp.status.intValue, getRespData(resp), blocking)
+
// If the statusCode does not not equal to expectedExitCode, it is acceptable that the statusCode
// equals to 200 for the case that either blocking or result is set to true.
if (!isStatusCodeExpected(expectedExitCode, rr.statusCode.intValue)) {
@@ -1404,6 +1410,7 @@ class RunWskRestCmd() extends FlatSpec with Matchers with ScalaFutures with WskA
rr.statusCode.intValue shouldBe expectedExitCode
}
}
+
rr
}
}
diff --git a/tests/src/test/scala/ha/ShootComponentsTests.scala b/tests/src/test/scala/ha/ShootComponentsTests.scala
index e3480bc..4807061 100644
--- a/tests/src/test/scala/ha/ShootComponentsTests.scala
+++ b/tests/src/test/scala/ha/ShootComponentsTests.scala
@@ -33,7 +33,7 @@ import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.unmarshalling.Unmarshal
import akka.stream.ActorMaterializer
import common._
-import common.rest.{HttpConnection, WskRest}
+import common.rest.{HttpConnection, WskRestOperations}
import pureconfig._
import spray.json._
import spray.json.DefaultJsonProtocol._
@@ -54,7 +54,7 @@ class ShootComponentsTests
with ShootComponentUtils {
implicit val wskprops = WskProps()
- val wsk = new WskRest
+ val wsk = new WskRestOperations
val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
implicit val materializer = ActorMaterializer()
diff --git a/tests/src/test/scala/limits/ThrottleTests.scala b/tests/src/test/scala/limits/ThrottleTests.scala
index bc5da1e..ae01309 100644
--- a/tests/src/test/scala/limits/ThrottleTests.scala
+++ b/tests/src/test/scala/limits/ThrottleTests.scala
@@ -33,7 +33,7 @@ import org.scalatest.concurrent.ScalaFutures
import org.scalatest.junit.JUnitRunner
import common._
import common.TestUtils._
-import common.rest.WskRest
+import common.rest.WskRestOperations
import WskAdmin.wskadmin
import spray.json._
import spray.json.DefaultJsonProtocol._
@@ -62,7 +62,7 @@ class ThrottleTests
implicit val testConfig = PatienceConfig(5.minutes)
implicit val wskprops = WskProps()
- val wsk = new WskRest
+ val wsk = new WskRestOperations
val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
val throttleWindow = 1.minute
@@ -301,7 +301,7 @@ class NamespaceSpecificThrottleTests
val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
- val wsk = new WskRest
+ val wsk = new WskRestOperations
def sanitizeNamespaces(namespaces: Seq[String], expectedExitCode: Int = SUCCESS_EXIT): Unit = {
val deletions = namespaces.map { ns =>
diff --git a/tests/src/test/scala/services/HeadersTests.scala b/tests/src/test/scala/services/HeadersTests.scala
index af67970..42c51c3 100644
--- a/tests/src/test/scala/services/HeadersTests.scala
+++ b/tests/src/test/scala/services/HeadersTests.scala
@@ -29,7 +29,7 @@ import org.scalatest.junit.JUnitRunner
import org.scalatest.time.Span.convertDurationToSpan
import common.TestUtils
import common.WhiskProperties
-import common.rest.{HttpConnection, WskRest}
+import common.rest.{HttpConnection, WskRestOperations}
import common.WskProps
import common.WskTestHelpers
import akka.http.scaladsl.model.Uri
@@ -81,7 +81,7 @@ class HeadersTests extends FlatSpec with Matchers with ScalaFutures with WskActo
val basePath = Path("/api/v1")
implicit val wskprops = WskProps()
- val wsk = new WskRest
+ val wsk = new WskRestOperations
/**
* Checks, if the required headers are in the list of all headers.
diff --git a/tests/src/test/scala/system/basic/WskActionTests.scala b/tests/src/test/scala/system/basic/WskActionTests.scala
index bee8170..4eddb13 100644
--- a/tests/src/test/scala/system/basic/WskActionTests.scala
+++ b/tests/src/test/scala/system/basic/WskActionTests.scala
@@ -23,7 +23,7 @@ import common.ActivationResult
import common.JsHelpers
import common.TestHelpers
import common.TestUtils
-import common.BaseWsk
+import common.WskOperations
import common.WskProps
import common.WskTestHelpers
import spray.json._
@@ -33,7 +33,7 @@ import spray.json.DefaultJsonProtocol._
abstract class WskActionTests extends TestHelpers with WskTestHelpers with JsHelpers {
implicit val wskprops = WskProps()
- val wsk: BaseWsk
+ val wsk: WskOperations
val testString = "this is a test"
val testResult = JsObject("count" -> testString.split(" ").length.toJson)
diff --git a/tests/src/test/scala/system/basic/WskActivationTests.scala b/tests/src/test/scala/system/basic/WskActivationTests.scala
index a96be29..4d5c216 100644
--- a/tests/src/test/scala/system/basic/WskActivationTests.scala
+++ b/tests/src/test/scala/system/basic/WskActivationTests.scala
@@ -20,7 +20,7 @@ package system.basic
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-import common.{BaseWsk, TestHelpers, TestUtils, WskProps, WskTestHelpers}
+import common.{TestHelpers, TestUtils, WskOperations, WskProps, WskTestHelpers}
import whisk.utils.retry
@@ -33,7 +33,7 @@ import spray.json.DefaultJsonProtocol._
abstract class WskActivationTests extends TestHelpers with WskTestHelpers {
implicit val wskprops = WskProps()
- val wsk: BaseWsk
+ val wsk: WskOperations
behavior of "Whisk activations"
diff --git a/tests/src/test/scala/system/basic/WskBasicJavaTests.scala b/tests/src/test/scala/system/basic/WskBasicJavaTests.scala
index fafbde2..ba64d53 100644
--- a/tests/src/test/scala/system/basic/WskBasicJavaTests.scala
+++ b/tests/src/test/scala/system/basic/WskBasicJavaTests.scala
@@ -24,7 +24,7 @@ import common.TestUtils
import common.TestUtils.ANY_ERROR_EXIT
import common.WskTestHelpers
import common.WskProps
-import common.BaseWsk
+import common.WskOperations
import org.junit.runner.RunWith
import org.scalatest.Matchers
@@ -36,7 +36,7 @@ import spray.json.JsString
abstract class WskBasicJavaTests extends TestHelpers with WskTestHelpers with Matchers {
implicit val wskprops = WskProps()
- val wsk: BaseWsk
+ val wsk: WskOperations
val expectedDuration = 120.seconds
val activationPollDuration = 60.seconds
diff --git a/tests/src/test/scala/system/basic/WskBasicNode6Tests.scala b/tests/src/test/scala/system/basic/WskBasicNode6Tests.scala
index f4a04e3..c829b6f 100644
--- a/tests/src/test/scala/system/basic/WskBasicNode6Tests.scala
+++ b/tests/src/test/scala/system/basic/WskBasicNode6Tests.scala
@@ -24,7 +24,7 @@ import common.JsHelpers
import common.TestHelpers
import common.TestUtils
import common.TestUtils.RunResult
-import common.BaseWsk
+import common.WskOperations
import common.WskProps
import common.WskTestHelpers
import spray.json._
@@ -33,7 +33,7 @@ import spray.json._
abstract class WskBasicNode6Tests extends TestHelpers with WskTestHelpers with JsHelpers {
implicit val wskprops = WskProps()
- val wsk: BaseWsk
+ val wsk: WskOperations
val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
lazy val currentNodeJsKind = "nodejs:6"
diff --git a/tests/src/test/scala/system/basic/WskBasicNodeDefaultTests.scala b/tests/src/test/scala/system/basic/WskBasicNodeDefaultTests.scala
index 2f5d8d3..0e7ed87 100644
--- a/tests/src/test/scala/system/basic/WskBasicNodeDefaultTests.scala
+++ b/tests/src/test/scala/system/basic/WskBasicNodeDefaultTests.scala
@@ -25,7 +25,7 @@ import common.TestHelpers
import common.TestUtils
import common.TestUtils.ANY_ERROR_EXIT
import common.TestUtils.RunResult
-import common.BaseWsk
+import common.WskOperations
import common.WskProps
import common.WskTestHelpers
import spray.json._
@@ -35,7 +35,7 @@ import spray.json.DefaultJsonProtocol._
abstract class WskBasicNodeDefaultTests extends TestHelpers with WskTestHelpers with JsHelpers {
implicit val wskprops = WskProps()
- val wsk: BaseWsk
+ val wsk: WskOperations
val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
val currentNodeJsDefaultKind = "nodejs:6"
diff --git a/tests/src/test/scala/system/basic/WskBasicPythonTests.scala b/tests/src/test/scala/system/basic/WskBasicPythonTests.scala
index ada635a..61941d0 100644
--- a/tests/src/test/scala/system/basic/WskBasicPythonTests.scala
+++ b/tests/src/test/scala/system/basic/WskBasicPythonTests.scala
@@ -26,7 +26,7 @@ import spray.json.DefaultJsonProtocol.StringJsonFormat
import common.JsHelpers
import common.TestHelpers
import common.TestUtils
-import common.BaseWsk
+import common.WskOperations
import common.WskProps
import common.WskTestHelpers
import common.WhiskProperties
@@ -35,7 +35,7 @@ import common.WhiskProperties
abstract class WskBasicPythonTests extends TestHelpers with WskTestHelpers with Matchers with JsHelpers {
implicit val wskprops = WskProps()
- val wsk: BaseWsk
+ val wsk: WskOperations
behavior of "Native Python Action"
diff --git a/tests/src/test/scala/system/basic/WskBasicSwift3Tests.scala b/tests/src/test/scala/system/basic/WskBasicSwift3Tests.scala
index 857beb0..174bd29 100644
--- a/tests/src/test/scala/system/basic/WskBasicSwift3Tests.scala
+++ b/tests/src/test/scala/system/basic/WskBasicSwift3Tests.scala
@@ -23,7 +23,7 @@ import scala.concurrent.duration.DurationInt
import common.JsHelpers
import common.TestHelpers
import common.TestUtils
-import common.BaseWsk
+import common.WskOperations
import common.WskProps
import common.WskTestHelpers
import spray.json._
@@ -33,7 +33,7 @@ import common.TestUtils.RunResult
abstract class WskBasicSwift3Tests extends TestHelpers with WskTestHelpers with JsHelpers {
implicit val wskprops: common.WskProps = WskProps()
- val wsk: BaseWsk
+ val wsk: WskOperations
val defaultAction: Some[String] = Some(TestUtils.getTestActionFilename("hello.swift"))
lazy val actionKind = "swift:3.1.1"
val activationMaxDuration = 2.minutes
diff --git a/tests/src/test/scala/system/basic/WskConductorTests.scala b/tests/src/test/scala/system/basic/WskConductorTests.scala
index aa4c5b6..22ba657 100644
--- a/tests/src/test/scala/system/basic/WskConductorTests.scala
+++ b/tests/src/test/scala/system/basic/WskConductorTests.scala
@@ -28,7 +28,7 @@ import common.StreamLogging
import common.JsHelpers
import common.TestHelpers
import common.TestUtils
-import common.BaseWsk
+import common.WskOperations
import common.WskProps
import common.WskTestHelpers
@@ -43,7 +43,7 @@ import whisk.http.Messages._
abstract class WskConductorTests extends TestHelpers with WskTestHelpers with JsHelpers with StreamLogging {
implicit val wskprops = WskProps()
- val wsk: BaseWsk
+ val wsk: WskOperations
val allowedActionDuration = 120 seconds
val testString = "this is a test"
diff --git a/tests/src/test/scala/system/basic/WskConsoleTests.scala b/tests/src/test/scala/system/basic/WskConsoleTests.scala
index 2d6f0fc..3baa03c 100644
--- a/tests/src/test/scala/system/basic/WskConsoleTests.scala
+++ b/tests/src/test/scala/system/basic/WskConsoleTests.scala
@@ -29,7 +29,7 @@ import org.scalatest.junit.JUnitRunner
import common.TestHelpers
import common.TestUtils
-import common.BaseWsk
+import common.WskOperations
import common.WskProps
import common.WskTestHelpers
import spray.json.DefaultJsonProtocol._
@@ -42,7 +42,7 @@ import spray.json._
abstract class WskConsoleTests extends TestHelpers with WskTestHelpers {
implicit val wskprops = WskProps()
- val wsk: BaseWsk
+ val wsk: WskOperations
val guestNamespace = wskprops.namespace
behavior of "Wsk Activation Console"
diff --git a/tests/src/test/scala/system/basic/WskPackageTests.scala b/tests/src/test/scala/system/basic/WskPackageTests.scala
index fe0daba..3b3c76b 100644
--- a/tests/src/test/scala/system/basic/WskPackageTests.scala
+++ b/tests/src/test/scala/system/basic/WskPackageTests.scala
@@ -24,7 +24,7 @@ import scala.concurrent.duration.DurationInt
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import common.TestUtils
-import common.BaseWsk
+import common.WskOperations
import common.WskProps
import spray.json._
import spray.json.DefaultJsonProtocol.StringJsonFormat
@@ -37,7 +37,7 @@ import common.WskProps
abstract class WskPackageTests extends TestHelpers with WskTestHelpers {
implicit val wskprops = WskProps()
- val wsk: BaseWsk
+ val wsk: WskOperations
val LOG_DELAY = 80 seconds
behavior of "Wsk Package"
diff --git a/tests/src/test/scala/system/basic/WskRestActionTests.scala b/tests/src/test/scala/system/basic/WskRestActionTests.scala
index de2bd2d..1f46628 100644
--- a/tests/src/test/scala/system/basic/WskRestActionTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestActionTests.scala
@@ -20,14 +20,14 @@ package system.basic
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-import common.rest.WskRest
+import common.rest.WskRestOperations
import common.TestUtils
import spray.json._
@RunWith(classOf[JUnitRunner])
class WskRestActionTests extends WskActionTests {
- override val wsk: WskRest = new WskRest
+ override val wsk: WskRestOperations = new WskRestOperations
it should "create an action with an empty file" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
val name = "empty"
diff --git a/tests/src/test/scala/system/basic/WskRestActivationTests.scala b/tests/src/test/scala/system/basic/WskRestActivationTests.scala
index 5044938..c7f7897 100644
--- a/tests/src/test/scala/system/basic/WskRestActivationTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestActivationTests.scala
@@ -20,9 +20,9 @@ package system.basic
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-import common.rest.WskRest
+import common.rest.WskRestOperations
@RunWith(classOf[JUnitRunner])
class WskRestActivationTests extends WskActivationTests {
- override val wsk: WskRest = new WskRest
+ override val wsk: WskRestOperations = new WskRestOperations
}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicJavaTests.scala b/tests/src/test/scala/system/basic/WskRestBasicJavaTests.scala
index 0ccbd56..5cc5126 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicJavaTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicJavaTests.scala
@@ -17,12 +17,12 @@
package system.basic
-import common.rest.WskRest
+import common.rest.WskRestOperations
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
class WskRestBasicJavaTests extends WskBasicJavaTests {
- override val wsk: common.rest.WskRest = new WskRest
+ override val wsk: common.rest.WskRestOperations = new WskRestOperations
}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicNode6Tests.scala b/tests/src/test/scala/system/basic/WskRestBasicNode6Tests.scala
index ba23bd6..792b13d 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicNode6Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicNode6Tests.scala
@@ -17,12 +17,12 @@
package system.basic
-import common.rest.WskRest
+import common.rest.WskRestOperations
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
class WskRestBasicNode6Tests extends WskBasicNode6Tests {
- override val wsk: common.rest.WskRest = new WskRest
+ override val wsk: common.rest.WskRestOperations = new WskRestOperations
}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicNode8Tests.scala b/tests/src/test/scala/system/basic/WskRestBasicNode8Tests.scala
index 65a4428..3b69b74 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicNode8Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicNode8Tests.scala
@@ -17,12 +17,12 @@
package system.basic
-import common.rest.WskRest
+import common.rest.WskRestOperations
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
class WskRestBasicNode8Tests extends WskBasicNode8Tests {
- override val wsk: common.rest.WskRest = new WskRest
+ override val wsk: common.rest.WskRestOperations = new WskRestOperations
}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicNodeDefaultTests.scala b/tests/src/test/scala/system/basic/WskRestBasicNodeDefaultTests.scala
index 43b2839..367aa9c 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicNodeDefaultTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicNodeDefaultTests.scala
@@ -17,12 +17,12 @@
package system.basic
-import common.rest.WskRest
+import common.rest.WskRestOperations
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
class WskRestBasicNodeDefaultTests extends WskBasicNodeDefaultTests {
- override val wsk: common.rest.WskRest = new WskRest
+ override val wsk: common.rest.WskRestOperations = new WskRestOperations
}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicPythonTests.scala b/tests/src/test/scala/system/basic/WskRestBasicPythonTests.scala
index 3273c99..d6242f1 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicPythonTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicPythonTests.scala
@@ -17,12 +17,12 @@
package system.basic
-import common.rest.WskRest
+import common.rest.WskRestOperations
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
class WskRestBasicPythonTests extends WskBasicPythonTests {
- override val wsk: common.rest.WskRest = new WskRest
+ override val wsk: common.rest.WskRestOperations = new WskRestOperations
}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicSwift311Tests.scala b/tests/src/test/scala/system/basic/WskRestBasicSwift311Tests.scala
index 06e4323..46e3935 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicSwift311Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicSwift311Tests.scala
@@ -17,13 +17,13 @@
package system.basic
-import common.rest.WskRest
+import common.rest.WskRestOperations
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
class WskRestBasicSwift311Tests extends WskBasicSwift3Tests {
- override val wsk: common.rest.WskRest = new WskRest
+ override val wsk: common.rest.WskRestOperations = new WskRestOperations
override lazy val actionKind = "swift:3.1.1"
}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicSwift41Tests.scala b/tests/src/test/scala/system/basic/WskRestBasicSwift41Tests.scala
index 2a44ccb..0222020 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicSwift41Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicSwift41Tests.scala
@@ -17,14 +17,14 @@
package system.basic
-import common.rest.WskRest
+import common.rest.WskRestOperations
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
class WskRestBasicSwift41Tests extends WskBasicSwift3Tests {
- override val wsk: common.rest.WskRest = new WskRest
+ override val wsk: common.rest.WskRestOperations = new WskRestOperations
override lazy val actionKind = "swift:4.1"
}
diff --git a/tests/src/test/scala/system/basic/WskRestBasicTests.scala b/tests/src/test/scala/system/basic/WskRestBasicTests.scala
index 7412f9b..3042205 100644
--- a/tests/src/test/scala/system/basic/WskRestBasicTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestBasicTests.scala
@@ -32,7 +32,7 @@ import org.scalatest.junit.JUnitRunner
import common.TestHelpers
import common.TestUtils
-import common.rest.WskRest
+import common.rest.WskRestOperations
import common.rest.RestResult
import common.WskProps
import common.WskTestHelpers
@@ -44,7 +44,7 @@ import whisk.http.Messages
class WskRestBasicTests extends TestHelpers with WskTestHelpers {
implicit val wskprops: common.WskProps = WskProps()
- val wsk: common.rest.WskRest = new WskRest
+ val wsk: common.rest.WskRestOperations = new WskRestOperations
val defaultAction: Some[String] = Some(TestUtils.getTestActionFilename("hello.js"))
/**
diff --git a/tests/src/test/scala/system/basic/WskRestConductorTests.scala b/tests/src/test/scala/system/basic/WskRestConductorTests.scala
index c43bcdb..7a0757b 100644
--- a/tests/src/test/scala/system/basic/WskRestConductorTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestConductorTests.scala
@@ -20,9 +20,9 @@ package system.basic
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-import common.rest.WskRest
+import common.rest.WskRestOperations
@RunWith(classOf[JUnitRunner])
class WskRestConductorTests extends WskConductorTests {
- override val wsk: WskRest = new WskRest
+ override val wsk: WskRestOperations = new WskRestOperations
}
diff --git a/tests/src/test/scala/system/basic/WskRestPackageTests.scala b/tests/src/test/scala/system/basic/WskRestPackageTests.scala
index df5f662..1751f06 100644
--- a/tests/src/test/scala/system/basic/WskRestPackageTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestPackageTests.scala
@@ -19,9 +19,9 @@ package system.basic
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-import common.rest.WskRest
+import common.rest.WskRestOperations
@RunWith(classOf[JUnitRunner])
class WskRestPackageTests extends WskPackageTests {
- override val wsk: WskRest = new WskRest
+ override val wsk: WskRestOperations = new WskRestOperations
}
diff --git a/tests/src/test/scala/system/basic/WskRestRuleTests.scala b/tests/src/test/scala/system/basic/WskRestRuleTests.scala
index d281a6b..7ba4ed7 100644
--- a/tests/src/test/scala/system/basic/WskRestRuleTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestRuleTests.scala
@@ -21,7 +21,7 @@ import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import common.TestUtils.RunResult
-import common.rest.WskRest
+import common.rest.WskRestOperations
import common.rest.RestResult
import whisk.utils.retry
@@ -33,7 +33,7 @@ import spray.json.DefaultJsonProtocol._
@RunWith(classOf[JUnitRunner])
class WskRestRuleTests extends WskRuleTests {
- override val wsk: common.rest.WskRest = new WskRest
+ override val wsk: common.rest.WskRestOperations = new WskRestOperations
override def verifyRuleList(ruleListResult: RunResult,
ruleNameEnable: String,
diff --git a/tests/src/test/scala/system/basic/WskRestSequenceTests.scala b/tests/src/test/scala/system/basic/WskRestSequenceTests.scala
index 916b575..5d5c8b5 100644
--- a/tests/src/test/scala/system/basic/WskRestSequenceTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestSequenceTests.scala
@@ -20,7 +20,7 @@ package system.basic
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-import common.rest.WskRest
+import common.rest.WskRestOperations
import whisk.core.WhiskConfig
/**
@@ -29,7 +29,7 @@ import whisk.core.WhiskConfig
@RunWith(classOf[JUnitRunner])
class WskRestSequenceTests extends WskSequenceTests {
- override val wsk: common.rest.WskRest = new WskRest
+ override val wsk: common.rest.WskRestOperations = new WskRestOperations
override val whiskConfig = new WhiskConfig(Map(WhiskConfig.actionSequenceMaxLimit -> null))
assert(whiskConfig.isValid)
}
diff --git a/tests/src/test/scala/system/basic/WskRestUnicodeJavaTests.scala b/tests/src/test/scala/system/basic/WskRestUnicodeJavaTests.scala
index 025261c..6b27621 100644
--- a/tests/src/test/scala/system/basic/WskRestUnicodeJavaTests.scala
+++ b/tests/src/test/scala/system/basic/WskRestUnicodeJavaTests.scala
@@ -22,12 +22,12 @@ import org.scalatest.junit.JUnitRunner
import common.JsHelpers
import common.WskTestHelpers
-import common.rest.WskRest
+import common.rest.WskRestOperations
@RunWith(classOf[JUnitRunner])
class WskRestUnicodeJavaTests extends WskUnicodeTests with WskTestHelpers with JsHelpers {
- override val wsk: common.rest.WskRest = new WskRest
+ override val wsk: common.rest.WskRestOperations = new WskRestOperations
override lazy val actionKind = "java"
override lazy val actionSource = "unicode.jar"
diff --git a/tests/src/test/scala/system/basic/WskRestUnicodeNode6Tests.scala b/tests/src/test/scala/system/basic/WskRestUnicodeNode6Tests.scala
index 5ebef6d..182dcec 100644
--- a/tests/src/test/scala/system/basic/WskRestUnicodeNode6Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestUnicodeNode6Tests.scala
@@ -22,12 +22,12 @@ import org.scalatest.junit.JUnitRunner
import common.JsHelpers
import common.WskTestHelpers
-import common.rest.WskRest
+import common.rest.WskRestOperations
@RunWith(classOf[JUnitRunner])
class WskRestUnicodeNode6Tests extends WskUnicodeTests with WskTestHelpers with JsHelpers {
- override val wsk: common.rest.WskRest = new WskRest
+ override val wsk: common.rest.WskRestOperations = new WskRestOperations
override lazy val actionKind = "nodejs:6"
override lazy val actionSource = "unicode.js"
diff --git a/tests/src/test/scala/system/basic/WskRestUnicodeNode8Tests.scala b/tests/src/test/scala/system/basic/WskRestUnicodeNode8Tests.scala
index 48a2e4d..35a7f29 100644
--- a/tests/src/test/scala/system/basic/WskRestUnicodeNode8Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestUnicodeNode8Tests.scala
@@ -22,12 +22,12 @@ import org.scalatest.junit.JUnitRunner
import common.JsHelpers
import common.WskTestHelpers
-import common.rest.WskRest
+import common.rest.WskRestOperations
@RunWith(classOf[JUnitRunner])
class WskRestUnicodeNode8Tests extends WskUnicodeTests with WskTestHelpers with JsHelpers {
- override val wsk: common.rest.WskRest = new WskRest
+ override val wsk: common.rest.WskRestOperations = new WskRestOperations
override lazy val actionKind = "nodejs:8"
override lazy val actionSource = "unicode.js"
diff --git a/tests/src/test/scala/system/basic/WskRestUnicodePython2Tests.scala b/tests/src/test/scala/system/basic/WskRestUnicodePython2Tests.scala
index e0612f6..a67e151 100644
--- a/tests/src/test/scala/system/basic/WskRestUnicodePython2Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestUnicodePython2Tests.scala
@@ -22,12 +22,12 @@ import org.scalatest.junit.JUnitRunner
import common.JsHelpers
import common.WskTestHelpers
-import common.rest.WskRest
+import common.rest.WskRestOperations
@RunWith(classOf[JUnitRunner])
class WskRestUnicodePython2Tests extends WskUnicodeTests with WskTestHelpers with JsHelpers {
- override val wsk: common.rest.WskRest = new WskRest
+ override val wsk: common.rest.WskRestOperations = new WskRestOperations
override lazy val actionKind = "python:2"
override lazy val actionSource = "unicode2.py"
diff --git a/tests/src/test/scala/system/basic/WskRestUnicodePython3Tests.scala b/tests/src/test/scala/system/basic/WskRestUnicodePython3Tests.scala
index 1202aba..6d74598 100644
--- a/tests/src/test/scala/system/basic/WskRestUnicodePython3Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestUnicodePython3Tests.scala
@@ -22,12 +22,12 @@ import org.scalatest.junit.JUnitRunner
import common.JsHelpers
import common.WskTestHelpers
-import common.rest.WskRest
+import common.rest.WskRestOperations
@RunWith(classOf[JUnitRunner])
class WskRestUnicodePython3Tests extends WskUnicodeTests with WskTestHelpers with JsHelpers {
- override val wsk: common.rest.WskRest = new WskRest
+ override val wsk: common.rest.WskRestOperations = new WskRestOperations
override lazy val actionKind = "python:3"
override lazy val actionSource = "unicode3.py"
diff --git a/tests/src/test/scala/system/basic/WskRestUnicodeSwift311Tests.scala b/tests/src/test/scala/system/basic/WskRestUnicodeSwift311Tests.scala
index fdb1924..3b1e5d9 100644
--- a/tests/src/test/scala/system/basic/WskRestUnicodeSwift311Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestUnicodeSwift311Tests.scala
@@ -22,12 +22,12 @@ import org.scalatest.junit.JUnitRunner
import common.JsHelpers
import common.WskTestHelpers
-import common.rest.WskRest
+import common.rest.WskRestOperations
@RunWith(classOf[JUnitRunner])
class WskRestUnicodeSwift311Tests extends WskUnicodeTests with WskTestHelpers with JsHelpers {
- override val wsk: common.rest.WskRest = new WskRest
+ override val wsk: common.rest.WskRestOperations = new WskRestOperations
override lazy val actionKind = "swift:3.1.1"
override lazy val actionSource = "unicode.swift"
diff --git a/tests/src/test/scala/system/basic/WskRestUnicodeSwift41Tests.scala b/tests/src/test/scala/system/basic/WskRestUnicodeSwift41Tests.scala
index 3ea4553..cd62237 100644
--- a/tests/src/test/scala/system/basic/WskRestUnicodeSwift41Tests.scala
+++ b/tests/src/test/scala/system/basic/WskRestUnicodeSwift41Tests.scala
@@ -18,14 +18,14 @@
package system.basic
import common.{JsHelpers, WskTestHelpers}
-import common.rest.WskRest
+import common.rest.WskRestOperations
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
class WskRestUnicodeSwift41Tests extends WskUnicodeTests with WskTestHelpers with JsHelpers {
- override val wsk: common.rest.WskRest = new WskRest
+ override val wsk: common.rest.WskRestOperations = new WskRestOperations
override lazy val actionKind = "swift:4.1"
override lazy val actionSource = "unicode.swift"
diff --git a/tests/src/test/scala/system/basic/WskRuleTests.scala b/tests/src/test/scala/system/basic/WskRuleTests.scala
index 29c99ea..e332aaa 100644
--- a/tests/src/test/scala/system/basic/WskRuleTests.scala
+++ b/tests/src/test/scala/system/basic/WskRuleTests.scala
@@ -22,7 +22,7 @@ import org.scalatest.junit.JUnitRunner
import common.TestHelpers
import common.TestUtils
import common.TestUtils.RunResult
-import common.BaseWsk
+import common.WskOperations
import common.WskProps
import common.WskTestHelpers
import common.RuleActivationResult
@@ -34,7 +34,7 @@ import java.time.Instant
abstract class WskRuleTests extends TestHelpers with WskTestHelpers {
implicit val wskprops = WskProps()
- val wsk: BaseWsk
+ val wsk: WskOperations
val defaultAction = TestUtils.getTestActionFilename("wc.js")
val secondAction = TestUtils.getTestActionFilename("hello.js")
val testString = "this is a test"
diff --git a/tests/src/test/scala/system/basic/WskSequenceTests.scala b/tests/src/test/scala/system/basic/WskSequenceTests.scala
index beb0ff3..5b9c509 100644
--- a/tests/src/test/scala/system/basic/WskSequenceTests.scala
+++ b/tests/src/test/scala/system/basic/WskSequenceTests.scala
@@ -32,7 +32,7 @@ import common.StreamLogging
import common.TestHelpers
import common.TestUtils
import common.TestUtils._
-import common.BaseWsk
+import common.WskOperations
import common.WskProps
import common.RuleActivationResult
import common.WskTestHelpers
@@ -52,7 +52,7 @@ import whisk.http.Messages.sequenceIsTooLong
abstract class WskSequenceTests extends TestHelpers with ScalatestRouteTest with WskTestHelpers with StreamLogging {
implicit val wskprops = WskProps()
- val wsk: BaseWsk
+ val wsk: WskOperations
val allowedActionDuration = 120 seconds
val shortDuration = 10 seconds
diff --git a/tests/src/test/scala/system/basic/WskUnicodeTests.scala b/tests/src/test/scala/system/basic/WskUnicodeTests.scala
index 8fe46cc..13f9376 100644
--- a/tests/src/test/scala/system/basic/WskUnicodeTests.scala
+++ b/tests/src/test/scala/system/basic/WskUnicodeTests.scala
@@ -23,7 +23,7 @@ import scala.concurrent.duration.DurationInt
import common.JsHelpers
import common.TestHelpers
import common.TestUtils
-import common.BaseWsk
+import common.WskOperations
import common.WskProps
import common.WskTestHelpers
import spray.json._
@@ -35,7 +35,7 @@ abstract class WskUnicodeTests extends TestHelpers with WskTestHelpers with JsHe
val actionSource: String
implicit val wskprops: common.WskProps = WskProps()
- val wsk: BaseWsk
+ val wsk: WskOperations
val activationMaxDuration = 2.minutes
val activationPollDuration = 3.minutes
diff --git a/tests/src/test/scala/system/rest/ActionSchemaTests.scala b/tests/src/test/scala/system/rest/ActionSchemaTests.scala
index 8db3259..7c6356e 100644
--- a/tests/src/test/scala/system/rest/ActionSchemaTests.scala
+++ b/tests/src/test/scala/system/rest/ActionSchemaTests.scala
@@ -29,7 +29,7 @@ import com.jayway.restassured.RestAssured
import common.TestUtils
import common.WhiskProperties
-import common.rest.WskRest
+import common.rest.WskRestOperations
import common.WskProps
import common.WskTestHelpers
import spray.json._
@@ -41,7 +41,7 @@ import spray.json._
class ActionSchemaTests extends FlatSpec with Matchers with RestUtil with JsonSchema with WskTestHelpers {
implicit val wskprops = WskProps()
- val wsk = new WskRest
+ val wsk = new WskRestOperations
val guestNamespace = wskprops.namespace
it should "respond to GET /actions as documented in swagger" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
diff --git a/tests/src/test/scala/whisk/common/UserEventTests.scala b/tests/src/test/scala/whisk/common/UserEventTests.scala
index 661b07e..cfa02dc 100644
--- a/tests/src/test/scala/whisk/common/UserEventTests.scala
+++ b/tests/src/test/scala/whisk/common/UserEventTests.scala
@@ -21,7 +21,7 @@ import java.nio.charset.StandardCharsets
import akka.actor.ActorSystem
import common._
-import common.rest.WskRest
+import common.rest.WskRestOperations
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.{BeforeAndAfterAll, FlatSpec, Matchers}
@@ -38,7 +38,7 @@ class UserEventTests extends FlatSpec with Matchers with WskTestHelpers with Str
implicit val system = ActorSystem("UserEventTestSystem")
val config = new WhiskConfig(WhiskConfig.kafkaHosts)
- val wsk = new WskRest
+ val wsk = new WskRestOperations
val groupid = "kafkatest"
val topic = "events"
diff --git a/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala b/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala
index e5bcff3..7251e1a 100644
--- a/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala
+++ b/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala
@@ -19,7 +19,7 @@ package whisk.core.admin
import common.WskAdmin.wskadmin
import common.{TestHelpers, TestUtils, WskAdmin, WskProps}
-import common.rest.WskRest
+import common.rest.WskRestOperations
import org.junit.runner.RunWith
import org.scalatest.{BeforeAndAfterAll, Matchers}
import org.scalatest.junit.JUnitRunner
@@ -115,7 +115,7 @@ class WskAdminTests extends TestHelpers with Matchers with BeforeAndAfterAll {
it should "verify guest account installed correctly" in {
implicit val wskprops = WskProps()
- val wsk = new WskRest
+ val wsk = new WskRestOperations
val ns = wsk.namespace.whois()
wskadmin.cli(Seq("user", "get", ns)).stdout.trim should be(wskprops.authKey)
}
diff --git a/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRestRoutemgmtActionTests.scala b/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRestRoutemgmtActionTests.scala
index aff8072..32584fc 100644
--- a/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRestRoutemgmtActionTests.scala
+++ b/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRestRoutemgmtActionTests.scala
@@ -20,12 +20,12 @@ package whisk.core.apigw.actions.test
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-import common.rest.WskRest
+import common.rest.WskRestOperations
/**
* Tests for basic CLI usage. Some of these tests require a deployed backend.
*/
@RunWith(classOf[JUnitRunner])
class ApiGwRestRoutemgmtActionTests extends ApiGwRoutemgmtActionTests {
- override lazy val wsk = new WskRest
+ override lazy val wsk = new WskRestOperations
}
diff --git a/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala b/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala
index b283af5..a2f09fe 100644
--- a/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala
+++ b/tests/src/test/scala/whisk/core/apigw/actions/test/ApiGwRoutemgmtActionTests.scala
@@ -27,7 +27,7 @@ import common.TestHelpers
import common.TestUtils.DONTCARE_EXIT
import common.TestUtils.RunResult
import common.TestUtils.SUCCESS_EXIT
-import common.BaseWsk
+import common.WskOperations
import common.WskActorSystem
import common.WskAdmin
import common.WskProps
@@ -50,7 +50,7 @@ abstract class ApiGwRoutemgmtActionTests
val systemId = "whisk.system"
implicit val wskprops = WskProps(authKey = WskAdmin.listKeys(systemId)(0)._1, namespace = systemId)
- val wsk: BaseWsk
+ val wsk: WskOperations
def getApis(bpOrName: Option[String],
relpath: Option[String] = None,
diff --git a/tests/src/test/scala/whisk/core/cli/test/ApiGwRestTests.scala b/tests/src/test/scala/whisk/core/cli/test/ApiGwRestTests.scala
index b118e81..dcb9104 100644
--- a/tests/src/test/scala/whisk/core/cli/test/ApiGwRestTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/ApiGwRestTests.scala
@@ -22,7 +22,7 @@ import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import spray.json.JsObject
import spray.json._
-import common.rest.WskRest
+import common.rest.WskRestOperations
import common.rest.RestResult
import common.TestUtils.{RunResult, _}
import common.TestUtils
@@ -34,7 +34,7 @@ import java.io.File
*/
@RunWith(classOf[JUnitRunner])
class ApiGwRestTests extends ApiGwRestBasicTests with RestUtil {
- override lazy val wsk = new WskRest
+ override lazy val wsk = new WskRestOperations
override lazy val createCode = OK.intValue
override def verifyBadCommands(rr: RunResult, badpath: String): Unit = {
diff --git a/tests/src/test/scala/whisk/core/cli/test/BaseApiGwTests.scala b/tests/src/test/scala/whisk/core/cli/test/BaseApiGwTests.scala
index 8aa24fc..5ebb00c 100644
--- a/tests/src/test/scala/whisk/core/cli/test/BaseApiGwTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/BaseApiGwTests.scala
@@ -33,7 +33,7 @@ import org.scalatest.junit.JUnitRunner
import common.TestHelpers
import common.TestUtils._
import common.WhiskProperties
-import common.BaseWsk
+import common.WskOperations
import common.WskProps
import common.WskTestHelpers
@@ -44,7 +44,7 @@ import common.WskTestHelpers
abstract class BaseApiGwTests extends TestHelpers with WskTestHelpers with BeforeAndAfterEach with BeforeAndAfterAll {
implicit val wskprops = WskProps()
- val wsk: BaseWsk
+ val wsk: WskOperations
// This test suite makes enough CLI invocations in 60 seconds to trigger the OpenWhisk
// throttling restriction. To avoid CLI failures due to being throttled, track the
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskActionSequenceTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskActionSequenceTests.scala
index 39b9efd..05aff02 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskActionSequenceTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskActionSequenceTests.scala
@@ -22,7 +22,7 @@ import org.scalatest.junit.JUnitRunner
import common.TestHelpers
import common.TestUtils
-import common.BaseWsk
+import common.WskOperations
import common.WskProps
import common.WskTestHelpers
import TestUtils.RunResult
@@ -36,7 +36,7 @@ import whisk.core.entity.EntityPath
abstract class WskActionSequenceTests extends TestHelpers with WskTestHelpers {
implicit val wskprops = WskProps()
- val wsk: BaseWsk
+ val wsk: WskOperations
val defaultNamespace = EntityPath.DEFAULT.asString
val namespace = wsk.namespace.whois()
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskEntitlementTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskEntitlementTests.scala
index e2d32a7..0e689c8 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskEntitlementTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskEntitlementTests.scala
@@ -24,7 +24,7 @@ import org.scalatest.junit.JUnitRunner
import common.TestHelpers
import common.TestUtils
import common.TestUtils.RunResult
-import common.BaseWsk
+import common.WskOperations
import common.WskProps
import common.WskTestHelpers
import spray.json._
@@ -36,7 +36,7 @@ import scala.concurrent.duration._
@RunWith(classOf[JUnitRunner])
abstract class WskEntitlementTests extends TestHelpers with WskTestHelpers with BeforeAndAfterAll {
- val wsk: BaseWsk
+ val wsk: WskOperations
lazy val defaultWskProps = WskProps()
lazy val guestWskProps = getAdditionalTestSubject(Subject().asString)
val forbiddenCode: Int
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskRestActionSequenceTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskRestActionSequenceTests.scala
index a96eb9e..955f9a3 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskRestActionSequenceTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskRestActionSequenceTests.scala
@@ -21,13 +21,13 @@ import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import spray.json._
-import common.rest.WskRest
+import common.rest.WskRestOperations
import common.rest.RestResult
import common.TestUtils.RunResult
@RunWith(classOf[JUnitRunner])
class WskRestActionSequenceTests extends WskActionSequenceTests {
- override lazy val wsk = new WskRest
+ override lazy val wsk = new WskRestOperations
override def verifyActionSequence(action: RunResult, name: String, compValue: JsArray, kindValue: JsString): Unit = {
val actionResultRest = action.asInstanceOf[RestResult]
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskRestBasicUsageTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskRestBasicUsageTests.scala
index 823abbf..c248ae1 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskRestBasicUsageTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskRestBasicUsageTests.scala
@@ -36,7 +36,7 @@ import common.TestUtils._
import common.WhiskProperties
import common.WskProps
import common.WskTestHelpers
-import common.rest.WskRest
+import common.rest.WskRestOperations
import spray.json.DefaultJsonProtocol._
import spray.json._
import whisk.core.entity._
@@ -51,7 +51,7 @@ import whisk.http.Messages
class WskRestBasicUsageTests extends TestHelpers with WskTestHelpers {
implicit val wskprops = WskProps()
- val wsk = new WskRest
+ val wsk = new WskRestOperations
val defaultAction: Some[String] = Some(TestUtils.getTestActionFilename("hello.js"))
val usrAgentHeaderRegEx: String = """\bUser-Agent\b": \[\s+"OpenWhisk\-CLI/1.\d+.*"""
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskRestEntitlementTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskRestEntitlementTests.scala
index 7395922..c017e5f 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskRestEntitlementTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskRestEntitlementTests.scala
@@ -24,13 +24,13 @@ import akka.http.scaladsl.model.StatusCodes.NotFound
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-import common.rest.WskRest
+import common.rest.WskRestOperations
import common.rest.RestResult
import common.TestUtils.RunResult
@RunWith(classOf[JUnitRunner])
class WskRestEntitlementTests extends WskEntitlementTests {
- override lazy val wsk = new WskRest
+ override lazy val wsk = new WskRestOperations
override lazy val forbiddenCode = Forbidden.intValue
override lazy val timeoutCode = BadGateway.intValue
override lazy val notFoundCode = NotFound.intValue
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskRestWebActionsTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskRestWebActionsTests.scala
index 832d365..517258e 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskRestWebActionsTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskRestWebActionsTests.scala
@@ -20,9 +20,9 @@ package whisk.core.cli.test
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
-import common.rest.WskRest
+import common.rest.WskRestOperations
@RunWith(classOf[JUnitRunner])
class WskRestWebActionsTests extends WskWebActionsTests {
- override lazy val wsk: common.rest.WskRest = new WskRest
+ override lazy val wsk: common.rest.WskRestOperations = new WskRestOperations
}
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
index b003e8d..a3b4f08 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
@@ -30,7 +30,7 @@ import com.jayway.restassured.response.Header
import common.TestHelpers
import common.TestUtils
import common.WhiskProperties
-import common.BaseWsk
+import common.WskOperations
import common.WskProps
import common.WskTestHelpers
import common.SimpleExec
@@ -48,7 +48,7 @@ import whisk.core.entity.Subject
abstract class WskWebActionsTests extends TestHelpers with WskTestHelpers with RestUtil with BeforeAndAfterAll {
val MAX_URL_LENGTH = 8192 // 8K matching nginx default
- val wsk: BaseWsk
+ val wsk: WskOperations
private implicit val wskprops = WskProps()
val namespace = wsk.namespace.whois()
diff --git a/tests/src/test/scala/whisk/core/database/test/CacheConcurrencyTests.scala b/tests/src/test/scala/whisk/core/database/test/CacheConcurrencyTests.scala
index d2d61bb..eadac08 100644
--- a/tests/src/test/scala/whisk/core/database/test/CacheConcurrencyTests.scala
+++ b/tests/src/test/scala/whisk/core/database/test/CacheConcurrencyTests.scala
@@ -32,7 +32,7 @@ import common.TestUtils
import common.WhiskProperties
import common.WskProps
import common.WskTestHelpers
-import common.rest.WskRest
+import common.rest.WskRestOperations
import spray.json.JsString
import whisk.common.TransactionId
import whisk.utils.retry
@@ -44,7 +44,7 @@ class CacheConcurrencyTests extends FlatSpec with WskTestHelpers with BeforeAndA
implicit private val transId = TransactionId.testing
implicit private val wp = WskProps()
- private val wsk = new WskRest
+ private val wsk = new WskRestOperations
val nExternalIters = 1
val nInternalIters = 5
diff --git a/tests/src/test/scala/whisk/core/limits/ActionLimitsTests.scala b/tests/src/test/scala/whisk/core/limits/ActionLimitsTests.scala
index 77999fb..5962fdc 100644
--- a/tests/src/test/scala/whisk/core/limits/ActionLimitsTests.scala
+++ b/tests/src/test/scala/whisk/core/limits/ActionLimitsTests.scala
@@ -32,7 +32,7 @@ import common.TestHelpers
import common.TestUtils
import common.TestUtils.{BAD_REQUEST, DONTCARE_EXIT, SUCCESS_EXIT}
import common.WhiskProperties
-import common.rest.WskRest
+import common.rest.WskRestOperations
import common.WskProps
import common.WskTestHelpers
import spray.json._
@@ -45,7 +45,7 @@ import whisk.http.Messages
class ActionLimitsTests extends TestHelpers with WskTestHelpers {
implicit val wskprops = WskProps()
- val wsk = new WskRest
+ val wsk = new WskRestOperations
val defaultSleepAction = TestUtils.getTestActionFilename("sleep.js")
val allowedActionDuration = 10 seconds
diff --git a/tests/src/test/scala/whisk/core/limits/MaxActionDurationTests.scala b/tests/src/test/scala/whisk/core/limits/MaxActionDurationTests.scala
index b35ffa8..95a0cbd 100644
--- a/tests/src/test/scala/whisk/core/limits/MaxActionDurationTests.scala
+++ b/tests/src/test/scala/whisk/core/limits/MaxActionDurationTests.scala
@@ -24,7 +24,7 @@ import org.scalatest.junit.JUnitRunner
import common.TestHelpers
import common.TestUtils
-import common.rest.WskRest
+import common.rest.WskRestOperations
import common.WskProps
import common.WskTestHelpers
import whisk.core.entity._
@@ -41,7 +41,7 @@ import org.scalatest.tagobjects.Slow
class MaxActionDurationTests extends TestHelpers with WskTestHelpers {
implicit val wskprops = WskProps()
- val wsk = new WskRest
+ val wsk = new WskRestOperations
/**
* Purpose of the following integration test is to verify that the action proxy
[incubator-openwhisk] 08/19: Remove unnecessary dependency
injection and flatten type hiearchy some more.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit 583862d4d8c1705eea1a6bc1749ee24703660651
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Fri Jun 8 16:18:51 2018 -0400
Remove unnecessary dependency injection and flatten type hiearchy some more.
---
tests/src/test/scala/common/BaseWsk.scala | 26 ++++++++++++--------------
tests/src/test/scala/common/rest/WskRest.scala | 19 +++++++++----------
2 files changed, 21 insertions(+), 24 deletions(-)
diff --git a/tests/src/test/scala/common/BaseWsk.scala b/tests/src/test/scala/common/BaseWsk.scala
index d91c578..53325e5 100644
--- a/tests/src/test/scala/common/BaseWsk.scala
+++ b/tests/src/test/scala/common/BaseWsk.scala
@@ -86,17 +86,7 @@ trait WaitFor {
}
}
-trait BaseRunWsk {
- /*
- * Utility function to return a JSON object from the CLI output that returns
- * an optional a status line following by the JSON data
- */
- def parseJsonString(jsonStr: String): JsObject = {
- jsonStr.substring(jsonStr.indexOf("\n") + 1).parseJson.asJsObject // Skip optional status line before parsing
- }
-}
-
-trait BaseWsk extends BaseRunWsk {
+trait BaseWsk {
val action: BaseAction
val trigger: BaseTrigger
val rule: BaseRule
@@ -104,9 +94,17 @@ trait BaseWsk extends BaseRunWsk {
val pkg: BasePackage
val namespace: BaseNamespace
val api: BaseApi
+
+ /*
+ * Utility function to return a JSON object from the CLI output that returns
+ * an optional a status line following by the JSON data
+ */
+ def parseJsonString(jsonStr: String): JsObject = {
+ jsonStr.substring(jsonStr.indexOf("\n") + 1).parseJson.asJsObject // Skip optional status line before parsing
+ }
}
-trait FullyQualifiedNames {
+object FullyQualifiedNames {
/**
* Fully qualifies the name of an entity with its namespace.
@@ -139,7 +137,7 @@ trait FullyQualifiedNames {
}
}
-trait BaseListOrGetFromCollection extends FullyQualifiedNames {
+trait BaseListOrGetFromCollection {
protected val noun: String
@@ -171,7 +169,7 @@ trait BaseListOrGetFromCollection extends FullyQualifiedNames {
saveAs: Option[String] = None)(implicit wp: WskProps): RunResult
}
-trait BaseDeleteFromCollection extends FullyQualifiedNames {
+trait BaseDeleteFromCollection {
protected val noun: String
diff --git a/tests/src/test/scala/common/rest/WskRest.scala b/tests/src/test/scala/common/rest/WskRest.scala
index a4d7ac6..a209735 100644
--- a/tests/src/test/scala/common/rest/WskRest.scala
+++ b/tests/src/test/scala/common/rest/WskRest.scala
@@ -155,8 +155,8 @@ class WskRest() extends RunWskRestCmd with BaseWsk {
override implicit val api = new WskRestApi
}
-trait ListOrGetFromCollectionRest extends BaseListOrGetFromCollection {
- self: RunWskRestCmd =>
+trait ListOrGetFromCollectionRest extends RunWskRestCmd with BaseListOrGetFromCollection {
+ import FullyQualifiedNames.resolve
/**
* List entities in collection.
@@ -202,14 +202,13 @@ trait ListOrGetFromCollectionRest extends BaseListOrGetFromCollection {
val (ns, entity) = getNamespaceEntityName(name)
val entPath = Path(s"$basePath/namespaces/$ns/$noun/$entity")
val resp = requestEntity(GET, entPath)(wp)
- val r = new RestResult(resp.status, getRespData(resp))
- validateStatusCode(expectedExitCode, r.statusCode.intValue)
- r
+ val rr = new RestResult(resp.status, getRespData(resp))
+ validateStatusCode(expectedExitCode, rr.statusCode.intValue)
+ rr
}
}
-trait DeleteFromCollectionRest extends BaseDeleteFromCollection {
- self: RunWskRestCmd =>
+trait DeleteFromCollectionRest extends RunWskRestCmd with BaseDeleteFromCollection {
/**
* Deletes entity from collection.
@@ -222,9 +221,9 @@ trait DeleteFromCollectionRest extends BaseDeleteFromCollection {
val (ns, entityName) = getNamespaceEntityName(name)
val path = Path(s"$basePath/namespaces/$ns/$noun/$entityName")
val resp = requestEntity(DELETE, path)(wp)
- val r = new RestResult(resp.status, getRespData(resp))
- validateStatusCode(expectedExitCode, r.statusCode.intValue)
- r
+ val rr = new RestResult(resp.status, getRespData(resp))
+ validateStatusCode(expectedExitCode, rr.statusCode.intValue)
+ rr
}
/**
[incubator-openwhisk] 16/19: Add back utility method used
downstream, with deprecation notice issued in logs.
Posted by md...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mdeuser pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
commit 49e89cbaa12b9aee8a0cb1c18f21a112c42df24a
Author: Rodric Rabbah <ro...@gmail.com>
AuthorDate: Sat Jun 9 01:15:04 2018 -0400
Add back utility method used downstream, with deprecation notice issued in logs.
---
tests/src/test/scala/common/WskTestHelpers.scala | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/tests/src/test/scala/common/WskTestHelpers.scala b/tests/src/test/scala/common/WskTestHelpers.scala
index 65d2f16..31e3d7c 100644
--- a/tests/src/test/scala/common/WskTestHelpers.scala
+++ b/tests/src/test/scala/common/WskTestHelpers.scala
@@ -320,6 +320,19 @@ trait WskTestHelpers extends Matchers {
wskadmin.cli(Seq("user", "delete", subject), expectedExitCode).stdout should include("Subject deleted")
}
}
- //Append the current timestamp in ms
+
+ /** Appends the current timestamp in ms. */
def withTimestamp(text: String) = s"${text}-${System.currentTimeMillis}"
+
+ /** Strips the first line if it ends in a new line as is common for CLI output. */
+ def removeCLIHeader(response: String): String = {
+ if (response.contains("\n")) response.substring(response.indexOf("\n")) else response
+ }
+
+ // using annotation will cause compile errors because we use -Xfatal-warnings
+ // @deprecated(message = "use wsk.parseJsonString instead", since = "pr #3741")
+ def getJSONFromResponse(response: String, isCli: Boolean = false): JsObject = {
+ println("!!! WARNING: method is deprecated; use wsk.parseJsonString instead")
+ if (isCli) removeCLIHeader(response).parseJson.asJsObject else response.parseJson.asJsObject
+ }
}