You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2017/09/18 14:55:35 UTC

[incubator-openwhisk-cli] 07/16: remove experimental web actions support

This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git

commit 12a12ba99a01239c4e5e6a0afbbd4c73863a94e7
Author: David Cariello <dr...@us.ibm.com>
AuthorDate: Wed Aug 30 19:17:11 2017 -0500

    remove experimental web actions support
---
 .../whisk/core/cli/test/WskWebActionsTests.scala   | 163 +++++++++------------
 1 file changed, 71 insertions(+), 92 deletions(-)

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 2834948..aacc3ad 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
@@ -47,94 +47,14 @@ import whisk.core.entity.Subject
  * Tests web actions.
  */
 @RunWith(classOf[JUnitRunner])
-class WskWebActionsTestsV1 extends WskWebActionsTests {
-    override val testRoutePath = "/api/v1/experimental/web"
-}
-
-@RunWith(classOf[JUnitRunner])
-class WskWebActionsTestsV2 extends WskWebActionsTests with BeforeAndAfterAll {
-    override val testRoutePath = "/api/v1/web"
-
-    private val subdomainRegex = Seq.fill(WhiskProperties.getPartsInVanitySubdomain)("[a-zA-Z0-9]+").mkString("-")
-
-    private val (vanitySubdomain, vanityNamespace, makeTestSubject) = {
-        if (namespace.matches(subdomainRegex)) {
-            (namespace, namespace, false)
-        } else {
-            val s = Subject().asString.toLowerCase // this will generate two confirming parts
-            (s, s.replace("-", "_"), true)
-        }
-    }
-
-    private val wskPropsForSubdomainTest = if (makeTestSubject) {
-        getAdditionalTestSubject(vanityNamespace) // create new subject for the test
-    } else {
-        WskProps()
-    }
-
-    override def afterAll() = {
-        if (makeTestSubject) {
-            disposeAdditionalTestSubject(vanityNamespace)
-        }
-    }
-
-    "test subdomain" should "have conforming parts" in {
-        vanitySubdomain should fullyMatch regex subdomainRegex.r
-        vanitySubdomain.length should be <= 63
-    }
-
-    "vanity subdomain" should "access a web action via namespace subdomain" in withAssetCleaner(wskPropsForSubdomainTest) {
-        (wp, assetHelper) =>
-            val actionName = "webaction"
-            val file = Some(TestCLIUtils.getTestActionFilename("echo.js"))
-
-            assetHelper.withCleaner(wsk.action, actionName) {
-                (action, _) => action.create(actionName, file, web = Some(true.toString))(wp)
-            }
-
-            val url = getServiceApiHost(vanitySubdomain, true) + s"/default/$actionName.text/a?a=A"
-            println(s"url: $url")
-
-            // try the rest assured path first, failing that, try curl with explicit resolve
-            Try {
-                val response = RestAssured.given().config(sslconfig).get(url)
-                val responseCode = response.statusCode
-                responseCode shouldBe 200
-                response.body.asString shouldBe "A"
-            } match {
-                case Failure(t) =>
-                    println(s"RestAssured path failed, trying curl: $t")
-                    implicit val tid = TransactionId.testing
-                    implicit val logger = new PrintStreamLogging(Console.out)
-                    val host = getServiceApiHost(vanitySubdomain, false)
-                    // if the edge host is a name, try to resolve it, otherwise, it should be an ip address already
-                    val edgehost = WhiskProperties.getEdgeHost
-                    val ip = Try(java.net.InetAddress.getByName(edgehost).getHostAddress) getOrElse "???"
-                    println(s"edge: $edgehost, ip: $ip")
-                    val cmd = Seq("curl", "-k", url, "--resolve", s"$host:$ip")
-                    val (stdout, stderr, exitCode) = SimpleExec.syncRunCmd(cmd)
-                    withClue(s"\n$stderr\n") {
-                        stdout shouldBe "A"
-                        exitCode shouldBe 0
-                    }
-
-                case _ =>
-            }
-    }
-}
-
-trait WskWebActionsTests
-    extends TestHelpers
-    with WskTestHelpers
-    with RestUtil {
-
+class WskWebActionsTests extends TestHelpers with WskTestHelpers with RestUtil with BeforeAndAfterAll {
     val MAX_URL_LENGTH = 8192 // 8K matching nginx default
 
     val wsk = new Wsk
     private implicit val wskprops = WskProps()
     val namespace = wsk.namespace.whois()
 
-    protected val testRoutePath: String
+    protected val testRoutePath: String = "/api/v1/web"
 
     behavior of "Wsk Web Actions"
 
@@ -184,11 +104,7 @@ trait WskWebActionsTests
             val name = "webaction"
             val file = Some(TestCLIUtils.getTestActionFilename("echo.js"))
             val host = getServiceURL()
-            val url = if (testRoutePath == "/api/v1/experimental/web") {
-                s"$host$testRoutePath/$namespace/default/$name.text/__ow_meta_namespace"
-            } else {
-                s"$host$testRoutePath/$namespace/default/$name.text/__ow_user"
-            }
+            val url = s"$host$testRoutePath/$namespace/default/$name.text/__ow_user"
 
             assetHelper.withCleaner(wsk.action, name) {
                 (action, _) =>
@@ -261,11 +177,7 @@ trait WskWebActionsTests
             val file = Some(TestCLIUtils.getTestActionFilename("echo.js"))
             val bodyContent = "This is the body"
             val host = getServiceURL()
-            val url = if (testRoutePath == "/api/v1/experimental/web") {
-                s"$host$testRoutePath/$namespace/default/$name.text/__ow_meta_body"
-            } else {
-                s"$host$testRoutePath/$namespace/default/$name.text/__ow_body"
-            }
+            val url = s"$host$testRoutePath/$namespace/default/webaction.text/__ow_body"
 
             assetHelper.withCleaner(wsk.action, name) {
                 (action, _) => action.create(name, file, web = Some("true"))
@@ -336,4 +248,71 @@ trait WskWebActionsTests
             response.header("Content-type") shouldBe "application/json"
             response.body.asString.parseJson.asJsObject shouldBe JsObject("status" -> "success".toJson)
     }
+
+    private val subdomainRegex = Seq.fill(WhiskProperties.getPartsInVanitySubdomain)("[a-zA-Z0-9]+").mkString("-")
+
+    private val (vanitySubdomain, vanityNamespace, makeTestSubject) = {
+        if (namespace.matches(subdomainRegex)) {
+            (namespace, namespace, false)
+        } else {
+            val s = Subject().asString.toLowerCase // this will generate two confirming parts
+            (s, s.replace("-", "_"), true)
+        }
+    }
+
+    private val wskPropsForSubdomainTest = if (makeTestSubject) {
+        getAdditionalTestSubject(vanityNamespace) // create new subject for the test
+    } else {
+        WskProps()
+    }
+
+    override def afterAll() = {
+        if (makeTestSubject) {
+            disposeAdditionalTestSubject(vanityNamespace)
+        }
+    }
+
+    "test subdomain" should "have conforming parts" in {
+        vanitySubdomain should fullyMatch regex subdomainRegex.r
+        vanitySubdomain.length should be <= 63
+    }
+
+    "vanity subdomain" should "access a web action via namespace subdomain" in withAssetCleaner(wskPropsForSubdomainTest) {
+        (wp, assetHelper) =>
+            val actionName = "webaction"
+
+            val file = Some(TestUtils.getTestActionFilename("echo.js"))
+            assetHelper.withCleaner(wsk.action, actionName) {
+                (action, _) => action.create(actionName, file, web = Some(true.toString))(wp)
+            }
+
+            val url = getServiceApiHost(vanitySubdomain, true) + s"/default/$actionName.text/a?a=A"
+            println(s"url: $url")
+
+            // try the rest assured path first, failing that, try curl with explicit resolve
+            Try {
+                val response = RestAssured.given().config(sslconfig).get(url)
+                val responseCode = response.statusCode
+                responseCode shouldBe 200
+                response.body.asString shouldBe "A"
+            } match {
+                case Failure(t) =>
+                    println(s"RestAssured path failed, trying curl: $t")
+                    implicit val tid = TransactionId.testing
+                    implicit val logger = new PrintStreamLogging(Console.out)
+                    val host = getServiceApiHost(vanitySubdomain, false)
+                    // if the edge host is a name, try to resolve it, otherwise, it should be an ip address already
+                    val edgehost = WhiskProperties.getEdgeHost
+                    val ip = Try(java.net.InetAddress.getByName(edgehost).getHostAddress) getOrElse "???"
+                    println(s"edge: $edgehost, ip: $ip")
+                    val cmd = Seq("curl", "-k", url, "--resolve", s"$host:$ip")
+                    val (stdout, stderr, exitCode) = SimpleExec.syncRunCmd(cmd)
+                    withClue(s"\n$stderr\n") {
+                        stdout shouldBe "A"
+                        exitCode shouldBe 0
+                    }
+
+                case _ =>
+            }
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>.