public static List<TargetInfo> parseOptTarget(CommandLine cmd, AlluxioConfiguration conf)
      throws IOException {
    String[] targets;
    if (cmd.hasOption(TARGET_OPTION_NAME)) {
      String argTarget = cmd.getOptionValue(TARGET_OPTION_NAME);
      if (StringUtils.isBlank(argTarget)) {
        throw new IOException("Option " + TARGET_OPTION_NAME + " can not be blank.");
      } else if (argTarget.contains(TARGET_SEPARATOR)) {
        targets = argTarget.split(TARGET_SEPARATOR);
      } else {
        targets = new String[]{argTarget};
      }
    } else {
      // By default we set on all targets (master/workers/job_master/job_workers)
      targets = new String[]{ROLE_MASTER, ROLE_JOB_MASTER, ROLE_WORKERS, ROLE_JOB_WORKERS};
    }
    return getTargetInfos(targets, conf);
  }
@Test
  public void parseWorkerTargets() throws Exception {
    CommandLine mockCommandLine = mock(CommandLine.class);
    String[] mockArgs = new String[]{"--target", "workers"};
    when(mockCommandLine.getArgs()).thenReturn(mockArgs);
    when(mockCommandLine.hasOption(LogLevel.TARGET_OPTION_NAME)).thenReturn(true);
    when(mockCommandLine.getOptionValue(LogLevel.TARGET_OPTION_NAME)).thenReturn(mockArgs[1]);

    // Prepare a list of workers
    WorkerClusterView workers = new WorkerClusterView(Arrays.asList(
        new WorkerInfo().setIdentity(WorkerIdentityTestUtils.randomLegacyId())
            .setAddress(new WorkerNetAddress().setHost("workers-1").setWebPort(WORKER_WEB_PORT))
            .setCapacityBytes(0)
            .setUsedBytes(0),
        new WorkerInfo().setIdentity(WorkerIdentityTestUtils.randomLegacyId())
            .setAddress(new WorkerNetAddress().setHost("workers-2").setWebPort(WORKER_WEB_PORT))
            .setCapacityBytes(0)
            .setUsedBytes(0)));
    try (MockedStatic<FileSystemContext> mockFactory = mockStatic(FileSystemContext.class)) {
      FileSystemContext mockFsContext = mock(FileSystemContext.class);
      when(mockFsContext.getCachedWorkers()).thenReturn(workers);
      mockFactory.when(() -> FileSystemContext.create(any(ClientContext.class)))
          .thenReturn(mockFsContext);

      List<LogLevel.TargetInfo> targets = LogLevel.parseOptTarget(mockCommandLine, mConf);
      assertEquals(2, targets.size());
      assertEquals(new LogLevel.TargetInfo("workers-1", WORKER_WEB_PORT, "worker"),
          targets.get(0));
      assertEquals(new LogLevel.TargetInfo("workers-2", WORKER_WEB_PORT, "worker"),
          targets.get(1));
    }
  }