csantanapr closed pull request #259: Move Feed Update Test URL: https://github.com/apache/incubator-openwhisk-package-kafka/pull/259
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/system/health/BasicHealthTest.scala b/tests/src/test/scala/system/health/BasicHealthTest.scala index 139ed21..c80458c 100644 --- a/tests/src/test/scala/system/health/BasicHealthTest.scala +++ b/tests/src/test/scala/system/health/BasicHealthTest.scala @@ -249,88 +249,4 @@ class BasicHealthTest } } } - - it should "correctly update isJSONData, isBinaryValue, and isBinaryKey" in withAssetCleaner(wskprops) { - val currentTime = s"${System.currentTimeMillis}" - - (wp, assetHelper) => - val triggerName = s"/_/dummyMessageHubTrigger-$currentTime" - println(s"Creating trigger $triggerName") - - val username = kafkaUtils.getAsJson("user") - val password = kafkaUtils.getAsJson("password") - val admin_url = kafkaUtils.getAsJson("kafka_admin_url") - val brokers = kafkaUtils.getAsJson("brokers") - - val feedCreationResult = assetHelper.withCleaner(wsk.trigger, triggerName) { - (trigger, _) => - trigger.create(triggerName, feed = Some(actionName), parameters = Map( - "user" -> username, - "password" -> password, - "api_key" -> kafkaUtils.getAsJson("api_key"), - "kafka_admin_url" -> admin_url, - "kafka_brokers_sasl" -> brokers, - "topic" -> topic.toJson, - "isJSONData" -> true.toJson, - "isBinaryKey" -> false.toJson, - "isBinaryValue" -> false.toJson - )) - } - - withActivation(wsk.activation, feedCreationResult, initialWait = 5 seconds, totalWait = 60 seconds) { - _.response.success shouldBe true - } - - val readRunResult = wsk.action.invoke(actionName, parameters = Map( - "triggerName" -> triggerName.toJson, - "lifecycleEvent" -> "READ".toJson, - "authKey" -> wp.authKey.toJson - )) - - withActivation(wsk.activation, readRunResult) { - activation => - activation.response.success shouldBe true - - inside (activation.response.result) { - case Some(result) => - val config = result.getFields("config").head.asInstanceOf[JsObject].fields - config should contain("isBinaryKey" -> false.toJson) - config should contain("isBinaryValue" -> false.toJson) - config should contain("isJSONData" -> true.toJson) - } - } - - val updateRunResult = wsk.action.invoke(actionName, parameters = Map( - "triggerName" -> triggerName.toJson, - "lifecycleEvent" -> "UPDATE".toJson, - "authKey" -> wp.authKey.toJson, - "isBinaryValue" -> true.toJson, - "isBinaryKey" -> true.toJson, - "isJSONData" -> false.toJson - )) - - withActivation(wsk.activation, updateRunResult) { - activation => - activation.response.success shouldBe true - } - - val run = wsk.action.invoke(actionName, parameters = Map( - "triggerName" -> triggerName.toJson, - "lifecycleEvent" -> "READ".toJson, - "authKey" -> wp.authKey.toJson - )) - - withActivation(wsk.activation, run) { - activation => - activation.response.success shouldBe true - - inside (activation.response.result) { - case Some(result) => - val config = result.getFields("config").head.asInstanceOf[JsObject].fields - config should contain("isBinaryKey" -> true.toJson) - config should contain("isBinaryValue" -> true.toJson) - config should contain("isJSONData" -> false.toJson) - } - } - } } diff --git a/tests/src/test/scala/system/packages/MessageHubFeedTests.scala b/tests/src/test/scala/system/packages/MessageHubFeedTests.scala index 9cd1e2f..ba17e84 100644 --- a/tests/src/test/scala/system/packages/MessageHubFeedTests.scala +++ b/tests/src/test/scala/system/packages/MessageHubFeedTests.scala @@ -385,6 +385,90 @@ class MessageHubFeedTests } } + it should "correctly update isJSONData, isBinaryValue, and isBinaryKey" in withAssetCleaner(wskprops) { + val currentTime = s"${System.currentTimeMillis}" + + (wp, assetHelper) => + val triggerName = s"/_/dummyMessageHubTrigger-$currentTime" + println(s"Creating trigger $triggerName") + + val username = kafkaUtils.getAsJson("user") + val password = kafkaUtils.getAsJson("password") + val admin_url = kafkaUtils.getAsJson("kafka_admin_url") + val brokers = kafkaUtils.getAsJson("brokers") + + val feedCreationResult = assetHelper.withCleaner(wsk.trigger, triggerName) { + (trigger, _) => + trigger.create(triggerName, feed = Some(actionName), parameters = Map( + "user" -> username, + "password" -> password, + "api_key" -> kafkaUtils.getAsJson("api_key"), + "kafka_admin_url" -> admin_url, + "kafka_brokers_sasl" -> brokers, + "topic" -> topic.toJson, + "isJSONData" -> true.toJson, + "isBinaryKey" -> false.toJson, + "isBinaryValue" -> false.toJson + )) + } + + withActivation(wsk.activation, feedCreationResult, initialWait = 5 seconds, totalWait = 60 seconds) { + _.response.success shouldBe true + } + + val readRunResult = wsk.action.invoke(actionName, parameters = Map( + "triggerName" -> triggerName.toJson, + "lifecycleEvent" -> "READ".toJson, + "authKey" -> wp.authKey.toJson + )) + + withActivation(wsk.activation, readRunResult) { + activation => + activation.response.success shouldBe true + + inside (activation.response.result) { + case Some(result) => + val config = result.getFields("config").head.asInstanceOf[JsObject].fields + config should contain("isBinaryKey" -> false.toJson) + config should contain("isBinaryValue" -> false.toJson) + config should contain("isJSONData" -> true.toJson) + } + } + + val updateRunResult = wsk.action.invoke(actionName, parameters = Map( + "triggerName" -> triggerName.toJson, + "lifecycleEvent" -> "UPDATE".toJson, + "authKey" -> wp.authKey.toJson, + "isBinaryValue" -> true.toJson, + "isBinaryKey" -> true.toJson, + "isJSONData" -> false.toJson + )) + + withActivation(wsk.activation, updateRunResult) { + activation => + activation.response.success shouldBe true + } + + val run = wsk.action.invoke(actionName, parameters = Map( + "triggerName" -> triggerName.toJson, + "lifecycleEvent" -> "READ".toJson, + "authKey" -> wp.authKey.toJson + )) + + withActivation(wsk.activation, run) { + activation => + activation.response.success shouldBe true + + inside (activation.response.result) { + case Some(result) => + val config = result.getFields("config").head.asInstanceOf[JsObject].fields + config should contain("isBinaryKey" -> true.toJson) + config should contain("isBinaryValue" -> true.toJson) + config should contain("isJSONData" -> false.toJson) + } + } + } + it should "fire a trigger when a message is posted to message hub before and after update" in withAssetCleaner(wskprops) { val currentTime = s"${System.currentTimeMillis}" ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services