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
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public final class PrometheusQueryRunner
{
private PrometheusQueryRunner() {}

public static DistributedQueryRunner createPrometheusQueryRunner(PrometheusServer server)
public static DistributedQueryRunner createPrometheusQueryRunner(PrometheusServer server, Map<String, String> extraProperties)
throws Exception
{
DistributedQueryRunner queryRunner = null;
try {
queryRunner = DistributedQueryRunner.builder(createSession()).build();
queryRunner = DistributedQueryRunner.builder(createSession()).setExtraProperties(extraProperties).build();

queryRunner.installPlugin(new PrometheusPlugin());
Map<String, String> properties = ImmutableMap.of(
Expand Down Expand Up @@ -75,7 +75,7 @@ public static void main(String[] args)
throws Exception
{
Logging.initialize();
DistributedQueryRunner queryRunner = createPrometheusQueryRunner(new PrometheusServer());
DistributedQueryRunner queryRunner = createPrometheusQueryRunner(new PrometheusServer(), ImmutableMap.of("http-server.http.port", "8080"));
Thread.sleep(10);
Logger log = Logger.get(PrometheusQueryRunner.class);
log.info("======== SERVER STARTED ========");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package io.trino.plugin.prometheus;

import com.google.common.collect.ImmutableMap;
import io.airlift.log.Logger;
import io.trino.testing.AbstractTestQueryFramework;
import io.trino.testing.MaterializedResult;
Expand All @@ -26,6 +27,7 @@
import java.util.concurrent.TimeUnit;

import static io.trino.plugin.prometheus.PrometheusQueryRunner.createPrometheusQueryRunner;
import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;

Expand All @@ -43,7 +45,7 @@ protected QueryRunner createQueryRunner()
throws Exception
{
this.server = new PrometheusServer();
return createPrometheusQueryRunner(server);
return createPrometheusQueryRunner(server, ImmutableMap.of());
}

@Test
Expand Down Expand Up @@ -100,8 +102,8 @@ public void testConfirmMetricAvailableAndCheckUp()
@Test
public void testPushDown()
{
// default interval on the `up` metric that Prometheus records on itself is 15 seconds, so this should only yield one row
// default interval on the `up` metric that Prometheus records on itself is about 15 seconds, so this should only yield one or two row
MaterializedResult results = computeActual("SELECT * FROM prometheus.default.up WHERE timestamp > (NOW() - INTERVAL '15' SECOND)");
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.

Can we instead create a timestamp literal in Java side and then send that as the predicate.
In the MaterializedResult then we can assert that all rows have a timestamp > the predicate (instead of counting number of rows which is inherently flaky).

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.

Also if we want to test pushdown happenned we should assert on the plan. Since even without pushdown the engine will filter results and we'll get filtered rows.

It's pre-existing issue though.

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.

Let me punt to #10784

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.

Do we have some stress test results somewhere? LGTM.

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.

Tested locally because the failure ratio was very low (1 / 500 attempts) in my laptop. Verified 2000 passes with this fix.

assertEquals(results.getRowCount(), 1);
assertThat(results).hasSizeBetween(1, 2);
}
}