drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ar...@apache.org
Subject [01/11] drill git commit: DRILL-5337: OpenTSDB storage plugin
Date Mon, 13 Nov 2017 12:07:15 GMT
Repository: drill
Updated Branches:
  refs/heads/master 29e054769 -> 3036d3700


http://git-wip-us.apache.org/repos/asf/drill/blob/496c97d1/contrib/storage-opentsdb/src/main/java/org/apache/drill/exec/store/openTSDB/schema/OpenTSDBSchemaFactory.java
----------------------------------------------------------------------
diff --git a/contrib/storage-opentsdb/src/main/java/org/apache/drill/exec/store/openTSDB/schema/OpenTSDBSchemaFactory.java
b/contrib/storage-opentsdb/src/main/java/org/apache/drill/exec/store/openTSDB/schema/OpenTSDBSchemaFactory.java
new file mode 100644
index 0000000..cca39d8
--- /dev/null
+++ b/contrib/storage-opentsdb/src/main/java/org/apache/drill/exec/store/openTSDB/schema/OpenTSDBSchemaFactory.java
@@ -0,0 +1,77 @@
+/*
+ * 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.drill.exec.store.openTSDB.schema;
+
+import org.apache.calcite.schema.SchemaPlus;
+import org.apache.calcite.schema.Table;
+import org.apache.drill.exec.store.AbstractSchema;
+import org.apache.drill.exec.store.SchemaConfig;
+import org.apache.drill.exec.store.SchemaFactory;
+import org.apache.drill.exec.store.openTSDB.DrillOpenTSDBTable;
+import org.apache.drill.exec.store.openTSDB.OpenTSDBScanSpec;
+import org.apache.drill.exec.store.openTSDB.OpenTSDBStoragePlugin;
+import org.apache.drill.exec.store.openTSDB.OpenTSDBStoragePluginConfig;
+import org.apache.drill.exec.store.openTSDB.client.Schema;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Set;
+
+public class OpenTSDBSchemaFactory implements SchemaFactory {
+
+  private static final Logger log = LoggerFactory.getLogger(OpenTSDBSchemaFactory.class);
+
+  private final String schemaName;
+  private final OpenTSDBStoragePlugin plugin;
+
+  public OpenTSDBSchemaFactory(OpenTSDBStoragePlugin plugin, String schemaName) {
+    this.plugin = plugin;
+    this.schemaName = schemaName;
+  }
+
+  @Override
+  public void registerSchemas(SchemaConfig schemaConfig, SchemaPlus parent) throws IOException
{
+    OpenTSDBSchema schema = new OpenTSDBSchema(schemaName);
+    parent.add(schemaName, schema);
+  }
+
+  class OpenTSDBSchema extends AbstractSchema {
+
+    OpenTSDBSchema(String name) {
+      super(Collections.<String>emptyList(), name);
+    }
+
+    @Override
+    public Table getTable(String name) {
+      OpenTSDBScanSpec scanSpec = new OpenTSDBScanSpec(name);
+        return new DrillOpenTSDBTable(schemaName, plugin, new Schema(plugin.getClient(),
name), scanSpec);
+    }
+
+    @Override
+    public Set<String> getTableNames() {
+      return plugin.getClient().getAllMetricNames();
+    }
+
+    @Override
+    public String getTypeName() {
+      return OpenTSDBStoragePluginConfig.NAME;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/496c97d1/contrib/storage-opentsdb/src/main/resources/bootstrap-storage-plugins.json
----------------------------------------------------------------------
diff --git a/contrib/storage-opentsdb/src/main/resources/bootstrap-storage-plugins.json b/contrib/storage-opentsdb/src/main/resources/bootstrap-storage-plugins.json
new file mode 100644
index 0000000..d1055c1
--- /dev/null
+++ b/contrib/storage-opentsdb/src/main/resources/bootstrap-storage-plugins.json
@@ -0,0 +1,9 @@
+{
+  "storage": {
+    openTSDB: {
+      type: "openTSDB",
+      connection: "http://localhost:10000",
+      enabled: false
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/496c97d1/contrib/storage-opentsdb/src/main/resources/drill-module.conf
----------------------------------------------------------------------
diff --git a/contrib/storage-opentsdb/src/main/resources/drill-module.conf b/contrib/storage-opentsdb/src/main/resources/drill-module.conf
new file mode 100644
index 0000000..d5743da
--- /dev/null
+++ b/contrib/storage-opentsdb/src/main/resources/drill-module.conf
@@ -0,0 +1,21 @@
+// 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.
+//
+//  This file tells Drill to consider this module when class path scanning.
+//  This file can also include any supplementary configuration information.
+//  This file is in HOCON format, see https://github.com/typesafehub/config/blob/master/HOCON.md
for more information.
+drill.classpath.scanning: {
+  packages += "org.apache.drill.exec.store.openTSDB"
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/496c97d1/contrib/storage-opentsdb/src/test/java/org/apache/drill/store/openTSDB/TestDataHolder.java
----------------------------------------------------------------------
diff --git a/contrib/storage-opentsdb/src/test/java/org/apache/drill/store/openTSDB/TestDataHolder.java
b/contrib/storage-opentsdb/src/test/java/org/apache/drill/store/openTSDB/TestDataHolder.java
new file mode 100644
index 0000000..c6e7228
--- /dev/null
+++ b/contrib/storage-opentsdb/src/test/java/org/apache/drill/store/openTSDB/TestDataHolder.java
@@ -0,0 +1,247 @@
+/*
+ * 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.drill.store.openTSDB;
+
+public class TestDataHolder {
+
+  public static final String SAMPLE_DATA_FOR_POST_REQUEST_WITH_TAGS = "[{" +
+      "\"metric\":\"warp.speed.test\"," +
+      "\"tags\":{\"symbol\":\"VOD.L\"}," +
+      "\"aggregateTags\":[]," +
+      "\"dps\":{" +
+      "\"1407165399\":196.3000030517578," +
+      "\"1407165402\":196.3000030517578," +
+      "\"1407165405\":196.3000030517578," +
+      "\"1407165407\":196.3000030517578," +
+      "\"1407165410\":196.3000030517578," +
+      "\"1407165422\":196.3000030517578," +
+      "\"1488271956\":111.11000061035156}}," +
+      "{\"metric\":\"warp.speed.test\"," +
+      "\"tags\":{\"symbol\":\"BP.L\"}," +
+      "\"aggregateTags\":[]," +
+      "\"dps\":{" +
+      "\"1407165399\":484.20001220703125," +
+      "\"1407165403\":484.1499938964844," +
+      "\"1407165405\":484.1499938964844," +
+      "\"1407165408\":484.1499938964844," +
+      "\"1407165419\":484.1499938964844," +
+      "\"1407165423\":484.2550048828125}}," +
+      "{\"metric\":\"warp.speed.test\"," +
+      "\"tags\":{\"symbol\":\"BARC.L\"}," +
+      "\"aggregateTags\":[]," +
+      "\"dps\":{" +
+      "\"1407165401\":224.14999389648438," +
+      "\"1407165404\":224.14999389648438," +
+      "\"1407165406\":224.14999389648438," +
+      "\"1407165409\":224.14999389648438," +
+      "\"1407165422\":224.14999389648438}" +
+      "}]";
+
+  public static final String SAMPLE_DATA_FOR_GET_TABLE_REQUEST =
+      "[{" +
+          "\"metric\":\"warp.speed.test\"," +
+          "\"tags\":{}," +
+          "\"aggregateTags\":[\"symbol\"]," +
+          "\"dps\":{" +
+          "\"1407165399\":680.5000152587891," +
+          "\"1407165401\":904.625," +
+          "\"1407165402\":904.6124954223633," +
+          "\"1407165403\":904.5999908447266," +
+          "\"1407165404\":904.5999908447266," +
+          "\"1407165405\":904.5999908447266," +
+          "\"1407165406\":904.5999908447266," +
+          "\"1407165407\":904.5999908447266," +
+          "\"1407165408\":904.5999908447266," +
+          "\"1407165409\":904.5999908447266," +
+          "\"1407165410\":904.5999908447266," +
+          "\"1407165419\":904.5999908447266," +
+          "\"1407165422\":904.6787490844727," +
+          "\"1407165423\":680.5550068842233," +
+          "\"1488271956\":111.11000061035156}" +
+          "}]";
+
+  public static final String SAMPLE_DATA_FOR_POST_DOWNSAMPLE_REQUEST_WITH_TAGS =
+      "[{" +
+          "\"metric\":\"warp.speed.test\"," +
+          "\"tags\":{\"symbol\":\"VOD.L\"}," +
+          "\"aggregateTags\":[]," +
+          "\"dps\":{" +
+          "\"1261440000\":196.3000030517578," +
+          "\"1419120000\":111.11000061035156}" +
+          "},{" +
+          "\"metric\":\"warp.speed.test\"" +
+          ",\"tags\":{\"symbol\":\"BP.L\"}," +
+          "\"aggregateTags\":[]," +
+          "\"dps\":{" +
+          "\"1261440000\":484.1758321126302}" +
+          "},{" +
+          "\"metric\":\"warp.speed.test\"," +
+          "\"tags\":{" +
+          "\"symbol\":\"BARC.L\"}," +
+          "\"aggregateTags\":[]," +
+          "\"dps\":{" +
+          "\"1261440000\":224.14999389648438}" +
+          "}]";
+
+  public static final String SAMPLE_DATA_FOR_GET_TABLE_NAME_REQUEST = "[\"warp.speed.test\"]";
+
+  public static final String SAMPLE_DATA_FOR_POST_DOWNSAMPLE_REQUEST_WITHOUT_TAGS =
+      "[{" +
+          "\"metric\":\"warp.speed.test\"," +
+          "\"tags\":{}," +
+          "\"aggregateTags\":[" +
+          "\"symbol\"]," +
+          "\"dps\":{" +
+          "\"1261440000\":904.6258290608723," +
+          "\"1419120000\":111.11000061035156}" +
+          "}]";
+
+  public static final String SAMPLE_DATA_FOR_POST_END_REQUEST_WITHOUT_TAGS =
+      "[{" +
+          "\"metric\":\"warp.speed.test\"," +
+          "\"tags\":{}," +
+          "\"aggregateTags\":[" +
+          "\"symbol\"]," +
+          "\"dps\":{" +
+          "\"1407165399\":680.5000152587891," +
+          "\"1407165401\":904.625," +
+          "\"1407165402\":904.6124954223633," +
+          "\"1419120000\":904.5999908447266}" +
+          "}]";
+
+  public static final String DOWNSAMPLE_REQUEST_WTIHOUT_TAGS =
+      "{" +
+          "\"start\":\"47y-ago\"," +
+          "\"end\":null," +
+          "\"queries\":[{" +
+          "\"aggregator\":\"sum\"," +
+          "\"metric\":\"warp.speed.test\"," +
+          "\"rate\":null," +
+          "\"downsample\":\"5y-avg\"," +
+          "\"tags\":{}" +
+          "}]" +
+          "}";
+
+  public static final String END_PARAM_REQUEST_WTIHOUT_TAGS =
+        "{" +
+          "\"start\":\"47y-ago\"," +
+          "\"end\":\"1407165403000\"," +
+          "\"queries\":[{" +
+          "\"aggregator\":\"sum\"," +
+          "\"metric\":\"warp.speed.test\"," +
+          "\"rate\":null," +
+          "\"downsample\":null," +
+          "\"tags\":{}" +
+          "}]" +
+          "}";
+
+
+  public static final String DOWNSAMPLE_REQUEST_WITH_TAGS =
+      "{" +
+          "\"start\":\"47y-ago\"," +
+          "\"end\":null," +
+          "\"queries\":[{" +
+          "\"aggregator\":\"sum\"," +
+          "\"metric\":\"warp.speed.test\"," +
+          "\"rate\":null," +
+          "\"downsample\":\"5y-avg\"," +
+          "\"tags\":{" +
+          "\"symbol\":\"*\"}" +
+          "}]" +
+          "}";
+
+  public static final String END_PARAM_REQUEST_WITH_TAGS =
+      "{" +
+          "\"start\":\"47y-ago\"," +
+          "\"end\":\"1407165403000\"," +
+          "\"queries\":[{" +
+          "\"aggregator\":\"sum\"," +
+          "\"metric\":\"warp.speed.test\"," +
+          "\"rate\":null," +
+          "\"downsample\":null," +
+          "\"tags\":{" +
+          "\"symbol\":\"*\"}" +
+          "}]" +
+          "}";
+
+  public static final String REQUEST_TO_NONEXISTENT_METRIC =
+      "{" +
+          "\"start\":\"47y-ago\"," +
+          "\"end\":null," +
+          "\"queries\":[{" +
+          "\"aggregator\":\"sum\"," +
+          "\"metric\":\"warp.spee\"," +
+          "\"rate\":null," +
+          "\"downsample\":null," +
+          "\"tags\":{" + "}" +
+          "}]" +
+          "}";
+
+
+  public static final String POST_REQUEST_WITHOUT_TAGS =
+      "{" +
+          "\"start\":\"47y-ago\"," +
+          "\"end\":null," +
+          "\"queries\":[{" +
+          "\"aggregator\":\"sum\"," +
+          "\"metric\":\"warp.speed.test\"," +
+          "\"rate\":null," +
+          "\"downsample\":null," +
+          "\"tags\":{}" +
+          "}]" +
+          "}";
+
+
+  public static final String POST_REQUEST_WITH_TAGS =
+      "{" +
+          "\"start\":\"47y-ago\"," +
+          "\"end\":null," +
+          "\"queries\":[{" +
+          "\"aggregator\":\"sum\"," +
+          "\"metric\":\"warp.speed.test\"," +
+          "\"rate\":null," +
+          "\"downsample\":null," +
+          "\"tags\":{" +
+          "\"symbol\":\"*\"}" +
+          "}]" +
+          "}";
+
+  public static final String SAMPLE_DATA_FOR_POST_END_REQUEST_WITH_TAGS =
+      "[{" +
+          "\"metric\":\"warp.speed.test\"," +
+          "\"tags\":{\"symbol\":\"VOD.L\"}," +
+          "\"aggregateTags\":[]," +
+          "\"dps\":{" +
+          "\"1407165399\":196.3000030517578," +
+          "\"1407165402\":196.3000030517578}" +
+          "},{" +
+          "\"metric\":\"warp.speed.test\"" +
+          ",\"tags\":{\"symbol\":\"BP.L\"}," +
+          "\"aggregateTags\":[]," +
+          "\"dps\":{" +
+          "\"1407165399\":484.20001220703125," +
+          "\"1407165403\":484.1499938964844}" +
+          "},{" +
+          "\"metric\":\"warp.speed.test\"," +
+          "\"tags\":{" +
+          "\"symbol\":\"BARC.L\"}," +
+          "\"aggregateTags\":[]," +
+          "\"dps\":{" +
+          "\"1407165401\":224.14999389648438}" +
+          "}]";
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/496c97d1/contrib/storage-opentsdb/src/test/java/org/apache/drill/store/openTSDB/TestOpenTSDBPlugin.java
----------------------------------------------------------------------
diff --git a/contrib/storage-opentsdb/src/test/java/org/apache/drill/store/openTSDB/TestOpenTSDBPlugin.java
b/contrib/storage-opentsdb/src/test/java/org/apache/drill/store/openTSDB/TestOpenTSDBPlugin.java
new file mode 100644
index 0000000..2d6c506
--- /dev/null
+++ b/contrib/storage-opentsdb/src/test/java/org/apache/drill/store/openTSDB/TestOpenTSDBPlugin.java
@@ -0,0 +1,189 @@
+/*
+ * 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.drill.store.openTSDB;
+
+import com.github.tomakehurst.wiremock.junit.WireMockRule;
+import org.apache.drill.PlanTestBase;
+import org.apache.drill.common.exceptions.UserRemoteException;
+import org.apache.drill.exec.store.StoragePluginRegistry;
+import org.apache.drill.exec.store.openTSDB.OpenTSDBStoragePlugin;
+import org.apache.drill.exec.store.openTSDB.OpenTSDBStoragePluginConfig;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
+import static org.apache.drill.store.openTSDB.TestDataHolder.DOWNSAMPLE_REQUEST_WITH_TAGS;
+import static org.apache.drill.store.openTSDB.TestDataHolder.DOWNSAMPLE_REQUEST_WTIHOUT_TAGS;
+import static org.apache.drill.store.openTSDB.TestDataHolder.END_PARAM_REQUEST_WITH_TAGS;
+import static org.apache.drill.store.openTSDB.TestDataHolder.END_PARAM_REQUEST_WTIHOUT_TAGS;
+import static org.apache.drill.store.openTSDB.TestDataHolder.POST_REQUEST_WITHOUT_TAGS;
+import static org.apache.drill.store.openTSDB.TestDataHolder.POST_REQUEST_WITH_TAGS;
+import static org.apache.drill.store.openTSDB.TestDataHolder.REQUEST_TO_NONEXISTENT_METRIC;
+import static org.apache.drill.store.openTSDB.TestDataHolder.SAMPLE_DATA_FOR_GET_TABLE_NAME_REQUEST;
+import static org.apache.drill.store.openTSDB.TestDataHolder.SAMPLE_DATA_FOR_GET_TABLE_REQUEST;
+import static org.apache.drill.store.openTSDB.TestDataHolder.SAMPLE_DATA_FOR_POST_DOWNSAMPLE_REQUEST_WITHOUT_TAGS;
+import static org.apache.drill.store.openTSDB.TestDataHolder.SAMPLE_DATA_FOR_POST_DOWNSAMPLE_REQUEST_WITH_TAGS;
+import static org.apache.drill.store.openTSDB.TestDataHolder.SAMPLE_DATA_FOR_POST_END_REQUEST_WITHOUT_TAGS;
+import static org.apache.drill.store.openTSDB.TestDataHolder.SAMPLE_DATA_FOR_POST_END_REQUEST_WITH_TAGS;
+import static org.apache.drill.store.openTSDB.TestDataHolder.SAMPLE_DATA_FOR_POST_REQUEST_WITH_TAGS;
+
+public class TestOpenTSDBPlugin extends PlanTestBase {
+
+  protected static OpenTSDBStoragePlugin storagePlugin;
+  protected static OpenTSDBStoragePluginConfig storagePluginConfig;
+
+  @Rule
+  public WireMockRule wireMockRule = new WireMockRule(10000);
+
+  @BeforeClass
+  public static void setup() throws Exception {
+    final StoragePluginRegistry pluginRegistry = getDrillbitContext().getStorage();
+    storagePlugin = (OpenTSDBStoragePlugin) pluginRegistry.getPlugin(OpenTSDBStoragePluginConfig.NAME);
+    storagePluginConfig = storagePlugin.getConfig();
+    storagePluginConfig.setEnabled(true);
+    pluginRegistry.createOrUpdate(OpenTSDBStoragePluginConfig.NAME, storagePluginConfig,
true);
+  }
+
+  @Before
+  public void init() {
+    setupPostStubs();
+    setupGetStubs();
+  }
+
+  private void setupGetStubs() {
+    wireMockRule.stubFor(get(urlEqualTo("/api/suggest?type=metrics&max=" + Integer.MAX_VALUE))
+        .willReturn(aResponse()
+            .withStatus(200)
+            .withHeader("Content-Type", "application/json")
+            .withBody(SAMPLE_DATA_FOR_GET_TABLE_NAME_REQUEST)));
+
+    wireMockRule.stubFor(get(urlEqualTo("/api/query?start=47y-ago&m=sum:warp.speed.test"))
+        .willReturn(aResponse()
+            .withStatus(200)
+            .withBody(SAMPLE_DATA_FOR_GET_TABLE_REQUEST)
+        ));
+  }
+
+  private void setupPostStubs() {
+    wireMockRule.stubFor(post(urlEqualTo("/api/query"))
+        .withRequestBody(equalToJson(POST_REQUEST_WITHOUT_TAGS))
+        .willReturn(aResponse()
+            .withStatus(200)
+            .withHeader("Content-Type", "application/json")
+            .withBody(SAMPLE_DATA_FOR_GET_TABLE_REQUEST)));
+
+    wireMockRule.stubFor(post(urlEqualTo("/api/query"))
+        .withRequestBody(equalToJson(POST_REQUEST_WITH_TAGS))
+        .willReturn(aResponse()
+            .withStatus(200)
+            .withHeader("Content-Type", "application/json")
+            .withBody(SAMPLE_DATA_FOR_POST_REQUEST_WITH_TAGS)));
+
+    wireMockRule.stubFor(post(urlEqualTo("/api/query"))
+        .withRequestBody(equalToJson(DOWNSAMPLE_REQUEST_WTIHOUT_TAGS))
+        .willReturn(aResponse()
+            .withStatus(200)
+            .withHeader("Content-Type", "application/json")
+            .withBody(SAMPLE_DATA_FOR_POST_DOWNSAMPLE_REQUEST_WITHOUT_TAGS)));
+
+    wireMockRule.stubFor(post(urlEqualTo("/api/query"))
+            .withRequestBody(equalToJson(END_PARAM_REQUEST_WTIHOUT_TAGS))
+            .willReturn(aResponse()
+                    .withStatus(200)
+                    .withHeader("Content-Type", "application/json")
+                    .withBody(SAMPLE_DATA_FOR_POST_END_REQUEST_WITHOUT_TAGS)));
+
+    wireMockRule.stubFor(post(urlEqualTo("/api/query"))
+        .withRequestBody(equalToJson(DOWNSAMPLE_REQUEST_WITH_TAGS))
+        .willReturn(aResponse()
+            .withStatus(200)
+            .withHeader("Content-Type", "application/json")
+            .withBody(SAMPLE_DATA_FOR_POST_DOWNSAMPLE_REQUEST_WITH_TAGS)));
+
+    wireMockRule.stubFor(post(urlEqualTo("/api/query"))
+            .withRequestBody(equalToJson(END_PARAM_REQUEST_WITH_TAGS))
+            .willReturn(aResponse()
+                    .withStatus(200)
+                    .withHeader("Content-Type", "application/json")
+                    .withBody(SAMPLE_DATA_FOR_POST_END_REQUEST_WITH_TAGS)));
+
+    wireMockRule.stubFor(post(urlEqualTo("/api/query"))
+        .withRequestBody(equalToJson(REQUEST_TO_NONEXISTENT_METRIC))
+        .willReturn(aResponse()
+            .withStatus(400)
+            .withHeader("Content-Type", "application/json")
+        ));
+  }
+
+  @Test
+  public void testBasicQueryFromWithRequiredParams() throws Exception {
+    String query =
+            "select * from openTSDB.`(metric=warp.speed.test, start=47y-ago, aggregator=sum)`";
+    Assert.assertEquals(18, testSql(query));
+  }
+
+  @Test
+  public void testBasicQueryGroupBy() throws Exception {
+    String query =
+            "select `timestamp`, sum(`aggregated value`) from openTSDB.`(metric=warp.speed.test,
aggregator=sum, start=47y-ago)` group by `timestamp`";
+    Assert.assertEquals(15, testSql(query));
+  }
+
+  @Test
+  public void testBasicQueryFromWithInterpolationParam() throws Exception {
+    String query = "select * from openTSDB.`(metric=warp.speed.test, aggregator=sum, start=47y-ago,
downsample=5y-avg)`";
+    Assert.assertEquals(4, testSql(query));
+  }
+
+  @Test
+  public void testBasicQueryFromWithEndParam() throws Exception {
+    String query = "select * from openTSDB.`(metric=warp.speed.test, aggregator=sum, start=47y-ago,
end=1407165403000))`";
+    Assert.assertEquals(5, testSql(query));
+  }
+
+  @Test(expected = UserRemoteException.class)
+  public void testBasicQueryWithoutTableName() throws Exception {
+    test("select * from openTSDB.``;");
+  }
+
+  @Test(expected = UserRemoteException.class)
+  public void testBasicQueryWithNonExistentTableName() throws Exception {
+    test("select * from openTSDB.`warp.spee`");
+  }
+
+  @Test
+  public void testPhysicalPlanExecutionBasedOnQuery() throws Exception {
+    String query = "EXPLAIN PLAN for select * from openTSDB.`(metric=warp.speed.test, start=47y-ago,
aggregator=sum)`";
+    String plan = getPlanInString(query, JSON_FORMAT);
+    Assert.assertEquals(18, testPhysical(plan));
+  }
+
+  @Test
+  public void testDescribe() throws Exception {
+    test("use openTSDB");
+    test("describe `warp.speed.test`");
+    Assert.assertEquals(1, testSql("show tables"));
+  }
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/496c97d1/distribution/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/pom.xml b/distribution/pom.xml
index 86c3d11..9bb21d6 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -223,6 +223,11 @@
         </dependency>
         <dependency>
           <groupId>org.apache.drill.contrib</groupId>
+          <artifactId>drill-opentsdb-storage</artifactId>
+          <version>${project.version}</version>
+        </dependency>
+        <dependency>
+          <groupId>org.apache.drill.contrib</groupId>
           <artifactId>drill-mongo-storage</artifactId>
           <version>${project.version}</version>
         </dependency>


Mime
View raw message