@BeforeSuite(groups = {"integration"})
    public static void beforeSuite() {
        if (isCloud) {
            if (!runQuery("CREATE DATABASE IF NOT EXISTS " + database)) {
                throw new RuntimeException("Failed to create database for testing.");
            }

            return;
        }

        if (clickhouseContainer != null) {
            if (clickhouseContainer.isRunning()) {
                return;
            }

            try {
                clickhouseContainer.start();

                if (clickhouseContainer.isRunning()) {
                    if (!runQuery("CREATE DATABASE IF NOT EXISTS `" + getDatabase() + "`")) {
                        throw new RuntimeException("Failed to create database");
                    }
                }
            } catch (RuntimeException e) {
                throw new IllegalStateException(new StringBuilder()
                        .append("Failed to start docker container for integration test.\r\n")
                        .append("If you prefer to run tests without docker, ")
                        .append("please follow instructions at https://github.com/ClickHouse/clickhouse-java#testing")
                        .toString(), e);
            }
        }
    }
Adaptive ClickHouse server environment for integration test. Two modes are
supported: 1) existing server(when system property {@code clickhouseServer}
is defined); and 2) test container.

<p>
Below system properties can be used for customization:
<ul>
<li>clickhouseServer - host of clickhouse server</li>
<li>clickhouse&lt;Protocol&gt;Port - port of specific protocol, for example:
{@code clickhouseGRPCPort}</li>
<li>clickhouseImage - custom docker image, with or without tag and/or image
digest</li>
<li>clickhouseVersion - version of clickhouse, could be replaced by the one
used in {@code clickhouseImage}</li>
<li>clickhouseTimezone - server timezone</li>
<li>additionalPackages - additional system packages should be installed in
container mode</li>
</ul>
clickhouse-client/src/test/java/com/clickhouse/client/ClickHouseServerForTest.java