-
Notifications
You must be signed in to change notification settings - Fork 3.8k
add test for batch indexing from hadoop #2650
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
Merged
Merged
Changes from all commits
Commits
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
114 changes: 114 additions & 0 deletions
114
integration-tests/src/test/java/io/druid/tests/hadoop/ITHadoopIndexTest.java
This file contains hidden or 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,114 @@ | ||
| /* | ||
| * Licensed to Metamarkets Group Inc. (Metamarkets) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. Metamarkets 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 io.druid.tests.hadoop; | ||
|
|
||
| import com.google.common.base.Throwables; | ||
| import com.google.inject.Inject; | ||
| import com.metamx.common.ISE; | ||
| import com.metamx.common.logger.Logger; | ||
| import io.druid.indexing.common.TaskStatus; | ||
| import io.druid.testing.IntegrationTestingConfig; | ||
| import io.druid.testing.guice.DruidTestModuleFactory; | ||
| import io.druid.testing.utils.RetryUtil; | ||
| import io.druid.tests.indexer.AbstractIndexerTest; | ||
| import org.testng.annotations.AfterClass; | ||
| import org.testng.annotations.BeforeClass; | ||
| import org.testng.annotations.Guice; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| import java.util.concurrent.Callable; | ||
|
|
||
| @Guice(moduleFactory = DruidTestModuleFactory.class) | ||
| public class ITHadoopIndexTest extends AbstractIndexerTest | ||
| { | ||
| private static final Logger LOG = new Logger(ITHadoopIndexTest.class); | ||
| private static final String BATCH_TASK = "/hadoop/batch_hadoop_indexer.json"; | ||
| private static final String BATCH_QUERIES_RESOURCE = "/hadoop/batch_hadoop_queries.json"; | ||
| private static final String BATCH_DATASOURCE = "batchHadoop"; | ||
| private boolean dataLoaded = false; | ||
|
|
||
| @Inject | ||
| private IntegrationTestingConfig config; | ||
|
|
||
| @BeforeClass | ||
| public void beforeClass() | ||
| { | ||
| loadData(config.getProperty ("hadoopTestDir") + "/batchHadoop1"); | ||
| dataLoaded = true; | ||
| } | ||
|
|
||
| @Test | ||
| public void testHadoopIndex() throws Exception | ||
| { | ||
| queryHelper.testQueriesFromFile(BATCH_QUERIES_RESOURCE, 2); | ||
| } | ||
|
|
||
| private void loadData(String hadoopDir) | ||
| { | ||
| String indexerSpec = ""; | ||
|
|
||
| try { | ||
| LOG.info("indexerFile name: [%s]", BATCH_TASK); | ||
| indexerSpec = getTaskAsString(BATCH_TASK); | ||
| indexerSpec = indexerSpec.replaceAll("%%HADOOP_TEST_PATH%%", hadoopDir); | ||
| } catch (Exception e) { | ||
| LOG.error ("could not read and modify indexer file: %s", e.getMessage()); | ||
| throw Throwables.propagate(e); | ||
| } | ||
|
|
||
| try { | ||
| final String taskID = indexer.submitTask(indexerSpec); | ||
| LOG.info("TaskID for loading index task %s", taskID); | ||
| indexer.waitUntilTaskCompletes (taskID, 60000, 20); | ||
| RetryUtil.retryUntil( | ||
| new Callable<Boolean>() | ||
| { | ||
| @Override | ||
| public Boolean call() throws Exception | ||
| { | ||
| return coordinator.areSegmentsLoaded(BATCH_DATASOURCE); | ||
|
|
||
| } | ||
| }, | ||
| true, | ||
| 20000, | ||
| 10, | ||
| "Segment-Load-Task-" + taskID | ||
| ); | ||
| } catch (Exception e) { | ||
| LOG.error ("data could not be loaded: %s", e.getMessage()); | ||
| throw Throwables.propagate(e); | ||
| } | ||
| } | ||
|
|
||
| @AfterClass | ||
| public void afterClass() | ||
| { | ||
| if (dataLoaded) | ||
| { | ||
| try | ||
| { | ||
| unloadAndKillData(BATCH_DATASOURCE); | ||
| } catch (Exception e) { | ||
| LOG.warn ("exception while removing segments: [%s]", e); | ||
| } | ||
| } | ||
| } | ||
| } |
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.
Is it documented that this must be set in the docker image?
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.
or is this just evaluated in the host env? I'm a bit flummoxed on when this gets executed.
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.
The ${env.xxx} things have to be present in environment variables when the mvn command is given to run tests with docker. Magically, the values from the environment are injected into DockerConfigProvider.
If we had docker set up so it could do hadoop, we'd edit integration-tests/README.md to say to export HADOOP_DIR to the name of a directory containing batchHadoop1, where the test data is in hdfs.
Even though the tests can't be run in docker yet, I wanted to add this line and make the mods to DockerConfigProvider.java to be able to do the configuration for the hdfs location, while I had it in my head what needed to be done. Maybe I should file an issue about hadoop-in-docker, and say that the support for using it is already there in the code, and what would need to be added to the README.
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.
I've modified issue #2531, which was for a batch indexing test, to be for being able to run such a test with docker.
Any other comments on this PR?