@Test
  public void test_322_16_ReadyForAllocation() throws Exception {
    WorkerStatusDAO workerStatus = WorkerDAOFactory.getInstance().getWorkerStatusDAO();

    RemoteWorkerManagementClient rwmc =
        workerAcceptanceUtil.createRemoteWorkerManagementClient(remotePeerID.getPublicKey());

    req_094_Util.getWorkerStatus(WorkerStatus.ALLOCATED_FOR_BROKER);

    TestCase.assertTrue(workerStatus.isLogged());
    TestCase.assertTrue(workerStatus.isAllocatedForBroker());
    TestCase.assertTrue(workerStatus.isAllocatedForRemotePeer());
    TestCase.assertFalse(workerStatus.isWorkingState());
    TestCase.assertTrue(workerStatus.isPreparingAllocationState());
    TestCase.assertEquals(workerStatus.getRemotePeerPublicKey(), remotePeerID.getPublicKey());

    req_092_Util.prepareAllocationCompletedOnPreparingAllocatedForRemoteBrokerWorker(
        component, rwmc, prepFuture);

    req_094_Util.getWorkerStatus(WorkerStatus.ALLOCATED_FOR_BROKER);

    TestCase.assertNotNull(workerStatus.getMasterPeerAddress());
    TestCase.assertEquals(workerStatus.getMasterPeerAddress(), peerID.getServiceID().toString());
    TestCase.assertTrue(workerStatus.isLogged());
    TestCase.assertTrue(workerStatus.isAllocatedForRemotePeer());
    TestCase.assertTrue(workerStatus.isAllocatedForBroker());
    TestCase.assertFalse(workerStatus.isPreparingAllocationState());
    TestCase.assertEquals(workerStatus.getRemotePeerPublicKey(), remotePeerID.getPublicKey());
  }
  @Test
  public void test_322_4_WorkerManagementClientIsUp() throws Exception {
    WorkerStatusDAO workerStatus = WorkerDAOFactory.getInstance().getWorkerStatusDAO();
    req_094_Util.getWorkerStatus(WorkerStatus.ALLOCATED_FOR_BROKER);

    TestCase.assertNotNull(workerStatus.getMasterPeerAddress());
    TestCase.assertTrue(workerStatus.isLogged());
    TestCase.assertFalse(workerStatus.isWorkingState());
    TestCase.assertTrue(workerStatus.isPreparingAllocationState());
    TestCase.assertTrue(workerStatus.isAllocatedForBroker());

    req_126_Util.notifyPeerRecoveryAtWorkerWithPeer(
        component, peerID, workerAcceptanceUtil.getPeerMonitorDeployment().getDeploymentID());

    req_094_Util.getWorkerStatus(WorkerStatus.ALLOCATED_FOR_BROKER);

    TestCase.assertNotNull(workerStatus.getMasterPeerAddress());
    TestCase.assertEquals(workerStatus.getMasterPeerAddress(), peerID.getServiceID().toString());
    TestCase.assertTrue(workerStatus.isLogged());
    TestCase.assertFalse(workerStatus.isWorkingState());
    TestCase.assertTrue(workerStatus.isPreparingAllocationState());
    TestCase.assertTrue(workerStatus.isAllocatedForRemotePeer());
    TestCase.assertTrue(workerStatus.isAllocatedForBroker());
    TestCase.assertEquals(workerStatus.getRemotePeerPublicKey(), remotePeerID.getPublicKey());
  }
Esempio n. 3
0
  @Test
  public void test_302_7_WorkerManagementClientIsUp() throws Exception {
    WorkerStatusDAO workerStatus = WorkerDAOFactory.getInstance().getWorkerStatusDAO();

    req_094_Util.getWorkerStatus(WorkerStatus.OWNER);
    TestCase.assertTrue(
        AcceptanceTestUtil.isInterested(component, peerID.getServiceID(), workerID));
    TestCase.assertNotNull(workerStatus.getMasterPeerAddress());

    req_126_Util.notifyPeerRecoveryAtWorkerWithoutPeer(
        component, peerID, workerAcceptanceUtil.getPeerMonitorDeployment().getDeploymentID());

    req_094_Util.getWorkerStatus(WorkerStatus.OWNER);
    TestCase.assertNotNull(workerStatus.getMasterPeerAddress());
    TestCase.assertEquals(workerStatus.getMasterPeerAddress(), peerID.getServiceID().toString());
  }
  @Test
  public void test_322_3_Status() throws Exception {
    WorkerStatusDAO workerStatus = WorkerDAOFactory.getInstance().getWorkerStatusDAO();
    TestCase.assertTrue(workerStatus.isLogged());
    TestCase.assertFalse(workerStatus.isWorkingState());
    TestCase.assertTrue(workerStatus.isAllocatedForBroker());

    req_094_Util.getWorkerStatus(WorkerStatus.ALLOCATED_FOR_BROKER);

    TestCase.assertNotNull(workerStatus.getMasterPeerAddress());
    TestCase.assertEquals(workerStatus.getMasterPeerAddress(), peerID.getServiceID().toString());
    TestCase.assertTrue(workerStatus.isLogged());
    TestCase.assertTrue(workerStatus.isPreparingAllocationState());
    TestCase.assertTrue(workerStatus.isAllocatedForRemotePeer());
    TestCase.assertTrue(workerStatus.isAllocatedForBroker());
    TestCase.assertEquals(workerStatus.getRemotePeerPublicKey(), remotePeerID.getPublicKey());
  }
  @Test
  public void test_322_17_Pause() throws Exception {
    WorkerStatusDAO workerStatus = WorkerDAOFactory.getInstance().getWorkerStatusDAO();
    req_094_Util.getWorkerStatus(WorkerStatus.ALLOCATED_FOR_BROKER);

    TestCase.assertNotNull(workerStatus.getMasterPeerAddress());
    TestCase.assertEquals(workerStatus.getMasterPeerAddress(), peerID.getServiceID().toString());
    TestCase.assertTrue(workerStatus.isLogged());
    TestCase.assertTrue(workerStatus.isAllocated());
    TestCase.assertTrue(workerStatus.isPreparingAllocationState());

    req_087_Util.pausePreparingAllocatedForBrokerWorker(component, wmc, prepFuture);

    req_094_Util.getWorkerStatus(WorkerStatus.OWNER);

    TestCase.assertNotNull(workerStatus.getMasterPeerAddress());
    TestCase.assertEquals(workerStatus.getMasterPeerAddress(), peerID.getServiceID().toString());
    TestCase.assertTrue(workerStatus.isLogged());
    TestCase.assertFalse(workerStatus.isAllocated());
  }
  @Test
  public void test_322_6_LoginSucceeded() throws Exception {
    WorkerStatusDAO workerStatus = WorkerDAOFactory.getInstance().getWorkerStatusDAO();
    req_094_Util.getWorkerStatus(WorkerStatus.ALLOCATED_FOR_BROKER);

    TestCase.assertNotNull(workerStatus.getMasterPeerAddress());
    TestCase.assertEquals(workerStatus.getMasterPeerAddress(), peerID.getServiceID().toString());
    TestCase.assertTrue(workerStatus.isLogged());
    TestCase.assertTrue(workerStatus.isAllocated());
    TestCase.assertTrue(workerStatus.isPreparingAllocationState());

    req_129_Util.loginAlreadyLoggedInIdle(component, peerPubKey, peerID, testStub);

    TestCase.assertTrue(workerStatus.isLogged());
    TestCase.assertTrue(workerStatus.isAllocated());
    TestCase.assertTrue(workerStatus.isAllocatedForRemotePeer());
    TestCase.assertTrue(workerStatus.isAllocatedForBroker());
    TestCase.assertEquals(workerStatus.getRemotePeerPublicKey(), remotePeerID.getPublicKey());
    TestCase.assertTrue(workerStatus.isPreparingAllocationState());
  }
  @Test
  public void test_322_14_WorkerManagementClientIsDown() throws Exception {
    WorkerStatusDAO workerStatus = WorkerDAOFactory.getInstance().getWorkerStatusDAO();
    req_094_Util.getWorkerStatus(WorkerStatus.ALLOCATED_FOR_BROKER);

    TestCase.assertTrue(workerStatus.isLogged());
    TestCase.assertTrue(workerStatus.isAllocatedForBroker());
    TestCase.assertTrue(workerStatus.isAllocatedForRemotePeer());
    TestCase.assertFalse(workerStatus.isWorkingState());
    TestCase.assertTrue(workerStatus.isPreparingAllocationState());
    TestCase.assertEquals(workerStatus.getRemotePeerPublicKey(), remotePeerID.getPublicKey());

    req_127_Util.notifyPeerFailureAtPreparingAllocatedForRemoteBrokerWorker(component, peerID);

    req_094_Util.getWorkerStatus(WorkerStatus.IDLE);
    TestCase.assertNotNull(workerStatus.getMasterPeerAddress());
    TestCase.assertTrue(workerStatus.isPreparingAllocationState());
    TestCase.assertFalse(workerStatus.isLogged());
    TestCase.assertFalse(workerStatus.isAllocated());
    TestCase.assertFalse(workerStatus.isWorkingState());
  }
  @Test
  public void test_322_13_PreparationError() throws Exception {
    WorkerStatusDAO workerStatus = WorkerDAOFactory.getInstance().getWorkerStatusDAO();

    TestCase.assertTrue(workerStatus.isLogged());
    TestCase.assertTrue(workerStatus.isAllocatedForBroker());
    TestCase.assertTrue(workerStatus.isAllocatedForRemotePeer());
    TestCase.assertFalse(workerStatus.isWorkingState());
    TestCase.assertTrue(workerStatus.isPreparingAllocationState());

    req_094_Util.getWorkerStatus(WorkerStatus.ALLOCATED_FOR_BROKER);

    req_125_Util.allocationError(
        component, wmc, prepFuture, true, WorkerStatus.ALLOCATED_FOR_BROKER);

    req_094_Util.getWorkerStatus(WorkerStatus.ERROR);
    TestCase.assertNotNull(workerStatus.getMasterPeerAddress());
    TestCase.assertEquals(workerStatus.getMasterPeerAddress(), peerID.getServiceID().toString());
    TestCase.assertTrue(workerStatus.isLogged());
    TestCase.assertTrue(workerStatus.isErrorState());
    TestCase.assertFalse(workerStatus.isPreparingAllocationState());
  }
Esempio n. 9
0
  public void prepareAllocationCompleted(
      WorkerComponent component,
      WorkerManagementClient wmc,
      RemoteWorkerManagementClient rwmc,
      WorkerStatus oldStatus,
      boolean toIdle,
      String remotePeerPubKey,
      String brokerPubKey,
      boolean peerFailed,
      Future<?> future,
      boolean isPreparingAllocationState,
      WorkerStatus status) {

    CommuneLogger oldLogger = component.getLogger();
    CommuneLogger newLogger = EasyMock.createMock(CommuneLogger.class);
    component.setLogger(newLogger);

    if (!isPreparingAllocationState) {
      newLogger.warn(
          ExecutionControllerMessages.getNotInPrepareAllocationStateMessage(
              WorkerDAOFactory.getInstance().getWorkerStatusDAO().getStatus().toString()));
    }

    if (future != null) {
      EasyMock.reset(future);
      EasyMock.expect(future.isDone()).andReturn(true).anyTimes();
      EasyMock.replay(future);
    }

    WorkerStatus newStatus = null;

    if (wmc != null) {
      EasyMock.reset(wmc);

      if (!peerFailed) {

        if (toIdle) {
          wmc.statusChanged(WorkerStatus.IDLE);

        } else if (remotePeerPubKey != null) {
          newStatus = WorkerStatus.ALLOCATED_FOR_PEER;
          wmc.statusChangedAllocatedForPeer(
              createRemoteWorkerManagementServiceID(), remotePeerPubKey);

        } else if (brokerPubKey != null) {
          newStatus = WorkerStatus.ALLOCATED_FOR_BROKER;
          wmc.statusChangedAllocatedForBroker(createWorkerServiceID(), brokerPubKey);
        }
      }
      EasyMock.replay(wmc);
    }

    if (rwmc != null) {
      newStatus = WorkerStatus.ALLOCATED_FOR_BROKER;
      EasyMock.reset(rwmc);
      rwmc.statusChangedAllocatedForBroker(createWorkerServiceID());
      EasyMock.replay(rwmc);
    }

    if (oldStatus != null) {
      newLogger.debug("Status changed from " + oldStatus + " to " + newStatus + ".");
    }

    if (isPreparingAllocationState) {
      newLogger.debug("Allocation action was completed.");
    }

    EasyMock.replay(newLogger);

    getWorkerExecutionClient().readyForAllocation();

    if (wmc != null && isPreparingAllocationState) {
      EasyMock.verify(wmc);
      EasyMock.reset(wmc);
    }

    if (rwmc != null && isPreparingAllocationState) {
      EasyMock.verify(rwmc);
      EasyMock.reset(rwmc);
    }

    EasyMock.verify(newLogger);
    component.setLogger(oldLogger);
  }