Skip to content

Commit 890ceb9

Browse files
Jaeho Yooebyhr
authored andcommitted
Fix timing race condition in QueryDetail equals test
1 parent e521a3f commit 890ceb9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

gateway-ha/src/test/java/io/trino/gateway/ha/router/BaseExternalUrlQueryHistoryTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ void testMultipleQueriesWithDifferentExternalUrls()
171171
@Test
172172
void testQueryDetailEqualsAndHashCodeWithExternalUrl()
173173
{
174+
long captureTime = System.currentTimeMillis();
175+
174176
QueryHistoryManager.QueryDetail queryDetail1 = new QueryHistoryManager.QueryDetail();
175177
queryDetail1.setQueryId("equals-test-1");
176178
queryDetail1.setQueryText("SELECT 1");
@@ -179,7 +181,7 @@ void testQueryDetailEqualsAndHashCodeWithExternalUrl()
179181
queryDetail1.setSource("sqlWorkbench");
180182
queryDetail1.setRoutingGroup("adhoc");
181183
queryDetail1.setExternalUrl("https://external.example.com");
182-
queryDetail1.setCaptureTime(System.currentTimeMillis());
184+
queryDetail1.setCaptureTime(captureTime);
183185

184186
QueryHistoryManager.QueryDetail queryDetail2 = new QueryHistoryManager.QueryDetail();
185187
queryDetail2.setQueryId("equals-test-1");
@@ -189,7 +191,7 @@ void testQueryDetailEqualsAndHashCodeWithExternalUrl()
189191
queryDetail2.setSource("sqlWorkbench");
190192
queryDetail2.setRoutingGroup("adhoc");
191193
queryDetail2.setExternalUrl("https://external.example.com");
192-
queryDetail2.setCaptureTime(System.currentTimeMillis());
194+
queryDetail2.setCaptureTime(captureTime);
193195

194196
// Test equals
195197
assertThat(queryDetail1).isEqualTo(queryDetail2);

0 commit comments

Comments
 (0)