forked from apache/druid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request apache#2650 from rasahner/IT_index_hadoop
add test for batch indexing from hadoop
- Loading branch information
Showing
9 changed files
with
3,955 additions
and
21 deletions.
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
114 changes: 114 additions & 0 deletions
114
integration-tests/src/test/java/io/druid/tests/hadoop/ITHadoopIndexTest.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,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.