aurora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zma...@apache.org
Subject aurora git commit: Add additional tests for the conversion of TaskStatus.
Date Wed, 08 Feb 2017 17:57:45 GMT
Repository: aurora
Updated Branches:
  refs/heads/master 5b7042c4e -> ad3377ab2


Add additional tests for the conversion of TaskStatus.

This adds additional testing for the `ProtosConversions` class, ensuring there
is the correct conversion between `SlaveID` and `AgentID`.

Reviewed at https://reviews.apache.org/r/56361/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/ad3377ab
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/ad3377ab
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/ad3377ab

Branch: refs/heads/master
Commit: ad3377ab257d2e6d299dc88ed5ac6674819f7bd0
Parents: 5b7042c
Author: Zameer Manji <zmanji@apache.org>
Authored: Wed Feb 8 09:57:18 2017 -0800
Committer: Zameer Manji <zmanji@apache.org>
Committed: Wed Feb 8 09:57:18 2017 -0800

----------------------------------------------------------------------
 .../scheduler/mesos/ProtosConversionTest.java   | 42 +++++++++++++++++++-
 1 file changed, 40 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/ad3377ab/src/test/java/org/apache/aurora/scheduler/mesos/ProtosConversionTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/mesos/ProtosConversionTest.java b/src/test/java/org/apache/aurora/scheduler/mesos/ProtosConversionTest.java
index 86e065c..8cdf9e5 100644
--- a/src/test/java/org/apache/aurora/scheduler/mesos/ProtosConversionTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/mesos/ProtosConversionTest.java
@@ -13,9 +13,15 @@
  */
 package org.apache.aurora.scheduler.mesos;
 
+import java.nio.ByteBuffer;
+import java.util.UUID;
+
+import com.google.protobuf.ByteString;
+
 import org.apache.mesos.Protos;
 import org.junit.Test;
 
+import static org.apache.aurora.scheduler.mesos.ProtosConversion.convert;
 import static org.junit.Assert.assertEquals;
 
 public class ProtosConversionTest {
@@ -24,7 +30,7 @@ public class ProtosConversionTest {
   public void testOfferIDRoundTrip() {
     Protos.OfferID offerID = Protos.OfferID.newBuilder().setValue("offer-id").build();
 
-    assertEquals(offerID, ProtosConversion.convert(ProtosConversion.convert(offerID)));
+    assertEquals(offerID, convert(convert(offerID)));
   }
 
   @Test
@@ -36,6 +42,38 @@ public class ProtosConversionTest {
         .setId(Protos.OfferID.newBuilder().setValue("offer-id").build())
         .build();
 
-    assertEquals(offer, ProtosConversion.convert(ProtosConversion.convert(offer)));
+    assertEquals(offer, convert(convert(offer)));
+  }
+
+  @Test
+  public void testTaskStatusRoundTrip() {
+    assertEquals(getStatus(), convert(convert(getStatus())));
+  }
+
+  @Test
+  public void testTaskStatusConvertsAgentId() {
+    Protos.TaskStatus status = getStatus();
+    assertEquals(status.getSlaveId().getValue(), convert(status).getAgentId().getValue());
+  }
+
+  private Protos.TaskStatus getStatus() {
+    UUID uuid = UUID.randomUUID();
+    ByteBuffer buf = ByteBuffer.allocate(16);
+    buf.putLong(uuid.getMostSignificantBits());
+    buf.putLong(uuid.getLeastSignificantBits());
+
+    return Protos.TaskStatus.newBuilder()
+        .setUuid(ByteString.copyFrom(buf))
+        .setTaskId(
+            Protos.TaskID.newBuilder()
+                .setValue("www-data-prod-hello-0-e3a2e294-a511-441c-a6bf-b8b4579029e7")
+                .build())
+        .setState(Protos.TaskState.TASK_RUNNING)
+        .setMessage("Reconciliation: Latest task state")
+        .setSlaveId(Protos.SlaveID.newBuilder()
+            .setValue("10718383-5b7b-450f-8581-865134b3920c-S0")
+            .build())
+        .setTimestamp(1.4864285213798552E9)
+        .build();
   }
 }


Mime
View raw message