TensorFlowWorkerComponent extends AbstractComponent { @Override public Component createComponent() throws IOException { return createComponentInternal(); } TensorFlowWorkerComponent(FileSystemOperations fsOperations,
                                   RemoteDirectoryManager remoteDirectoryManager,
                                   TensorFlowRunJobParameters parameters, Role role,
                                   TensorFlowLaunchCommandFactory launchCommandFactory,
                                   Configuration yarnConfig); @Override Component createComponent();  }
@Test public void testWorkerComponentWithNullResource() throws IOException { TensorFlowRunJobParameters parameters = new TensorFlowRunJobParameters(); parameters.setWorkerResource(null); TensorFlowWorkerComponent workerComponent = createWorkerComponent(parameters); expectedException.expect(NullPointerException.class); expectedException.expectMessage("Worker resource must not be null"); workerComponent.createComponent(); }
@Test public void testWorkerComponentWithNullJobName() throws IOException { TensorFlowRunJobParameters parameters = new TensorFlowRunJobParameters(); parameters.setWorkerResource(testCommons.resource); parameters.setNumWorkers(1); parameters.setName(null); TensorFlowWorkerComponent workerComponent = createWorkerComponent(parameters); expectedException.expect(NullPointerException.class); expectedException.expectMessage("Job name must not be null"); workerComponent.createComponent(); }
@Test public void testNormalWorkerComponentZeroNumberOfWorkers() throws IOException { testCommons.yarnConfig.set("hadoop.registry.dns.domain-name", "testDomain"); TensorFlowRunJobParameters parameters = new TensorFlowRunJobParameters(); parameters.setWorkerResource(testCommons.resource); parameters.setName("testJobName"); parameters.setWorkerDockerImage("testWorkerDockerImage"); parameters.setNumWorkers(0); TensorFlowWorkerComponent workerComponent = createWorkerComponent(parameters); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Number of workers should be at least 1!"); workerComponent.createComponent(); }
@Test public void testNormalWorkerComponentNumWorkersIsOne() throws IOException { testCommons.yarnConfig.set("hadoop.registry.dns.domain-name", "testDomain"); TensorFlowRunJobParameters parameters = new TensorFlowRunJobParameters(); parameters.setWorkerResource(testCommons.resource); parameters.setName("testJobName"); parameters.setNumWorkers(1); parameters.setWorkerDockerImage("testWorkerDockerImage"); TensorFlowWorkerComponent workerComponent = createWorkerComponent(parameters); Component component = workerComponent.createComponent(); assertEquals(0L, (long) component.getNumberOfContainers()); verifyCommons(component); }
@Test public void testNormalWorkerComponentNumWorkersIsTwo() throws IOException { testCommons.yarnConfig.set("hadoop.registry.dns.domain-name", "testDomain"); TensorFlowRunJobParameters parameters = new TensorFlowRunJobParameters(); parameters.setWorkerResource(testCommons.resource); parameters.setName("testJobName"); parameters.setNumWorkers(2); parameters.setWorkerDockerImage("testWorkerDockerImage"); TensorFlowWorkerComponent workerComponent = createWorkerComponent(parameters); Component component = workerComponent.createComponent(); assertEquals(1L, (long) component.getNumberOfContainers()); verifyCommons(component); }
@Test public void testPrimaryWorkerComponentNumWorkersIsTwo() throws IOException { testCommons.yarnConfig.set("hadoop.registry.dns.domain-name", "testDomain"); testCommons = new ComponentTestCommons(TensorFlowRole.PRIMARY_WORKER); testCommons.setupTensorFlow(); TensorFlowRunJobParameters parameters = new TensorFlowRunJobParameters(); parameters.setWorkerResource(testCommons.resource); parameters.setName("testJobName"); parameters.setNumWorkers(2); parameters.setWorkerDockerImage("testWorkerDockerImage"); TensorFlowWorkerComponent workerComponent = createWorkerComponent(parameters); Component component = workerComponent.createComponent(); assertEquals(1L, (long) component.getNumberOfContainers()); verifyCommons(component, ImmutableMap.of( "yarn.service.container-state-report-as-service-state", "true")); }