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 <rod...@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 - } -}