public static boolean runQuery(String sql) {
        LOGGER.info("runQuery: (\"" + sql + "\")");

        try {
            throw new Exception("test");
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (clickhouseContainer != null) {
            try {
                Container.ExecResult res =  clickhouseContainer.execInContainer("clickhouse-client",
                        "-u", "default", "--password", getPassword(), "--query", sql);
                if (res.getExitCode() != 0) {
                    LOGGER.error("query execution result: stderr={}, stdout={}", res.getStderr(), res.getStdout() );
                }
                return res.getExitCode() == 0;
            } catch (Exception e) {
                throw new RuntimeException("runQuery('" + sql + "') failed", e);
            }
        } else {
            //Create database for testing

            ClickHouseNode server = getClickHouseNode(ClickHouseProtocol.HTTP, isCloud(), ClickHouseNode.builder().build());

            String uri = server.getBaseUri();

            try {
                URL serverURL = new URL(uri);
                LOGGER.info("sending request to {} (uri={})", serverURL, uri);

                for (int attempts = 0; attempts < 10; attempts++) {
                    HttpURLConnection httpConn = (HttpURLConnection) serverURL.openConnection();
                    try {
                        httpConn.setRequestMethod("POST");
                        httpConn.setDoOutput(true);
                        httpConn.setRequestProperty("Authorization", "Basic " + Base64.getEncoder().encodeToString(("default:" + getPassword()).getBytes()));

                        try (OutputStream out = httpConn.getOutputStream()) {
                            out.write(sql.getBytes(StandardCharsets.UTF_8));
                            out.flush();
                        }

                        if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
                            return true;
                        }
                    } finally {
                        if (httpConn != null) {
                            httpConn.disconnect();
                        }
                    }
                }
            } catch (Exception e) {
                LOGGER.error("failed to run query", e);
            }

            return false;
        }
    }
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