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/incubator-openwhisk.git
The following commit(s) were added to refs/heads/master by this push: new 9b69d27 Revert "Added functions to create a trigger and create a rule. (#2718)" (#2740) 9b69d27 is described below commit 9b69d278fc98e2f24db4855b356c30ed0422747b Author: Carlos Santana <csantan...@gmail.com> AuthorDate: Wed Sep 13 22:07:35 2017 -0400 Revert "Added functions to create a trigger and create a rule. (#2718)" (#2740) This reverts commit ec56eb81005a0a62cadd591ca55e1468c73df2b3. --- core/swift3Action/spm-build/_Whisk.swift | 27 +++------ tests/dat/actions/createRule.swift | 13 ---- tests/dat/actions/createTrigger.swift | 7 --- .../scala/whisk/core/cli/test/Swift3Tests.scala | 70 ---------------------- 4 files changed, 7 insertions(+), 110 deletions(-) diff --git a/core/swift3Action/spm-build/_Whisk.swift b/core/swift3Action/spm-build/_Whisk.swift index 59efc78..2bdda05 100644 --- a/core/swift3Action/spm-build/_Whisk.swift +++ b/core/swift3Action/spm-build/_Whisk.swift @@ -25,32 +25,19 @@ class Whisk { let strBlocking = blocking ? "true" : "false" let path = "/api/v1/namespaces/\(parsedAction.namespace)/actions/\(parsedAction.name)?blocking=\(strBlocking)" - return sendWhiskRequestSyncronish(uriPath: path, params: params, method: "post") + return postSyncronish(uriPath: path, params: params) } class func trigger(eventNamed event : String, withParameters params : [String:Any]) -> [String:Any] { let parsedEvent = parseQualifiedName(name: event) let path = "/api/v1/namespaces/\(parsedEvent.namespace)/triggers/\(parsedEvent.name)?blocking=true" - return sendWhiskRequestSyncronish(uriPath: path, params: params, method: "post") - } - - class func createTrigger(triggerNamed trigger: String, withParameters params : [String:Any]) -> [String:Any] { - let parsedTrigger = parseQualifiedName(name: trigger) - let path = "/api/v1/namespaces/\(parsedTrigger.namespace)/triggers/\(parsedTrigger.name)" - return sendWhiskRequestSyncronish(uriPath: path, params: params, method: "put") - } - - class func createRule(ruleNamed ruleName: String, withTrigger triggerName: String, andAction actionName: String) -> [String:Any] { - let parsedRule = parseQualifiedName(name: ruleName) - let path = "/api/v1/namespaces/\(parsedRule.namespace)/rules/\(parsedRule.name)" - let params = ["trigger":triggerName, "action":actionName] - return sendWhiskRequestSyncronish(uriPath: path, params: params, method: "put") + return postSyncronish(uriPath: path, params: params) } // handle the GCD dance to make the post async, but then obtain/return // the result from this function sync - private class func sendWhiskRequestSyncronish(uriPath path: String, params : [String:Any], method: String) -> [String:Any] { + private class func postSyncronish(uriPath path: String, params : [String:Any]) -> [String:Any] { var response : [String:Any]! let queue = DispatchQueue.global() @@ -58,7 +45,7 @@ class Whisk { invokeGroup.enter() queue.async { - sendWhiskRequest(uriPath: path, params: params, method: method, group: invokeGroup) { result in + post(uriPath: path, params: params, group: invokeGroup) { result in response = result } } @@ -122,8 +109,8 @@ class Whisk { return (httpType, host, port, authKey) } - // actually do the call to the specified OpenWhisk URI path - private class func sendWhiskRequest(uriPath: String, params : [String:Any], method: String, group: DispatchGroup, callback : @escaping([String:Any]) -> Void) { + // actually do the POST call to the specified OpenWhisk URI path + private class func post(uriPath: String, params : [String:Any], group: DispatchGroup, callback : @escaping([String:Any]) -> Void) { let communicationDetails = initializeCommunication() let loginData: Data = communicationDetails.authKey.data(using: String.Encoding.utf8, allowLossyConversion: false)! @@ -139,7 +126,7 @@ class Whisk { // TODO vary the schema based on the port? let requestOptions = [ClientRequest.Options.schema(communicationDetails.httpType), - ClientRequest.Options.method(method), + ClientRequest.Options.method("post"), ClientRequest.Options.hostname(communicationDetails.host), ClientRequest.Options.port(communicationDetails.port), ClientRequest.Options.path(encodedPath), diff --git a/tests/dat/actions/createRule.swift b/tests/dat/actions/createRule.swift deleted file mode 100644 index 67fa062..0000000 --- a/tests/dat/actions/createRule.swift +++ /dev/null @@ -1,13 +0,0 @@ -func main(args: [String:Any]) -> [String:Any] { - guard let triggerName = args["triggerName"] as? String else { - return ["error": "You must specify a triggerName parameter!"] - } - guard let actionName = args["actionName"] as? String else { - return ["error": "You must specify a actionName parameter!"] - } - guard let ruleName = args["ruleName"] as? String else { - return ["error": "You must specify a ruleName parameter!"] - } - print("Rule Name: \(ruleName), Trigger Name: \(triggerName), actionName: \(actionName)") - return Whisk.createRule(ruleNamed: ruleName, withTrigger: triggerName, andAction: actionName) -} diff --git a/tests/dat/actions/createTrigger.swift b/tests/dat/actions/createTrigger.swift deleted file mode 100644 index 7039ac4..0000000 --- a/tests/dat/actions/createTrigger.swift +++ /dev/null @@ -1,7 +0,0 @@ -func main(args: [String:Any]) -> [String:Any] { - guard let triggerName = args["triggerName"] as? String else { - return ["error": "You must specify a triggerName parameter!"] - } - print("Trigger Name: \(triggerName)") - return Whisk.createTrigger(triggerNamed: triggerName, withParameters: [:]) -} 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 513cf94..547a2e2 100644 --- a/tests/src/test/scala/whisk/core/cli/test/Swift3Tests.scala +++ b/tests/src/test/scala/whisk/core/cli/test/Swift3Tests.scala @@ -143,74 +143,4 @@ class Swift3Tests extends TestHelpers with WskTestHelpers with Matchers { } } } - - it should "allow Swift actions to create a trigger" in withAssetCleaner(wskprops) { (wp, assetHelper) => - // create an action that creates the trigger - val file = TestUtils.getTestActionFilename("createTrigger.swift") - val actionName = "ActionThatTriggers" - - // the name of the trigger to create - val triggerName = s"TestTrigger ${System.currentTimeMillis()}" - - assetHelper.withCleaner(wsk.action, actionName) { (action, _) => - assetHelper.withCleaner(wsk.trigger, triggerName) { (_, _) => - // using an asset cleaner on the created trigger name will clean it up at the conclusion of the test - action.create(name = actionName, artifact = Some(file), kind = Some("swift:3")) - } - } - - // invoke the action - val run = wsk.action.invoke(actionName, Map("triggerName" -> triggerName.toJson)) - withActivation(wsk.activation, run, initialWait = 5 seconds, totalWait = 60 seconds) { activation => - // should be successful - activation.response.success shouldBe true - - // should have a field named "name" which is the name of the trigger created - activation.response.result.get.fields("name") shouldBe triggerName.toJson - } - } - - it should "allow Swift actions to create a rule" in withAssetCleaner(wskprops) { (wp, assetHelper) => - val ruleTriggerName = s"TestTrigger ${System.currentTimeMillis()}" - val ruleActionName = s"TestAction ${System.currentTimeMillis()}" - val ruleName = s"TestRule ${System.currentTimeMillis()}" - - // create a dummy action and trigger for the rule - assetHelper.withCleaner(wsk.action, ruleActionName) { (action, name) => - val dummyFile = TestUtils.getTestActionFilename("hello.swift") - action.create(name, artifact = Some(dummyFile), kind = Some("swift:3")) - } - - assetHelper.withCleaner(wsk.trigger, ruleTriggerName) { (trigger, name) => - assetHelper.withCleaner(wsk.rule, ruleName) { (_, _) => - // using an asset cleaner on the created trigger name will clean it up at the conclusion of the test - trigger.create(name) - } - } - - // create an action that creates the rule - val createRuleFile = TestUtils.getTestActionFilename("createRule.swift") - assetHelper.withCleaner(wsk.action, "ActionThatCreatesRule") { (action, name) => - action.create(name, artifact = Some(createRuleFile), kind = Some("swift:3")) - } - - // invoke the create rule action - val runCreateRule = wsk.action.invoke( - "ActionThatCreatesRule", - Map( - "triggerName" -> s"/_/$ruleTriggerName".toJson, - "actionName" -> s"/_/$ruleActionName".toJson, - "ruleName" -> ruleName.toJson)) - - withActivation(wsk.activation, runCreateRule, initialWait = 5 seconds, totalWait = 60 seconds) { activation => - // should be successful - activation.response.success shouldBe true - - // should have a field named "trigger" which is the name of the trigger associated with the rule - activation.response.result.get.fields("trigger").asJsObject.fields("name") shouldBe ruleTriggerName.toJson - - // should have a field named "action" which is the name of the action associated with the rule - activation.response.result.get.fields("action").asJsObject.fields("name") shouldBe ruleActionName.toJson - } - } } -- To stop receiving notification emails like this one, please contact ['"commits@openwhisk.apache.org" <commits@openwhisk.apache.org>'].