TensorFlowConfigEnvGenerator { public static String getTFConfigEnv(String componentName, int nWorkers, int nPs, String serviceName, String userName, String domain) { String commonEndpointSuffix = YarnServiceUtils .getDNSNameCommonSuffix(serviceName, userName, domain, 8000); TFConfigEnv tfConfigEnv = new TFConfigEnv(nWorkers, nPs, componentName, commonEndpointSuffix); return tfConfigEnv.toJson(); }  static String getTFConfigEnv(String componentName, int nWorkers,
      int nPs, String serviceName, String userName, String domain);  }
@Test public void testSimpleDistributedTFConfigGeneratorWorker() { String json = TensorFlowConfigEnvGenerator.getTFConfigEnv("worker", 5, 3, "wtan", "tf-job-001", "example.com"); assertEquals(json, "{\\\"cluster\\\":{\\\"master\\\":[\\\"master-0.wtan" + ".tf-job-001.example.com:8000\\\"],\\\"worker\\\":[\\\"worker-0.wtan" + ".tf-job-001.example.com:8000\\\",\\\"worker-1.wtan.tf-job-001" + ".example.com:8000\\\",\\\"worker-2.wtan.tf-job-001.example" + ".com:8000\\\",\\\"worker-3.wtan.tf-job-001.example.com:8000\\\"]," + "\\\"ps\\\":[\\\"ps-0.wtan.tf-job-001.example.com:8000\\\",\\\"ps-1" + ".wtan.tf-job-001.example.com:8000\\\",\\\"ps-2.wtan.tf-job-001" + ".example.com:8000\\\"]},\\\"task\\\":{ \\\"type\\\":\\\"worker\\\", " + "\\\"index\\\":$_TASK_INDEX},\\\"environment\\\":\\\"cloud\\\"}"); }
@Test public void testSimpleDistributedTFConfigGeneratorMaster() { String json = TensorFlowConfigEnvGenerator.getTFConfigEnv("master", 2, 1, "wtan", "tf-job-001", "example.com"); assertEquals(json, "{\\\"cluster\\\":{\\\"master\\\":[\\\"master-0.wtan" + ".tf-job-001.example.com:8000\\\"],\\\"worker\\\":[\\\"worker-0.wtan" + ".tf-job-001.example.com:8000\\\"],\\\"ps\\\":[\\\"ps-0.wtan" + ".tf-job-001.example.com:8000\\\"]},\\\"task\\\":{ " + "\\\"type\\\":\\\"master\\\", \\\"index\\\":$_TASK_INDEX}," + "\\\"environment\\\":\\\"cloud\\\"}"); }
@Test public void testSimpleDistributedTFConfigGeneratorPS() { String json = TensorFlowConfigEnvGenerator.getTFConfigEnv("ps", 5, 3, "wtan", "tf-job-001", "example.com"); assertEquals(json, "{\\\"cluster\\\":{\\\"master\\\":[\\\"master-0.wtan" + ".tf-job-001.example.com:8000\\\"],\\\"worker\\\":[\\\"worker-0.wtan" + ".tf-job-001.example.com:8000\\\",\\\"worker-1.wtan.tf-job-001" + ".example.com:8000\\\",\\\"worker-2.wtan.tf-job-001.example" + ".com:8000\\\",\\\"worker-3.wtan.tf-job-001.example.com:8000\\\"]," + "\\\"ps\\\":[\\\"ps-0.wtan.tf-job-001.example.com:8000\\\",\\\"ps-1" + ".wtan.tf-job-001.example.com:8000\\\",\\\"ps-2.wtan.tf-job-001" + ".example.com:8000\\\"]},\\\"task\\\":{ \\\"type\\\":\\\"ps\\\", " + "\\\"index\\\":$_TASK_INDEX},\\\"environment\\\":\\\"cloud\\\"}"); }