You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2017/11/10 16:52:08 UTC

[GitHub] houshengbo closed pull request #2931: Replace the test cases under whisk.core.cli.test package

houshengbo closed pull request #2931: Replace the test cases under whisk.core.cli.test package
URL: https://github.com/apache/incubator-openwhisk/pull/2931
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/tests/src/test/resources/application.conf b/tests/src/test/resources/application.conf
index 03b3e0df5b..39960d76af 100644
--- a/tests/src/test/resources/application.conf
+++ b/tests/src/test/resources/application.conf
@@ -1,5 +1,3 @@
-akka.ssl-config.hostnameVerifierClass = common.rest.AcceptAllHostNameVerifier
-
 whisk.spi {
   SimpleSpi = whisk.spi.SimpleSpiImpl
   MissingSpi = whisk.spi.MissingImpl
diff --git a/tests/src/test/scala/common/BaseWsk.scala b/tests/src/test/scala/common/BaseWsk.scala
index 9d7cafe980..0917fa6942 100644
--- a/tests/src/test/scala/common/BaseWsk.scala
+++ b/tests/src/test/scala/common/BaseWsk.scala
@@ -274,7 +274,7 @@ trait BaseActivation extends BaseRunWsk {
   def pollFor(N: Int,
               entity: Option[String],
               limit: Option[Int] = None,
-              since: Option[Instant],
+              since: Option[Instant] = None,
               retries: Int,
               pollPeriod: Duration = 1.second)(implicit wp: WskProps): Seq[String]
 
diff --git a/tests/src/test/scala/common/TestUtils.java b/tests/src/test/scala/common/TestUtils.java
index 0042445469..5f781055ba 100644
--- a/tests/src/test/scala/common/TestUtils.java
+++ b/tests/src/test/scala/common/TestUtils.java
@@ -64,13 +64,19 @@
     public static final int BAD_REQUEST     = 144;      // 400 - 256 = 144
     public static final int UNAUTHORIZED    = 145;      // 401 - 256 = 145
     public static final int FORBIDDEN       = 147;      // 403 - 256 = 147
+    public static final int FORBIDDEN_HTTP  = 403;
     public static final int NOT_FOUND       = 148;      // 404 - 256 = 148
+    public static final int NOT_FOUND_HTTP  = 404;
     public static final int NOT_ALLOWED     = 149;      // 405 - 256 = 149
     public static final int CONFLICT        = 153;      // 409 - 256 = 153
     public static final int TOO_LARGE       = 157;      // 413 - 256 = 157
+    public static final int TOO_LARGE_HTTP  = 413;
     public static final int THROTTLED       = 173;      // 429 (TOO_MANY_REQUESTS) - 256 = 173
+    public static final int THROTTLED_HTTP  = 429;
     public static final int APP_ERROR       = 246;      // 502 - 256 = 246
+    public static final int APP_ERROR_HTTP  = 502;
     public static final int TIMEOUT         = 246;      // 502 (GATEWAY_TIMEOUT) - 256 = 246
+    public static final int TIMEOUT_HTTP    = 502;
 
     private static final File catalogDir = WhiskProperties.getFileRelativeToWhiskHome("catalog");
     private static final File testActionsDir = WhiskProperties.getFileRelativeToWhiskHome("tests/dat/actions");
diff --git a/tests/src/test/scala/common/WhiskProperties.java b/tests/src/test/scala/common/WhiskProperties.java
index 915ed6a761..781f0bf91e 100644
--- a/tests/src/test/scala/common/WhiskProperties.java
+++ b/tests/src/test/scala/common/WhiskProperties.java
@@ -200,11 +200,20 @@ public static String getRouterHost() {
         return whiskProperties.getProperty("router.host");
     }
 
+    public static String getApiProto() {
+        return whiskProperties.getProperty("whisk.api.host.proto");
+    }
+
+    public static String getApiHost() {
+        return whiskProperties.getProperty("whisk.api.host.name");
+    }
+
+    public static String getApiPort() {
+        return whiskProperties.getProperty("whisk.api.host.port");
+    }
+
     public static String getApiHostForAction() {
-        String proto = whiskProperties.getProperty("whisk.api.host.proto");
-        String port = whiskProperties.getProperty("whisk.api.host.port");
-        String host = whiskProperties.getProperty("whisk.api.host.name");
-        return proto + "://" + host + ":" + port;
+        return getApiProto() + "://" + getApiHost() + ":" + getApiPort();
     }
 
     public static String getApiHostForClient(String subdomain, boolean includeProtocol) {
@@ -235,11 +244,11 @@ public static int getControllerBasePort() {
     }
 
     public static String getBaseControllerHost() {
-    	return getControllerHosts().split(",")[0];
+        return getControllerHosts().split(",")[0];
     }
 
     public static String getBaseControllerAddress() {
-    	return getBaseControllerHost() + ":" + getControllerBasePort();
+        return getBaseControllerHost() + ":" + getControllerBasePort();
     }
 
     public static int getMaxActionInvokesPerMinute() {
diff --git a/tests/src/test/scala/common/rest/WskRest.scala b/tests/src/test/scala/common/rest/WskRest.scala
index 199d7d6139..3e81f45c7e 100644
--- a/tests/src/test/scala/common/rest/WskRest.scala
+++ b/tests/src/test/scala/common/rest/WskRest.scala
@@ -35,12 +35,14 @@ import scala.collection.mutable.Buffer
 import scala.collection.immutable.Seq
 import scala.concurrent.duration.Duration
 import scala.concurrent.duration.DurationInt
-import scala.concurrent.Future
 import scala.language.postfixOps
 import scala.util.Failure
 import scala.util.Success
 import scala.util.Try
 import scala.util.{Failure, Success}
+import akka.stream.scaladsl.{Keep, Sink, Source}
+import akka.stream.{OverflowStrategy, QueueOfferResult}
+import scala.concurrent.{Future, Promise}
 
 import akka.http.scaladsl.model.StatusCode
 import akka.http.scaladsl.model.StatusCodes.Accepted
@@ -62,6 +64,7 @@ import akka.http.scaladsl.model.HttpMethods.GET
 import akka.http.scaladsl.model.HttpMethods.POST
 import akka.http.scaladsl.model.HttpMethods.PUT
 import akka.http.scaladsl.HttpsConnectionContext
+import akka.http.scaladsl.settings.ConnectionPoolSettings
 
 import akka.stream.ActorMaterializer
 
@@ -95,7 +98,7 @@ import javax.net.ssl.{HostnameVerifier, KeyManager, SSLContext, SSLSession, X509
 import com.typesafe.sslconfig.akka.AkkaSSLConfig
 
 class AcceptAllHostNameVerifier extends HostnameVerifier {
-  def verify(s: String, sslSession: SSLSession) = true
+  override def verify(s: String, sslSession: SSLSession): Boolean = true
 }
 
 object SSL {
@@ -138,8 +141,9 @@ trait ListOrGetFromCollectionRest extends BaseListOrGetFromCollection {
                     expectedExitCode: Int = OK.intValue)(implicit wp: WskProps): RestResult = {
 
     val entPath = namespace map { ns =>
-      val (ns, name) = getNamespaceEntityName(resolve(namespace))
-      Path(s"$basePath/namespaces/$ns/$noun/$name/")
+      val (nspace, name) = getNamespaceEntityName(resolve(namespace))
+      if (name.isEmpty) Path(s"$basePath/namespaces/$nspace/$noun")
+      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) } ++ {
@@ -374,14 +378,23 @@ class WskRestAction
       }
     } else {
       bodyContent = bodyContent ++ Map("exec" -> exec.toJson, "parameters" -> params, "annotations" -> annos)
+    }
 
-      bodyContent = bodyContent ++ {
-        timeout map { t =>
-          Map("limits" -> JsObject("timeout" -> t.toMillis.toJson))
-        } getOrElse Map[String, JsValue]()
-      }
+    val limits = Map[String, JsValue]() ++ {
+      timeout map { t =>
+        Map("timeout" -> t.toMillis.toJson)
+      } getOrElse Map[String, JsValue]()
+    } ++ {
+      logsize map { log =>
+        Map("logs" -> log.toMB.toJson)
+      } getOrElse Map[String, JsValue]()
+    } ++ {
+      memory map { m =>
+        Map("memory" -> m.toMB.toJson)
+      } getOrElse Map[String, JsValue]()
     }
 
+    bodyContent = if (!limits.isEmpty) bodyContent ++ Map("limits" -> limits.toJson) else bodyContent
     val path = Path(s"$basePath/namespaces/$namespace/$noun/$actName")
     val resp =
       if (update) requestEntity(PUT, path, Map("overwrite" -> "true"), Some(JsObject(bodyContent).toString))
@@ -1138,16 +1151,21 @@ class RunWskRestCmd() extends FlatSpec with RunWskCmd with Matchers with ScalaFu
 
   implicit val config = PatienceConfig(100 seconds, 15 milliseconds)
   implicit val materializer = ActorMaterializer()
-  val whiskRestUrl = Uri(WhiskProperties.getApiHostForAction)
+  val queueSize = 10
+  val maxOpenRequest = 1024
   val basePath = Path("/api/v1")
 
   val sslConfig = AkkaSSLConfig().mapSettings { s =>
-    s.withLoose(s.loose.withAcceptAnyCertificate(true).withDisableHostnameVerification(true))
+    s.withHostnameVerifierClass(classOf[AcceptAllHostNameVerifier].asInstanceOf[Class[HostnameVerifier]])
   }
+
   val connectionContext = new HttpsConnectionContext(SSL.nonValidatingContext, Some(sslConfig))
 
   def isStatusCodeExpected(expectedExitCode: Int, statusCode: Int): Boolean = {
-    return statusCode == expectedExitCode
+    if ((expectedExitCode != DONTCARE_EXIT) && (expectedExitCode != ANY_ERROR_EXIT))
+      statusCode == expectedExitCode
+    else
+      true
   }
 
   def validateStatusCode(expectedExitCode: Int, statusCode: Int) = {
@@ -1175,15 +1193,38 @@ class RunWskRestCmd() extends FlatSpec with RunWskCmd with Matchers with ScalaFu
       HttpEntity(ContentTypes.`application/json`, b)
     } getOrElse HttpEntity(ContentTypes.`application/json`, "")
     val request = HttpRequest(method, uri, List(Authorization(creds)), entity = entity)
-
-    Http().singleRequest(request, connectionContext)
+    val connectionPoolSettings = ConnectionPoolSettings(actorSystem).withMaxOpenRequests(maxOpenRequest)
+    val pool = Http().cachedHostConnectionPoolHttps[Promise[HttpResponse]](
+      host = WhiskProperties.getApiHost,
+      connectionContext = connectionContext,
+      settings = connectionPoolSettings)
+    val queue = Source
+      .queue[(HttpRequest, Promise[HttpResponse])](queueSize, OverflowStrategy.dropNew)
+      .via(pool)
+      .toMat(Sink.foreach({
+        case ((Success(resp), p)) => p.success(resp)
+        case ((Failure(e), p))    => p.failure(e)
+      }))(Keep.left)
+      .run
+
+    val promise = Promise[HttpResponse]
+    val responsePromise = Promise[HttpResponse]()
+    queue.offer(request -> responsePromise).flatMap {
+      case QueueOfferResult.Enqueued => responsePromise.future
+      case QueueOfferResult.Dropped =>
+        Future.failed(new RuntimeException("Queue has overflowed. Please try again later."))
+      case QueueOfferResult.Failure(ex) => Future.failed(ex)
+      case QueueOfferResult.QueueClosed =>
+        Future.failed(
+          new RuntimeException("Queue was closed (pool shut down) while running the request. Please try again later."))
+    }
   }
 
   def requestEntity(method: HttpMethod,
                     path: Path,
                     params: Map[String, String] = Map(),
                     body: Option[String] = None,
-                    whiskUrl: Uri = whiskRestUrl)(implicit wp: WskProps): HttpResponse = {
+                    whiskUrl: Uri = Uri(""))(implicit wp: WskProps): HttpResponse = {
     val creds = getBasicHttpCredentials(wp)
     request(method, whiskUrl.withPath(path).withQuery(Uri.Query(params)), body, creds = creds).futureValue
   }
@@ -1218,7 +1259,6 @@ class RunWskRestCmd() extends FlatSpec with RunWskCmd with Matchers with ScalaFu
   }
 
   def convertStringIntoKeyValue(file: String, feed: Option[String] = None, web: Option[String] = None): JsArray = {
-    var paramsList = Vector[JsObject]()
     val input = FileUtils.readFileToString(new File(file))
     val in = input.parseJson.convertTo[Map[String, JsValue]]
     convertMapIntoKeyValue(in, feed, web)
@@ -1232,9 +1272,21 @@ class RunWskRestCmd() extends FlatSpec with RunWskCmd with Matchers with ScalaFu
     paramsList = feed map { f =>
       paramsList :+ JsObject("key" -> "feed".toJson, "value" -> f.toJson)
     } getOrElse paramsList
-    paramsList = web map { w =>
-      paramsList :+ JsObject("key" -> "web-export".toJson, "value" -> w.toJson)
-    } getOrElse paramsList
+    paramsList = web match {
+      case Some("true") =>
+        paramsList :+ JsObject("key" -> "web-export".toJson, "value" -> true.toJson) :+ JsObject(
+          "key" -> "raw-http".toJson,
+          "value" -> false.toJson) :+ JsObject("key" -> "final".toJson, "value" -> true.toJson)
+      case Some("false") =>
+        paramsList :+ JsObject("key" -> "web-export".toJson, "value" -> false.toJson) :+ JsObject(
+          "key" -> "raw-http".toJson,
+          "value" -> false.toJson) :+ JsObject("key" -> "final".toJson, "value" -> false.toJson)
+      case Some("raw") =>
+        paramsList :+ JsObject("key" -> "web-export".toJson, "value" -> true.toJson) :+ JsObject(
+          "key" -> "raw-http".toJson,
+          "value" -> true.toJson) :+ JsObject("key" -> "final".toJson, "value" -> true.toJson)
+      case _ => paramsList
+    }
     JsArray(paramsList)
   }
 
@@ -1277,8 +1329,10 @@ class RunWskRestCmd() extends FlatSpec with RunWskCmd with Matchers with ScalaFu
       case Array(empty, namespace, entityName) if empty.isEmpty => (namespace, entityName)
       // Example: namespace/package_name/entity_name
       case Array(namespace, packageName, entityName) => (namespace, s"$packageName/$entityName")
+      // Example: /namespace
+      case Array(empty, namespace) if empty.isEmpty => (namespace, "")
       // Example: package_name/entity_name
-      case Array(packageName, entityName) => (wp.namespace, s"$packageName/$entityName")
+      case Array(packageName, entityName) if !packageName.isEmpty => (wp.namespace, s"$packageName/$entityName")
       // Example: entity_name
       case Array(entityName) => (wp.namespace, entityName)
       case _                 => (wp.namespace, name)
@@ -1298,7 +1352,7 @@ class RunWskRestCmd() extends FlatSpec with RunWskCmd with Matchers with ScalaFu
       Some(FileUtils.readFileToString(new File(pf)))
     } getOrElse Some(parameters.toJson.toString())
     val resp = requestEntity(POST, path, paramMap, input)
-    val r = new RestResult(resp.status.intValue, getRespData(resp))
+    val r = 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)) {
@@ -1393,8 +1447,8 @@ object RestResult {
     obj.fields.get(key).map(_.convertTo[Vector[JsObject]]).getOrElse(Vector(JsObject()))
   }
 
-  def convertStausCodeToExitCode(statusCode: StatusCode): Int = {
-    if (statusCode == OK)
+  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
   }
@@ -1408,9 +1462,9 @@ object RestResult {
   }
 }
 
-class RestResult(var statusCode: StatusCode, var respData: String = "")
+class RestResult(var statusCode: StatusCode, var respData: String = "", blocking: Boolean = false)
     extends RunResult(
-      RestResult.convertStausCodeToExitCode(statusCode),
+      RestResult.convertStausCodeToExitCode(statusCode, blocking),
       respData,
       RestResult.convertHttpResponseToStderr(respData)) {
 
diff --git a/tests/src/test/scala/ha/ShootComponentsTests.scala b/tests/src/test/scala/ha/ShootComponentsTests.scala
index 4b28ded8ed..fa1aba121e 100644
--- a/tests/src/test/scala/ha/ShootComponentsTests.scala
+++ b/tests/src/test/scala/ha/ShootComponentsTests.scala
@@ -36,7 +36,7 @@ import akka.http.scaladsl.unmarshalling.Unmarshal
 import akka.stream.ActorMaterializer
 import common.TestUtils
 import common.WhiskProperties
-import common.Wsk
+import common.rest.WskRest
 import common.WskActorSystem
 import common.WskProps
 import common.WskTestHelpers
@@ -47,7 +47,7 @@ import whisk.utils.retry
 class ShootComponentsTests extends FlatSpec with Matchers with WskTestHelpers with ScalaFutures with WskActorSystem {
 
   implicit val wskprops = WskProps()
-  val wsk = new Wsk
+  val wsk = new WskRest
   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 8da66e811d..eef21eee3a 100644
--- a/tests/src/test/scala/limits/ThrottleTests.scala
+++ b/tests/src/test/scala/limits/ThrottleTests.scala
@@ -34,7 +34,7 @@ import common.TestHelpers
 import common.TestUtils
 import common.TestUtils._
 import common.WhiskProperties
-import common.Wsk
+import common.rest.WskRest
 import common.WskActorSystem
 import common.WskProps
 import common.WskTestHelpers
@@ -65,7 +65,7 @@ class ThrottleTests
 
   implicit val testConfig = PatienceConfig(5.minutes)
   implicit val wskprops = WskProps()
-  val wsk = new Wsk
+  val wsk = new WskRest
   val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
 
   val throttleWindow = 1.minute
@@ -296,7 +296,7 @@ class NamespaceSpecificThrottleTests
     with LocalHelper {
 
   val wskadmin = new RunWskAdminCmd {}
-  val wsk = new Wsk
+  val wsk = new WskRest
 
   val defaultAction = Some(TestUtils.getTestActionFilename("hello.js"))
 
@@ -346,10 +346,10 @@ class NamespaceSpecificThrottleTests
       trigger.create(triggerName)
     }
 
-    wsk.action.invoke(actionName, expectedExitCode = TestUtils.THROTTLED).stderr should {
+    wsk.action.invoke(actionName, expectedExitCode = TestUtils.THROTTLED_HTTP).stderr should {
       include(prefix(tooManyRequests(0, 0))) and include("allowed: 0")
     }
-    wsk.trigger.fire(triggerName, expectedExitCode = TestUtils.THROTTLED).stderr should {
+    wsk.trigger.fire(triggerName, expectedExitCode = TestUtils.THROTTLED_HTTP).stderr should {
       include(prefix(tooManyRequests(0, 0))) and include("allowed: 0")
     }
   }
@@ -401,7 +401,7 @@ class NamespaceSpecificThrottleTests
       action.create(actionName, defaultAction)
     }
 
-    wsk.action.invoke(actionName, expectedExitCode = TestUtils.THROTTLED).stderr should {
+    wsk.action.invoke(actionName, expectedExitCode = TestUtils.THROTTLED_HTTP).stderr should {
       include(prefix(tooManyConcurrentRequests(0, 0))) and include("allowed: 0")
     }
   }
diff --git a/tests/src/test/scala/services/HeadersTests.scala b/tests/src/test/scala/services/HeadersTests.scala
index 6d0b4c267f..f3184c87f1 100644
--- a/tests/src/test/scala/services/HeadersTests.scala
+++ b/tests/src/test/scala/services/HeadersTests.scala
@@ -31,7 +31,7 @@ import org.scalatest.time.Span.convertDurationToSpan
 
 import common.TestUtils
 import common.WhiskProperties
-import common.Wsk
+import common.rest.WskRest
 import common.WskProps
 import common.WskTestHelpers
 
@@ -82,7 +82,7 @@ class HeadersTests extends FlatSpec with Matchers with ScalaFutures with WskActo
 
   val basePath = Path("/api/v1")
   implicit val wskprops = WskProps()
-  val wsk = new Wsk
+  val wsk = new WskRest
 
   /**
    * Checks, if the required headers are in the list of all headers.
diff --git a/tests/src/test/scala/system/rest/ActionSchemaTests.scala b/tests/src/test/scala/system/rest/ActionSchemaTests.scala
index 9b0560aec1..b88b231887 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.Wsk
+import common.rest.WskRest
 import common.WskProps
 import common.WskTestHelpers
 import spray.json.JsArray
@@ -43,7 +43,7 @@ import spray.json.pimpString
 class ActionSchemaTests extends FlatSpec with Matchers with RestUtil with JsonSchema with WskTestHelpers {
 
   implicit val wskprops = WskProps()
-  val wsk = new Wsk
+  val wsk = new WskRest
   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/core/admin/WskAdminTests.scala b/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala
index c42e2e8cf9..b2bc3b4289 100644
--- a/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala
+++ b/tests/src/test/scala/whisk/core/admin/WskAdminTests.scala
@@ -25,7 +25,7 @@ import org.scalatest.junit.JUnitRunner
 
 import common.RunWskAdminCmd
 import common.TestHelpers
-import common.Wsk
+import common.rest.WskRest
 import common.WskAdmin
 import common.WskProps
 import whisk.core.entity.AuthKey
@@ -87,7 +87,7 @@ class WskAdminTests extends TestHelpers with Matchers {
   it should "verify guest account installed correctly" in {
     val wskadmin = new RunWskAdminCmd {}
     implicit val wskprops = WskProps()
-    val wsk = new Wsk
+    val wsk = new WskRest
     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/cli/test/SequenceMigrationTests.scala b/tests/src/test/scala/whisk/core/cli/test/SequenceMigrationTests.scala
index 977505f4f1..acc0361867 100644
--- a/tests/src/test/scala/whisk/core/cli/test/SequenceMigrationTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/SequenceMigrationTests.scala
@@ -29,7 +29,7 @@ import org.scalatest.junit.JUnitRunner
 import akka.stream.ActorMaterializer
 import common.TestHelpers
 import common.TestUtils
-import common.Wsk
+import common.rest.WskRest
 import common.WskProps
 import common.WskTestHelpers
 import spray.json._
@@ -47,7 +47,7 @@ class SequenceMigrationTests extends TestHelpers with BeforeAndAfter with DbUtil
 
   implicit val matzerializer = ActorMaterializer()
   implicit val wskprops = WskProps()
-  val wsk = new Wsk
+  val wsk = new WskRest
   val whiskConfig = new WhiskConfig(WhiskEntityStore.requiredProperties)
   // handle on the entity datastore
   val entityStore = WhiskEntityStore.datastore(whiskConfig)
diff --git a/tests/src/test/scala/whisk/core/cli/test/Swift311Tests.scala b/tests/src/test/scala/whisk/core/cli/test/Swift311Tests.scala
index a879475d28..6c8a5c978e 100644
--- a/tests/src/test/scala/whisk/core/cli/test/Swift311Tests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/Swift311Tests.scala
@@ -23,5 +23,5 @@ import org.scalatest.junit.JUnitRunner
 @RunWith(classOf[JUnitRunner])
 class Swift311Tests extends Swift3Tests {
 
-  override lazy val runtimeContainer = "swift:3.1.1"
+  override lazy val runtimeContainer: String = "swift:3.1.1"
 }
diff --git a/tests/src/test/scala/whisk/core/cli/test/Swift3Tests.scala b/tests/src/test/scala/whisk/core/cli/test/Swift3Tests.scala
index 513cf9405a..5d4c02fa6c 100644
--- a/tests/src/test/scala/whisk/core/cli/test/Swift3Tests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/Swift3Tests.scala
@@ -24,7 +24,7 @@ import org.scalatest.Matchers
 import org.scalatest.junit.JUnitRunner
 import common.TestHelpers
 import common.TestUtils
-import common.Wsk
+import common.rest.WskRest
 import common.WskProps
 import common.WskTestHelpers
 import spray.json.DefaultJsonProtocol.StringJsonFormat
@@ -34,7 +34,7 @@ import spray.json.pimpAny
 class Swift3Tests extends TestHelpers with WskTestHelpers with Matchers {
 
   implicit val wskprops = WskProps()
-  val wsk = new Wsk
+  val wsk = new WskRest
   val expectedDuration = 45 seconds
   val activationPollDuration = 60 seconds
 
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 b547cb48a9..ab12ceb294 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskActionSequenceTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskActionSequenceTests.scala
@@ -22,9 +22,10 @@ import org.scalatest.junit.JUnitRunner
 
 import common.TestHelpers
 import common.TestUtils
-import common.Wsk
+import common.BaseWsk
 import common.WskProps
 import common.WskTestHelpers
+import TestUtils.RunResult
 import spray.json._
 import whisk.core.entity.EntityPath
 
@@ -32,12 +33,12 @@ import whisk.core.entity.EntityPath
  * Tests creation and retrieval of a sequence action
  */
 @RunWith(classOf[JUnitRunner])
-class WskActionSequenceTests extends TestHelpers with WskTestHelpers {
+abstract class WskActionSequenceTests extends TestHelpers with WskTestHelpers {
 
-  implicit val wskprops = WskProps()
-  val wsk = new Wsk
+  implicit val wskprops: common.WskProps = WskProps()
+  val wsk: BaseWsk
   val defaultNamespace = EntityPath.DEFAULT.asString
-  val namespace = wsk.namespace.whois()
+  val namespace: String = wsk.namespace.whois()
 
   behavior of "Wsk Action Sequence"
 
@@ -75,7 +76,12 @@ class WskActionSequenceTests extends TestHelpers with WskTestHelpers {
       action.create(name, Some(artifacts), kind = Some("sequence"))
     }
 
-    val stdout = wsk.action.get(name).stdout
+    val action = wsk.action.get(name)
+    verifyActionSequence(action, name, compValue, kindValue)
+  }
+
+  def verifyActionSequence(action: RunResult, name: String, compValue: JsArray, kindValue: JsString): Unit = {
+    val stdout = action.stdout
     assert(stdout.startsWith(s"ok: got action $name\n"))
     wsk.parseJsonString(stdout).fields("exec").asJsObject.fields("components") shouldBe compValue
     wsk.parseJsonString(stdout).fields("exec").asJsObject.fields("kind") shouldBe kindValue
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskCliActionSequenceTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskCliActionSequenceTests.scala
new file mode 100644
index 0000000000..06da3489ed
--- /dev/null
+++ b/tests/src/test/scala/whisk/core/cli/test/WskCliActionSequenceTests.scala
@@ -0,0 +1,28 @@
+/*
+ * 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 org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+import common.Wsk
+
+@RunWith(classOf[JUnitRunner])
+class WskCliActionSequenceTests extends WskActionSequenceTests {
+  override lazy val wsk = new Wsk
+}
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskCliEntitlementTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskCliEntitlementTests.scala
new file mode 100644
index 0000000000..e25369cbc1
--- /dev/null
+++ b/tests/src/test/scala/whisk/core/cli/test/WskCliEntitlementTests.scala
@@ -0,0 +1,34 @@
+/*
+ * 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 org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+import common.Wsk
+import common.TestUtils.FORBIDDEN
+import common.TestUtils.TIMEOUT
+import common.TestUtils.NOT_FOUND
+
+@RunWith(classOf[JUnitRunner])
+class WskCliEntitlementTests extends WskEntitlementTests {
+  override lazy val wsk = new Wsk
+  override lazy val forbiddenCode = FORBIDDEN
+  override lazy val timeoutCode = TIMEOUT
+  override lazy val notFoundCode = NOT_FOUND
+}
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskCliWebActionsTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskCliWebActionsTests.scala
new file mode 100644
index 0000000000..048fdced5b
--- /dev/null
+++ b/tests/src/test/scala/whisk/core/cli/test/WskCliWebActionsTests.scala
@@ -0,0 +1,28 @@
+/*
+ * 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 org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+import common.Wsk
+
+@RunWith(classOf[JUnitRunner])
+class WskCliWebActionsTests extends WskWebActionsTests {
+  override lazy val wsk: common.Wsk = new Wsk
+}
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 cd58febd28..e2abe442fa 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskEntitlementTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskEntitlementTests.scala
@@ -23,10 +23,8 @@ import org.scalatest.junit.JUnitRunner
 
 import common.TestHelpers
 import common.TestUtils
-import common.TestUtils.FORBIDDEN
-import common.TestUtils.NOT_FOUND
-import common.TestUtils.TIMEOUT
-import common.Wsk
+import common.TestUtils.RunResult
+import common.BaseWsk
 import common.WskProps
 import common.WskTestHelpers
 import spray.json._
@@ -35,17 +33,21 @@ import whisk.core.entity.Subject
 import whisk.core.entity.WhiskPackage
 
 @RunWith(classOf[JUnitRunner])
-class WskEntitlementTests extends TestHelpers with WskTestHelpers with BeforeAndAfterAll {
+abstract class WskEntitlementTests extends TestHelpers with WskTestHelpers with BeforeAndAfterAll {
 
-  val wsk = new Wsk
+  val wsk: BaseWsk
   lazy val defaultWskProps = WskProps()
   lazy val guestWskProps = getAdditionalTestSubject(Subject().asString)
+  val forbiddenCode: Int
+  val timeoutCode: Int
+  val notFoundCode: Int
 
   override def afterAll() = {
     disposeAdditionalTestSubject(guestWskProps.namespace)
   }
 
   val samplePackage = "samplePackage"
+  val samplePackage1 = "samplePackage1"
   val sampleAction = "sampleAction"
   val fullSampleActionName = s"$samplePackage/$sampleAction"
   val guestNamespace = guestWskProps.namespace
@@ -61,12 +63,13 @@ class WskEntitlementTests extends TestHelpers with WskTestHelpers with BeforeAnd
       }
 
       val fullyQualifiedActionName = s"/$guestNamespace/$privateAction"
-      wsk.action.get(fullyQualifiedActionName, expectedExitCode = FORBIDDEN)(defaultWskProps).stderr should include(
-        "not authorized")
+      wsk.action
+        .get(fullyQualifiedActionName, expectedExitCode = forbiddenCode)(defaultWskProps)
+        .stderr should include("not authorized")
 
       withAssetCleaner(defaultWskProps) { (wp, assetHelper) =>
         assetHelper.withCleaner(wsk.action, fullyQualifiedActionName, confirmDelete = false) { (action, name) =>
-          val rr = action.create(name, None, update = true, expectedExitCode = FORBIDDEN)(wp)
+          val rr = action.create(name, None, update = true, expectedExitCode = forbiddenCode)(wp)
           rr.stderr should include("not authorized")
           rr
         }
@@ -77,17 +80,19 @@ class WskEntitlementTests extends TestHelpers with WskTestHelpers with BeforeAnd
             Some(fullyQualifiedActionName),
             kind = Some("sequence"),
             update = true,
-            expectedExitCode = FORBIDDEN)(wp)
+            expectedExitCode = forbiddenCode)(wp)
           rr.stderr should include("not authorized")
           rr
         }
       }
 
-      wsk.action.delete(fullyQualifiedActionName, expectedExitCode = FORBIDDEN)(defaultWskProps).stderr should include(
-        "not authorized")
+      wsk.action
+        .delete(fullyQualifiedActionName, expectedExitCode = forbiddenCode)(defaultWskProps)
+        .stderr should include("not authorized")
 
-      wsk.action.invoke(fullyQualifiedActionName, expectedExitCode = FORBIDDEN)(defaultWskProps).stderr should include(
-        "not authorized")
+      wsk.action
+        .invoke(fullyQualifiedActionName, expectedExitCode = forbiddenCode)(defaultWskProps)
+        .stderr should include("not authorized")
   }
 
   it should "reject deleting action in shared package not owned by authkey" in withAssetCleaner(guestWskProps) {
@@ -104,7 +109,7 @@ class WskEntitlementTests extends TestHelpers with WskTestHelpers with BeforeAnd
 
       val fullyQualifiedActionName = s"/$guestNamespace/$fullSampleActionName"
       wsk.action.get(fullyQualifiedActionName)(defaultWskProps)
-      wsk.action.delete(fullyQualifiedActionName, expectedExitCode = FORBIDDEN)(defaultWskProps)
+      wsk.action.delete(fullyQualifiedActionName, expectedExitCode = forbiddenCode)(defaultWskProps)
   }
 
   it should "reject create action in shared package not owned by authkey" in withAssetCleaner(guestWskProps) {
@@ -118,7 +123,7 @@ class WskEntitlementTests extends TestHelpers with WskTestHelpers with BeforeAnd
 
       withAssetCleaner(defaultWskProps) { (wp, assetHelper) =>
         assetHelper.withCleaner(wsk.action, fullyQualifiedActionName, confirmDelete = false) { (action, name) =>
-          action.create(name, file, expectedExitCode = FORBIDDEN)(wp)
+          action.create(name, file, expectedExitCode = forbiddenCode)(wp)
         }
       }
   }
@@ -136,7 +141,8 @@ class WskEntitlementTests extends TestHelpers with WskTestHelpers with BeforeAnd
       }
 
       val fullyQualifiedActionName = s"/$guestNamespace/$fullSampleActionName"
-      wsk.action.create(fullyQualifiedActionName, None, update = true, expectedExitCode = FORBIDDEN)(defaultWskProps)
+      wsk.action.create(fullyQualifiedActionName, None, update = true, expectedExitCode = forbiddenCode)(
+        defaultWskProps)
   }
 
   behavior of "Wsk Package Listing"
@@ -146,9 +152,13 @@ class WskEntitlementTests extends TestHelpers with WskTestHelpers with BeforeAnd
       pkg.create(samplePackage, shared = Some(true))(wp)
     }
 
-    val fullyQualifiedPackageName = s"/$guestNamespace/$samplePackage"
-    val result = wsk.pkg.list(Some(s"/$guestNamespace"))(defaultWskProps).stdout
-    result should include regex (fullyQualifiedPackageName + """\s+shared""")
+    val packageList = wsk.pkg.list(Some(s"/$guestNamespace"))(defaultWskProps)
+    verifyPackageSharedList(packageList, guestNamespace, samplePackage)
+  }
+
+  def verifyPackageSharedList(packageList: RunResult, namespace: String, packageName: String): Unit = {
+    val fullyQualifiedPackageName = s"/$namespace/$packageName"
+    packageList.stdout should include regex (fullyQualifiedPackageName + """\s+shared""")
   }
 
   it should "not list private packages" in withAssetCleaner(guestWskProps) { (wp, assetHelper) =>
@@ -156,9 +166,13 @@ class WskEntitlementTests extends TestHelpers with WskTestHelpers with BeforeAnd
       pkg.create(samplePackage)(wp)
     }
 
-    val fullyQualifiedPackageName = s"/$guestNamespace/$samplePackage"
-    val result = wsk.pkg.list(Some(s"/$guestNamespace"))(defaultWskProps).stdout
-    result should not include regex(fullyQualifiedPackageName)
+    val packageList = wsk.pkg.list(Some(s"/$guestNamespace"))(defaultWskProps)
+    verifyPackageNotSharedList(packageList, guestNamespace, samplePackage)
+  }
+
+  def verifyPackageNotSharedList(packageList: RunResult, namespace: String, packageName: String): Unit = {
+    val fullyQualifiedPackageName = s"/$namespace/$packageName"
+    packageList.stdout should not include regex(fullyQualifiedPackageName)
   }
 
   it should "list shared package actions" in withAssetCleaner(guestWskProps) { (wp, assetHelper) =>
@@ -173,9 +187,13 @@ class WskEntitlementTests extends TestHelpers with WskTestHelpers with BeforeAnd
     }
 
     val fullyQualifiedPackageName = s"/$guestNamespace/$samplePackage"
-    val fullyQualifiedActionName = s"/$guestNamespace/$fullSampleActionName"
-    val result = wsk.action.list(Some(fullyQualifiedPackageName))(defaultWskProps).stdout
-    result should include regex (fullyQualifiedActionName)
+    val packageList = wsk.action.list(Some(fullyQualifiedPackageName))(defaultWskProps)
+    verifyPackageList(packageList, guestNamespace, samplePackage, sampleAction)
+  }
+
+  def verifyPackageList(packageList: RunResult, namespace: String, packageName: String, actionName: String): Unit = {
+    val result = packageList.stdout
+    result should include regex (s"/$namespace/$packageName/$actionName")
   }
 
   behavior of "Wsk Package Binding"
@@ -212,7 +230,7 @@ class WskEntitlementTests extends TestHelpers with WskTestHelpers with BeforeAnd
     val provider = s"/$guestNamespace/$samplePackage"
     withAssetCleaner(defaultWskProps) { (wp, assetHelper) =>
       assetHelper.withCleaner(wsk.pkg, name, confirmDelete = false) { (pkg, _) =>
-        pkg.bind(provider, name, expectedExitCode = FORBIDDEN)(wp)
+        pkg.bind(provider, name, expectedExitCode = forbiddenCode)(wp)
       }
     }
   }
@@ -231,12 +249,8 @@ class WskEntitlementTests extends TestHelpers with WskTestHelpers with BeforeAnd
     }
 
     val fullyQualifiedActionName = s"/$guestNamespace/$fullSampleActionName"
-    val stdout = wsk.action.get(fullyQualifiedActionName)(defaultWskProps).stdout
-    stdout should include("name")
-    stdout should include("parameters")
-    stdout should include("limits")
-    stdout should include regex (""""key": "a"""")
-    stdout should include regex (""""value": "A"""")
+    val action = wsk.action.get(fullyQualifiedActionName)(defaultWskProps)
+    verifyAction(action)
 
     val run = wsk.action.invoke(fullyQualifiedActionName)(defaultWskProps)
 
@@ -245,6 +259,15 @@ class WskEntitlementTests extends TestHelpers with WskTestHelpers with BeforeAnd
     })(defaultWskProps)
   }
 
+  def verifyAction(action: RunResult) = {
+    val stdout = action.stdout
+    stdout should include("name")
+    stdout should include("parameters")
+    stdout should include("limits")
+    stdout should include regex (""""key": "a"""")
+    stdout should include regex (""""value": "A"""")
+  }
+
   it should "invoke an action sequence from package" in withAssetCleaner(guestWskProps) { (wp, assetHelper) =>
     assetHelper.withCleaner(wsk.pkg, samplePackage) { (pkg, _) =>
       pkg.create(samplePackage, parameters = Map("a" -> "A".toJson), shared = Some(true))(wp)
@@ -294,7 +317,7 @@ class WskEntitlementTests extends TestHelpers with WskTestHelpers with BeforeAnd
 
       // change package visibility
       wsk.pkg.create(privateSamplePackage, update = true, shared = Some(false))(guestwp)
-      wsk.action.invoke("sequence", expectedExitCode = FORBIDDEN)(defaultWskProps)
+      wsk.action.invoke("sequence", expectedExitCode = forbiddenCode)(defaultWskProps)
     }
   }
 
@@ -342,9 +365,9 @@ class WskEntitlementTests extends TestHelpers with WskTestHelpers with BeforeAnd
       val fullyQualifiedFeedName = s"/$guestNamespace/$sampleFeed"
       withAssetCleaner(defaultWskProps) { (wp, assetHelper) =>
         assetHelper.withCleaner(wsk.trigger, "badfeed", confirmDelete = false) { (trigger, name) =>
-          trigger.create(name, feed = Some(fullyQualifiedFeedName), expectedExitCode = TIMEOUT)(wp)
+          trigger.create(name, feed = Some(fullyQualifiedFeedName), expectedExitCode = timeoutCode)(wp)
         }
-        wsk.trigger.get("badfeed", expectedExitCode = NOT_FOUND)(wp)
+        wsk.trigger.get("badfeed", expectedExitCode = notFoundCode)(wp)
       }
   }
 
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskRestActionSequenceTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskRestActionSequenceTests.scala
new file mode 100644
index 0000000000..f8cec3e89a
--- /dev/null
+++ b/tests/src/test/scala/whisk/core/cli/test/WskRestActionSequenceTests.scala
@@ -0,0 +1,37 @@
+/*
+ * 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 org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+import spray.json._
+
+import common.rest.WskRest
+import common.rest.RestResult
+import common.TestUtils.RunResult
+
+@RunWith(classOf[JUnitRunner])
+class WskRestActionSequenceTests extends WskActionSequenceTests {
+  override lazy val wsk: common.rest.WskRest = new WskRest
+
+  override def verifyActionSequence(action: RunResult, name: String, compValue: JsArray, kindValue: JsString): Unit = {
+    val actionResultRest = action.asInstanceOf[RestResult]
+    actionResultRest.respBody.fields("exec").asJsObject.fields("components") shouldBe compValue
+    actionResultRest.respBody.fields("exec").asJsObject.fields("kind") shouldBe kindValue
+  }
+}
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskRestEntitlementTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskRestEntitlementTests.scala
new file mode 100644
index 0000000000..515dcbae5a
--- /dev/null
+++ b/tests/src/test/scala/whisk/core/cli/test/WskRestEntitlementTests.scala
@@ -0,0 +1,70 @@
+/*
+ * 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 org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+import common.rest.WskRest
+import common.rest.RestResult
+import common.TestUtils.FORBIDDEN_HTTP
+import common.TestUtils.TIMEOUT_HTTP
+import common.TestUtils.NOT_FOUND_HTTP
+import common.TestUtils.RunResult
+
+@RunWith(classOf[JUnitRunner])
+class WskRestEntitlementTests extends WskEntitlementTests {
+  override lazy val wsk: common.rest.WskRest = new WskRest
+  override lazy val forbiddenCode = FORBIDDEN_HTTP
+  override lazy val timeoutCode = TIMEOUT_HTTP
+  override lazy val notFoundCode = NOT_FOUND_HTTP
+
+  override def verifyAction(action: RunResult): org.scalatest.Assertion = {
+    val stdout = action.stdout
+    stdout should include("name")
+    stdout should include("parameters")
+    stdout should include("limits")
+    stdout should include regex (""""key":"a"""")
+    stdout should include regex (""""value":"A"""")
+  }
+
+  override def verifyPackageList(packageList: RunResult,
+                                 namespace: String,
+                                 packageName: String,
+                                 actionName: String): Unit = {
+    val packageListResultRest = packageList.asInstanceOf[RestResult]
+    val packages = packageListResultRest.getBodyListJsObject()
+    val ns = s"$namespace/$packageName"
+    packages.exists(pack =>
+      RestResult.getField(pack, "namespace") == ns && RestResult.getField(pack, "name") == actionName)
+  }
+
+  override def verifyPackageSharedList(packageList: RunResult, namespace: String, packageName: String): Unit = {
+    val packageListResultRest = packageList.asInstanceOf[RestResult]
+    val packages = packageListResultRest.getBodyListJsObject()
+    packages.exists(pack =>
+      RestResult.getField(pack, "namespace") == namespace && RestResult.getField(pack, "name") == packageName)
+  }
+
+  override def verifyPackageNotSharedList(packageList: RunResult, namespace: String, packageName: String): Unit = {
+    val packageListResultRest = packageList.asInstanceOf[RestResult]
+    val packages = packageListResultRest.getBodyListJsObject()
+    packages.exists(pack => RestResult.getField(pack, "namespace") != namespace)
+    packages.exists(pack => RestResult.getField(pack, "name") != packageName)
+  }
+}
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskRestWebActionsTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskRestWebActionsTests.scala
new file mode 100644
index 0000000000..832d36558d
--- /dev/null
+++ b/tests/src/test/scala/whisk/core/cli/test/WskRestWebActionsTests.scala
@@ -0,0 +1,28 @@
+/*
+ * 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 org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+import common.rest.WskRest
+
+@RunWith(classOf[JUnitRunner])
+class WskRestWebActionsTests extends WskWebActionsTests {
+  override lazy val wsk: common.rest.WskRest = new WskRest
+}
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 45c77ef84a..1df5cda07e 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
@@ -33,6 +33,7 @@ import com.jayway.restassured.response.Header
 import common.TestHelpers
 import common.TestUtils
 import common.WhiskProperties
+import common.BaseWsk
 import common.Wsk
 import common.WskProps
 import common.WskTestHelpers
@@ -48,12 +49,12 @@ import whisk.core.entity.Subject
  * Tests web actions.
  */
 @RunWith(classOf[JUnitRunner])
-class WskWebActionsTests extends TestHelpers with WskTestHelpers with RestUtil with BeforeAndAfterAll {
-  val MAX_URL_LENGTH = 8192 // 8K matching nginx default
+abstract class WskWebActionsTests extends TestHelpers with WskTestHelpers with RestUtil with BeforeAndAfterAll {
+  val MAX_URL_LENGTH: Int = 8192 // 8K matching nginx default
 
-  val wsk = new Wsk
+  val wsk: BaseWsk
   private implicit val wskprops = WskProps()
-  val namespace = wsk.namespace.whois()
+  val namespace: String = wsk.namespace.whois()
 
   protected val testRoutePath: String = "/api/v1/web"
 
@@ -70,6 +71,18 @@ class WskWebActionsTests extends TestHelpers with WskTestHelpers with RestUtil w
       action.create(name, file, web = Some("true"))
     }
 
+    var act = wsk.action.get(name)
+    println("action is " + act.stdout)
+
+    val testName = "testName"
+    assetHelper.withCleaner(wsk.action, testName) { (action, _) =>
+      val wskCli = new Wsk
+      wskCli.action.create(testName, file, web = Some("true"))
+    }
+
+    act = wsk.action.get(testName)
+    println("action cli is " + act.stdout)
+
     val resWithContentType =
       RestAssured.given().contentType("application/json").body(bodyContent.compactPrint).config(sslconfig).post(url)
 
@@ -270,10 +283,8 @@ class WskWebActionsTests extends TestHelpers with WskTestHelpers with RestUtil w
 
     response.statusCode shouldBe 200
     val cookieHeaders = response.headers.getList("Set-Cookie")
-    cookieHeaders should contain allOf (
-      new Header("Set-Cookie", "a=b"),
-      new Header("Set-Cookie", "c=d")
-    )
+    cookieHeaders should contain allOf (new Header("Set-Cookie", "a=b"),
+    new Header("Set-Cookie", "c=d"))
   }
 
   it should "handle http web action with base64 encoded response" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
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 7bc56ba7d6..66f3ef4441 100644
--- a/tests/src/test/scala/whisk/core/database/test/CacheConcurrencyTests.scala
+++ b/tests/src/test/scala/whisk/core/database/test/CacheConcurrencyTests.scala
@@ -27,7 +27,7 @@ import org.scalatest.junit.JUnitRunner
 
 import common.TestUtils
 import common.TestUtils._
-import common.Wsk
+import common.rest.WskRest
 import common.WskProps
 import common.WskTestHelpers
 import spray.json.JsString
@@ -40,7 +40,7 @@ class CacheConcurrencyTests extends FlatSpec with WskTestHelpers with BeforeAndA
 
   implicit private val transId = TransactionId.testing
   implicit private val wp = WskProps()
-  private val wsk = new Wsk
+  private val wsk = new WskRest
 
   val nExternalIters = 1
   val nInternalIters = 5
@@ -97,7 +97,7 @@ class CacheConcurrencyTests extends FlatSpec with WskTestHelpers with BeforeAndA
       }
 
       run("get after delete") { name =>
-        wsk.action.get(name, expectedExitCode = NOT_FOUND)
+        wsk.action.get(name, expectedExitCode = NOT_FOUND_HTTP)
       }
 
       run("recreate") { name =>
diff --git a/tests/src/test/scala/whisk/core/limits/ActionLimitsTests.scala b/tests/src/test/scala/whisk/core/limits/ActionLimitsTests.scala
index 4ac38f267a..ca1337a186 100644
--- a/tests/src/test/scala/whisk/core/limits/ActionLimitsTests.scala
+++ b/tests/src/test/scala/whisk/core/limits/ActionLimitsTests.scala
@@ -29,9 +29,9 @@ import org.scalatest.junit.JUnitRunner
 import common.ActivationResult
 import common.TestHelpers
 import common.TestUtils
-import common.TestUtils.TOO_LARGE
+import common.TestUtils.TOO_LARGE_HTTP
 import common.WhiskProperties
-import common.Wsk
+import common.rest.WskRest
 import common.WskProps
 import common.WskTestHelpers
 import spray.json._
@@ -47,7 +47,7 @@ import whisk.http.Messages
 class ActionLimitsTests extends TestHelpers with WskTestHelpers {
 
   implicit val wskprops = WskProps()
-  val wsk = new Wsk()
+  val wsk = new WskRest
 
   val defaultDosAction = TestUtils.getTestActionFilename("timeout.js")
   val allowedActionDuration = 10 seconds
@@ -148,10 +148,10 @@ class ActionLimitsTests extends TestHelpers with WskTestHelpers {
 
       // this tests an active ack failure to post from invoker
       val args = Map("size" -> (allowedSize + 1).toJson, "char" -> "a".toJson)
-      val code = if (blocking) TestUtils.APP_ERROR else TestUtils.SUCCESS_EXIT
+      val code = if (blocking) TestUtils.APP_ERROR_HTTP else TestUtils.ACCEPTED
       val rr = wsk.action.invoke(name, args, blocking = blocking, expectedExitCode = code)
       if (blocking) {
-        checkResponse(wsk.parseJsonString(rr.stderr).convertTo[ActivationResult])
+        checkResponse(wsk.parseJsonString(rr.respData).convertTo[ActivationResult])
       } else {
         withActivation(wsk.activation, rr, totalWait = 120 seconds) { checkResponse(_) }
       }
@@ -187,7 +187,7 @@ class ActionLimitsTests extends TestHelpers with WskTestHelpers {
     pw.close
 
     assetHelper.withCleaner(wsk.action, name, confirmDelete = false) { (action, _) =>
-      action.create(name, Some(actionCode.getAbsolutePath), expectedExitCode = TOO_LARGE)
+      action.create(name, Some(actionCode.getAbsolutePath), expectedExitCode = TOO_LARGE_HTTP)
     }
 
     actionCode.delete
diff --git a/tests/src/test/scala/whisk/core/limits/MaxActionDurationTests.scala b/tests/src/test/scala/whisk/core/limits/MaxActionDurationTests.scala
index 261e300d99..dba2eebffe 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.Wsk
+import common.rest.WskRest
 import common.WskProps
 import common.WskTestHelpers
 import whisk.core.entity._
@@ -40,7 +40,7 @@ import whisk.core.entity.TimeLimit
 class MaxActionDurationTests extends TestHelpers with WskTestHelpers {
 
   implicit val wskprops = WskProps()
-  val wsk = new Wsk
+  val wsk = new WskRest
 
   // swift is not tested, because it uses the same proxy like python
   "node-, python, and java-action" should "run up to the max allowed duration" in withAssetCleaner(wskprops) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services