Skip to content

Commit

Permalink
address more and more and more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
harishnelakurthi committed Sep 24, 2024
1 parent 02dea1b commit 86d573f
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,29 +166,29 @@ public void testTrinoClusterHostCookie()
RequestBody requestBody = RequestBody.create("SELECT 1", MediaType.get("application/json; charset=utf-8"));

// When X-Trino-Routing-Group is set in header, query should be routed to cluster under the routing group
Request requestOne =
Request requestWithoutCookie =
new Request.Builder()
.url("http://localhost:" + routerPort + "/v1/statement")
.addHeader("X-Trino-User", "test")
.post(requestBody)
.addHeader("X-Trino-Routing-Group", "scheduled")
.build();
Response responseOne = httpClient.newCall(requestOne).execute();
Response responseOne = httpClient.newCall(requestWithoutCookie).execute();
assertThat(responseOne.body().string()).contains("http://localhost:" + routerPort);
List<Cookie> cookies = Cookie.parseAll(responseOne.request().url(), responseOne.headers());
Cookie cookie = cookies.stream().filter(c -> c.name().equals("trinoClusterHost")).collect(onlyElement());
assertThat(cookie.value()).isEqualTo("localhost");
// test with sending the request which includes trinoClusterHost in the cookie
// when X-Trino-Routing-Group is set in header, query should be routed to cluster under the routing group
Request requestTwo =
Request requestWithCookie =
new Request.Builder()
.url("http://localhost:" + routerPort + "/v1/statement")
.addHeader("X-Trino-User", "test")
.post(requestBody)
.addHeader("X-Trino-Routing-Group", "scheduled")
.addHeader("Cookie", "trinoClientHost=foo.example.com")
.build();
Response responseTwo = httpClient.newCall(requestTwo).execute();
Response responseTwo = httpClient.newCall(requestWithCookie).execute();
assertThat(responseTwo.body().string()).contains("http://localhost:" + routerPort);
cookies = Cookie.parseAll(responseTwo.request().url(), responseTwo.headers());
cookie = cookies.stream().filter(c -> c.name().equals("trinoClusterHost")).collect(onlyElement());
Expand Down

0 comments on commit 86d573f

Please sign in to comment.