You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ra...@apache.org on 2019/12/20 22:00:17 UTC

[openwhisk] branch master updated: Separate test cases for the logs and results APIs of activation (#4777)

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

rabbah pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk.git


The following commit(s) were added to refs/heads/master by this push:
     new 8eb922f  Separate test cases for the logs and results APIs of activation (#4777)
8eb922f is described below

commit 8eb922f568d7843cdb1068252d29ba5723b30283
Author: David Grove <dg...@users.noreply.github.com>
AuthorDate: Fri Dec 20 17:00:07 2019 -0500

    Separate test cases for the logs and results APIs of activation (#4777)
    
    Split the existing WskActivationTests into two tests, one for logs and
    one for the rest of the activation apis (currently only results). This
    enables a clean exclusion of the logs portion of the tests when using
    the KubernetesContainerFactory (which is not able to distinguish the
    stdout and stderr streams due to deficiencies in how container logs
    are exposed through the Kubernetes API).
---
 tests/build.gradle                                 |  8 ++++++
 ...ionTests.scala => WskActivationLogsTests.scala} | 29 +++-------------------
 .../scala/system/basic/WskActivationTests.scala    | 26 -------------------
 3 files changed, 12 insertions(+), 51 deletions(-)

diff --git a/tests/build.gradle b/tests/build.gradle
index 2c0d158..d3e04e7 100644
--- a/tests/build.gradle
+++ b/tests/build.gradle
@@ -163,6 +163,14 @@ task testSystemBasic(type: Test) {
     include getPattern("REQUIRE_SYSTEM_BASIC", "includes")
 }
 
+task testSystemKCF(type: Test) {
+    exclude getPattern("REQUIRE_SYSTEM_BASIC", "excludes")
+    include getPattern("REQUIRE_SYSTEM_BASIC", "includes")
+
+    // KubernetesContainerFactory's logs API is not reliable and mixes stdout/stderr into a single stream
+    exclude "**/*ActivationLogsTests*"
+}
+
 task testUnit(type: Test) {
     systemProperty("whisk.spi.ArtifactStoreProvider", "org.apache.openwhisk.core.database.memory.MemoryArtifactStoreProvider")
     exclude getPattern("REQUIRE_ONLY_DB", "excludes")
diff --git a/tests/src/test/scala/system/basic/WskActivationTests.scala b/tests/src/test/scala/system/basic/WskActivationLogsTests.scala
similarity index 69%
copy from tests/src/test/scala/system/basic/WskActivationTests.scala
copy to tests/src/test/scala/system/basic/WskActivationLogsTests.scala
index 29352a5..fb83574 100644
--- a/tests/src/test/scala/system/basic/WskActivationTests.scala
+++ b/tests/src/test/scala/system/basic/WskActivationLogsTests.scala
@@ -17,23 +17,21 @@
 
 package system.basic
 
+import common._
 import common.rest.WskRestOperations
+import org.apache.openwhisk.utils.retry
 import org.junit.runner.RunWith
 import org.scalatest.junit.JUnitRunner
-import common._
-import org.apache.openwhisk.utils.retry
 
 import scala.concurrent.duration._
-import spray.json._
-import spray.json.DefaultJsonProtocol._
 
 @RunWith(classOf[JUnitRunner])
-class WskActivationTests extends TestHelpers with WskTestHelpers with WskActorSystem {
+class WskActivationLogsTests extends TestHelpers with WskTestHelpers with WskActorSystem {
 
   implicit val wskprops = WskProps()
   val wsk: WskOperations = new WskRestOperations
 
-  behavior of "Whisk activations"
+  behavior of "Whisk activation logs"
 
   it should "fetch logs using activation logs API" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
     val name = "logFetch"
@@ -58,23 +56,4 @@ class WskActivationTests extends TestHelpers with WskTestHelpers with WskActorSy
       }, 60 * 5, Some(1.second)) // retry for 5 minutes
     }
   }
-
-  it should "fetch result using activation result API" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
-    val name = "hello"
-    val expectedResult = JsObject(
-      "result" -> JsObject("payload" -> "hello, undefined!".toJson),
-      "success" -> true.toJson,
-      "status" -> "success".toJson)
-
-    assetHelper.withCleaner(wsk.action, name) { (action, _) =>
-      action.create(name, Some(TestUtils.getTestActionFilename("hello.js")))
-    }
-
-    withActivation(wsk.activation, wsk.action.invoke(name)) { activation =>
-      val result = wsk.activation.result(Some(activation.activationId)).stdout.parseJson.asJsObject
-      //Remove size from comparison as its exact value may vary
-      val resultWithoutSize = JsObject(result.fields - "size")
-      resultWithoutSize shouldBe expectedResult
-    }
-  }
 }
diff --git a/tests/src/test/scala/system/basic/WskActivationTests.scala b/tests/src/test/scala/system/basic/WskActivationTests.scala
index 29352a5..b5c39de 100644
--- a/tests/src/test/scala/system/basic/WskActivationTests.scala
+++ b/tests/src/test/scala/system/basic/WskActivationTests.scala
@@ -21,9 +21,7 @@ import common.rest.WskRestOperations
 import org.junit.runner.RunWith
 import org.scalatest.junit.JUnitRunner
 import common._
-import org.apache.openwhisk.utils.retry
 
-import scala.concurrent.duration._
 import spray.json._
 import spray.json.DefaultJsonProtocol._
 
@@ -35,30 +33,6 @@ class WskActivationTests extends TestHelpers with WskTestHelpers with WskActorSy
 
   behavior of "Whisk activations"
 
-  it should "fetch logs using activation logs API" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
-    val name = "logFetch"
-    val logFormat = "\\d+-\\d+-\\d+T\\d+:\\d+:\\d+.\\d+Z\\s+%s: %s"
-
-    assetHelper.withCleaner(wsk.action, name) { (action, _) =>
-      action.create(name, Some(TestUtils.getTestActionFilename("log.js")))
-    }
-
-    val run = wsk.action.invoke(name)
-
-    // Even though the activation was blocking, the activation itself might not have appeared in the database.
-    withActivation(wsk.activation, run) { activation =>
-      // Needs to be retried because there might be an SPI being plugged in which is handling logs not consistent with
-      // the database where the activation itself comes from (activation in CouchDB, logs in Elasticsearch for
-      // example).
-      retry({
-        val logs = wsk.activation.logs(Some(activation.activationId)).stdout
-
-        logs should include regex logFormat.format("stdout", "this is stdout")
-        logs should include regex logFormat.format("stderr", "this is stderr")
-      }, 60 * 5, Some(1.second)) // retry for 5 minutes
-    }
-  }
-
   it should "fetch result using activation result API" in withAssetCleaner(wskprops) { (wp, assetHelper) =>
     val name = "hello"
     val expectedResult = JsObject(