Skip to content

Instantly share code, notes, and snippets.

@Marthym
Created November 5, 2014 10:24
Show Gist options
  • Save Marthym/688e060560e6ae7454cf to your computer and use it in GitHub Desktop.
Save Marthym/688e060560e6ae7454cf to your computer and use it in GitHub Desktop.
Wait until database is correctly started
/* Using a mysql inside docker for executing test, I need to wait for MySQL is completly started before running test */
Awaitility.await().atMost(5, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
try (Connection conn = ds.getConnection()) {
return true;
} catch (Exception e) {
System.out.println(e.getClass() + ": " + e.getLocalizedMessage());
return false;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment