Skip to content

Commit

Permalink
UTs for ExtensionsConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
himanshug committed Mar 25, 2016
1 parent 004b00b commit e78a469
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/content/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Many of Druid's external dependencies can be plugged in as modules. Extensions c
|--------|-----------|-------|
|`druid.extensions.directory`|The root extension directory where user can put extensions related files. Druid will load extensions stored under this directory.|`extensions` (This is a relative path to Druid's working directory)|
|`druid.extensions.hadoopDependenciesDir`|The root hadoop dependencies directory where user can put hadoop related dependencies files. Druid will load the dependencies based on the hadoop coordinate specified in the hadoop index task.|`hadoop-dependencies` (This is a relative path to Druid's working directory|
|`druid.extensions.hadoopContainerDruidClasspath`|Hadoop Indexing launches hadoop jobs and this configuration provides way to explicitly set the user classpath for the hadoop job. By default this is computed automatically by druid based on the druid process classpath and set of extensions. However, sometimes you might want to be explicit to resolve dependency conflicts between druid and hadoop.|druid classpath and extensions|
|`druid.extensions.hadoopContainerDruidClasspath`|Hadoop Indexing launches hadoop jobs and this configuration provides way to explicitly set the user classpath for the hadoop job. By default this is computed automatically by druid based on the druid process classpath and set of extensions. However, sometimes you might want to be explicit to resolve dependency conflicts between druid and hadoop.|null|
|`druid.extensions.loadList`|A JSON array of extensions to load from extension directories by Druid. If it is not specified, its value will be `null` and Druid will load all the extensions under `druid.extensions.directory`. If its value is empty list `[]`, then no extensions will be loaded at all.|null|
|`druid.extensions.searchCurrentClassloader`|This is a boolean flag that determines if Druid will search the main classloader for extensions. It defaults to true but can be turned off if you have reason to not automatically add all modules on the classpath.|true|

Expand Down
82 changes: 82 additions & 0 deletions processing/src/test/java/io/druid/guice/ExtensionsConfigTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* 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.guice;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import io.druid.segment.TestHelper;
import org.junit.Assert;
import org.junit.Test;

/**
*/
public class ExtensionsConfigTest
{
@Test
public void testSerdeWithDefaults() throws Exception
{
String json = "{}";
ObjectMapper mapper = TestHelper.getObjectMapper();

ExtensionsConfig config = mapper.readValue(
mapper.writeValueAsString(
mapper.readValue(json, ExtensionsConfig.class)
),
ExtensionsConfig.class
);

Assert.assertTrue(config.searchCurrentClassloader());
Assert.assertEquals("extensions", config.getDirectory());
Assert.assertEquals("hadoop-dependencies", config.getHadoopDependenciesDir());
Assert.assertNull(config.getHadoopContainerDruidClasspath());
Assert.assertNull(config.getLoadList());
}

@Test
public void testSerdeWithNonDefaults() throws Exception
{
String json = "{\n"
+ " \"searchCurrentClassloader\": false,\n"
+ " \"directory\": \"testExtensions\",\n"
+ " \"hadoopDependenciesDir\": \"testHadoopDependenciesDir\",\n"
+ " \"hadoopContainerDruidClasspath\": \"testHadoopContainerClasspath\",\n"
+ " \"loadList\": [\"a\",\"b\"]\n"
+ "}";
ObjectMapper mapper = TestHelper.getObjectMapper();

ExtensionsConfig config = mapper.readValue(
mapper.writeValueAsString(
mapper.readValue(json, ExtensionsConfig.class)
),
ExtensionsConfig.class
);

Assert.assertFalse(config.searchCurrentClassloader());
Assert.assertEquals("testExtensions", config.getDirectory());
Assert.assertEquals("testHadoopDependenciesDir", config.getHadoopDependenciesDir());
Assert.assertEquals("testHadoopContainerClasspath", config.getHadoopContainerDruidClasspath());
Assert.assertEquals(
ImmutableList.of(
"a", "b"
),
config.getLoadList()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public static List<URL> getURLsForClasspath(String cp)
File f = new File(paths[i]);
if ("*".equals(f.getName())) {
File parentDir = f.getParentFile();
if (parentDir.exists() && parentDir.isDirectory()) {
if (parentDir.isDirectory()) {
File[] jars = parentDir.listFiles(
new FilenameFilter()
{
Expand Down

0 comments on commit e78a469

Please sign in to comment.