TensorFlowServiceSpec extends AbstractServiceSpec { @Override public ServiceWrapper create() throws IOException { LOG.info("Creating TensorFlow service spec"); ServiceWrapper serviceWrapper = createServiceSpecWrapper(); if (tensorFlowParameters.getNumWorkers() > 0) { addWorkerComponents(serviceWrapper, Framework.TENSORFLOW); } if (tensorFlowParameters.getNumPS() > 0) { addPsComponent(serviceWrapper); } if (tensorFlowParameters.isTensorboardEnabled()) { createTensorBoardComponent(serviceWrapper); } handleQuicklinks(serviceWrapper.getService()); return serviceWrapper; } TensorFlowServiceSpec(TensorFlowRunJobParameters parameters,
      ClientContext clientContext, FileSystemOperations fsOperations,
      TensorFlowLaunchCommandFactory launchCommandFactory,
      Localizer localizer); @Override ServiceWrapper create();  }
@Test public void testTensorFlowhServiceSpec() throws IOException { testCommons = new ComponentTestCommons(TensorFlowRole.PRIMARY_WORKER); testCommons.setupTensorFlow(); TensorFlowRunJobParameters parameters = new TensorFlowRunJobParameters(); parameters.setWorkerResource(testCommons.resource); parameters.setName("testJobName"); parameters.setNumWorkers(1); parameters.setWorkerLaunchCmd("testWorkerLaunchCommand"); MockClientContext mockClientContext = new MockClientContext(DEFAULT_JOB_NAME); FileSystemOperations fsOperations = new FileSystemOperations(mockClientContext); HadoopEnvironmentSetup hadoopEnv = new HadoopEnvironmentSetup(mockClientContext, fsOperations); TensorFlowLaunchCommandFactory launchCommandFactory = new TensorFlowLaunchCommandFactory(hadoopEnv, parameters, new Configuration()); Localizer localizer = new Localizer(fsOperations, mockClientContext.getRemoteDirectoryManager(), parameters); TensorFlowServiceSpec tensorFlowhServiceSpec = new TensorFlowServiceSpec(parameters, mockClientContext, fsOperations, launchCommandFactory, localizer); ServiceWrapper serviceWrapper = tensorFlowhServiceSpec.create(); Service service = serviceWrapper.getService(); assertNotNull("Service must not be null!", service); List<Component> components = service.getComponents(); assertEquals("Number of components is not correct!", 1, components.size()); Component component = components.get(0); assertEquals(1L, (long) component.getNumberOfContainers()); assertEquals("./run-PRIMARY_WORKER.sh", component.getLaunchCommand()); }