You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "mario-renau-alstom (via GitHub)" <gi...@apache.org> on 2023/08/15 11:14:30 UTC

[GitHub] [incubator-pekko-samples] mario-renau-alstom opened a new pull request, #66: Tests for worker and work executor

mario-renau-alstom opened a new pull request, #66:
URL: https://github.com/apache/incubator-pekko-samples/pull/66

   Added sample test for Worker and WorkExecutor


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


[GitHub] [incubator-pekko-samples] pjfanning commented on a diff in pull request #66: Tests for worker and work executor

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #66:
URL: https://github.com/apache/incubator-pekko-samples/pull/66#discussion_r1294490009


##########
pekko-sample-distributed-workers-scala/src/test/scala/worker/WorkerSpec.scala:
##########
@@ -0,0 +1,39 @@
+package worker
+
+import org.apache.pekko
+import org.apache.pekko.actor.typed.delivery.ConsumerController
+import org.apache.pekko.actor.typed.scaladsl.Behaviors
+import pekko.actor.testkit.typed.scaladsl.ScalaTestWithActorTestKit
+import org.scalatest.wordspec.AnyWordSpecLike
+
+class WorkerSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike{
+
+  "A Worker" must {
+
+    "start work when in idle state" in {
+      val workExecutorProbe = createTestProbe[WorkExecutor.ExecuteWork]()
+      val worker = spawn(Worker(workExecutorFactory = () => Behaviors.monitor(workExecutorProbe.ref, WorkExecutor())))
+      val work = WorkManager.DoWork(Work("TestWork", 1000))
+      val deliveryProbe = createTestProbe[ConsumerController.Confirmed]()
+      val deliveredMessage = Worker.DeliveredMessage(deliveryProbe.ref, work, 1)
+
+      worker ! deliveredMessage
+
+      workExecutorProbe.expectMessageType[WorkExecutor.ExecuteWork]
+    }
+
+    "confirm the work when work is complete" in {
+      val workExecutorProbe = createTestProbe[WorkExecutor.ExecuteWork]()
+      val worker = spawn(Worker(workExecutorFactory = () => Behaviors.monitor(workExecutorProbe.ref, WorkExecutor())))
+      val work = WorkManager.DoWork(Work("TestWork", 1000))
+
+      val deliveryProbe = createTestProbe[ConsumerController.Confirmed]()
+      val deliveredMessage = Worker.DeliveredMessage(deliveryProbe.ref, work, 1)
+
+      worker ! deliveredMessage
+      worker ! Worker.WorkComplete("Successful result")
+
+      deliveryProbe.expectMessageType[ConsumerController.Confirmed]
+    }
+  }
+}

Review Comment:
   please add new lines at end of files



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


[GitHub] [incubator-pekko-samples] mario-renau-alstom closed pull request #66: Tests for worker and work executor

Posted by "mario-renau-alstom (via GitHub)" <gi...@apache.org>.
mario-renau-alstom closed pull request #66: Tests for worker and work executor
URL: https://github.com/apache/incubator-pekko-samples/pull/66


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


[GitHub] [incubator-pekko-samples] mario-renau-alstom commented on a diff in pull request #66: Tests for worker and work executor

Posted by "mario-renau-alstom (via GitHub)" <gi...@apache.org>.
mario-renau-alstom commented on code in PR #66:
URL: https://github.com/apache/incubator-pekko-samples/pull/66#discussion_r1294647949


##########
pekko-sample-distributed-workers-scala/src/test/scala/worker/WorkerSpec.scala:
##########
@@ -0,0 +1,39 @@
+package worker
+
+import org.apache.pekko
+import org.apache.pekko.actor.typed.delivery.ConsumerController
+import org.apache.pekko.actor.typed.scaladsl.Behaviors
+import pekko.actor.testkit.typed.scaladsl.ScalaTestWithActorTestKit
+import org.scalatest.wordspec.AnyWordSpecLike
+
+class WorkerSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike{
+
+  "A Worker" must {
+
+    "start work when in idle state" in {
+      val workExecutorProbe = createTestProbe[WorkExecutor.ExecuteWork]()
+      val worker = spawn(Worker(workExecutorFactory = () => Behaviors.monitor(workExecutorProbe.ref, WorkExecutor())))
+      val work = WorkManager.DoWork(Work("TestWork", 1000))
+      val deliveryProbe = createTestProbe[ConsumerController.Confirmed]()
+      val deliveredMessage = Worker.DeliveredMessage(deliveryProbe.ref, work, 1)
+
+      worker ! deliveredMessage
+
+      workExecutorProbe.expectMessageType[WorkExecutor.ExecuteWork]
+    }
+
+    "confirm the work when work is complete" in {
+      val workExecutorProbe = createTestProbe[WorkExecutor.ExecuteWork]()
+      val worker = spawn(Worker(workExecutorFactory = () => Behaviors.monitor(workExecutorProbe.ref, WorkExecutor())))
+      val work = WorkManager.DoWork(Work("TestWork", 1000))
+
+      val deliveryProbe = createTestProbe[ConsumerController.Confirmed]()
+      val deliveredMessage = Worker.DeliveredMessage(deliveryProbe.ref, work, 1)
+
+      worker ! deliveredMessage
+      worker ! Worker.WorkComplete("Successful result")
+
+      deliveryProbe.expectMessageType[ConsumerController.Confirmed]
+    }
+  }
+}

Review Comment:
   Fixed



##########
pekko-sample-distributed-workers-scala/src/test/scala/worker/WorkerSpec.scala:
##########
@@ -0,0 +1,39 @@
+package worker
+
+import org.apache.pekko
+import org.apache.pekko.actor.typed.delivery.ConsumerController

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


[GitHub] [incubator-pekko-samples] pjfanning commented on pull request #66: Tests for worker and work executor

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #66:
URL: https://github.com/apache/incubator-pekko-samples/pull/66#issuecomment-1679300801

   The CI builds failed because this file is not correctly formatted.
   
   pekko-sample-distributed-workers-scala/src/test/scala/worker/WorkerSpec.scala
   
   Could you run `sbt scalaftmtAll` ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


[GitHub] [incubator-pekko-samples] pjfanning commented on a diff in pull request #66: Tests for worker and work executor

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #66:
URL: https://github.com/apache/incubator-pekko-samples/pull/66#discussion_r1294491241


##########
pekko-sample-distributed-workers-scala/src/test/scala/worker/WorkerSpec.scala:
##########
@@ -0,0 +1,39 @@
+package worker
+
+import org.apache.pekko
+import org.apache.pekko.actor.typed.delivery.ConsumerController

Review Comment:
   can you remove the org.apache from this import and the next one 



##########
pekko-sample-distributed-workers-scala/src/test/scala/worker/WorkerSpec.scala:
##########
@@ -0,0 +1,39 @@
+package worker
+
+import org.apache.pekko
+import org.apache.pekko.actor.typed.delivery.ConsumerController

Review Comment:
   can you remove the org.apache from this import and the next one ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org