<p>I create a custom object using java-client for Kubernetes API in the beforeAll method of the integration tests. After the custom object is created the pods get created too. However, it only works when I set Thread.sleep for a few seconds. Without it, the object is created and then all the tests executed. I also defined watch on custom object statuses, but it does not help either.
Is there any other way (except for Thread.sleep) to hold for a few seconds until the pods get created?</p>

<p>My code for the custom object creation:</p>

<pre><code>def createWatchCustomObjectsCalls() = {
    client.getHttpClient.setReadTimeout(0, TimeUnit.SECONDS)
    val watchCalls: Watch[V1Namespace]  = Watch.createWatch(client,
      apiInstance.listNamespacedCustomObjectCall(crdGroup, crdVersion,  crdNamespace, crdPlural, "true",  null, null, true,null,  null),
      new TypeToken[Watch.Response[V1Namespace]]{}.getType)
    watchCalls
  }

 override def beforeAll(): Unit = {
    val creationResourcePath = Source.getClass.getResource("/" + httpServerScriptName).getPath
    val serverStartupProcessBuilder = Seq("sh", creationResourcePath, "&amp;") #&gt; Console.out
    serverStartupProcessBuilder.run()

    val body = convertYamlToJson()
    val sparkAppCreation = apiInstance.createNamespacedCustomObject(crdGroup, crdVersion, crdNamespace, crdPlural, body,"true")
    println(sparkAppCreation)
}
</code></pre>

<p>You can synchronously check in a while loop if pods had been created:</p>

<pre><code>// while
val currentPodList = getCoreV1Api()
                    .listPodForAllNamespaces(null /* _continue */,
                                            null /* fieldSelector */,
                                            null /* includeUninitialized */,
                                            null /* labelSelector */,
                                            null /* limit */,
                                            "false" /* pretty */,
                                            null /* resourceVersion */,
                                            null /* timeoutSeconds */,
                                            false /* watch */)
                    .getItems();
// check items from currentPodList
// end while
</code></pre>
