code: public void waitForWorkersRegistered(int timeoutMs)
        throws TimeoutException, InterruptedException, IOException {
      try (MetaMasterClient client =
               new RetryHandlingMetaMasterClient(MasterClientContext
                   .newBuilder(ClientContext.create(ServerConfiguration.global())).build())) {
        CommonUtils.waitFor("workers registered", () -> {
          try {
            return client.getMasterInfo(Collections.emptySet())
                .getWorkerAddressesList().size() == mNumWorkers;
          } catch (UnavailableException e) {
            return false;
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }, WaitForOptions.defaults().setInterval(200).setTimeoutMs(timeoutMs));
      }
    }
docs: Waits for all workers registered with master.
  
  @param timeoutMs the timeout to wait