myriad-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dar...@apache.org
Subject [1/2] incubator-myriad git commit: MYRIAD-200
Date Tue, 12 Jul 2016 18:51:41 GMT
Repository: incubator-myriad
Updated Branches:
  refs/heads/master 6354ce6ac -> 4a6e50c41


http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/4a6e50c4/myriad-scheduler/src/test/java/org/apache/myriad/scheduler/fgs/OfferLifeCycleManagerTest.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/test/java/org/apache/myriad/scheduler/fgs/OfferLifeCycleManagerTest.java
b/myriad-scheduler/src/test/java/org/apache/myriad/scheduler/fgs/OfferLifeCycleManagerTest.java
new file mode 100644
index 0000000..a16e8e6
--- /dev/null
+++ b/myriad-scheduler/src/test/java/org/apache/myriad/scheduler/fgs/OfferLifeCycleManagerTest.java
@@ -0,0 +1,54 @@
+package org.apache.myriad.scheduler.fgs;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.apache.hadoop.net.NodeBase;
+import org.apache.hadoop.yarn.api.records.impl.pb.NodeIdPBImpl;
+import org.apache.hadoop.yarn.api.records.impl.pb.ResourcePBImpl;
+import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto;
+import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
+import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNodeImpl;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode;
+import org.apache.mesos.Protos.Offer;
+import org.apache.myriad.TestObjectFactory;
+import org.apache.myriad.scheduler.MockSchedulerDriver;
+import org.apache.myriad.scheduler.MyriadDriver;
+import org.apache.myriad.state.MockRMContext;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit tests for OfferLifeCycleManager
+ */
+public class OfferLifeCycleManagerTest {
+  OfferLifecycleManager manager;
+
+  @Before
+  public void setUp() throws Exception {
+    NodeStore store = new NodeStore();
+    NodeIdProto nodeId = NodeIdProto.newBuilder().setHost("localhost").setPort(8000).build();
+    RMNode rmNode = new RMNodeImpl(new NodeIdPBImpl(nodeId), new MockRMContext(), "localhost",
8000, 8070, new NodeBase(),
+            new ResourcePBImpl(), "1.0");
+    SchedulerNode node = new FiCaSchedulerNode(rmNode, false);
+    store.add(node);
+    manager = new OfferLifecycleManager(store, new MyriadDriver(new MockSchedulerDriver()));
+  }
+  
+  @Test
+  public void testAddOffers() throws Exception {
+    manager.addOffers(TestObjectFactory.getOffer("localhost", "slave-1", "mock-framework",
"offer-1"));
+    assertNotNull(manager.getOfferFeed("localhost").poll());
+  }
+
+  @Test
+  public void testMarkAsConsumed() throws Exception {
+    Offer offer = TestObjectFactory.getOffer("localhost-1", "slave-2", "mock-framework",
"consumed-offer-1");
+    manager.addOffers(offer);
+    manager.markAsConsumed(offer);
+    ConsumedOffer cOffers = manager.getConsumedOffer("localhost-1");
+    Offer cOffer = cOffers.getOffers().get(0);
+    assertEquals(offer, cOffer);
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/4a6e50c4/myriad-scheduler/src/test/java/org/apache/myriad/scheduler/fgs/OfferUtilsTest.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/test/java/org/apache/myriad/scheduler/fgs/OfferUtilsTest.java
b/myriad-scheduler/src/test/java/org/apache/myriad/scheduler/fgs/OfferUtilsTest.java
new file mode 100644
index 0000000..915ac0b
--- /dev/null
+++ b/myriad-scheduler/src/test/java/org/apache/myriad/scheduler/fgs/OfferUtilsTest.java
@@ -0,0 +1,74 @@
+package org.apache.myriad.scheduler.fgs;
+
+import java.util.List;
+
+import org.apache.mesos.Protos;
+import org.apache.mesos.Protos.FrameworkID;
+import org.apache.mesos.Protos.Offer;
+import org.apache.mesos.Protos.OfferID;
+import org.apache.mesos.Protos.Resource;
+import org.apache.mesos.Protos.SlaveID;
+import org.apache.mesos.Protos.Value;
+import org.apache.mesos.Protos.Value.Scalar;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+import com.google.common.collect.Lists;
+
+/**
+ * Unit tests for OfferUtils
+ */
+public class OfferUtilsTest {
+
+  List<Offer> offers;
+
+  @Before
+  public void setUp() throws Exception {
+    offers = generateOffers(generateResources());
+  }
+
+  private List<Offer> generateOffers(List<Resource> resources) {
+    FrameworkID fidOne = Protos.FrameworkID.newBuilder().setValue("framework-1").build();
+    FrameworkID fidTwo = Protos.FrameworkID.newBuilder().setValue("framework-2").build();
+    FrameworkID fidThree = Protos.FrameworkID.newBuilder().setValue("framework-3").build();
+    FrameworkID fidFour = Protos.FrameworkID.newBuilder().setValue("framework-4").build();
+
+    OfferID oidOne = Protos.OfferID.newBuilder().setValue("offer-1").build();
+    OfferID oidTwo = Protos.OfferID.newBuilder().setValue("offer-2").build(); 
+    OfferID oidThree = Protos.OfferID.newBuilder().setValue("offer-3").build(); 
+    OfferID oidFour = Protos.OfferID.newBuilder().setValue("offer-4").build(); 
+
+    SlaveID sidOne = Protos.SlaveID.newBuilder().setValue("slave-1").build();
+    SlaveID sidTwo = Protos.SlaveID.newBuilder().setValue("slave-2").build();
+    SlaveID sidThree = Protos.SlaveID.newBuilder().setValue("slave-3").build();
+    SlaveID sidFour = Protos.SlaveID.newBuilder().setValue("slave-4").build();
+
+    Offer offerOne = Protos.Offer.newBuilder().setFrameworkId(fidOne).setHostname("10.0.0.1").setId(oidOne).setSlaveId(sidOne).
+        addResources(resources.get(0)).addResources(resources.get(1)).build();
+    Offer offerTwo = Protos.Offer.newBuilder().setFrameworkId(fidTwo).setHostname("10.0.0.2").setId(oidTwo).setSlaveId(sidTwo).
+        addResources(resources.get(2)).addResources(resources.get(3)).build();
+    Offer offerThree = Protos.Offer.newBuilder().setFrameworkId(fidThree).setHostname("10.0.0.3").setId(oidThree).setSlaveId(sidThree).
+        addResources(resources.get(0)).addResources(resources.get(3)).build();
+    Offer offerFour = Protos.Offer.newBuilder().setFrameworkId(fidFour).setHostname("10.0.0.4").setId(oidFour).setSlaveId(sidFour).
+        addResources(resources.get(2)).addResources(resources.get(1)).build();
+
+    return Lists.newArrayList(offerOne, offerTwo, offerThree, offerFour);
+  }
+  
+  private List<Resource> generateResources() {
+    Resource rOne = Protos.Resource.newBuilder().setName("cpus").setType(Value.Type.SCALAR).setScalar(Scalar.newBuilder().setValue(0.5)).build();
+    Resource rTwo = Protos.Resource.newBuilder().setName("mem").setType(Value.Type.SCALAR).setScalar(Scalar.newBuilder().setValue(1.0)).build();
+    Resource rThree = Protos.Resource.newBuilder().setName("cpus").setType(Value.Type.SCALAR).setScalar(Scalar.newBuilder().setValue(1.0)).build();
+    Resource rFour = Protos.Resource.newBuilder().setName("mem").setType(Value.Type.SCALAR).setScalar(Scalar.newBuilder().setValue(2.0)).build();
+    
+    return Lists.newArrayList(rOne, rTwo, rThree, rFour);
+  }
+  
+  @Test
+  public void testgetYarnResourcesFromMesosOffers() throws Exception {
+    org.apache.hadoop.yarn.api.records.Resource resource = OfferUtils.getYarnResourcesFromMesosOffers(offers);
+    assertEquals(6.0, resource.getMemory(), 1.0);
+    assertEquals(3.0, resource.getVirtualCores(), 1.0);
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/4a6e50c4/myriad-scheduler/src/test/java/org/apache/myriad/state/ClusterTest.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/test/java/org/apache/myriad/state/ClusterTest.java b/myriad-scheduler/src/test/java/org/apache/myriad/state/ClusterTest.java
new file mode 100644
index 0000000..69954b7
--- /dev/null
+++ b/myriad-scheduler/src/test/java/org/apache/myriad/state/ClusterTest.java
@@ -0,0 +1,62 @@
+package org.apache.myriad.state;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.myriad.scheduler.ServiceResourceProfile;
+import org.apache.myriad.scheduler.constraints.LikeConstraint;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit tests for Cluster
+ */
+public class ClusterTest {
+  Cluster cluster;
+  NodeTask task1, task2, task3;
+
+  @Before
+  public void setUp() throws Exception {
+    cluster = new Cluster();
+    cluster.setClusterName("test-cluster");
+    cluster.setMinQuota(5.0);
+    cluster.setResourceManagerHost("localhost");
+    cluster.setResourceManagerPort("8192");
+
+    task1 = new NodeTask(new ServiceResourceProfile("profile1", 0.1, 1024.0), new LikeConstraint("hostname1",
"host-[0-9]*.example1.com"));
+    task2 = new NodeTask(new ServiceResourceProfile("profile2", 0.2, 1024.0), new LikeConstraint("hostname2",
"host-[0-9]*.example2.com"));
+    task3 = new NodeTask(new ServiceResourceProfile("profile3", 0.3, 1024.0), new LikeConstraint("hostname3",
"host-[0-9]*.example3.com"));
+  }
+
+  private void resetCluster() throws Exception {
+    cluster.removeAllNodes();
+  }
+
+  @Test
+  public void testCoreAttributes() throws Exception {
+    assertEquals("test-cluster", cluster.getClusterName());
+    assertEquals(5.0, cluster.getMinQuota(), 0.0001);
+    assertEquals("localhost", cluster.getResourceManagerHost());
+    assertEquals("8192", cluster.getResourceManagerPort());  
+  }
+
+  @Test
+  public void testAddNode() throws Exception {
+    resetCluster();
+    cluster.addNode(task1);
+    assertEquals(1, cluster.getNodes().size());
+    cluster.addNode(task2);
+    assertEquals(2, cluster.getNodes().size());
+  }
+
+  @Test
+  public void testRemoveNode() throws Exception {
+    resetCluster();
+    cluster.addNode(task1);
+    cluster.addNode(task2);
+    cluster.addNode(task3);
+    cluster.removeNode(task1);
+    assertEquals(2, cluster.getNodes().size());
+    cluster.removeNode(task2);
+    assertEquals(1, cluster.getNodes().size());
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/4a6e50c4/myriad-scheduler/src/test/java/org/apache/myriad/state/MockDispatcher.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/test/java/org/apache/myriad/state/MockDispatcher.java b/myriad-scheduler/src/test/java/org/apache/myriad/state/MockDispatcher.java
new file mode 100644
index 0000000..bc06441
--- /dev/null
+++ b/myriad-scheduler/src/test/java/org/apache/myriad/state/MockDispatcher.java
@@ -0,0 +1,32 @@
+package org.apache.myriad.state;
+
+import org.apache.hadoop.yarn.event.Dispatcher;
+import org.apache.hadoop.yarn.event.EventHandler;
+import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEvent;
+
+/**
+ * Mock Dispatcher implementation for unit tests
+ */
+public class MockDispatcher implements Dispatcher {
+  EventHandler<RMAppEvent> handler = new MockEventHandler();
+
+  /**
+   * Mock EventHandler implementation for unit tests
+   */
+  public static class MockEventHandler implements EventHandler<RMAppEvent> {
+    @Override
+    public void handle(RMAppEvent event) {
+      //noop
+    }  
+  }
+
+  @Override
+  public EventHandler<RMAppEvent> getEventHandler() {
+    return handler;
+  }
+
+  @Override
+  public void register(Class<? extends Enum> eventType, EventHandler handler) {
+    //noop
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/4a6e50c4/myriad-scheduler/src/test/java/org/apache/myriad/state/MockFuture.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/test/java/org/apache/myriad/state/MockFuture.java b/myriad-scheduler/src/test/java/org/apache/myriad/state/MockFuture.java
new file mode 100644
index 0000000..fa4628f
--- /dev/null
+++ b/myriad-scheduler/src/test/java/org/apache/myriad/state/MockFuture.java
@@ -0,0 +1,44 @@
+package org.apache.myriad.state;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.mesos.state.Variable;
+
+/**
+ * Stubbed-out implementation for unit tests
+ */
+public class MockFuture implements Future<Variable> {
+  private Variable value;
+
+  public MockFuture(Variable value) {
+    this.value = value;
+  }
+  @Override
+  public boolean cancel(boolean mayInterruptIfRunning) {
+    return false;
+  }
+
+  @Override
+  public boolean isCancelled() {
+    return false;
+  }
+
+  @Override
+  public boolean isDone() {
+    return false;
+  }
+
+  @Override
+  public Variable get() throws InterruptedException, ExecutionException {
+    return value;
+  }
+
+  @Override
+  public Variable get(long timeout, TimeUnit unit)
+        throws InterruptedException, ExecutionException, TimeoutException {
+    return value;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/4a6e50c4/myriad-scheduler/src/test/java/org/apache/myriad/state/MockRMApp.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/test/java/org/apache/myriad/state/MockRMApp.java b/myriad-scheduler/src/test/java/org/apache/myriad/state/MockRMApp.java
new file mode 100644
index 0000000..822c08a
--- /dev/null
+++ b/myriad-scheduler/src/test/java/org/apache/myriad/state/MockRMApp.java
@@ -0,0 +1,202 @@
+package org.apache.myriad.state;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationReport;
+import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
+import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
+import org.apache.hadoop.yarn.api.records.NodeId;
+import org.apache.hadoop.yarn.api.records.Priority;
+import org.apache.hadoop.yarn.api.records.ReservationId;
+import org.apache.hadoop.yarn.api.records.ResourceRequest;
+import org.apache.hadoop.yarn.api.records.YarnApplicationState;
+import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
+import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEvent;
+import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppMetrics;
+import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppState;
+import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttempt;
+import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
+
+/**
+ * Mock RMApp for unit tests
+ */
+public class MockRMApp implements RMApp {
+  static final int DT = 1000000;
+  String user = "yarn";
+  String name = "mock-app";
+  String queue = "mock-queue";
+  long start = System.currentTimeMillis();
+  long submit = start - (5 * DT);
+  long finish = start + (15 * DT);
+  RMAppState state = RMAppState.NEW;
+  String applicationType = "mock";
+  ApplicationId id;
+  ApplicationSubmissionContext context;
+  String tUrl = "localhost:8080";
+  String oUrl = "localhost:8081";
+  int maxAppAttempts = 5;
+  
+  Map<ApplicationAttemptId, RMAppAttempt> attempts = new HashMap<ApplicationAttemptId,
RMAppAttempt>();
+
+  public MockRMApp(int newId, long time, RMAppState state) {
+    finish = time;
+    id = ApplicationId.newInstance(System.currentTimeMillis(), newId);
+    context = ApplicationSubmissionContext.newInstance(id, name, queue, Priority.newInstance(0),
null, false, false, newId, null, applicationType);
+    this.state = state;
+  }
+  
+  @Override
+  public void handle(RMAppEvent event) {
+
+  }
+
+  @Override
+  public ApplicationId getApplicationId() {
+    return id;
+  }
+
+  @Override
+  public ApplicationSubmissionContext getApplicationSubmissionContext() {
+    return context;
+  }
+
+  @Override
+  public RMAppState getState() {
+    return state;
+  }
+
+  @Override
+  public String getUser() {
+    return user;
+  }
+
+  @Override
+  public float getProgress() {
+    return 0;
+  }
+
+  @Override
+  public RMAppAttempt getRMAppAttempt(ApplicationAttemptId appAttemptId) {
+    return null;
+  }
+
+  @Override
+  public String getQueue() {
+    return queue;
+  }
+
+  @Override
+  public void setQueue(String queue) {
+    this.queue = queue;
+  }
+
+  @Override
+  public String getName() {
+    return name;
+  }
+
+  @Override
+  public RMAppAttempt getCurrentAppAttempt() {
+    return null;
+  }
+
+  @Override
+  public Map<ApplicationAttemptId, RMAppAttempt> getAppAttempts() {
+    return attempts;
+  }
+
+  @Override
+  public ApplicationReport createAndGetApplicationReport(String clientUserName, boolean allowAccess)
{
+    return null;
+  }
+
+  @Override
+  public int pullRMNodeUpdates(Collection<RMNode> updatedNodes) {
+    return 0;
+  }
+
+  @Override
+  public long getFinishTime() {
+    return finish;
+  }
+
+  @Override
+  public long getStartTime() {
+    return start;
+  }
+
+  @Override
+  public long getSubmitTime() {
+    return submit;
+  }
+
+  @Override
+  public String getTrackingUrl() {
+    return this.tUrl;
+  }
+
+  @Override
+  public String getOriginalTrackingUrl() {
+    return this.oUrl;
+  }
+
+  @Override
+  public StringBuilder getDiagnostics() {
+    return null;
+  }
+
+  @Override
+  public FinalApplicationStatus getFinalApplicationStatus() {
+    return null;
+  }
+
+  @Override
+  public int getMaxAppAttempts() {
+    return this.maxAppAttempts;
+  }
+
+  @Override
+  public String getApplicationType() {
+    return this.applicationType;
+  }
+
+  @Override
+  public Set<String> getApplicationTags() {
+    return null;
+  }
+
+  @Override
+  public boolean isAppFinalStateStored() {
+    return false;
+  }
+
+  @Override
+  public Set<NodeId> getRanNodes() {
+    return null;
+  }
+
+  @Override
+  public YarnApplicationState createApplicationState() {
+    return null;
+  }
+
+  @Override
+  public RMAppMetrics getRMAppMetrics() {
+    return null;
+  }
+
+  @Override
+  public ReservationId getReservationId() {
+    return null;
+  }
+
+  @Override
+  public ResourceRequest getAMResourceRequest() {
+    return null;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/4a6e50c4/myriad-scheduler/src/test/java/org/apache/myriad/state/MockRMContext.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/test/java/org/apache/myriad/state/MockRMContext.java b/myriad-scheduler/src/test/java/org/apache/myriad/state/MockRMContext.java
new file mode 100644
index 0000000..42fa045
--- /dev/null
+++ b/myriad-scheduler/src/test/java/org/apache/myriad/state/MockRMContext.java
@@ -0,0 +1,339 @@
+package org.apache.myriad.state;
+
+import java.nio.ByteBuffer;
+import java.util.concurrent.ConcurrentMap;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.ha.HAServiceProtocol;
+import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState;
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.NodeId;
+import org.apache.hadoop.yarn.conf.ConfigurationProvider;
+import org.apache.hadoop.yarn.event.Dispatcher;
+import org.apache.hadoop.yarn.server.resourcemanager.AdminService;
+import org.apache.hadoop.yarn.server.resourcemanager.ApplicationMasterService;
+import org.apache.hadoop.yarn.server.resourcemanager.ClientRMService;
+import org.apache.hadoop.yarn.server.resourcemanager.NodesListManager;
+import org.apache.hadoop.yarn.server.resourcemanager.RMActiveServiceContext;
+import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
+import org.apache.hadoop.yarn.server.resourcemanager.ResourceTrackerService;
+import org.apache.hadoop.yarn.server.resourcemanager.ahs.RMApplicationHistoryWriter;
+import org.apache.hadoop.yarn.server.resourcemanager.metrics.SystemMetricsPublisher;
+import org.apache.hadoop.yarn.server.resourcemanager.nodelabels.RMNodeLabelsManager;
+import org.apache.hadoop.yarn.server.resourcemanager.recovery.RMStateStore;
+import org.apache.hadoop.yarn.server.resourcemanager.reservation.ReservationSystem;
+import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
+import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.AMLivelinessMonitor;
+import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.ContainerAllocationExpirer;
+import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
+import org.apache.hadoop.yarn.server.resourcemanager.security.AMRMTokenSecretManager;
+import org.apache.hadoop.yarn.server.resourcemanager.security.ClientToAMTokenSecretManagerInRM;
+import org.apache.hadoop.yarn.server.resourcemanager.security.DelegationTokenRenewer;
+import org.apache.hadoop.yarn.server.resourcemanager.security.NMTokenSecretManagerInRM;
+import org.apache.hadoop.yarn.server.resourcemanager.security.RMContainerTokenSecretManager;
+import org.apache.hadoop.yarn.server.resourcemanager.security.RMDelegationTokenSecretManager;
+
+/**
+ * Mock implementation of RMContext for the purposes of JUnit tests
+ */
+public class MockRMContext implements RMContext {
+  Dispatcher dispatcher;
+  boolean haEnabled = false;
+  RMStateStore stateStore;
+  AMLivelinessMonitor amLivelinessMonitor;
+  AMLivelinessMonitor amFinishingMonitor;
+  RMActiveServiceContext activeServiceContext;
+  HAServiceState haServiceState = HAServiceProtocol.HAServiceState.INITIALIZING;
+  Configuration yarnConfiguration;
+  RMNodeLabelsManager mgr;
+  ResourceScheduler resourceScheduler;
+  boolean workPreservingRecoveryEnabled;
+  NMTokenSecretManagerInRM nmTokenSecretManager;
+  RMApplicationHistoryWriter rmApplicationHistoryWriter = new RMApplicationHistoryWriter();
+  RMDelegationTokenSecretManager delegationTokenSecretManager;
+  RMContainerTokenSecretManager containerTokenSecretManager;
+  NodesListManager nodesListManager;
+  ContainerAllocationExpirer containerAllocationExpirer;
+  AMRMTokenSecretManager tokenSecretManager;
+  DelegationTokenRenewer delegationTokenRenewer;
+  ClientRMService clientRMService;
+  ApplicationMasterService applicationMasterService;
+  ResourceTrackerService resourceTrackerService;
+  SystemMetricsPublisher systemMetricsPublisher;
+  ConfigurationProvider configurationProvider;
+  AdminService adminService;
+  
+  public void setApplicationMasterService(ApplicationMasterService applicationMasterService)
{
+    this.applicationMasterService = applicationMasterService;
+  }
+
+  public RMActiveServiceContext getActiveServiceContext() {
+    return activeServiceContext;
+  }
+
+  public void setActiveServiceContext(RMActiveServiceContext activeServiceContext) {
+    this.activeServiceContext = activeServiceContext;
+  }
+
+  public void setResourceTrackerService(ResourceTrackerService resourceTrackerService) {
+    this.resourceTrackerService = resourceTrackerService;
+  }
+
+  public void setContainerTokenSecretManager(RMContainerTokenSecretManager containerTokenSecretManager)
{
+    this.containerTokenSecretManager = containerTokenSecretManager;
+  }
+
+  public void setDelegationTokenRenewer(DelegationTokenRenewer delegationTokenRenewer) {
+    this.delegationTokenRenewer = delegationTokenRenewer;
+  }
+
+  public void setAdminService(AdminService adminService) {
+    this.adminService = adminService;
+  }
+
+  public void setConfigurationProvider(ConfigurationProvider configurationProvider) {
+    this.configurationProvider = configurationProvider;
+  }
+
+  public void setDelegationTokenSecretManager(RMDelegationTokenSecretManager delegationTokenSecretManager)
{
+    this.delegationTokenSecretManager = delegationTokenSecretManager;
+  }
+
+  public void setTokenSecretManager(AMRMTokenSecretManager tokenSecretManager) {
+    this.tokenSecretManager = tokenSecretManager;
+  }
+
+  public void setContainerAllocationExpirer(ContainerAllocationExpirer containerAllocationExpirer)
{
+    this.containerAllocationExpirer = containerAllocationExpirer;
+  }
+
+  public void setNodesListManager(NodesListManager nodesListManager) {
+    this.nodesListManager = nodesListManager;
+  }
+
+  public void setNmTokenSecretManager(NMTokenSecretManagerInRM nmTokenSecretManager) {
+    this.nmTokenSecretManager = nmTokenSecretManager;
+  }
+
+  public void setWorkPreservingRecoveryEnabled(boolean workPreservingRecoveryEnabled) {
+    this.workPreservingRecoveryEnabled = workPreservingRecoveryEnabled;
+  }
+
+  public void setResourceScheduler(ResourceScheduler resourceScheduler) {
+    this.resourceScheduler = resourceScheduler;
+  }
+
+  public void setMgr(RMNodeLabelsManager mgr) {
+    this.mgr = mgr;
+  }
+
+  public void setYarnConfiguration(Configuration yarnConfiguration) {
+    this.yarnConfiguration = yarnConfiguration;
+  }
+  
+  public void setHaEnabled(boolean haEnabled) {
+    this.haEnabled = haEnabled;
+  }
+
+  public void setAmLivelinessMonitor(AMLivelinessMonitor amLivelinessMonitor) {
+    this.amLivelinessMonitor = amLivelinessMonitor;
+  }
+
+  public void setAmFinishingMonitor(AMLivelinessMonitor amFinishingMonitor) {
+    this.amFinishingMonitor = amFinishingMonitor;
+  }
+
+  public void setDispatcher(Dispatcher dispatcher) {
+    this.dispatcher = dispatcher;
+  }
+
+  public void setStateStore(RMStateStore stateStore) {
+    this.stateStore = stateStore;
+  }
+
+  @Override
+  public Dispatcher getDispatcher() {
+    return dispatcher;
+  }
+
+  @Override
+  public boolean isHAEnabled() {
+    return haEnabled;
+  }
+
+  @Override
+  public HAServiceState getHAServiceState() {
+    return haServiceState;
+  }
+
+  @Override
+  public RMStateStore getStateStore() {
+    return stateStore;
+  }
+
+  @Override
+  public ConcurrentMap<ApplicationId, RMApp> getRMApps() {
+    return null;
+  }
+
+  @Override
+  public ConcurrentMap<ApplicationId, ByteBuffer> getSystemCredentialsForApps() {
+    return null;
+  }
+
+  @Override
+  public ConcurrentMap<String, RMNode> getInactiveRMNodes() {
+    return null;
+  }
+
+  @Override
+  public ConcurrentMap<NodeId, RMNode> getRMNodes() {
+    return null;
+  }
+
+  @Override
+  public AMLivelinessMonitor getAMLivelinessMonitor() {
+    return amLivelinessMonitor;
+  }
+
+  @Override
+  public AMLivelinessMonitor getAMFinishingMonitor() {
+    return amFinishingMonitor;
+  }
+
+  @Override
+  public ContainerAllocationExpirer getContainerAllocationExpirer() {
+    return containerAllocationExpirer;
+  }
+
+  @Override
+  public DelegationTokenRenewer getDelegationTokenRenewer() {
+    return delegationTokenRenewer;
+  }
+
+  @Override
+  public AMRMTokenSecretManager getAMRMTokenSecretManager() {
+    return tokenSecretManager;
+  }
+
+  @Override
+  public RMContainerTokenSecretManager getContainerTokenSecretManager() {
+    return containerTokenSecretManager;
+  }
+
+  @Override
+  public NMTokenSecretManagerInRM getNMTokenSecretManager() {
+    return nmTokenSecretManager;
+  }
+
+  @Override
+  public ResourceScheduler getScheduler() {
+    return resourceScheduler;
+  }
+
+  @Override
+  public NodesListManager getNodesListManager() {
+    return nodesListManager;
+  }
+
+  @Override
+  public ClientToAMTokenSecretManagerInRM getClientToAMTokenSecretManager() {
+    return null;
+  }
+
+  @Override
+  public AdminService getRMAdminService() {
+    return adminService;
+  }
+
+  @Override
+  public ClientRMService getClientRMService() {
+    return clientRMService;
+  }
+
+  @Override
+  public ApplicationMasterService getApplicationMasterService() {
+    return applicationMasterService;
+  }
+
+  @Override
+  public ResourceTrackerService getResourceTrackerService() {
+    return resourceTrackerService;
+  }
+
+  @Override
+  public void setClientRMService(ClientRMService clientRMService) {
+    this.clientRMService = clientRMService;
+  }
+
+  @Override
+  public RMDelegationTokenSecretManager getRMDelegationTokenSecretManager() {
+    return delegationTokenSecretManager;
+  }
+
+  @Override
+  public void setRMDelegationTokenSecretManager(RMDelegationTokenSecretManager delegationTokenSecretManager)
{
+    this.delegationTokenSecretManager = delegationTokenSecretManager;
+  }
+
+  @Override
+  public RMApplicationHistoryWriter getRMApplicationHistoryWriter() {
+    return rmApplicationHistoryWriter;
+  }
+
+  @Override
+  public void setRMApplicationHistoryWriter(RMApplicationHistoryWriter rmApplicationHistoryWriter)
{
+    this.rmApplicationHistoryWriter = rmApplicationHistoryWriter;
+  }
+
+  @Override
+  public void setSystemMetricsPublisher(SystemMetricsPublisher systemMetricsPublisher) {
+    this.systemMetricsPublisher = systemMetricsPublisher;
+  }
+
+  @Override
+  public SystemMetricsPublisher getSystemMetricsPublisher() {
+    return systemMetricsPublisher;
+  }
+
+  @Override
+  public ConfigurationProvider getConfigurationProvider() {
+    return configurationProvider;
+  }
+
+  @Override
+  public boolean isWorkPreservingRecoveryEnabled() {
+    return workPreservingRecoveryEnabled;
+  }
+
+  @Override
+  public RMNodeLabelsManager getNodeLabelManager() {
+    return mgr;
+  }
+
+  @Override
+  public void setNodeLabelManager(RMNodeLabelsManager mgr) {
+    this.mgr = mgr;
+  }
+
+  @Override
+  public long getEpoch() {
+    return 0;
+  }
+
+  @Override
+  public ReservationSystem getReservationSystem() {
+    return null;
+  }
+
+  @Override
+  public boolean isSchedulerReadyForAllocatingContainers() {
+    return false;
+  }
+
+  @Override
+  public Configuration getYarnConfiguration() {
+    return this.yarnConfiguration;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/4a6e50c4/myriad-scheduler/src/test/java/org/apache/myriad/state/MockState.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/test/java/org/apache/myriad/state/MockState.java b/myriad-scheduler/src/test/java/org/apache/myriad/state/MockState.java
new file mode 100644
index 0000000..ba29ff8
--- /dev/null
+++ b/myriad-scheduler/src/test/java/org/apache/myriad/state/MockState.java
@@ -0,0 +1,45 @@
+package org.apache.myriad.state;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.concurrent.Future;
+
+import org.apache.mesos.state.State;
+import org.apache.mesos.state.Variable;
+
+/**
+ * Stubbed-out implementation for unit tests
+ */
+public class MockState implements State {
+  private Map<String, Future<Variable>> values = new HashMap<String, Future<Variable>>();
+
+  @Override
+  public Future<Variable> fetch(String name) {
+    return values.get(name);
+  }
+
+  @Override
+  public Future<Variable> store(Variable variable) {
+    MockFuture future = new MockFuture(variable);
+    
+    if (!(variable instanceof MockVariable)) {
+      throw new IllegalArgumentException("The Variable must be a MockVariable");
+    }
+    
+    MockVariable mVar = (MockVariable) variable;
+    values.put(mVar.name(), future);
+
+    return future;
+  }
+
+  @Override
+  public Future<Boolean> expunge(Variable variable) {
+    return null;
+  }
+
+  @Override
+  public Future<Iterator<String>> names() {
+    return null;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/4a6e50c4/myriad-scheduler/src/test/java/org/apache/myriad/state/MockVariable.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/test/java/org/apache/myriad/state/MockVariable.java b/myriad-scheduler/src/test/java/org/apache/myriad/state/MockVariable.java
new file mode 100644
index 0000000..06655e3
--- /dev/null
+++ b/myriad-scheduler/src/test/java/org/apache/myriad/state/MockVariable.java
@@ -0,0 +1,35 @@
+package org.apache.myriad.state;
+
+import org.apache.mesos.state.Variable;
+
+/**
+ * Simplified implementation for unit tests
+ */
+public class MockVariable extends Variable {
+  private byte[] value;
+  private String name;
+  public MockVariable(){}
+ 
+  public MockVariable setValue(byte[] value) {
+    this.value = value.clone();
+    return this;
+  }
+
+  public MockVariable setName(String name) {
+    this.name = name;
+    return this;
+  }
+
+  @Override
+  public byte[] value() {
+    return this.value.clone();
+  }
+
+  public String name() {
+    return this.name;
+  }
+  @Override
+  public Variable mutate(byte[] value) {
+    return new MockVariable();
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/4a6e50c4/myriad-scheduler/src/test/java/org/apache/myriad/state/MyriadStateTest.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/test/java/org/apache/myriad/state/MyriadStateTest.java b/myriad-scheduler/src/test/java/org/apache/myriad/state/MyriadStateTest.java
new file mode 100644
index 0000000..e5a378f
--- /dev/null
+++ b/myriad-scheduler/src/test/java/org/apache/myriad/state/MyriadStateTest.java
@@ -0,0 +1,21 @@
+package org.apache.myriad.state;
+
+import org.apache.mesos.Protos.FrameworkID;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit test for MyriadState
+ */
+public class MyriadStateTest {
+  @Test
+  public void testSetAndGetFrameworkITask() throws Exception {
+    MockState mState = new MockState();
+    mState.store(new MockVariable().setName("frameworkId").setValue(FrameworkID.newBuilder().setValue("mock-framework").build().toByteArray()));
+
+    MyriadState state = new MyriadState(mState);
+    state.setFrameworkId(FrameworkID.newBuilder().setValue("mock-framework").build());
+
+    assertEquals("mock-framework", state.getFrameworkID().getValue());
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/4a6e50c4/myriad-scheduler/src/test/java/org/apache/myriad/state/NodeTaskTest.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/test/java/org/apache/myriad/state/NodeTaskTest.java b/myriad-scheduler/src/test/java/org/apache/myriad/state/NodeTaskTest.java
new file mode 100644
index 0000000..d3cf2fe
--- /dev/null
+++ b/myriad-scheduler/src/test/java/org/apache/myriad/state/NodeTaskTest.java
@@ -0,0 +1,40 @@
+package org.apache.myriad.state;
+
+import org.apache.myriad.scheduler.ServiceResourceProfile;
+import org.apache.myriad.scheduler.constraints.LikeConstraint;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit test cases for NodeTask
+ */
+public class NodeTaskTest {
+  NodeTask task;
+
+  @Before
+  public void setUp() throws Exception {    
+    task = new NodeTask(new ServiceResourceProfile("profile", 0.1, 1024.0), new LikeConstraint("hostname",
"host-[0-9]*.example.com"));
+    
+    task.setHostname("localhost");
+    task.setTaskPrefix("prefix");
+    task.setProfile(new ServiceResourceProfile("ServiceResourceProfile", 0.1, 1024.0, 0.1,
512.0));
+  }
+  
+  @Test
+  public void testCoreState() throws Exception {
+    Assert.assertEquals("prefix", task.getTaskPrefix());
+    Assert.assertEquals("localhost", task.getHostname());
+  }
+  
+  @Test
+  public void testConstraintState() throws Exception {
+    Assert.assertEquals("LIKE", task.getConstraint().getType().toString());
+  }
+  
+  @Test
+  public void testServiceResourceProfileState() throws Exception {
+    Assert.assertEquals(new Double(1024.0), task.getProfile().getMemory());
+    Assert.assertEquals(new Double(0.1), task.getProfile().getCpus());
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/4a6e50c4/myriad-scheduler/src/test/java/org/apache/myriad/state/SchedulerStateTest.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/test/java/org/apache/myriad/state/SchedulerStateTest.java
b/myriad-scheduler/src/test/java/org/apache/myriad/state/SchedulerStateTest.java
new file mode 100644
index 0000000..a3cdf4f
--- /dev/null
+++ b/myriad-scheduler/src/test/java/org/apache/myriad/state/SchedulerStateTest.java
@@ -0,0 +1,65 @@
+package org.apache.myriad.state;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.Set;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.yarn.server.resourcemanager.recovery.MyriadFileSystemRMStateStore;
+import org.apache.mesos.Protos.FrameworkID;
+import org.apache.mesos.Protos.TaskID;
+import org.apache.myriad.TestObjectFactory;
+import org.apache.myriad.scheduler.ServiceResourceProfile;
+import org.apache.myriad.scheduler.constraints.LikeConstraint;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.collect.Sets;
+
+/**
+ * Unit tests for SchedulerState
+ */
+public class SchedulerStateTest {
+  SchedulerState state;
+
+  @Before
+  public void setUp() throws Exception {
+    MyriadFileSystemRMStateStore store = TestObjectFactory.getStateStore(getConfiguration());
+    state = new SchedulerState(store);    
+  }
+
+  @Test
+  public void testSetFrameworkID() throws Exception {
+    state.setFrameworkId(FrameworkID.newBuilder().setValue("mock-framework").build());
+    assertEquals("mock-framework", state.getFrameworkID().get().getValue());
+  }
+  
+  @Test
+  public void testAddAndRemoveTask() throws Exception {
+    NodeTask task1 = new NodeTask(new ServiceResourceProfile("profile1", 0.1, 1024.0), new
LikeConstraint("hostname", "host-[0-9]*.example.com"));
+    NodeTask task2 = new NodeTask(new ServiceResourceProfile("profile2", 0.1, 1024.0), new
LikeConstraint("hostname", "host-[0-9]*.example.com"));
+    TaskID id1 = TaskID.newBuilder().setValue("mock-task-1").build();
+    TaskID id2 = TaskID.newBuilder().setValue("mock-task-2").build();
+    
+    Set<TaskID> taskIds = Sets.newHashSet(id1, id2);
+    state.addTask(id1, task1);
+    assertNotNull(state.getTask(id1));
+    state.addTask(id2, task2);
+    assertNotNull(state.getTask(id2));
+    assertEquals(2, state.getTasks(taskIds).size());
+    state.removeTask(id1);   
+    assertEquals(1, state.getTasks(taskIds).size());
+    assertNull(state.getTask(id1)); 
+    state.removeTask(id2);   
+    assertEquals(0, state.getTasks(taskIds).size());
+    assertNull(state.getTask(id2)); 
+  }
+
+  private Configuration getConfiguration() {
+    Configuration conf = new Configuration();
+    conf.set("yarn.resourcemanager.fs.state-store.uri", "file:///tmp/");
+    return conf;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/4a6e50c4/myriad-scheduler/src/test/java/org/apache/myriad/state/utils/ByteBufferSupportTest.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/test/java/org/apache/myriad/state/utils/ByteBufferSupportTest.java
b/myriad-scheduler/src/test/java/org/apache/myriad/state/utils/ByteBufferSupportTest.java
new file mode 100644
index 0000000..6794ec2
--- /dev/null
+++ b/myriad-scheduler/src/test/java/org/apache/myriad/state/utils/ByteBufferSupportTest.java
@@ -0,0 +1,184 @@
+package org.apache.myriad.state.utils;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.mesos.Protos;
+import org.apache.mesos.Protos.CommandInfo;
+import org.apache.mesos.Protos.ExecutorID;
+import org.apache.mesos.Protos.ExecutorInfo;
+import org.apache.mesos.Protos.FrameworkID;
+import org.apache.myriad.scheduler.ServiceResourceProfile;
+import org.apache.myriad.scheduler.constraints.LikeConstraint;
+import org.apache.myriad.state.NodeTask;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.collect.Lists;
+
+/**
+ * Unit tests for ByteBufferSupport class
+ *
+ */
+public class ByteBufferSupportTest {
+
+  private static final byte[] BYTE_ARRAY = getByteArray("e04fd020ea3a6910a2d808002b30309d");
+
+  private NodeTask task;
+
+  @Before
+  public void setUp() throws Exception {
+    task = new NodeTask(new ServiceResourceProfile("profile", 0.1, 1024.0), new LikeConstraint("hostname",
"host-[0-9]*.example.com"));    
+    task.setHostname("localhost");
+    task.setTaskPrefix("prefix"); 
+    task.setExecutorInfo(getExecutorInfo());
+  }
+
+  private ExecutorInfo getExecutorInfo() {
+    FrameworkID id = Protos.FrameworkID.newBuilder().setValue("framework1").build();
+    ExecutorID eid = Protos.ExecutorID.newBuilder().setValue("executor1").build();
+    CommandInfo cm = Protos.CommandInfo.newBuilder().setValue("command").build();
+    return ExecutorInfo.newBuilder().setFrameworkId(id).setExecutorId(eid).setCommand(cm).build();
+  }
+
+  private ByteBuffer getByteBuffer(byte[] bytes) {
+    ByteBuffer bb = ByteBuffer.allocate(bytes.length);
+    bb.put(bytes);
+    bb.rewind();  
+    return bb;
+  }
+
+  private static byte[] getByteArray(String s) {
+    int len = s.length();
+    byte[] data = new byte[len / 2];
+    for (int i = 0; i < len; i += 2) {
+      data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) 
+        + Character.digit(s.charAt(i + 1), 16));
+    }
+    return data;
+  }
+
+  @Test
+  public void testGetBytes() throws Exception {
+    ByteBuffer bb = getByteBuffer(BYTE_ARRAY);
+    
+    byte[] bytes = ByteBufferSupport.getBytes(bb, bb.capacity());
+    
+    assertEquals(BYTE_ARRAY.length, bytes.length);
+    
+    for (int i = 0, j = bytes.length; i < j; i++) {
+      assertEquals(bytes[i], BYTE_ARRAY[i]);
+    }
+  }
+  
+  @Test
+  public void testFillBuffer() throws Exception {
+    ByteBuffer bb = ByteBufferSupport.fillBuffer(BYTE_ARRAY);
+    ByteBuffer bbCompare = getByteBuffer(BYTE_ARRAY);
+
+    assertEquals(bb, bbCompare); 
+  }
+  
+  @Test
+  public void testNonEmptyAddByteBuffer() throws Exception {
+    ByteBuffer bb = getByteBuffer(BYTE_ARRAY);
+    ByteArrayOutputStream stream = new ByteArrayOutputStream();
+
+    ByteBufferSupport.addByteBuffer(bb, stream);
+    assertEquals(20, stream.size());
+    ByteBufferSupport.addByteBuffer(bb, stream);
+    assertEquals(40, stream.size());
+  }
+  
+  @Test
+  public void testEmptyAddByteBuffer() throws Exception {
+    ByteArrayOutputStream stream = new ByteArrayOutputStream();
+    ByteBuffer bb = getByteBuffer(ArrayUtils.EMPTY_BYTE_ARRAY);
+    ByteBufferSupport.addByteBuffer(bb, stream);
+    assertEquals(0, stream.size());
+  }  
+  
+  @Test
+  public void testNullAddByteBuffer() throws Exception {
+    ByteArrayOutputStream stream = new ByteArrayOutputStream();
+
+    ByteBufferSupport.addByteBuffer(null, stream);
+    assertEquals(0, stream.size());
+  }
+  
+  @Test
+  public void testNonEmptyAddByteBufferList() throws Exception {
+    ByteBuffer bb = getByteBuffer(BYTE_ARRAY);
+    ByteBuffer bbTwo = getByteBuffer(BYTE_ARRAY);
+    ByteArrayOutputStream stream = new ByteArrayOutputStream();
+
+    List<ByteBuffer> bList = Lists.newArrayList(bb, bbTwo);
+    
+    ByteBufferSupport.addByteBuffers(bList, stream);
+    assertEquals(44, stream.size());
+  }
+
+  @Test
+  public void testToIntBuffer() throws Exception {
+    byte[] bytes = ByteBufferSupport.toIntBytes(10);
+    assertEquals(4, bytes.length);
+    assertEquals(10, bytes[0]);
+    assertEquals(0, bytes[1]);
+    assertEquals(0, bytes[2]);
+    assertEquals(0, bytes[3]);
+  }
+
+  @Test
+  public void testNodeTaskToFromByteBuffer() throws Exception {
+    ByteBuffer bb = ByteBufferSupport.toByteBuffer(task);
+    NodeTask sTask = ByteBufferSupport.toNodeTask(bb);
+
+    assertEquals(task.getClass().getName(), sTask.getClass().getName());
+    assertEquals(task.getHostname(), sTask.getHostname());
+    assertEquals(task.getSlaveId(), sTask.getSlaveId());
+    assertEquals(task.getTaskPrefix(), sTask.getTaskPrefix());
+    assertEquals(task.getProfile(), sTask.getProfile());
+    assertEquals(task.getSlaveAttributes(), sTask.getSlaveAttributes());
+    assertEquals(task.getConstraint(), sTask.getConstraint());
+    assertEquals(task.getExecutorInfo(), sTask.getExecutorInfo());
+  }
+
+  @Test
+  public void testFrameworkIDToFromByteBuffer() throws Exception {
+    ByteBuffer bb = ByteBufferSupport.toByteBuffer(getExecutorInfo().getFrameworkId());
+    FrameworkID id = ByteBufferSupport.toFrameworkID(bb);
+
+    assertEquals(getExecutorInfo().getFrameworkId(), id);
+  }
+
+  @Test
+  public void testToString() throws Exception {
+    String output = ByteBufferSupport.toString(ByteBufferSupport.toByteBuffer(task));
+
+    assertTrue(output.contains("\"name\":\"profile\""));
+    assertTrue(output.contains("\"cpus\":0.1"));
+    assertTrue(output.contains("\"memory\":1024.0"));
+    assertTrue(output.contains("\"executorCpu\":0.0"));
+    assertTrue(output.contains("\"executorMemory\":0.0"));
+    assertTrue(output.contains("\"className\":\"org.apache.myriad.scheduler.ServiceResourceProfile\""));
+  }
+
+  public void testExecutorInfoToFromByteBuffer() throws Exception {
+    ExecutorInfo info = getExecutorInfo();   
+    ByteBuffer bb = ByteBufferSupport.toByteBuffer(task);
+    ExecutorInfo bInfo = ByteBufferSupport.toExecutorInfo(bb);
+
+    assertEquals(info.getClass().getName(), bInfo.getClass().getName());
+  }
+
+  public void testGetConstraint() throws Exception {
+    ByteBuffer bb = ByteBufferSupport.toByteBuffer(task);
+
+    assertEquals(task.getConstraint(), ByteBufferSupport.getConstraint(bb));
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/4a6e50c4/myriad-scheduler/src/test/java/org/apache/myriad/webapp/HttpConnectorProviderTest.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/test/java/org/apache/myriad/webapp/HttpConnectorProviderTest.java
b/myriad-scheduler/src/test/java/org/apache/myriad/webapp/HttpConnectorProviderTest.java
new file mode 100644
index 0000000..5c4dd7d
--- /dev/null
+++ b/myriad-scheduler/src/test/java/org/apache/myriad/webapp/HttpConnectorProviderTest.java
@@ -0,0 +1,22 @@
+package org.apache.myriad.webapp;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.myriad.BaseConfigurableTest;
+import org.junit.Test;
+import org.mortbay.jetty.Connector;
+
+/**
+ * Unit tests for HttpConnectionProvider
+ */
+public class HttpConnectorProviderTest extends BaseConfigurableTest {
+
+  @Test
+  public void testConnector() throws Exception {
+    HttpConnectorProvider provider = new HttpConnectorProvider(cfg);
+    Connector connector = provider.get();
+    assertEquals(8192, connector.getPort());
+    assertEquals("0.0.0.0", connector.getHost());
+    assertEquals("Myriad", connector.getName());
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/4a6e50c4/myriad-scheduler/src/test/java/org/apache/myriad/webapp/MyriadWebServerTest.java
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/test/java/org/apache/myriad/webapp/MyriadWebServerTest.java
b/myriad-scheduler/src/test/java/org/apache/myriad/webapp/MyriadWebServerTest.java
new file mode 100644
index 0000000..31c7119
--- /dev/null
+++ b/myriad-scheduler/src/test/java/org/apache/myriad/webapp/MyriadWebServerTest.java
@@ -0,0 +1,29 @@
+package org.apache.myriad.webapp;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.myriad.BaseConfigurableTest;
+import org.apache.myriad.TestObjectFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit test cases for MyriadWebServer class
+ */
+public class MyriadWebServerTest extends BaseConfigurableTest {
+  MyriadWebServer webServer;
+
+  @Before
+  public void setUp() throws Exception {
+    super.setUp();
+    webServer = TestObjectFactory.getMyriadWebServer(cfg);
+  }
+
+  @Test
+  public void testStartStopMyriadWebServer() throws Exception {
+    webServer.start();
+    assertEquals(MyriadWebServer.Status.STARTED, webServer.getStatus());
+    webServer.stop();
+    assertEquals(MyriadWebServer.Status.STOPPED, webServer.getStatus());
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-myriad/blob/4a6e50c4/myriad-scheduler/src/test/resources/myriad-config-test-default.yml
----------------------------------------------------------------------
diff --git a/myriad-scheduler/src/test/resources/myriad-config-test-default.yml b/myriad-scheduler/src/test/resources/myriad-config-test-default.yml
index 2945bcd..f6f6b58 100644
--- a/myriad-scheduler/src/test/resources/myriad-config-test-default.yml
+++ b/myriad-scheduler/src/test/resources/myriad-config-test-default.yml
@@ -15,8 +15,10 @@
 # specific language governing permissions and limitations
 # under the License.
 
+servedConfigPath: /tmp/myriadEtc
+servedBinaryPath: /tmp/myriadBinary
 mesosMaster: 10.0.2.15:5050
-haEnabled:  true
+haEnabled:  false
 checkpoint: false
 frameworkFailoverTimeout: 44200000
 frameworkName: MyriadTest
@@ -58,7 +60,8 @@ yarnEnvironment:
 mesosAuthenticationPrincipal:
 mesosAuthenticationSecretFilename:
 services:
-   jobhistory:
+   jobhistory:  
+     maxInstances: 1
      jvmMaxMemoryMB: 1024
      cpus: 1
      ports:


Mime
View raw message