From fd18ca316a6dd88863480c1707d04b19d40ba4a6 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Sat, 14 Mar 2020 09:32:15 -0700 Subject: [PATCH 1/2] Run MongoQueryRunner on port 8080 --- .../prestosql/plugin/mongodb/MongoQueryRunner.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/presto-mongodb/src/test/java/io/prestosql/plugin/mongodb/MongoQueryRunner.java b/presto-mongodb/src/test/java/io/prestosql/plugin/mongodb/MongoQueryRunner.java index 6aebbb8af649..d3ce008d7ef4 100644 --- a/presto-mongodb/src/test/java/io/prestosql/plugin/mongodb/MongoQueryRunner.java +++ b/presto-mongodb/src/test/java/io/prestosql/plugin/mongodb/MongoQueryRunner.java @@ -44,10 +44,18 @@ public static DistributedQueryRunner createMongoQueryRunner(MongoServer server, public static DistributedQueryRunner createMongoQueryRunner(MongoServer server, Iterable> tables) throws Exception + { + return createMongoQueryRunner(server, tables, ImmutableMap.of()); + } + + public static DistributedQueryRunner createMongoQueryRunner(MongoServer server, Iterable> tables, Map extraProperties) + throws Exception { DistributedQueryRunner queryRunner = null; try { - queryRunner = DistributedQueryRunner.builder(createSession()).build(); + queryRunner = DistributedQueryRunner.builder(createSession()) + .setExtraProperties(extraProperties) + .build(); queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch"); @@ -85,7 +93,8 @@ public static void main(String[] args) throws Exception { Logging.initialize(); - DistributedQueryRunner queryRunner = createMongoQueryRunner(new MongoServer(), TpchTable.getTables()); + Map properties = ImmutableMap.of("http-server.http.port", "8080"); + DistributedQueryRunner queryRunner = createMongoQueryRunner(new MongoServer(), TpchTable.getTables(), properties); Thread.sleep(10); Logger log = Logger.get(MongoQueryRunner.class); log.info("======== SERVER STARTED ========"); From d122e5513649af273a9fed523332f513dfe14f31 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Sat, 14 Mar 2020 09:38:40 -0700 Subject: [PATCH 2/2] Cleanup code in MongoQueryRunner --- .../plugin/mongodb/MongoQueryRunner.java | 20 ++++--------------- .../mongodb/TestMongoDistributedQueries.java | 3 ++- .../TestMongoIntegrationSmokeTest.java | 2 +- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/presto-mongodb/src/test/java/io/prestosql/plugin/mongodb/MongoQueryRunner.java b/presto-mongodb/src/test/java/io/prestosql/plugin/mongodb/MongoQueryRunner.java index d3ce008d7ef4..cb587290f5b9 100644 --- a/presto-mongodb/src/test/java/io/prestosql/plugin/mongodb/MongoQueryRunner.java +++ b/presto-mongodb/src/test/java/io/prestosql/plugin/mongodb/MongoQueryRunner.java @@ -13,7 +13,6 @@ */ package io.prestosql.plugin.mongodb; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.mongodb.MongoClient; import io.airlift.log.Logger; @@ -36,18 +35,6 @@ public final class MongoQueryRunner private MongoQueryRunner() {} - public static DistributedQueryRunner createMongoQueryRunner(MongoServer server, TpchTable... tables) - throws Exception - { - return createMongoQueryRunner(server, ImmutableList.copyOf(tables)); - } - - public static DistributedQueryRunner createMongoQueryRunner(MongoServer server, Iterable> tables) - throws Exception - { - return createMongoQueryRunner(server, tables, ImmutableMap.of()); - } - public static DistributedQueryRunner createMongoQueryRunner(MongoServer server, Iterable> tables, Map extraProperties) throws Exception { @@ -60,9 +47,10 @@ public static DistributedQueryRunner createMongoQueryRunner(MongoServer server, queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch"); - Map properties = ImmutableMap.of( - "mongodb.seeds", server.getAddress().toString(), - "mongodb.socket-keep-alive", "true"); + Map properties = ImmutableMap.builder() + .put("mongodb.seeds", server.getAddress().toString()) + .put("mongodb.socket-keep-alive", "true") + .build(); queryRunner.installPlugin(new MongoPlugin()); queryRunner.createCatalog("mongodb", "mongodb", properties); diff --git a/presto-mongodb/src/test/java/io/prestosql/plugin/mongodb/TestMongoDistributedQueries.java b/presto-mongodb/src/test/java/io/prestosql/plugin/mongodb/TestMongoDistributedQueries.java index 67933167f8d0..46c4217cd535 100644 --- a/presto-mongodb/src/test/java/io/prestosql/plugin/mongodb/TestMongoDistributedQueries.java +++ b/presto-mongodb/src/test/java/io/prestosql/plugin/mongodb/TestMongoDistributedQueries.java @@ -13,6 +13,7 @@ */ package io.prestosql.plugin.mongodb; +import com.google.common.collect.ImmutableMap; import io.prestosql.testing.AbstractTestQueries; import io.prestosql.testing.QueryRunner; import io.prestosql.tpch.TpchTable; @@ -32,7 +33,7 @@ protected QueryRunner createQueryRunner() throws Exception { this.server = new MongoServer(); - return createMongoQueryRunner(server, TpchTable.getTables()); + return createMongoQueryRunner(server, TpchTable.getTables(), ImmutableMap.of()); } @AfterClass(alwaysRun = true) diff --git a/presto-mongodb/src/test/java/io/prestosql/plugin/mongodb/TestMongoIntegrationSmokeTest.java b/presto-mongodb/src/test/java/io/prestosql/plugin/mongodb/TestMongoIntegrationSmokeTest.java index 4e7d86b3cfe9..286d9bea5dd5 100644 --- a/presto-mongodb/src/test/java/io/prestosql/plugin/mongodb/TestMongoIntegrationSmokeTest.java +++ b/presto-mongodb/src/test/java/io/prestosql/plugin/mongodb/TestMongoIntegrationSmokeTest.java @@ -50,7 +50,7 @@ protected QueryRunner createQueryRunner() { this.server = new MongoServer(); this.client = createMongoClient(server); - return createMongoQueryRunner(server, ORDERS); + return createMongoQueryRunner(server, ImmutableList.of(ORDERS), ImmutableMap.of()); } @AfterClass(alwaysRun = true)