@Test public void deploySuccessTest() throws Exception { Mockito.doNothing().when(driversMakerServiceMock).generateBenchmark(Mockito.anyString(), Mockito.anyLong(), Mockito.anyInt()); Mockito.doNothing().when(fabanManagerServiceMock).deployExperimentToFaban(Mockito.anyString(), Mockito.anyString(), Mockito.anyLong()); StartTask startTask = new StartTask(experimentID, experimentModelDAOMock, minioServiceMock, fabanManagerServiceMock, driversMakerServiceMock); Boolean result = startTask.call(); Assert.assertTrue(result); }
@Override public Boolean call() { logger.info("deploying experiment: " + experimentID); try { String experimentYamlString = IOUtils .toString(minioService.getExperimentDefinition(experimentID), StandardCharsets.UTF_8); BenchFlowExperiment experiment = BenchFlowExperimentAPI.experimentFromExperimentYaml(experimentYamlString); int numTrials = experiment.configuration().terminationCriteria().experiment().numberOfTrials(); experimentModelDAO.setNumTrials(experimentID, numTrials); DriversMakerCompatibleID driversMakerCompatibleID = new DriversMakerCompatibleID(experimentID); String driversMakerExperimentID = driversMakerCompatibleID.getDriversMakerExperimentID(); String experimentName = driversMakerCompatibleID.getExperimentName(); long experimentNumber = driversMakerCompatibleID.getExperimentNumber(); saveDriversMakerCompatibleFilesOnMinio(experiment, driversMakerExperimentID, experimentNumber); driversMakerService.generateBenchmark(experimentName, experimentNumber, numTrials); fabanManagerService.deployExperimentToFaban(experimentID, driversMakerExperimentID, experimentNumber); return true; } catch (IOException e) { logger.error( "could not read experiment bundle files for " + experimentID + " : " + e.getMessage()); return false; } catch (BenchmarkGenerationException e) { logger.info("BenchmarkGenerationException - " + e.getMessage()); return false; } catch (BenchMarkDeploymentException e) { logger.info("BenchMarkDeploymentException - " + e.getMessage()); return false; } catch (BenchFlowDeserializationException | BenchFlowExperimentIDDoesNotExistException e) { e.printStackTrace(); return false; } }
StartTask extends AbortableCallable<Boolean> { @Override public Boolean call() { logger.info("deploying experiment: " + experimentID); try { String experimentYamlString = IOUtils .toString(minioService.getExperimentDefinition(experimentID), StandardCharsets.UTF_8); BenchFlowExperiment experiment = BenchFlowExperimentAPI.experimentFromExperimentYaml(experimentYamlString); int numTrials = experiment.configuration().terminationCriteria().experiment().numberOfTrials(); experimentModelDAO.setNumTrials(experimentID, numTrials); DriversMakerCompatibleID driversMakerCompatibleID = new DriversMakerCompatibleID(experimentID); String driversMakerExperimentID = driversMakerCompatibleID.getDriversMakerExperimentID(); String experimentName = driversMakerCompatibleID.getExperimentName(); long experimentNumber = driversMakerCompatibleID.getExperimentNumber(); saveDriversMakerCompatibleFilesOnMinio(experiment, driversMakerExperimentID, experimentNumber); driversMakerService.generateBenchmark(experimentName, experimentNumber, numTrials); fabanManagerService.deployExperimentToFaban(experimentID, driversMakerExperimentID, experimentNumber); return true; } catch (IOException e) { logger.error( "could not read experiment bundle files for " + experimentID + " : " + e.getMessage()); return false; } catch (BenchmarkGenerationException e) { logger.info("BenchmarkGenerationException - " + e.getMessage()); return false; } catch (BenchMarkDeploymentException e) { logger.info("BenchMarkDeploymentException - " + e.getMessage()); return false; } catch (BenchFlowDeserializationException | BenchFlowExperimentIDDoesNotExistException e) { e.printStackTrace(); return false; } } }
StartTask extends AbortableCallable<Boolean> { @Override public Boolean call() { logger.info("deploying experiment: " + experimentID); try { String experimentYamlString = IOUtils .toString(minioService.getExperimentDefinition(experimentID), StandardCharsets.UTF_8); BenchFlowExperiment experiment = BenchFlowExperimentAPI.experimentFromExperimentYaml(experimentYamlString); int numTrials = experiment.configuration().terminationCriteria().experiment().numberOfTrials(); experimentModelDAO.setNumTrials(experimentID, numTrials); DriversMakerCompatibleID driversMakerCompatibleID = new DriversMakerCompatibleID(experimentID); String driversMakerExperimentID = driversMakerCompatibleID.getDriversMakerExperimentID(); String experimentName = driversMakerCompatibleID.getExperimentName(); long experimentNumber = driversMakerCompatibleID.getExperimentNumber(); saveDriversMakerCompatibleFilesOnMinio(experiment, driversMakerExperimentID, experimentNumber); driversMakerService.generateBenchmark(experimentName, experimentNumber, numTrials); fabanManagerService.deployExperimentToFaban(experimentID, driversMakerExperimentID, experimentNumber); return true; } catch (IOException e) { logger.error( "could not read experiment bundle files for " + experimentID + " : " + e.getMessage()); return false; } catch (BenchmarkGenerationException e) { logger.info("BenchmarkGenerationException - " + e.getMessage()); return false; } catch (BenchMarkDeploymentException e) { logger.info("BenchMarkDeploymentException - " + e.getMessage()); return false; } catch (BenchFlowDeserializationException | BenchFlowExperimentIDDoesNotExistException e) { e.printStackTrace(); return false; } } StartTask(String experimentID); @VisibleForTesting  StartTask(String experimentID, BenchFlowExperimentModelDAO experimentModelDAO,
      MinioService minioService, FabanManagerService fabanManagerService,
      DriversMakerService driversMakerService); }
StartTask extends AbortableCallable<Boolean> { @Override public Boolean call() { logger.info("deploying experiment: " + experimentID); try { String experimentYamlString = IOUtils .toString(minioService.getExperimentDefinition(experimentID), StandardCharsets.UTF_8); BenchFlowExperiment experiment = BenchFlowExperimentAPI.experimentFromExperimentYaml(experimentYamlString); int numTrials = experiment.configuration().terminationCriteria().experiment().numberOfTrials(); experimentModelDAO.setNumTrials(experimentID, numTrials); DriversMakerCompatibleID driversMakerCompatibleID = new DriversMakerCompatibleID(experimentID); String driversMakerExperimentID = driversMakerCompatibleID.getDriversMakerExperimentID(); String experimentName = driversMakerCompatibleID.getExperimentName(); long experimentNumber = driversMakerCompatibleID.getExperimentNumber(); saveDriversMakerCompatibleFilesOnMinio(experiment, driversMakerExperimentID, experimentNumber); driversMakerService.generateBenchmark(experimentName, experimentNumber, numTrials); fabanManagerService.deployExperimentToFaban(experimentID, driversMakerExperimentID, experimentNumber); return true; } catch (IOException e) { logger.error( "could not read experiment bundle files for " + experimentID + " : " + e.getMessage()); return false; } catch (BenchmarkGenerationException e) { logger.info("BenchmarkGenerationException - " + e.getMessage()); return false; } catch (BenchMarkDeploymentException e) { logger.info("BenchMarkDeploymentException - " + e.getMessage()); return false; } catch (BenchFlowDeserializationException | BenchFlowExperimentIDDoesNotExistException e) { e.printStackTrace(); return false; } } StartTask(String experimentID); @VisibleForTesting  StartTask(String experimentID, BenchFlowExperimentModelDAO experimentModelDAO,
      MinioService minioService, FabanManagerService fabanManagerService,
      DriversMakerService driversMakerService); @Override Boolean call(); }
StartTask extends AbortableCallable<Boolean> { @Override public Boolean call() { logger.info("deploying experiment: " + experimentID); try { String experimentYamlString = IOUtils .toString(minioService.getExperimentDefinition(experimentID), StandardCharsets.UTF_8); BenchFlowExperiment experiment = BenchFlowExperimentAPI.experimentFromExperimentYaml(experimentYamlString); int numTrials = experiment.configuration().terminationCriteria().experiment().numberOfTrials(); experimentModelDAO.setNumTrials(experimentID, numTrials); DriversMakerCompatibleID driversMakerCompatibleID = new DriversMakerCompatibleID(experimentID); String driversMakerExperimentID = driversMakerCompatibleID.getDriversMakerExperimentID(); String experimentName = driversMakerCompatibleID.getExperimentName(); long experimentNumber = driversMakerCompatibleID.getExperimentNumber(); saveDriversMakerCompatibleFilesOnMinio(experiment, driversMakerExperimentID, experimentNumber); driversMakerService.generateBenchmark(experimentName, experimentNumber, numTrials); fabanManagerService.deployExperimentToFaban(experimentID, driversMakerExperimentID, experimentNumber); return true; } catch (IOException e) { logger.error( "could not read experiment bundle files for " + experimentID + " : " + e.getMessage()); return false; } catch (BenchmarkGenerationException e) { logger.info("BenchmarkGenerationException - " + e.getMessage()); return false; } catch (BenchMarkDeploymentException e) { logger.info("BenchMarkDeploymentException - " + e.getMessage()); return false; } catch (BenchFlowDeserializationException | BenchFlowExperimentIDDoesNotExistException e) { e.printStackTrace(); return false; } } StartTask(String experimentID); @VisibleForTesting  StartTask(String experimentID, BenchFlowExperimentModelDAO experimentModelDAO,
      MinioService minioService, FabanManagerService fabanManagerService,
      DriversMakerService driversMakerService); @Override Boolean call();  }