[GitHub] dubeejw commented on a change in pull request #217: Add ability to get trigger configuration and status

2017-10-17 Thread git
dubeejw commented on a change in pull request #217: Add ability to get trigger 
configuration and status
URL: 
https://github.com/apache/incubator-openwhisk-package-kafka/pull/217#discussion_r145153254
 
 

 ##
 File path: tests/src/test/scala/system/packages/MessageHubFeedTests.scala
 ##
 @@ -274,6 +274,67 @@ class MessageHubFeedTests
   assert(matchingActivations.length == 0)
   }
 
+  it should "return correct status and configuration" 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")
+
+  createTrigger(assetHelper, triggerName, parameters = Map(
+"user" -> username,
+"password" -> password,
+"api_key" -> kafkaUtils.getAsJson("api_key"),
+"kafka_admin_url" -> admin_url,
+"kafka_brokers_sasl" -> brokers,
+"topic" -> topic.toJson,
+"isBinaryKey" -> false.toJson,
+"isBinaryValue" -> false.toJson
+  ))
+
+  val run = wsk.action.invoke(actionName, parameters = Map(
 
 Review comment:
   I understand that the trigger will not be fetched on the read based on how 
the OpenWhisk infrastructure is setup. However, is there a test to make sure 
this provider errors as expected?
 

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


[GitHub] dubeejw commented on a change in pull request #217: Add ability to get trigger configuration and status

2017-10-17 Thread git
dubeejw commented on a change in pull request #217: Add ability to get trigger 
configuration and status
URL: 
https://github.com/apache/incubator-openwhisk-package-kafka/pull/217#discussion_r145153451
 
 

 ##
 File path: action/kafkaFeedWeb.js
 ##
 @@ -61,6 +61,35 @@ function main(params) {
 
 resolve(common.webResponse(statusCode, body));
 });
+} else if (params.__ow_method === "get") {
 
 Review comment:
   Can you open an issue for this?
 

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


[GitHub] dubeejw commented on a change in pull request #217: Add ability to get trigger configuration and status

2017-10-17 Thread git
dubeejw commented on a change in pull request #217: Add ability to get trigger 
configuration and status
URL: 
https://github.com/apache/incubator-openwhisk-package-kafka/pull/217#discussion_r145149823
 
 

 ##
 File path: tests/src/test/scala/system/packages/MessageHubFeedTests.scala
 ##
 @@ -274,6 +274,67 @@ class MessageHubFeedTests
   assert(matchingActivations.length == 0)
   }
 
+  it should "return correct status and configuration" 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")
+
+  createTrigger(assetHelper, triggerName, parameters = Map(
+"user" -> username,
+"password" -> password,
+"api_key" -> kafkaUtils.getAsJson("api_key"),
+"kafka_admin_url" -> admin_url,
+"kafka_brokers_sasl" -> brokers,
+"topic" -> topic.toJson,
+"isBinaryKey" -> false.toJson,
+"isBinaryValue" -> false.toJson
+  ))
+
+  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
+  val status = 
result.getFields("status").head.asInstanceOf[JsObject].fields
+
+  config should contain("brokers" -> brokers)
 
 Review comment:
   I see two different possible values for dataChanged.
   
   ![screen shot 2017-10-17 at 10 33 53 
am](https://user-images.githubusercontent.com/11520887/31670932-c4504d26-b326-11e7-82fe-e1b7de6dce20.png)
   
 

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


[GitHub] dubeejw commented on a change in pull request #217: Add ability to get trigger configuration and status

2017-10-17 Thread git
dubeejw commented on a change in pull request #217: Add ability to get trigger 
configuration and status
URL: 
https://github.com/apache/incubator-openwhisk-package-kafka/pull/217#discussion_r145149185
 
 

 ##
 File path: tests/src/test/scala/system/packages/MessageHubFeedTests.scala
 ##
 @@ -274,6 +274,67 @@ class MessageHubFeedTests
   assert(matchingActivations.length == 0)
   }
 
+  it should "return correct status and configuration" 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")
+
+  createTrigger(assetHelper, triggerName, parameters = Map(
+"user" -> username,
+"password" -> password,
+"api_key" -> kafkaUtils.getAsJson("api_key"),
+"kafka_admin_url" -> admin_url,
+"kafka_brokers_sasl" -> brokers,
+"topic" -> topic.toJson,
+"isBinaryKey" -> false.toJson,
+"isBinaryValue" -> false.toJson
+  ))
+
+  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
+  val status = 
result.getFields("status").head.asInstanceOf[JsObject].fields
+
+  config should contain("brokers" -> brokers)
 
 Review comment:
   So we know what the returned trigger name will be. That means the config 
property can be compared to a JsObject.
   
   What does dateChanged look like? Is that a timestamp?
 

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


[GitHub] dubeejw commented on a change in pull request #217: Add ability to get trigger configuration and status

2017-10-13 Thread git
dubeejw commented on a change in pull request #217: Add ability to get trigger 
configuration and status
URL: 
https://github.com/apache/incubator-openwhisk-package-kafka/pull/217#discussion_r144567795
 
 

 ##
 File path: tests/src/test/scala/system/packages/MessageHubFeedTests.scala
 ##
 @@ -274,6 +274,67 @@ class MessageHubFeedTests
   assert(matchingActivations.length == 0)
   }
 
+  it should "return correct status and configuration" 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")
+
+  createTrigger(assetHelper, triggerName, parameters = Map(
+"user" -> username,
+"password" -> password,
+"api_key" -> kafkaUtils.getAsJson("api_key"),
+"kafka_admin_url" -> admin_url,
+"kafka_brokers_sasl" -> brokers,
+"topic" -> topic.toJson,
+"isBinaryKey" -> false.toJson,
+"isBinaryValue" -> false.toJson
+  ))
+
+  val run = wsk.action.invoke(actionName, parameters = Map(
 
 Review comment:
   I mean the authKey you are passing as a parameter to the action.
 

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


[GitHub] dubeejw commented on a change in pull request #217: Add ability to get trigger configuration and status

2017-10-13 Thread git
dubeejw commented on a change in pull request #217: Add ability to get trigger 
configuration and status
URL: 
https://github.com/apache/incubator-openwhisk-package-kafka/pull/217#discussion_r144568866
 
 

 ##
 File path: tests/src/test/scala/system/packages/MessageHubFeedTests.scala
 ##
 @@ -274,6 +274,67 @@ class MessageHubFeedTests
   assert(matchingActivations.length == 0)
   }
 
+  it should "return correct status and configuration" 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")
+
+  createTrigger(assetHelper, triggerName, parameters = Map(
+"user" -> username,
+"password" -> password,
+"api_key" -> kafkaUtils.getAsJson("api_key"),
+"kafka_admin_url" -> admin_url,
+"kafka_brokers_sasl" -> brokers,
+"topic" -> topic.toJson,
+"isBinaryKey" -> false.toJson,
+"isBinaryValue" -> false.toJson
+  ))
+
+  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
+  val status = 
result.getFields("status").head.asInstanceOf[JsObject].fields
+
+  config should contain("brokers" -> brokers)
 
 Review comment:
   What does the triggerName look like when it is returned here?
 

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


[GitHub] dubeejw commented on a change in pull request #217: Add ability to get trigger configuration and status

2017-10-13 Thread git
dubeejw commented on a change in pull request #217: Add ability to get trigger 
configuration and status
URL: 
https://github.com/apache/incubator-openwhisk-package-kafka/pull/217#discussion_r144569084
 
 

 ##
 File path: action/kafkaFeedWeb.js
 ##
 @@ -61,6 +61,35 @@ function main(params) {
 
 resolve(common.webResponse(statusCode, body));
 });
+} else if (params.__ow_method === "get") {
+const triggerURL = common.getTriggerURL(params.authKey, 
params.endpoint, params.triggerName);
+
+return common.verifyTriggerAuth(triggerURL)
+.then(() => {
+db = new Database(params.DB_URL, params.DB_NAME);
+return db.getTrigger(params.triggerName);
+})
+.then((triggerDoc) => {
+var body = {
+config: {
+triggerName: triggerDoc.triggerName,
+topic: triggerDoc.topic,
+isJSONData: triggerDoc.isJSONData,
+isBinaryValue: triggerDoc.isBinaryValue,
+isBinaryKey: triggerDoc.isBinaryKey,
+isMessageHub: triggerDoc.isMessageHub,
+brokers: triggerDoc.brokers,
+kafka_admin_url: triggerDoc.kafka_admin_url,
+username: triggerDoc.username,
+password: triggerDoc.password
 
 Review comment:
   @csantanapr, thoughts on exposing the password here?
 

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


[GitHub] dubeejw commented on a change in pull request #217: Add ability to get trigger configuration and status

2017-10-13 Thread git
dubeejw commented on a change in pull request #217: Add ability to get trigger 
configuration and status
URL: 
https://github.com/apache/incubator-openwhisk-package-kafka/pull/217#discussion_r144566377
 
 

 ##
 File path: action/kafkaFeedWeb.js
 ##
 @@ -61,6 +61,35 @@ function main(params) {
 
 resolve(common.webResponse(statusCode, body));
 });
+} else if (params.__ow_method === "get") {
+const triggerURL = common.getTriggerURL(params.authKey, 
params.endpoint, params.triggerName);
+
+return common.verifyTriggerAuth(triggerURL)
+.then(() => {
+db = new Database(params.DB_URL, params.DB_NAME);
+return db.getTrigger(params.triggerName);
+})
+.then((triggerDoc) => {
+var body = {
+config: {
+triggerName: triggerDoc.triggerName,
+topic: triggerDoc.topic,
+isJSONData: triggerDoc.isJSONData,
+isBinaryValue: triggerDoc.isBinaryValue,
+isBinaryKey: triggerDoc.isBinaryKey,
+isMessageHub: triggerDoc.isMessageHub,
+brokers: triggerDoc.brokers,
+kafka_admin_url: triggerDoc.kafka_admin_url,
+username: triggerDoc.username,
+password: triggerDoc.password
 
 Review comment:
   The code is not entirely duplicated. messageHubFeedWeb.js has a different 
method to validate parameters. Most of the shared code there is separated out 
into functions that is shared amongst the new files.
 

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


[GitHub] dubeejw commented on a change in pull request #217: Add ability to get trigger configuration and status

2017-10-12 Thread git
dubeejw commented on a change in pull request #217: Add ability to get trigger 
configuration and status
URL: 
https://github.com/apache/incubator-openwhisk-package-kafka/pull/217#discussion_r144405919
 
 

 ##
 File path: tests/src/test/scala/system/packages/MessageHubFeedTests.scala
 ##
 @@ -274,6 +274,67 @@ class MessageHubFeedTests
   assert(matchingActivations.length == 0)
   }
 
+  it should "return correct status and configuration" 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")
+
+  createTrigger(assetHelper, triggerName, parameters = Map(
+"user" -> username,
+"password" -> password,
+"api_key" -> kafkaUtils.getAsJson("api_key"),
+"kafka_admin_url" -> admin_url,
+"kafka_brokers_sasl" -> brokers,
+"topic" -> topic.toJson,
+"isBinaryKey" -> false.toJson,
+"isBinaryValue" -> false.toJson
+  ))
+
+  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
+  val status = 
result.getFields("status").head.asInstanceOf[JsObject].fields
+
+  config should contain("brokers" -> brokers)
 
 Review comment:
   Ex:
   ```
   val expectedConfig = JsObject("isBinaryKey" -> false.toJson,
   "isBinaryValue" -> false.toJson, 
etc...)
   config shouldBe(expectedConfig)
   ```
 

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


[GitHub] dubeejw commented on a change in pull request #217: Add ability to get trigger configuration and status

2017-10-12 Thread git
dubeejw commented on a change in pull request #217: Add ability to get trigger 
configuration and status
URL: 
https://github.com/apache/incubator-openwhisk-package-kafka/pull/217#discussion_r144406104
 
 

 ##
 File path: action/lib/common.js
 ##
 @@ -130,6 +130,30 @@ function deleteTrigger(endpoint, params, actionName) {
 });
 }
 
+function getTrigger(endpoint, params, actionName) {
+var options = {
+method: 'GET',
+url: getWebActionURL(endpoint, actionName),
+rejectUnauthorized: false,
 
 Review comment:
   What's `rejectUnauthorized` do?
 

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


[GitHub] dubeejw commented on a change in pull request #217: Add ability to get trigger configuration and status

2017-10-12 Thread git
dubeejw commented on a change in pull request #217: Add ability to get trigger 
configuration and status
URL: 
https://github.com/apache/incubator-openwhisk-package-kafka/pull/217#discussion_r144398796
 
 

 ##
 File path: action/kafkaFeedWeb.js
 ##
 @@ -61,6 +61,35 @@ function main(params) {
 
 resolve(common.webResponse(statusCode, body));
 });
+} else if (params.__ow_method === "get") {
+const triggerURL = common.getTriggerURL(params.authKey, 
params.endpoint, params.triggerName);
+
+return common.verifyTriggerAuth(triggerURL)
+.then(() => {
+db = new Database(params.DB_URL, params.DB_NAME);
+return db.getTrigger(params.triggerName);
+})
+.then((triggerDoc) => {
+var body = {
+config: {
+triggerName: triggerDoc.triggerName,
+topic: triggerDoc.topic,
+isJSONData: triggerDoc.isJSONData,
+isBinaryValue: triggerDoc.isBinaryValue,
+isBinaryKey: triggerDoc.isBinaryKey,
+isMessageHub: triggerDoc.isMessageHub,
+brokers: triggerDoc.brokers,
+kafka_admin_url: triggerDoc.kafka_admin_url,
+username: triggerDoc.username,
+password: triggerDoc.password
 
 Review comment:
   Do we really want to return the password?
 

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


[GitHub] dubeejw commented on a change in pull request #217: Add ability to get trigger configuration and status

2017-10-12 Thread git
dubeejw commented on a change in pull request #217: Add ability to get trigger 
configuration and status
URL: 
https://github.com/apache/incubator-openwhisk-package-kafka/pull/217#discussion_r144398720
 
 

 ##
 File path: action/kafkaFeedWeb.js
 ##
 @@ -61,6 +61,35 @@ function main(params) {
 
 resolve(common.webResponse(statusCode, body));
 });
+} else if (params.__ow_method === "get") {
 
 Review comment:
   Code is the same as in messageHubFeedWeb.js. Should make it a shared method 
between the two.
 

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


[GitHub] dubeejw commented on a change in pull request #217: Add ability to get trigger configuration and status

2017-10-12 Thread git
dubeejw commented on a change in pull request #217: Add ability to get trigger 
configuration and status
URL: 
https://github.com/apache/incubator-openwhisk-package-kafka/pull/217#discussion_r144405919
 
 

 ##
 File path: tests/src/test/scala/system/packages/MessageHubFeedTests.scala
 ##
 @@ -274,6 +274,67 @@ class MessageHubFeedTests
   assert(matchingActivations.length == 0)
   }
 
+  it should "return correct status and configuration" 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")
+
+  createTrigger(assetHelper, triggerName, parameters = Map(
+"user" -> username,
+"password" -> password,
+"api_key" -> kafkaUtils.getAsJson("api_key"),
+"kafka_admin_url" -> admin_url,
+"kafka_brokers_sasl" -> brokers,
+"topic" -> topic.toJson,
+"isBinaryKey" -> false.toJson,
+"isBinaryValue" -> false.toJson
+  ))
+
+  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
+  val status = 
result.getFields("status").head.asInstanceOf[JsObject].fields
+
+  config should contain("brokers" -> brokers)
 
 Review comment:
   Ex:
   ```
   val expectedConfig = JsObject("isBinaryKey" -> false.toJson, "isBinaryValue" 
-> false.toJson, etc...)
   config shouldBe(expectedConfig)
   ```
 

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


[GitHub] dubeejw commented on a change in pull request #217: Add ability to get trigger configuration and status

2017-10-12 Thread git
dubeejw commented on a change in pull request #217: Add ability to get trigger 
configuration and status
URL: 
https://github.com/apache/incubator-openwhisk-package-kafka/pull/217#discussion_r144405679
 
 

 ##
 File path: tests/src/test/scala/system/packages/MessageHubFeedTests.scala
 ##
 @@ -274,6 +274,67 @@ class MessageHubFeedTests
   assert(matchingActivations.length == 0)
   }
 
+  it should "return correct status and configuration" 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")
+
+  createTrigger(assetHelper, triggerName, parameters = Map(
+"user" -> username,
+"password" -> password,
+"api_key" -> kafkaUtils.getAsJson("api_key"),
+"kafka_admin_url" -> admin_url,
+"kafka_brokers_sasl" -> brokers,
+"topic" -> topic.toJson,
+"isBinaryKey" -> false.toJson,
+"isBinaryValue" -> false.toJson
+  ))
+
+  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
+  val status = 
result.getFields("status").head.asInstanceOf[JsObject].fields
+
+  config should contain("brokers" -> brokers)
 
 Review comment:
   You should be able build a JsObject that has all these fields then do one or 
two comparisons instead of several.
 

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


[GitHub] dubeejw commented on a change in pull request #217: Add ability to get trigger configuration and status

2017-10-12 Thread git
dubeejw commented on a change in pull request #217: Add ability to get trigger 
configuration and status
URL: 
https://github.com/apache/incubator-openwhisk-package-kafka/pull/217#discussion_r144398884
 
 

 ##
 File path: tests/src/test/scala/system/packages/MessageHubFeedTests.scala
 ##
 @@ -274,6 +274,67 @@ class MessageHubFeedTests
   assert(matchingActivations.length == 0)
   }
 
+  it should "return correct status and configuration" 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")
+
+  createTrigger(assetHelper, triggerName, parameters = Map(
+"user" -> username,
+"password" -> password,
+"api_key" -> kafkaUtils.getAsJson("api_key"),
+"kafka_admin_url" -> admin_url,
+"kafka_brokers_sasl" -> brokers,
+"topic" -> topic.toJson,
+"isBinaryKey" -> false.toJson,
+"isBinaryValue" -> false.toJson
+  ))
+
+  val run = wsk.action.invoke(actionName, parameters = Map(
 
 Review comment:
   Should have a test to ensure this fails with an bad auth key.
 

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