Program: 7420
Project: 7420
Buggy source:
@Category(SlowTests.class) @Test public void testAppWithServices() throws Exception {
  ApplicationManager applicationManager=deployApplication(AppWithServices.class);
  try {
    LOG.info("String_Node_Str");
    ServiceManager serviceManager=applicationManager.startService(AppWithServices.SERVICE_NAME);
    serviceStatusCheck(serviceManager,true);
    LOG.info("String_Node_Str");
    URL url=new URL(serviceManager.getServiceURL(5,TimeUnit.SECONDS),"String_Node_Str");
    HttpRequest request=HttpRequest.get(url).build();
    HttpResponse response=HttpRequests.execute(request);
    Assert.assertEquals(200,response.getResponseCode());
    url=new URL(serviceManager.getServiceURL(5,TimeUnit.SECONDS),"String_Node_Str");
    request=HttpRequest.get(url).build();
    response=HttpRequests.execute(request);
    Assert.assertEquals(500,response.getResponseCode());
    url=new URL(serviceManager.getServiceURL(5,TimeUnit.SECONDS),"String_Node_Str");
    request=HttpRequest.get(url).build();
    response=HttpRequests.execute(request);
    Assert.assertEquals(200,response.getResponseCode());
    RuntimeMetrics serviceMetrics=RuntimeStats.getServiceMetrics(AppWithServices.APP_NAME,AppWithServices.SERVICE_NAME);
    serviceMetrics.waitForinput(3,5,TimeUnit.SECONDS);
    Assert.assertEquals(3,serviceMetrics.getInput());
    Assert.assertEquals(2,serviceMetrics.getProcessed());
    Assert.assertEquals(1,serviceMetrics.getException());
    LOG.info("String_Node_Str");
    ServiceManager datasetWorkerServiceManager=applicationManager.startService(AppWithServices.DATASET_WORKER_SERVICE_NAME);
    serviceStatusCheck(datasetWorkerServiceManager,true);
    ProcedureManager procedureManager=applicationManager.startProcedure("String_Node_Str");
    ProcedureClient procedureClient=procedureManager.getClient();
    String result=procedureClient.query("String_Node_Str",ImmutableMap.of(AppWithServices.PROCEDURE_DATASET_KEY,AppWithServices.DATASET_TEST_KEY));
    String decodedResult=new Gson().fromJson(result,String.class);
    Assert.assertEquals(AppWithServices.DATASET_TEST_VALUE,decodedResult);
    String path=String.format("String_Node_Str",AppWithServices.APP_NAME,AppWithServices.DATASET_WORKER_SERVICE_NAME);
    url=new URL(serviceManager.getServiceURL(5,TimeUnit.SECONDS),path);
    request=HttpRequest.get(url).build();
    response=HttpRequests.execute(request);
    Assert.assertEquals(200,response.getResponseCode());
    datasetWorkerServiceManager.stop();
    serviceStatusCheck(datasetWorkerServiceManager,false);
    LOG.info("String_Node_Str");
    serviceManager.stop();
    serviceStatusCheck(serviceManager,false);
    LOG.info("String_Node_Str");
    result=procedureClient.query("String_Node_Str",ImmutableMap.of(AppWithServices.PROCEDURE_DATASET_KEY,AppWithServices.DATASET_TEST_KEY_STOP));
    decodedResult=new Gson().fromJson(result,String.class);
    Assert.assertEquals(AppWithServices.DATASET_TEST_VALUE_STOP,decodedResult);
    procedureManager.stop();
  }
  finally {
    applicationManager.stopAll();
  }
}

Fixed version (ground truth):
@Category(SlowTests.class) @Test public void testAppWithServices() throws Exception {
  ApplicationManager applicationManager=deployApplication(AppWithServices.class);
  try {
    LOG.info("String_Node_Str");
    ServiceManager serviceManager=applicationManager.startService(AppWithServices.SERVICE_NAME);
    serviceStatusCheck(serviceManager,true);
    LOG.info("String_Node_Str");
    URL url=new URL(serviceManager.getServiceURL(5,TimeUnit.SECONDS),"String_Node_Str");
    HttpRequest request=HttpRequest.get(url).build();
    HttpResponse response=HttpRequests.execute(request);
    Assert.assertEquals(200,response.getResponseCode());
    url=new URL(serviceManager.getServiceURL(5,TimeUnit.SECONDS),"String_Node_Str");
    request=HttpRequest.get(url).build();
    response=HttpRequests.execute(request);
    Assert.assertEquals(500,response.getResponseCode());
    url=new URL(serviceManager.getServiceURL(5,TimeUnit.SECONDS),"String_Node_Str");
    request=HttpRequest.get(url).build();
    response=HttpRequests.execute(request);
    Assert.assertEquals(200,response.getResponseCode());
    RuntimeMetrics serviceMetrics=RuntimeStats.getServiceMetrics(AppWithServices.APP_NAME,AppWithServices.SERVICE_NAME);
    serviceMetrics.waitForinput(3,5,TimeUnit.SECONDS);
    Assert.assertEquals(3,serviceMetrics.getInput());
    Assert.assertEquals(2,serviceMetrics.getProcessed());
    Assert.assertEquals(1,serviceMetrics.getException());
    LOG.info("String_Node_Str");
    Map<String,String> args=ImmutableMap.of(AppWithServices.WRITE_VALUE_RUN_KEY,AppWithServices.DATASET_TEST_VALUE,AppWithServices.WRITE_VALUE_STOP_KEY,AppWithServices.DATASET_TEST_VALUE_STOP);
    ServiceManager datasetWorkerServiceManager=applicationManager.startService(AppWithServices.DATASET_WORKER_SERVICE_NAME,args);
    serviceStatusCheck(datasetWorkerServiceManager,true);
    ProcedureManager procedureManager=applicationManager.startProcedure("String_Node_Str");
    ProcedureClient procedureClient=procedureManager.getClient();
    String result=procedureClient.query("String_Node_Str",ImmutableMap.of(AppWithServices.PROCEDURE_DATASET_KEY,AppWithServices.DATASET_TEST_KEY));
    String decodedResult=new Gson().fromJson(result,String.class);
    Assert.assertEquals(AppWithServices.DATASET_TEST_VALUE,decodedResult);
    String path=String.format("String_Node_Str",AppWithServices.APP_NAME,AppWithServices.DATASET_WORKER_SERVICE_NAME);
    url=new URL(serviceManager.getServiceURL(5,TimeUnit.SECONDS),path);
    request=HttpRequest.get(url).build();
    response=HttpRequests.execute(request);
    Assert.assertEquals(200,response.getResponseCode());
    datasetWorkerServiceManager.stop();
    serviceStatusCheck(datasetWorkerServiceManager,false);
    LOG.info("String_Node_Str");
    serviceManager.stop();
    serviceStatusCheck(serviceManager,false);
    LOG.info("String_Node_Str");
    result=procedureClient.query("String_Node_Str",ImmutableMap.of(AppWithServices.PROCEDURE_DATASET_KEY,AppWithServices.DATASET_TEST_KEY_STOP));
    decodedResult=new Gson().fromJson(result,String.class);
    Assert.assertEquals(AppWithServices.DATASET_TEST_VALUE_STOP,decodedResult);
    procedureManager.stop();
  }
  finally {
    applicationManager.stopAll();
  }
}