Skip to content

Commit

Permalink
Fix flaky test TestQueryStateInfoResource
Browse files Browse the repository at this point in the history
  • Loading branch information
highker committed Apr 18, 2018
1 parent 35a17a0 commit 5192ed9
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import com.facebook.presto.client.QueryResults;
import com.facebook.presto.server.testing.TestingPrestoServer;
import com.facebook.presto.tpch.TpchPlugin;
import io.airlift.http.client.HttpClient;
import io.airlift.http.client.Request;
import io.airlift.http.client.UnexpectedResponseException;
Expand Down Expand Up @@ -43,6 +44,8 @@
@Test(singleThreaded = true)
public class TestQueryStateInfoResource
{
private static final String LONG_LASTING_QUERY = "SELECT * FROM tpch.sf1.lineitem";

private TestingPrestoServer server;
private HttpClient client;
private QueryResults queryResults;
Expand All @@ -51,6 +54,8 @@ public class TestQueryStateInfoResource
throws Exception
{
server = new TestingPrestoServer();
server.installPlugin(new TpchPlugin());
server.createCatalog("tpch", "tpch");
client = new JettyHttpClient();
}

Expand All @@ -59,14 +64,14 @@ public void setup()
{
Request request1 = preparePost()
.setUri(uriBuilderFrom(server.getBaseUrl()).replacePath("/v1/statement").build())
.setBodyGenerator(createStaticBodyGenerator("show catalogs", UTF_8))
.setBodyGenerator(createStaticBodyGenerator(LONG_LASTING_QUERY, UTF_8))
.setHeader(PRESTO_USER, "user1")
.build();
queryResults = client.execute(request1, createJsonResponseHandler(jsonCodec(QueryResults.class)));

Request request2 = preparePost()
.setUri(uriBuilderFrom(server.getBaseUrl()).replacePath("/v1/statement").build())
.setBodyGenerator(createStaticBodyGenerator("show catalogs", UTF_8))
.setBodyGenerator(createStaticBodyGenerator(LONG_LASTING_QUERY, UTF_8))
.setHeader(PRESTO_USER, "user2")
.build();
client.execute(request2, createJsonResponseHandler(jsonCodec(QueryResults.class)));
Expand Down

0 comments on commit 5192ed9

Please sign in to comment.