kfaraz commented on code in PR #18805:
URL: https://github.com/apache/druid/pull/18805#discussion_r2588063621
##########
embedded-tests/src/test/java/org/apache/druid/testing/embedded/query/JdbcQueryTest.java:
##########
@@ -47,69 +40,55 @@
import java.util.Properties;
import java.util.Set;
-@Test(groups = {TestNGGroup.QUERY, TestNGGroup.CENTRALIZED_DATASOURCE_SCHEMA})
-@Guice(moduleFactory = DruidTestModuleFactory.class)
-public class ITJdbcQueryTest
+public class JdbcQueryTest extends QueryTestBase
{
- private static final Logger LOG = new Logger(ITJdbcQueryTest.class);
- private static final String WIKIPEDIA_DATA_SOURCE = "wikipedia_editstream";
+ private static final Logger LOG = new Logger(JdbcQueryTest.class);
private static final String CONNECTION_TEMPLATE =
"jdbc:avatica:remote:url=%s/druid/v2/sql/avatica/";
private static final String TLS_CONNECTION_TEMPLATE =
"jdbc:avatica:remote:url=%s/druid/v2/sql/avatica/;truststore=%s;truststore_password=%s;keystore=%s;keystore_password=%s;key_password=%s";
private static final String QUERY_TEMPLATE =
- "SELECT \"user\", SUM(\"added\"), COUNT(*)" +
- "FROM \"wikipedia\" " +
- "WHERE \"__time\" >= CURRENT_TIMESTAMP - INTERVAL '99' YEAR AND
\"language\" = %s" +
- "GROUP BY 1 ORDER BY 3 DESC LIMIT 10";
- private static final String QUERY = StringUtils.format(QUERY_TEMPLATE,
"'en'");
-
- private static final String QUERY_PARAMETERIZED =
StringUtils.format(QUERY_TEMPLATE, "?");
+ "SELECT \"item\", SUM(\"value\"), COUNT(*) "
+ + "FROM \"%s\" "
+ + "WHERE \"__time\" >= CURRENT_TIMESTAMP - INTERVAL '99' YEAR AND
\"value\" < %s \n"
+ + "GROUP BY 1 ORDER BY 3 DESC LIMIT 10";
private String[] connections;
private Properties connectionProperties;
- @Inject
- private IntegrationTestingConfig config;
-
- @Inject
- SSLClientConfig sslConfig;
-
- @Inject
- private DataLoaderHelper dataLoaderHelper;
+ private String tableName;
- @BeforeMethod
- public void before()
+ @Override
+ protected void beforeAll()
{
connectionProperties = new Properties();
connectionProperties.setProperty("user", "admin");
connectionProperties.setProperty("password", "priest");
connections = new String[]{
- StringUtils.format(CONNECTION_TEMPLATE, config.getRouterUrl()),
- StringUtils.format(CONNECTION_TEMPLATE, config.getBrokerUrl()),
- StringUtils.format(
- TLS_CONNECTION_TEMPLATE,
- config.getRouterTLSUrl(),
- sslConfig.getTrustStorePath(),
- sslConfig.getTrustStorePasswordProvider().getPassword(),
- sslConfig.getKeyStorePath(),
- sslConfig.getKeyStorePasswordProvider().getPassword(),
- sslConfig.getKeyManagerPasswordProvider().getPassword()
- ),
- StringUtils.format(
- TLS_CONNECTION_TEMPLATE,
- config.getBrokerTLSUrl(),
- sslConfig.getTrustStorePath(),
- sslConfig.getTrustStorePasswordProvider().getPassword(),
- sslConfig.getKeyStorePath(),
- sslConfig.getKeyStorePasswordProvider().getPassword(),
- sslConfig.getKeyManagerPasswordProvider().getPassword()
- )
+ StringUtils.format(CONNECTION_TEMPLATE, getServerUrl(router)),
+ StringUtils.format(CONNECTION_TEMPLATE, getServerUrl(broker)),
+ // Add in the consecutive patch
+ // StringUtils.format(
+ // TLS_CONNECTION_TEMPLATE,
+ // config.getRouterTLSUrl(),
+ // sslConfig.getTrustStorePath(),
+ // sslConfig.getTrustStorePasswordProvider().getPassword(),
+ // sslConfig.getKeyStorePath(),
+ // sslConfig.getKeyStorePasswordProvider().getPassword(),
+ // sslConfig.getKeyManagerPasswordProvider().getPassword()
+ //),
+ // StringUtils.format(
+ // TLS_CONNECTION_TEMPLATE,
+ // config.getBrokerTLSUrl(),
+ // sslConfig.getTrustStorePath(),
+ // sslConfig.getTrustStorePasswordProvider().getPassword(),
+ // sslConfig.getKeyStorePath(),
+ // sslConfig.getKeyStorePasswordProvider().getPassword(),
+ // sslConfig.getKeyManagerPasswordProvider().getPassword()
+ // )
};
- // ensure that wikipedia segments are loaded completely
- dataLoaderHelper.waitUntilDatasourceIsReady(WIKIPEDIA_DATA_SOURCE);
- dataLoaderHelper.waitUntilDatasourceIsReady("wikipedia");
- dataLoaderHelper.waitUntilDatasourceIsReady("twitterstream");
+
+ tableName = ingestBasicData();
Review Comment:
Rename pending?
##########
embedded-tests/src/test/java/org/apache/druid/testing/embedded/query/QueryTestBase.java:
##########
@@ -102,10 +111,46 @@ void setUp()
}
}
+ /**
+ * Ingests Druid with some the data from {@link
MoreResources.Task#BASIC_INDEX} in a synchronous manner.
+ *
+ * @return ingested datasource name
+ */
+ protected String ingestBasicData()
+ {
+ String datasourceName = EmbeddedClusterApis.createTestDatasourceName();
+
+ final String taskId = IdUtils.getRandomId();
+ final IndexTask task =
MoreResources.Task.BASIC_INDEX.get().dataSource(datasourceName).withId(taskId);
+ cluster.callApi().onLeaderOverlord(o -> o.runTask(taskId, task));
+ cluster.callApi().waitForTaskToSucceed(taskId, overlord);
+ cluster.callApi().waitForAllSegmentsToBeAvailable(datasourceName,
coordinator, broker);
+ return datasourceName;
+ }
+
+ /**
+ * Execute an async SQL query against the given endpoint via the HTTP client.
+ */
+ protected ListenableFuture<StatusResponseHolder> executeQueryAsync(String
endpoint, String query)
+ {
+ URL url;
+ try {
+ url = new URL(endpoint);
+ }
+ catch (MalformedURLException e) {
+ throw new AssertionError("Malformed URL");
+ }
+
+ Request request = new Request(HttpMethod.POST, url);
+ request.addHeader("Content-Type", MediaType.APPLICATION_JSON);
+ request.setContent(query.getBytes(StandardCharsets.UTF_8));
+ return httpClientRef.go(request, StatusResponseHandler.getInstance());
Review Comment:
We can try to augment the `EmbeddedClusterApis` to provide this
functionality and also some API to cancel queries in a follow up PR. Not needed
right now.
##########
integration-tests/docker/environment-configs/historical-for-query-error-test:
##########
@@ -29,4 +30,4 @@ druid_processing_numThreads=2
druid_query_groupBy_maxOnDiskStorage=300000000
druid_segmentCache_locations=[{"path":"/shared/druid/indexCache-query-error-test","maxSize":5000000000}]
druid_auth_basic_common_cacheDirectory=/tmp/authCache/historical-query-error-test
-druid_server_https_crlPath=/tls/revocations.crl
+druid_server_https_crlPath=/tls/revocations.crl
Review Comment:
extra change?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]