Repository: armadaproject/armada

Issue:
Scala client: submitHealth() in ArmadaClient wrapper should return a Future
The `SubmitGrpc.scala` generated from the original `submit.proto` defines the `health()` method as returning a `Future[HealthCheckResponse]` - make the ArmadaClient convenience wrapper's `submitHealth()` also return the
same. Without this change, an `UnsupportedOperationException` is raised in some tests.


Discussion:

Solution patch:
diff --git a/client/scala/armada-scala-client/src/main/scala/io/armadaproject/armada/ArmadaClient.scala b/client/scala/armada-scala-client/src/main/scala/io/armadaproject/armada/ArmadaClient.scala
index 1911ad7b..5de67b6d 100644
--- a/client/scala/armada-scala-client/src/main/scala/io/armadaproject/armada/ArmadaClient.scala
+++ b/client/scala/armada-scala-client/src/main/scala/io/armadaproject/armada/ArmadaClient.scala
@@ -51,9 +51,8 @@ class ArmadaClient(channel: ManagedChannel) {
     blockingStub.health(Empty()).status
   }
 
-  def submitHealth(): HealthCheckResponse.ServingStatus = {
-    val blockingStub = SubmitGrpc.blockingStub(channel)
-    blockingStub.health(Empty()).status
+  def submitHealth(): scala.concurrent.Future[HealthCheckResponse] = {
+    SubmitGrpc.stub(channel).health(Empty())
   }
 
   def createQueue(name: String): Unit = {



Test patch:
diff --git a/client/scala/armada-scala-client/src/test/scala/io/armadaproject/armada/ArmadaClientSuite.scala b/client/scala/armada-scala-client/src/test/scala/io/armadaproject/armada/ArmadaClientSuite.scala
index e6bf25cd..d1c04a62 100644
--- a/client/scala/armada-scala-client/src/test/scala/io/armadaproject/armada/ArmadaClientSuite.scala
+++ b/client/scala/armada-scala-client/src/test/scala/io/armadaproject/armada/ArmadaClientSuite.scala
@@ -266,6 +266,10 @@ class ArmadaClientSuite extends AnyFunSuite with BeforeAndAfterAll {
   private val statusMap: TrieMap[String, JobState] =
     new TrieMap // key is job id
 
+  // Required for processing Futures in test
+  implicit val ec: scala.concurrent.ExecutionContext =
+    scala.concurrent.ExecutionContext.global
+
   override def beforeAll(): Unit = {
     import scala.concurrent.ExecutionContext
     server = ServerBuilder
@@ -299,8 +303,13 @@ class ArmadaClientSuite extends AnyFunSuite with BeforeAndAfterAll {
 
   test("ArmadaClient.submitHealth()") {
     val ac = ArmadaClient("localhost", testPort)
-    val status = ac.submitHealth()
-    assert(status === HealthCheckResponse.ServingStatus.SERVING)
+    val healthResp = ac.submitHealth()
+    healthResp.onComplete {
+      case scala.util.Success(resp) =>
+        assert(resp.status === HealthCheckResponse.ServingStatus.SERVING)
+      case scala.util.Failure(exception) =>
+        fail("submitHealth() test failed: " + exception)
+    }
   }
 
   test("ArmadaClient.submitJobs()") {