Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ jobs:
- { modules: plugin/trino-hive }
- { modules: plugin/trino-hive, profile: test-parquet }
- { modules: plugin/trino-elasticsearch }
- { modules: plugin/trino-elasticsearch, profile: test-stats }
- { modules: plugin/trino-mongodb }
- { modules: plugin/trino-kafka }
- { modules: plugin/trino-pinot }
Expand Down
44 changes: 0 additions & 44 deletions plugin/trino-elasticsearch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -400,48 +400,4 @@
</plugins>
</pluginManagement>
</build>

<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<!-- You can only bind one statistics bean per JVM, otherwise you'll see problems with statistics being 0 despite backpressure handling -->
<!-- This test should be run in isolation, to avoid the possibility of some other test also registering statistic beans -->
<exclude>**/TestElasticsearchBackpressure*</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>test-stats</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/TestElasticsearchBackpressure*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.net.HostAndPort;
import io.airlift.log.Logger;
import io.trino.Session;
import io.trino.metadata.QualifiedObjectName;
import io.trino.plugin.jmx.JmxPlugin;
import io.trino.plugin.tpch.TpchPlugin;
Expand Down Expand Up @@ -53,11 +52,26 @@ public static DistributedQueryRunner createElasticsearchQueryRunner(
Map<String, String> extraConnectorProperties,
int nodeCount)
throws Exception
{
return createElasticsearchQueryRunner(address, tables, extraProperties, extraConnectorProperties, nodeCount, "elasticsearch");
}

public static DistributedQueryRunner createElasticsearchQueryRunner(
HostAndPort address,
Iterable<TpchTable<?>> tables,
Map<String, String> extraProperties,
Map<String, String> extraConnectorProperties,
int nodeCount,
String catalogName)
throws Exception
{
RestHighLevelClient client = null;
DistributedQueryRunner queryRunner = null;
try {
queryRunner = DistributedQueryRunner.builder(createSession())
queryRunner = DistributedQueryRunner.builder(testSessionBuilder()
.setCatalog(catalogName)
.setSchema(TPCH_SCHEMA)
.build())
.setExtraProperties(extraProperties)
.setNodeCount(nodeCount)
.build();
Expand All @@ -70,7 +84,7 @@ public static DistributedQueryRunner createElasticsearchQueryRunner(

ElasticsearchConnectorFactory testFactory = new ElasticsearchConnectorFactory();

installElasticsearchPlugin(address, queryRunner, testFactory, extraConnectorProperties);
installElasticsearchPlugin(address, queryRunner, catalogName, testFactory, extraConnectorProperties);

TestingTrinoClient trinoClient = queryRunner.getClient();

Expand All @@ -91,7 +105,12 @@ public static DistributedQueryRunner createElasticsearchQueryRunner(
}
}

private static void installElasticsearchPlugin(HostAndPort address, QueryRunner queryRunner, ElasticsearchConnectorFactory factory, Map<String, String> extraConnectorProperties)
private static void installElasticsearchPlugin(
Comment thread
Laonel marked this conversation as resolved.
Outdated
HostAndPort address,
QueryRunner queryRunner,
String catalogName,
ElasticsearchConnectorFactory factory,
Map<String, String> extraConnectorProperties)
{
queryRunner.installPlugin(new ElasticsearchPlugin(factory));
Map<String, String> config = ImmutableMap.<String, String>builder()
Expand All @@ -107,7 +126,7 @@ private static void installElasticsearchPlugin(HostAndPort address, QueryRunner
.putAll(extraConnectorProperties)
.buildOrThrow();

queryRunner.createCatalog("elasticsearch", "elasticsearch", config);
queryRunner.createCatalog(catalogName, "elasticsearch", config);
}

private static void loadTpchTopic(RestHighLevelClient client, TestingTrinoClient trinoClient, TpchTable<?> table)
Expand All @@ -119,11 +138,6 @@ private static void loadTpchTopic(RestHighLevelClient client, TestingTrinoClient
LOG.info("Imported %s in %s", table.getTableName(), nanosSince(start).convertToMostSuccinctTimeUnit());
}

public static Session createSession()
{
return testSessionBuilder().setCatalog("elasticsearch").setSchema(TPCH_SCHEMA).build();
}

public static void main(String[] args)
throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ protected QueryRunner createQueryRunner()
ImmutableMap.of(),
// This test can only run on a single node, otherwise each node exports its own stats beans and they override each other
// You can only bind one such bean per JVM, so this causes problems with statistics being 0 despite backpressure handling
1);
1,
// Use a unique catalog name to make sure JMX stats beans are unique and not affected by other tests
"elasticsearch-backpressure");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use something like io.trino.testing.sql.TestTable#randomTableSuffix? Or is it overkill?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might, I decided to go with a static name since this is executed just once for just one test.

A different approach could be to make the catalog name randomized on the ElasticsearchQueryRunner level, but since it was just the backpressure test causing the issue I decided to limit the changes to that test.

}

@AfterClass(alwaysRun = true)
Expand Down