You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ra...@apache.org on 2020/04/09 20:35:24 UTC
[openwhisk] branch master updated: add activationId to event message
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/openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new ecf92b0 add activationId to event message
ecf92b0 is described below
commit ecf92b030a125274a764606df379fc6d0805eade
Author: Brendan Doyle <br...@qualtrics.com>
AuthorDate: Fri Apr 3 00:41:31 2020 -0700
add activationId to event message
---
.../org/apache/openwhisk/core/connector/Message.scala | 3 +++
.../core/monitoring/metrics/KamonRecorderTests.scala | 14 ++++++++++++--
.../monitoring/metrics/PrometheusRecorderTests.scala | 14 ++++++++++++--
.../core/connector/test/EventMessageTests.scala | 17 +++++++++++++++--
.../core/entity/test/ActivationCompatTests.scala | 2 ++
5 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/common/scala/src/main/scala/org/apache/openwhisk/core/connector/Message.scala b/common/scala/src/main/scala/org/apache/openwhisk/core/connector/Message.scala
index b66d70b..0ab248a 100644
--- a/common/scala/src/main/scala/org/apache/openwhisk/core/connector/Message.scala
+++ b/common/scala/src/main/scala/org/apache/openwhisk/core/connector/Message.scala
@@ -289,6 +289,7 @@ object EventMessageBody extends DefaultJsonProtocol {
}
case class Activation(name: String,
+ activationId: String,
statusCode: Int,
duration: Duration,
waitTime: Duration,
@@ -338,6 +339,7 @@ object Activation extends DefaultJsonProtocol {
jsonFormat(
Activation.apply _,
"name",
+ "activationId",
"statusCode",
"duration",
"waitTime",
@@ -369,6 +371,7 @@ object Activation extends DefaultJsonProtocol {
} yield {
Activation(
fqn,
+ a.activationId.asString,
a.response.statusCode,
toDuration(a.duration.getOrElse(0)),
toDuration(a.annotations.getAs[Long](WhiskActivation.waitTimeAnnotation).getOrElse(0)),
diff --git a/core/monitoring/user-events/src/test/scala/org/apache/openwhisk/core/monitoring/metrics/KamonRecorderTests.scala b/core/monitoring/user-events/src/test/scala/org/apache/openwhisk/core/monitoring/metrics/KamonRecorderTests.scala
index 3ef93d5..df75c2b 100644
--- a/core/monitoring/user-events/src/test/scala/org/apache/openwhisk/core/monitoring/metrics/KamonRecorderTests.scala
+++ b/core/monitoring/user-events/src/test/scala/org/apache/openwhisk/core/monitoring/metrics/KamonRecorderTests.scala
@@ -25,7 +25,7 @@ import kamon.module.MetricReporter
import kamon.Kamon
import kamon.tag.Lookups
import org.apache.openwhisk.core.connector.{Activation, EventMessage}
-import org.apache.openwhisk.core.entity.{ActivationResponse, Subject, UUID}
+import org.apache.openwhisk.core.entity.{ActivationId, ActivationResponse, Subject, UUID}
import org.junit.runner.RunWith
import org.scalatest.BeforeAndAfterEach
import org.scalatest.junit.JUnitRunner
@@ -118,7 +118,17 @@ class KamonRecorderTests extends KafkaSpecBase with BeforeAndAfterEach with Kamo
private def newActivationEvent(actionPath: String) =
EventMessage(
"test",
- Activation(actionPath, 2, 3.millis, 5.millis, 11.millis, kind, false, memory, None),
+ Activation(
+ actionPath,
+ ActivationId.generate().asString,
+ 2,
+ 3.millis,
+ 5.millis,
+ 11.millis,
+ kind,
+ false,
+ memory,
+ None),
Subject("testuser"),
initiator,
UUID("test"),
diff --git a/core/monitoring/user-events/src/test/scala/org/apache/openwhisk/core/monitoring/metrics/PrometheusRecorderTests.scala b/core/monitoring/user-events/src/test/scala/org/apache/openwhisk/core/monitoring/metrics/PrometheusRecorderTests.scala
index 22cafac..4d75995 100644
--- a/core/monitoring/user-events/src/test/scala/org/apache/openwhisk/core/monitoring/metrics/PrometheusRecorderTests.scala
+++ b/core/monitoring/user-events/src/test/scala/org/apache/openwhisk/core/monitoring/metrics/PrometheusRecorderTests.scala
@@ -19,7 +19,7 @@ package org.apache.openwhisk.core.monitoring.metrics
import io.prometheus.client.CollectorRegistry
import org.apache.openwhisk.core.connector.{Activation, EventMessage}
-import org.apache.openwhisk.core.entity.{ActivationResponse, Subject, UUID}
+import org.apache.openwhisk.core.entity.{ActivationId, ActivationResponse, Subject, UUID}
import org.junit.runner.RunWith
import org.scalatest.BeforeAndAfterEach
import org.scalatest.junit.JUnitRunner
@@ -83,7 +83,17 @@ class PrometheusRecorderTests extends KafkaSpecBase with BeforeAndAfterEach with
private def newActivationEvent(actionPath: String, kind: String, memory: String) =
EventMessage(
"test",
- Activation(actionPath, 2, 1254.millis, 30.millis, 433433.millis, kind, false, memory.toInt, None),
+ Activation(
+ actionPath,
+ ActivationId.generate().asString,
+ 2,
+ 1254.millis,
+ 30.millis,
+ 433433.millis,
+ kind,
+ false,
+ memory.toInt,
+ None),
Subject("testuser"),
initiator,
UUID("test"),
diff --git a/tests/src/test/scala/org/apache/openwhisk/core/connector/test/EventMessageTests.scala b/tests/src/test/scala/org/apache/openwhisk/core/connector/test/EventMessageTests.scala
index 56c4396..73a2840 100644
--- a/tests/src/test/scala/org/apache/openwhisk/core/connector/test/EventMessageTests.scala
+++ b/tests/src/test/scala/org/apache/openwhisk/core/connector/test/EventMessageTests.scala
@@ -40,11 +40,12 @@ class EventMessageTests extends FlatSpec with Matchers {
behavior of "Activation"
+ val activationId = ActivationId.generate()
val fullActivation = WhiskActivation(
namespace = EntityPath("ns"),
name = EntityName("a"),
Subject(),
- activationId = ActivationId.generate(),
+ activationId = activationId,
start = Instant.now(),
end = Instant.now(),
response = ActivationResponse.success(Some(JsObject("res" -> JsNumber(1))), Some(42)),
@@ -60,6 +61,7 @@ class EventMessageTests extends FlatSpec with Matchers {
Activation.from(fullActivation) shouldBe Success(
Activation(
"ns2/a",
+ activationId.asString,
0,
toDuration(123),
toDuration(5),
@@ -87,7 +89,18 @@ class EventMessageTests extends FlatSpec with Matchers {
"ns2/a"))
Activation.from(a) shouldBe Success(
- Activation("ns2/a", 0, toDuration(0), toDuration(0), toDuration(0), "testkind", false, 0, None, Some(42)))
+ Activation(
+ "ns2/a",
+ activationId.asString,
+ 0,
+ toDuration(0),
+ toDuration(0),
+ toDuration(0),
+ "testkind",
+ false,
+ 0,
+ None,
+ Some(42)))
}
it should "Transform a activation with status code" in {
diff --git a/tests/src/test/scala/org/apache/openwhisk/core/entity/test/ActivationCompatTests.scala b/tests/src/test/scala/org/apache/openwhisk/core/entity/test/ActivationCompatTests.scala
index 659a604..fd8872d 100644
--- a/tests/src/test/scala/org/apache/openwhisk/core/entity/test/ActivationCompatTests.scala
+++ b/tests/src/test/scala/org/apache/openwhisk/core/entity/test/ActivationCompatTests.scala
@@ -145,6 +145,7 @@ class ActivationCompatTests extends FlatSpec with Matchers with WhiskInstants wi
val activationJs = """
|{
| "causedBy": "sequence",
+ | "activationId": "be97c2fed5dc43d097c2fed5dc73d085",
| "conductor": false,
| "duration": 123,
| "initTime": 10,
@@ -159,6 +160,7 @@ class ActivationCompatTests extends FlatSpec with Matchers with WhiskInstants wi
"""
|{
| "userDefinedStatusCode": 404,
+ | "activationId": "be97c2fed5dc43d097c2fed5dc73d085",
| "causedBy": "sequence",
| "conductor": false,
| "duration": 123,