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/01 19:30:38 UTC
[GitHub] houshengbo closed pull request #2890: Replace WskConsoleTests with REST implementation
houshengbo closed pull request #2890: Replace WskConsoleTests with REST implementation
URL: https://github.com/apache/incubator-openwhisk/pull/2890
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/scala/common/rest/WskRest.scala b/tests/src/test/scala/common/rest/WskRest.scala
index d31ade1bf4..392cc3bc5e 100644
--- a/tests/src/test/scala/common/rest/WskRest.scala
+++ b/tests/src/test/scala/common/rest/WskRest.scala
@@ -18,7 +18,6 @@
package common.rest
import java.io.File
-import java.time.Clock
import java.time.Instant
import java.util.Base64
import java.security.cert.X509Certificate
@@ -606,11 +605,9 @@ class WskRestActivation extends RunWskRestCmd with HasActivationRest with WaitFo
override def console(duration: Duration, since: Option[Duration] = None, expectedExitCode: Int = SUCCESS_EXIT)(
implicit wp: WskProps): RestResult = {
var sinceTime = System.currentTimeMillis()
- val utc = Instant.now(Clock.systemUTC()).toEpochMilli
sinceTime = since map { s =>
sinceTime - s.toMillis
} getOrElse sinceTime
- val pollTimeout = duration.toSeconds
waitForActivationConsole(duration, Instant.ofEpochMilli(sinceTime))
}
@@ -766,7 +763,6 @@ class WskRestActivation extends RunWskRestCmd with HasActivationRest with WaitFo
def waitForActivationConsole(totalWait: Duration = 30 seconds, sinceTime: Instant)(
implicit wp: WskProps): RestResult = {
- var result = new RestResult(NotFound)
Thread.sleep(totalWait.toMillis)
listActivation(since = Some(sinceTime))(wp)
}
diff --git a/tests/src/test/scala/system/basic/WskCliConsoleTests.scala b/tests/src/test/scala/system/basic/WskCliConsoleTests.scala
new file mode 100644
index 0000000000..e8652d3152
--- /dev/null
+++ b/tests/src/test/scala/system/basic/WskCliConsoleTests.scala
@@ -0,0 +1,30 @@
+/*
+ * 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 system.basic;
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+import common.Wsk
+
+/**
+ * Tests of the text console
+ */
+@RunWith(classOf[JUnitRunner])
+class WskCliConsoleTests extends WskConsoleTests {
+ override val wsk: Wsk = new Wsk
+}
diff --git a/tests/src/test/scala/system/basic/WskConsoleTests.scala b/tests/src/test/scala/system/basic/WskConsoleTests.scala
index 6f27b3a7a1..1b28fc270b 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.Wsk
+import common.BaseWsk
import common.WskProps
import common.WskTestHelpers
import spray.json.DefaultJsonProtocol.IntJsonFormat
@@ -40,10 +40,10 @@ import spray.json.pimpAny
* Tests of the text console
*/
@RunWith(classOf[JUnitRunner])
-class WskConsoleTests extends TestHelpers with WskTestHelpers {
+abstract class WskConsoleTests extends TestHelpers with WskTestHelpers {
- implicit val wskprops = WskProps()
- val wsk = new Wsk
+ implicit val wskprops: common.WskProps = WskProps()
+ val wsk: BaseWsk
val guestNamespace = wskprops.namespace
/**
@@ -70,7 +70,18 @@ class WskConsoleTests extends TestHelpers with WskTestHelpers {
val start = Instant.now.minusSeconds(5)
val payload = new String("from the console!".getBytes, "UTF-8")
val run = wsk.action.invoke(fullActionName, Map("payload" -> payload.toJson))
- withActivation(wsk.activation, run, totalWait = 30 seconds) { activation =>
+
+ val duration = Duration(Instant.now.minusMillis(start.toEpochMilli).toEpochMilli, MILLISECONDS)
+ withActivation(wsk.activation, run, totalWait = 30.seconds) { activation =>
+ // Time recorded by invoker, some contingency to make query more robust
+ val queryTime = activation.start.minusMillis(500)
+ // since: poll for activations since specified point in time (absolute)
+ val activations = wsk.activation.pollFor(N = 1, Some(actionName), since = Some(queryTime), retries = 80).length
+ withClue(
+ s"expected activations of action '${actionName}' since ${queryTime.toString} / initial activation ${activation.activationId}:") {
+ activations should be(1)
+ }
+
val duration = Duration(Instant.now.minusMillis(start.toEpochMilli).toEpochMilli, MILLISECONDS)
val pollTime = 10 seconds
// since: poll for activations since specified number of seconds ago (relative)
diff --git a/tests/src/test/scala/system/basic/WskRestConsoleTests.scala b/tests/src/test/scala/system/basic/WskRestConsoleTests.scala
new file mode 100644
index 0000000000..b84c5cd28c
--- /dev/null
+++ b/tests/src/test/scala/system/basic/WskRestConsoleTests.scala
@@ -0,0 +1,30 @@
+/*
+ * 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 system.basic;
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+import common.rest.WskRest
+
+/**
+ * Tests of the text console
+ */
+@RunWith(classOf[JUnitRunner])
+class WskRestConsoleTests extends WskConsoleTests {
+ override val wsk: WskRest = new WskRest
+}
----------------------------------------------------------------
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