From 8722f4cc185463af3341dc68e21f7c2758a26b09 Mon Sep 17 00:00:00 2001 From: Himanshu Gupta Date: Fri, 1 May 2015 19:39:25 -0500 Subject: [PATCH 1/3] UTs for ConvertProperties --- .../cli/convert/ConvertPropertiesTest.java | 71 +++++++++++++++++++ .../resources/convertProps/new.properties | 20 ++++++ .../resources/convertProps/old.properties | 21 ++++++ 3 files changed, 112 insertions(+) create mode 100644 services/src/test/java/io/druid/cli/convert/ConvertPropertiesTest.java create mode 100644 services/src/test/resources/convertProps/new.properties create mode 100644 services/src/test/resources/convertProps/old.properties diff --git a/services/src/test/java/io/druid/cli/convert/ConvertPropertiesTest.java b/services/src/test/java/io/druid/cli/convert/ConvertPropertiesTest.java new file mode 100644 index 00000000000..cf7042aaa99 --- /dev/null +++ b/services/src/test/java/io/druid/cli/convert/ConvertPropertiesTest.java @@ -0,0 +1,71 @@ +/* + * 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.cli.convert; + +import org.apache.commons.io.FileUtils; +import org.junit.After; +import org.junit.Assert; +import org.junit.Test; +import org.junit.Rule; + +import io.airlift.command.Cli; + +import org.junit.rules.TemporaryFolder; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Properties; + +public class ConvertPropertiesTest +{ + @Rule + public TemporaryFolder tmpFolder = new TemporaryFolder(); + + @Test + public void testConvertProperties() throws IOException + { + String oldPropertiesFile = this.getClass().getResource("/convertProps/old.properties").getFile(); + + File convertedPropertiesFile = tmpFolder.newFile(); + + Cli parser = Cli.builder("convertProps") + .withCommand(ConvertProperties.class) + .build(); + Object command = parser.parse("convertProps","-f", oldPropertiesFile,"-o", convertedPropertiesFile.getAbsolutePath()); + Assert.assertNotNull(command); + ConvertProperties convertProperties = (ConvertProperties) command; + convertProperties.run(); + + Properties actualConvertedProperties = new Properties(); + actualConvertedProperties.load(new FileInputStream(convertedPropertiesFile)); + + Properties expectedConvertedProperties = new Properties(); + expectedConvertedProperties.load(this.getClass().getResourceAsStream("/convertProps/new.properties")); + + Assert.assertEquals(expectedConvertedProperties, actualConvertedProperties); + } + + @After + public void tearDown() throws IOException + { + FileUtils.deleteDirectory(tmpFolder.getRoot()); + } +} diff --git a/services/src/test/resources/convertProps/new.properties b/services/src/test/resources/convertProps/new.properties new file mode 100644 index 00000000000..008bddd1a4e --- /dev/null +++ b/services/src/test/resources/convertProps/new.properties @@ -0,0 +1,20 @@ +druid.metadata.storage.type=mysql +druid.metadata.storage.connector.connectURI=jdbc:mysql://localhost:3306/druid +druid.metadata.storage.connector.createTables=true +druid.metadata.storage.connector.password=diurd +druid.metadata.storage.connector.user=druid + +druid.metadata.storage.tables.base=druid +druid.metadata.storage.tables.segmentTable=druid_segments +druid.metadata.storage.tables.ruleTable=druid_rules +druid.metadata.storage.tables.configTable=druid_config +druid.metadata.storage.tables.tasks=druid_tasks +druid.metadata.storage.tables.taskLog=druid_taskLog +druid.metadata.storage.tables.taskLock=druid_taskLock + +druid.indexer.storage.type=metadata +druid.publish.type=metadata + +druid.extensions.coordinates=["io.druid.extensions:mysql-metadata-storage"] + +leave.me.alone=xxx diff --git a/services/src/test/resources/convertProps/old.properties b/services/src/test/resources/convertProps/old.properties new file mode 100644 index 00000000000..8f045b335e3 --- /dev/null +++ b/services/src/test/resources/convertProps/old.properties @@ -0,0 +1,21 @@ +druid.db.connector.connectURI=jdbc:mysql://localhost:3306/druid +druid.db.connector.createTables=true +druid.db.connector.password=diurd +druid.db.connector.user=druid +druid.db.connector.useValidationQuery=false +druid.db.connector.validationQuery=SELECT 1 + +druid.db.tables.base=druid +druid.db.tables.segmentTable=druid_segments +druid.db.tables.ruleTable=druid_rules +druid.db.tables.configTable=druid_config +druid.db.tables.tasks=druid_tasks +druid.db.tables.taskLog=druid_taskLog +druid.db.tables.taskLock=druid_taskLock + +druid.indexer.storage.type=db +druid.publish.type=db + +druid.extensions.coordinates=[] + +leave.me.alone=xxx From aa10626b61b5a8dd6264eab0e7bdfe8258e2a4b2 Mon Sep 17 00:00:00 2001 From: Himanshu Gupta Date: Fri, 1 May 2015 19:40:08 -0500 Subject: [PATCH 2/3] adding druid.db.tables.xxx renames and druid.db.connectory.*validation* from ConvertProperties --- .../druid/cli/convert/ConvertProperties.java | 11 ++++- .../java/io/druid/cli/convert/Remove.java | 47 +++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 services/src/main/java/io/druid/cli/convert/Remove.java diff --git a/services/src/main/java/io/druid/cli/convert/ConvertProperties.java b/services/src/main/java/io/druid/cli/convert/ConvertProperties.java index d3f5e0c8aa3..97690e0aa12 100644 --- a/services/src/main/java/io/druid/cli/convert/ConvertProperties.java +++ b/services/src/main/java/io/druid/cli/convert/ConvertProperties.java @@ -68,7 +68,16 @@ public class ConvertProperties implements Runnable new Rename("druid.db.connector.connectURI", "druid.metadata.storage.connector.connectURI"), new Rename("druid.db.connector.user", "druid.metadata.storage.connector.user"), new Rename("druid.db.connector.password", "druid.metadata.storage.connector.password"), + new Remove("druid.db.connector.validationQuery"), + new Remove("druid.db.connector.useValidationQuery"), + new Rename("druid.db.connector.createTables", "druid.metadata.storage.connector.createTables"), new Rename("druid.db.tables.base", "druid.metadata.storage.tables.base"), + new Rename("druid.db.tables.configTable", "druid.metadata.storage.tables.configTable"), + new Rename("druid.db.tables.segmentTable", "druid.metadata.storage.tables.segmentTable"), + new Rename("druid.db.tables.ruleTable", "druid.metadata.storage.tables.ruleTable"), + new Rename("druid.db.tables.taskLock", "druid.metadata.storage.tables.taskLock"), + new Rename("druid.db.tables.tasks", "druid.metadata.storage.tables.tasks"), + new Rename("druid.db.tables.taskLog", "druid.metadata.storage.tables.taskLog"), new PropertyConverter() { // Add a new config for metadata storage type, and update property name @@ -124,7 +133,7 @@ public class ConvertProperties implements Runnable ); } catch (IOException e) { - throw com.google.api.client.repackaged.com.google.common.base.Throwables.propagate(e); + throw Throwables.propagate(e); } coordinates.addAll(oldCoordinates); coordinates.add(String.format("io.druid.extensions:%s-metadata-storage", parseJdbcUrl(jdbcUrl))); diff --git a/services/src/main/java/io/druid/cli/convert/Remove.java b/services/src/main/java/io/druid/cli/convert/Remove.java new file mode 100644 index 00000000000..eb025b14112 --- /dev/null +++ b/services/src/main/java/io/druid/cli/convert/Remove.java @@ -0,0 +1,47 @@ +/* +* 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.cli.convert; + +import com.google.common.collect.ImmutableMap; + +import java.util.Map; +import java.util.Properties; + +public class Remove implements PropertyConverter +{ + private final String propertyToRemove; + + public Remove(String propertyToRemove) + { + this.propertyToRemove = propertyToRemove; + } + + @Override + public boolean canHandle(String property) + { + return this.propertyToRemove.equals(property); + } + + @Override + public Map convert(Properties properties) + { + return ImmutableMap.of(); + } +} From eca69fd0841a8b3bd5aa4cde3bdc624f3513077d Mon Sep 17 00:00:00 2001 From: Himanshu Gupta Date: Sun, 3 May 2015 08:30:39 -0500 Subject: [PATCH 3/3] remove validation query config from docs as its not valid anymore --- docs/content/Configuration.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/content/Configuration.md b/docs/content/Configuration.md index 202a6fe116a..cce3e196f4f 100644 --- a/docs/content/Configuration.md +++ b/docs/content/Configuration.md @@ -151,8 +151,6 @@ These properties specify the jdbc connection and other configuration around the |`druid.metadata.storage.connector.user`|The username to connect with.|none| |`druid.metadata.storage.connector.password`|The password to connect with.|none| |`druid.metadata.storage.connector.createTables`|If Druid requires a table and it doesn't exist, create it?|true| -|`druid.metadata.storage.connector.useValidationQuery`|Validate a table with a query.|false| -|`druid.metadata.storage.connector.validationQuery`|The query to validate with.|SELECT 1| |`druid.metadata.storage.tables.base`|The base name for tables.|druid| |`druid.metadata.storage.tables.segmentTable`|The table to use to look for segments.|druid_segments| |`druid.metadata.storage.tables.ruleTable`|The table to use to look for segment load/drop rules.|druid_rules|