forked from apache/druid
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Patch for the ITs for MSQ #1
Open
LakshSingla
wants to merge
12
commits into
target-msq-first-it
Choose a base branch
from
msq-first-it
base: target-msq-first-it
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ac14060
Refine the IT framework
paul-rogers e034f60
Final revsions
paul-rogers 7e98bdb
Disabled flaky tests to get a clean build
paul-rogers 754ba9c
Build fixes
paul-rogers 1a5af17
first test, serde causing problems
LakshSingla c0357d2
serde working
LakshSingla 51170bc
insert and select check
LakshSingla 9ac998f
Merge fix
paul-rogers b99fcc2
Add cluster annotations for MSQ test cases
LakshSingla e2aef43
Merge branch '220325-docker' of https://github.com/paul-rogers/druid …
LakshSingla 5a51441
Add cluster config for MSQ
LakshSingla 8daef61
Add MSQ config to the pom.xml
LakshSingla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
integration-tests-ex/cases/src/test/java/org/apache/druid/testsEx/msq/ITMultiStageQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.druid.testsEx.msq; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.google.inject.Inject; | ||
import org.apache.druid.testing.IntegrationTestingConfig; | ||
import org.apache.druid.testing.clients.MsqTestClient; | ||
import org.apache.druid.testing.guice.models.MSQTaskReportDeserializable; | ||
import org.apache.druid.testing.utils.MsqQueryWithResults; | ||
import org.apache.druid.testing.utils.MsqTestQueryHelper; | ||
import org.apache.druid.testsEx.categories.BatchIndex; | ||
import org.apache.druid.testsEx.config.DruidTestRunner; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.junit.runner.RunWith; | ||
|
||
import java.util.Map; | ||
|
||
@RunWith(DruidTestRunner.class) | ||
@Category(BatchIndex.class) | ||
public class ITMultiStageQuery | ||
{ | ||
@Inject | ||
private MsqTestQueryHelper msqHelper; | ||
|
||
@Inject | ||
private MsqTestClient msqClient; | ||
|
||
@Inject | ||
private IntegrationTestingConfig config; | ||
@Inject | ||
|
||
private ObjectMapper jsonMapper; | ||
|
||
@Test | ||
public void test() throws Exception | ||
{ | ||
String query = | ||
"INSERT INTO dst SELECT *\n" | ||
+ "FROM TABLE(extern(\n" | ||
+ " '{\n" | ||
+ " \"type\": \"inline\",\n" | ||
+ " \"data\": \"a,b,1\\nc,d,2\\n\"\n" | ||
+ " }',\n" | ||
+ " '{\n" | ||
+ " \"type\": \"csv\",\n" | ||
+ " \"columns\": [\"x\",\"y\",\"z\"],\n" | ||
+ " \"listDelimiter\": null,\n" | ||
+ " \"findColumnsFromHeader\": false,\n" | ||
+ " \"skipHeaderRows\": 0\n" | ||
+ " }',\n" | ||
+ " '[\n" | ||
+ " {\"name\": \"x\", \"type\": \"STRING\"},\n" | ||
+ " {\"name\": \"y\", \"type\": \"STRING\"},\n" | ||
+ " {\"name\": \"z\", \"type\": \"LONG\"}\n" | ||
+ " ]'\n" | ||
+ "))\n" | ||
+ "PARTITIONED BY ALL TIME"; | ||
String taskId = msqHelper.submitMsqTask(query); | ||
msqHelper.pollTaskIdForCompletion(taskId, 0); | ||
Map<String, MSQTaskReportDeserializable> reports = msqHelper.fetchStatusReports(taskId); | ||
|
||
String resultsQuery = "SELECT * FROM dst"; | ||
String resultsTaskId = msqHelper.submitMsqTask(resultsQuery); | ||
msqHelper.pollTaskIdForCompletion(resultsTaskId, 0); | ||
msqHelper.compareResults(resultsTaskId, new MsqQueryWithResults( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Results should also be served from a file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where we can use the existing format which holds both the query and expected results. |
||
query, | ||
ImmutableList.of( | ||
ImmutableMap.of("x", "a", "y", "b", "z", 1), | ||
ImmutableMap.of("x", "c", "y", "d", "z", 2) | ||
) | ||
)); | ||
int x = 5; | ||
x += 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...n-tests/src/main/java/org/apache/druid/testing/clients/MsqOverlordResourceTestClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.druid.testing.clients; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.google.common.collect.ImmutableList; | ||
import com.google.inject.Inject; | ||
import org.apache.druid.guice.annotations.Json; | ||
import org.apache.druid.java.util.common.ISE; | ||
import org.apache.druid.java.util.common.StringUtils; | ||
import org.apache.druid.java.util.http.client.HttpClient; | ||
import org.apache.druid.java.util.http.client.response.StatusResponseHolder; | ||
import org.apache.druid.msq.guice.MSQIndexingModule; | ||
import org.apache.druid.msq.indexing.report.MSQTaskReport; | ||
import org.apache.druid.testing.IntegrationTestingConfig; | ||
import org.apache.druid.testing.guice.TestClient; | ||
import org.apache.druid.testing.guice.models.MSQTaskReportDeserializable; | ||
import org.jboss.netty.handler.codec.http.HttpMethod; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class MsqOverlordResourceTestClient extends OverlordResourceTestClient | ||
{ | ||
ObjectMapper jsonMapper; | ||
|
||
@Inject | ||
MsqOverlordResourceTestClient( | ||
@Json ObjectMapper jsonMapper, | ||
@TestClient HttpClient httpClient, | ||
IntegrationTestingConfig config | ||
) | ||
{ | ||
super(jsonMapper, httpClient, config); | ||
this.jsonMapper = jsonMapper; | ||
} | ||
|
||
public Map<String, MSQTaskReportDeserializable> getTaskReportForMsqTask(String taskId) | ||
{ | ||
try { | ||
StatusResponseHolder response = makeRequest( | ||
HttpMethod.GET, | ||
StringUtils.format( | ||
"%s%s", | ||
getIndexerURL(), | ||
StringUtils.format("task/%s/reports", StringUtils.urlEncode(taskId)) | ||
) | ||
); | ||
jsonMapper.registerModules(new MSQIndexingModule().getJacksonModules()); | ||
jsonMapper.registerSubtypes(ImmutableList.of(MSQTaskReportDeserializable.class)); | ||
return jsonMapper.readValue( | ||
response.getContent(), | ||
new TypeReference<Map<String, MSQTaskReportDeserializable>>() | ||
{ | ||
} | ||
); | ||
} | ||
catch (ISE e) { | ||
throw e; | ||
} | ||
catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
private static class MsqTaskReportType extends HashMap<String, MSQTaskReport> | ||
{ | ||
|
||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
integration-tests/src/main/java/org/apache/druid/testing/clients/MsqTestClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.druid.testing.clients; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.google.inject.Inject; | ||
import org.apache.druid.java.util.http.client.HttpClient; | ||
import org.apache.druid.sql.http.SqlQuery; | ||
import org.apache.druid.testing.IntegrationTestingConfig; | ||
import org.apache.druid.testing.guice.TestClient; | ||
|
||
import javax.ws.rs.core.MediaType; | ||
|
||
public class MsqTestClient extends AbstractQueryResourceTestClient<SqlQuery> | ||
{ | ||
@Inject | ||
MsqTestClient( | ||
ObjectMapper jsonMapper, | ||
@TestClient HttpClient httpClient, | ||
IntegrationTestingConfig config | ||
) | ||
{ | ||
super(jsonMapper, null, httpClient, config.getRouterUrl(), MediaType.APPLICATION_JSON, null); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...s/src/main/java/org/apache/druid/testing/guice/models/MSQResultsReportDeserializable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.druid.testing.guice.models; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.google.common.base.Preconditions; | ||
import org.apache.druid.segment.column.RowSignature; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.List; | ||
|
||
public class MSQResultsReportDeserializable | ||
{ | ||
private final RowSignature signature; | ||
@Nullable | ||
private final List<String> sqlTypeNames; | ||
private final List<Object[]> results; | ||
|
||
@JsonCreator | ||
public MSQResultsReportDeserializable( | ||
@JsonProperty("signature") final RowSignature signature, | ||
@JsonProperty("sqlTypeNames") @Nullable final List<String> sqlTypeNames, | ||
@JsonProperty("results") final List<Object[]> results | ||
) | ||
{ | ||
this.signature = Preconditions.checkNotNull(signature, "signature"); | ||
this.sqlTypeNames = sqlTypeNames; | ||
this.results = Preconditions.checkNotNull(results, "results"); | ||
} | ||
|
||
@JsonProperty("signature") | ||
public RowSignature getSignature() | ||
{ | ||
return signature; | ||
} | ||
|
||
@JsonProperty("sqlTypeNames") | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public List<String> getSqlTypeNames() | ||
{ | ||
return sqlTypeNames; | ||
} | ||
|
||
@JsonProperty("results") | ||
public List<Object[]> getResults() | ||
{ | ||
return results; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be picked up from a file using a http data source
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not necessary to put queries in a file. Existing tests use files, but only because they have many queries. However, since this query is rather complex, it might be easier to maintain if it is in a file.
The existing format may not be a good fit for MSQ tests, so we might want to create a simplified form for use here.