From 69545cb51751d827cad7af9cf8a1cb1f2ce362d3 Mon Sep 17 00:00:00 2001 From: Bolek Ziobrowski <26925920+bziobrowski@users.noreply.github.com> Date: Thu, 9 Jan 2025 11:52:17 +0100 Subject: [PATCH] Fix formatting. --- .../utils/RoundRobinURIProviderTest.java | 237 +++++++++--------- 1 file changed, 119 insertions(+), 118 deletions(-) diff --git a/pinot-common/src/test/java/org/apache/pinot/common/utils/RoundRobinURIProviderTest.java b/pinot-common/src/test/java/org/apache/pinot/common/utils/RoundRobinURIProviderTest.java index 0ab67d6e8494..f5dba93bf2f9 100644 --- a/pinot-common/src/test/java/org/apache/pinot/common/utils/RoundRobinURIProviderTest.java +++ b/pinot-common/src/test/java/org/apache/pinot/common/utils/RoundRobinURIProviderTest.java @@ -49,134 +49,135 @@ public void testHostAddressRoundRobin() }; try (MockedStatic mock = Mockito.mockStatic(InetAddress.class)) { - mock.when(() -> InetAddress.getAllByName("localhost")).thenReturn(localHostAddresses); - mock.when(() -> InetAddress.getAllByName("testweb.com")).thenReturn(testWebAddresses); + mock.when(() -> InetAddress.getAllByName("localhost")).thenReturn(localHostAddresses); + mock.when(() -> InetAddress.getAllByName("testweb.com")).thenReturn(testWebAddresses); - TestCase[] testCases = new TestCase[]{ - new TestCase("http://127.0.0.1", Collections.singletonList("http://127.0.0.1")), - new TestCase("http://127.0.0.1/", Collections.singletonList("http://127.0.0.1/")), - new TestCase("http://127.0.0.1/?", Collections.singletonList("http://127.0.0.1/?")), - new TestCase("http://127.0.0.1/?it=5", Collections.singletonList("http://127.0.0.1/?it=5")), - new TestCase("http://127.0.0.1/me/out?it=5", Collections.singletonList("http://127.0.0.1/me/out?it=5")), - new TestCase("http://127.0.0.1:20000", Collections.singletonList("http://127.0.0.1:20000")), - new TestCase("http://127.0.0.1:20000/", Collections.singletonList("http://127.0.0.1:20000/")), - new TestCase("http://127.0.0.1:20000/?", Collections.singletonList("http://127.0.0.1:20000/?")), - new TestCase("http://127.0.0.1:20000/?it=5", Collections.singletonList("http://127.0.0.1:20000/?it=5")), - new TestCase("http://127.0.0.1:20000/me/out?it=5", - Collections.singletonList("http://127.0.0.1:20000/me/out?it=5")), + TestCase[] testCases = new TestCase[]{ + new TestCase("http://127.0.0.1", Collections.singletonList("http://127.0.0.1")), + new TestCase("http://127.0.0.1/", Collections.singletonList("http://127.0.0.1/")), + new TestCase("http://127.0.0.1/?", Collections.singletonList("http://127.0.0.1/?")), + new TestCase("http://127.0.0.1/?it=5", Collections.singletonList("http://127.0.0.1/?it=5")), + new TestCase("http://127.0.0.1/me/out?it=5", Collections.singletonList("http://127.0.0.1/me/out?it=5")), + new TestCase("http://127.0.0.1:20000", Collections.singletonList("http://127.0.0.1:20000")), + new TestCase("http://127.0.0.1:20000/", Collections.singletonList("http://127.0.0.1:20000/")), + new TestCase("http://127.0.0.1:20000/?", Collections.singletonList("http://127.0.0.1:20000/?")), + new TestCase("http://127.0.0.1:20000/?it=5", Collections.singletonList("http://127.0.0.1:20000/?it=5")), + new TestCase("http://127.0.0.1:20000/me/out?it=5", + Collections.singletonList("http://127.0.0.1:20000/me/out?it=5")), - new TestCase("http://localhost", Arrays.asList("http://127.0.0.1", "http://[0:0:0:0:0:0:0:1]")), - new TestCase("http://localhost/", Arrays.asList("http://127.0.0.1/", "http://[0:0:0:0:0:0:0:1]/")), - new TestCase("http://localhost/?", Arrays.asList("http://127.0.0.1/?", "http://[0:0:0:0:0:0:0:1]/?")), - new TestCase("http://localhost/?it=5", - Arrays.asList("http://127.0.0.1/?it=5", "http://[0:0:0:0:0:0:0:1]/?it=5")), - new TestCase("http://localhost/me/out?it=5", - Arrays.asList("http://127.0.0.1/me/out?it=5", "http://[0:0:0:0:0:0:0:1]/me/out?it=5")), - new TestCase("http://localhost:20000", - Arrays.asList("http://127.0.0.1:20000", "http://[0:0:0:0:0:0:0:1]:20000")), - new TestCase("http://localhost:20000/", - Arrays.asList("http://127.0.0.1:20000/", "http://[0:0:0:0:0:0:0:1]:20000/")), - new TestCase("http://localhost:20000/?", - Arrays.asList("http://127.0.0.1:20000/?", "http://[0:0:0:0:0:0:0:1]:20000/?")), - new TestCase("http://localhost:20000/?it=5", - Arrays.asList("http://127.0.0.1:20000/?it=5", "http://[0:0:0:0:0:0:0:1]:20000/?it=5")), - new TestCase("http://localhost:20000/me/out?it=5", - Arrays.asList("http://127.0.0.1:20000/me/out?it=5", "http://[0:0:0:0:0:0:0:1]:20000/me/out?it=5")), + new TestCase("http://localhost", Arrays.asList("http://127.0.0.1", "http://[0:0:0:0:0:0:0:1]")), + new TestCase("http://localhost/", Arrays.asList("http://127.0.0.1/", "http://[0:0:0:0:0:0:0:1]/")), + new TestCase("http://localhost/?", Arrays.asList("http://127.0.0.1/?", "http://[0:0:0:0:0:0:0:1]/?")), + new TestCase("http://localhost/?it=5", + Arrays.asList("http://127.0.0.1/?it=5", "http://[0:0:0:0:0:0:0:1]/?it=5")), + new TestCase("http://localhost/me/out?it=5", + Arrays.asList("http://127.0.0.1/me/out?it=5", "http://[0:0:0:0:0:0:0:1]/me/out?it=5")), + new TestCase("http://localhost:20000", + Arrays.asList("http://127.0.0.1:20000", "http://[0:0:0:0:0:0:0:1]:20000")), + new TestCase("http://localhost:20000/", + Arrays.asList("http://127.0.0.1:20000/", "http://[0:0:0:0:0:0:0:1]:20000/")), + new TestCase("http://localhost:20000/?", + Arrays.asList("http://127.0.0.1:20000/?", "http://[0:0:0:0:0:0:0:1]:20000/?")), + new TestCase("http://localhost:20000/?it=5", + Arrays.asList("http://127.0.0.1:20000/?it=5", "http://[0:0:0:0:0:0:0:1]:20000/?it=5")), + new TestCase("http://localhost:20000/me/out?it=5", + Arrays.asList("http://127.0.0.1:20000/me/out?it=5", "http://[0:0:0:0:0:0:0:1]:20000/me/out?it=5")), - new TestCase("http://testweb.com", - Arrays.asList("http://192.168.3.1", "http://192.168.3.2", "http://192.168.3.3")), - new TestCase("http://testweb.com/", - Arrays.asList("http://192.168.3.1/", "http://192.168.3.2/", "http://192.168.3.3/")), - new TestCase("http://testweb.com/?", - Arrays.asList("http://192.168.3.1/?", "http://192.168.3.2/?", "http://192.168.3.3/?")), - new TestCase("http://testweb.com/?it=5", - Arrays.asList("http://192.168.3.1/?it=5", "http://192.168.3.2/?it=5", "http://192.168.3.3/?it=5")), - new TestCase("http://testweb.com/me/out?it=5", - Arrays.asList("http://192.168.3.1/me/out?it=5", "http://192.168.3.2/me/out?it=5", - "http://192.168.3.3/me/out?it=5")), - new TestCase("http://testweb.com:20000", - Arrays.asList("http://192.168.3.1:20000", "http://192.168.3.2:20000", "http://192.168.3.3:20000")), - new TestCase("http://testweb.com:20000/", - Arrays.asList("http://192.168.3.1:20000/", "http://192.168.3.2:20000/", "http://192.168.3.3:20000/")), - new TestCase("http://testweb.com:20000/?", - Arrays.asList("http://192.168.3.1:20000/?", "http://192.168.3.2:20000/?", "http://192.168.3.3:20000/?")), - new TestCase("http://testweb.com:20000/?it=5", - Arrays.asList("http://192.168.3.1:20000/?it=5", "http://192.168.3.2:20000/?it=5", - "http://192.168.3.3:20000/?it=5")), - new TestCase("http://testweb.com:20000/me/out?it=5", - Arrays.asList("http://192.168.3.1:20000/me/out?it=5", "http://192.168.3.2:20000/me/out?it=5", - "http://192.168.3.3:20000/me/out?it=5")), + new TestCase("http://testweb.com", + Arrays.asList("http://192.168.3.1", "http://192.168.3.2", "http://192.168.3.3")), + new TestCase("http://testweb.com/", + Arrays.asList("http://192.168.3.1/", "http://192.168.3.2/", "http://192.168.3.3/")), + new TestCase("http://testweb.com/?", + Arrays.asList("http://192.168.3.1/?", "http://192.168.3.2/?", "http://192.168.3.3/?")), + new TestCase("http://testweb.com/?it=5", + Arrays.asList("http://192.168.3.1/?it=5", "http://192.168.3.2/?it=5", "http://192.168.3.3/?it=5")), + new TestCase("http://testweb.com/me/out?it=5", + Arrays.asList("http://192.168.3.1/me/out?it=5", "http://192.168.3.2/me/out?it=5", + "http://192.168.3.3/me/out?it=5")), + new TestCase("http://testweb.com:20000", + Arrays.asList("http://192.168.3.1:20000", "http://192.168.3.2:20000", "http://192.168.3.3:20000")), + new TestCase("http://testweb.com:20000/", + Arrays.asList("http://192.168.3.1:20000/", "http://192.168.3.2:20000/", "http://192.168.3.3:20000/")), + new TestCase("http://testweb.com:20000/?", + Arrays.asList("http://192.168.3.1:20000/?", "http://192.168.3.2:20000/?", "http://192.168.3.3:20000/?")), + new TestCase("http://testweb.com:20000/?it=5", + Arrays.asList("http://192.168.3.1:20000/?it=5", "http://192.168.3.2:20000/?it=5", + "http://192.168.3.3:20000/?it=5")), + new TestCase("http://testweb.com:20000/me/out?it=5", + Arrays.asList("http://192.168.3.1:20000/me/out?it=5", "http://192.168.3.2:20000/me/out?it=5", + "http://192.168.3.3:20000/me/out?it=5")), - new TestCase("https://127.0.0.1", Collections.singletonList("https://127.0.0.1")), - new TestCase("https://127.0.0.1/", Collections.singletonList("https://127.0.0.1/")), - new TestCase("https://127.0.0.1/?", Collections.singletonList("https://127.0.0.1/?")), - new TestCase("https://127.0.0.1/?it=5", Collections.singletonList("https://127.0.0.1/?it=5")), - new TestCase("https://127.0.0.1/me/out?it=5", Collections.singletonList("https://127.0.0.1/me/out?it=5")), - new TestCase("https://127.0.0.1:20000", Collections.singletonList("https://127.0.0.1:20000")), - new TestCase("https://127.0.0.1:20000/", Collections.singletonList("https://127.0.0.1:20000/")), - new TestCase("https://127.0.0.1:20000/?", Collections.singletonList("https://127.0.0.1:20000/?")), - new TestCase("https://127.0.0.1:20000/?it=5", Collections.singletonList("https://127.0.0.1:20000/?it=5")), - new TestCase("https://127.0.0.1:20000/me/out?it=5", - Collections.singletonList("https://127.0.0.1:20000/me/out?it=5")), + new TestCase("https://127.0.0.1", Collections.singletonList("https://127.0.0.1")), + new TestCase("https://127.0.0.1/", Collections.singletonList("https://127.0.0.1/")), + new TestCase("https://127.0.0.1/?", Collections.singletonList("https://127.0.0.1/?")), + new TestCase("https://127.0.0.1/?it=5", Collections.singletonList("https://127.0.0.1/?it=5")), + new TestCase("https://127.0.0.1/me/out?it=5", Collections.singletonList("https://127.0.0.1/me/out?it=5")), + new TestCase("https://127.0.0.1:20000", Collections.singletonList("https://127.0.0.1:20000")), + new TestCase("https://127.0.0.1:20000/", Collections.singletonList("https://127.0.0.1:20000/")), + new TestCase("https://127.0.0.1:20000/?", Collections.singletonList("https://127.0.0.1:20000/?")), + new TestCase("https://127.0.0.1:20000/?it=5", Collections.singletonList("https://127.0.0.1:20000/?it=5")), + new TestCase("https://127.0.0.1:20000/me/out?it=5", + Collections.singletonList("https://127.0.0.1:20000/me/out?it=5")), - new TestCase("https://localhost", Arrays.asList("https://127.0.0.1", "https://[0:0:0:0:0:0:0:1]")), - new TestCase("https://localhost/", Arrays.asList("https://127.0.0.1/", "https://[0:0:0:0:0:0:0:1]/")), - new TestCase("https://localhost/?", Arrays.asList("https://127.0.0.1/?", "https://[0:0:0:0:0:0:0:1]/?")), - new TestCase("https://localhost/?it=5", - Arrays.asList("https://127.0.0.1/?it=5", "https://[0:0:0:0:0:0:0:1]/?it=5")), - new TestCase("https://localhost/me/out?it=5", - Arrays.asList("https://127.0.0.1/me/out?it=5", "https://[0:0:0:0:0:0:0:1]/me/out?it=5")), - new TestCase("https://localhost:20000", - Arrays.asList("https://127.0.0.1:20000", "https://[0:0:0:0:0:0:0:1]:20000")), - new TestCase("https://localhost:20000/", - Arrays.asList("https://127.0.0.1:20000/", "https://[0:0:0:0:0:0:0:1]:20000/")), - new TestCase("https://localhost:20000/?", - Arrays.asList("https://127.0.0.1:20000/?", "https://[0:0:0:0:0:0:0:1]:20000/?")), - new TestCase("https://localhost:20000/?it=5", - Arrays.asList("https://127.0.0.1:20000/?it=5", "https://[0:0:0:0:0:0:0:1]:20000/?it=5")), + new TestCase("https://localhost", Arrays.asList("https://127.0.0.1", "https://[0:0:0:0:0:0:0:1]")), + new TestCase("https://localhost/", Arrays.asList("https://127.0.0.1/", "https://[0:0:0:0:0:0:0:1]/")), + new TestCase("https://localhost/?", Arrays.asList("https://127.0.0.1/?", "https://[0:0:0:0:0:0:0:1]/?")), + new TestCase("https://localhost/?it=5", + Arrays.asList("https://127.0.0.1/?it=5", "https://[0:0:0:0:0:0:0:1]/?it=5")), + new TestCase("https://localhost/me/out?it=5", + Arrays.asList("https://127.0.0.1/me/out?it=5", "https://[0:0:0:0:0:0:0:1]/me/out?it=5")), + new TestCase("https://localhost:20000", + Arrays.asList("https://127.0.0.1:20000", "https://[0:0:0:0:0:0:0:1]:20000")), + new TestCase("https://localhost:20000/", + Arrays.asList("https://127.0.0.1:20000/", "https://[0:0:0:0:0:0:0:1]:20000/")), + new TestCase("https://localhost:20000/?", + Arrays.asList("https://127.0.0.1:20000/?", "https://[0:0:0:0:0:0:0:1]:20000/?")), + new TestCase("https://localhost:20000/?it=5", + Arrays.asList("https://127.0.0.1:20000/?it=5", "https://[0:0:0:0:0:0:0:1]:20000/?it=5")), - new TestCase("https://testweb.com", - Arrays.asList("https://192.168.3.1", "https://192.168.3.2", "https://192.168.3.3")), - new TestCase("https://testweb.com/", - Arrays.asList("https://192.168.3.1/", "https://192.168.3.2/", "https://192.168.3.3/")), - new TestCase("https://testweb.com/?", - Arrays.asList("https://192.168.3.1/?", "https://192.168.3.2/?", "https://192.168.3.3/?")), - new TestCase("https://testweb.com/?it=5", - Arrays.asList("https://192.168.3.1/?it=5", "https://192.168.3.2/?it=5", "https://192.168.3.3/?it=5")), - new TestCase("https://testweb.com/me/out?it=5", - Arrays.asList("https://192.168.3.1/me/out?it=5", "https://192.168.3.2/me/out?it=5", - "https://192.168.3.3/me/out?it=5")), - new TestCase("https://testweb.com:20000", - Arrays.asList("https://192.168.3.1:20000", "https://192.168.3.2:20000", "https://192.168.3.3:20000")), - new TestCase("https://testweb.com:20000/", - Arrays.asList("https://192.168.3.1:20000/", "https://192.168.3.2:20000/", "https://192.168.3.3:20000/")), - new TestCase("https://testweb.com:20000/?", - Arrays.asList("https://192.168.3.1:20000/?", "https://192.168.3.2:20000/?", "https://192.168.3.3:20000/?")), - new TestCase("https://testweb.com:20000/?it=5", - Arrays.asList("https://192.168.3.1:20000/?it=5", "https://192.168.3.2:20000/?it=5", - "https://192.168.3.3:20000/?it=5")), - new TestCase("https://testweb.com:20000/me/out?it=5", - Arrays.asList("https://192.168.3.1:20000/me/out?it=5", "https://192.168.3.2:20000/me/out?it=5", - "https://192.168.3.3:20000/me/out?it=5")), - }; + new TestCase("https://testweb.com", + Arrays.asList("https://192.168.3.1", "https://192.168.3.2", "https://192.168.3.3")), + new TestCase("https://testweb.com/", + Arrays.asList("https://192.168.3.1/", "https://192.168.3.2/", "https://192.168.3.3/")), + new TestCase("https://testweb.com/?", + Arrays.asList("https://192.168.3.1/?", "https://192.168.3.2/?", "https://192.168.3.3/?")), + new TestCase("https://testweb.com/?it=5", + Arrays.asList("https://192.168.3.1/?it=5", "https://192.168.3.2/?it=5", "https://192.168.3.3/?it=5")), + new TestCase("https://testweb.com/me/out?it=5", + Arrays.asList("https://192.168.3.1/me/out?it=5", "https://192.168.3.2/me/out?it=5", + "https://192.168.3.3/me/out?it=5")), + new TestCase("https://testweb.com:20000", + Arrays.asList("https://192.168.3.1:20000", "https://192.168.3.2:20000", "https://192.168.3.3:20000")), + new TestCase("https://testweb.com:20000/", + Arrays.asList("https://192.168.3.1:20000/", "https://192.168.3.2:20000/", "https://192.168.3.3:20000/")), + new TestCase("https://testweb.com:20000/?", + Arrays.asList("https://192.168.3.1:20000/?", "https://192.168.3.2:20000/?", + "https://192.168.3.3:20000/?")), + new TestCase("https://testweb.com:20000/?it=5", + Arrays.asList("https://192.168.3.1:20000/?it=5", "https://192.168.3.2:20000/?it=5", + "https://192.168.3.3:20000/?it=5")), + new TestCase("https://testweb.com:20000/me/out?it=5", + Arrays.asList("https://192.168.3.1:20000/me/out?it=5", "https://192.168.3.2:20000/me/out?it=5", + "https://192.168.3.3:20000/me/out?it=5")), + }; - for (TestCase testCase : testCases) { - String uri = testCase._originalUri; - RoundRobinURIProvider uriProvider = new RoundRobinURIProvider(List.of(new URI(uri)), true); - int n = testCase._expectedUris.size(); - int previousIndex = -1; - int currentIndex; - for (int i = 0; i < 2 * n; i++) { - String actualUri = uriProvider.next().toString(); - currentIndex = testCase._expectedUris.indexOf(actualUri); - Assert.assertTrue(currentIndex != -1); - if (previousIndex != -1) { - Assert.assertEquals((previousIndex + 1) % n, currentIndex); + for (TestCase testCase : testCases) { + String uri = testCase._originalUri; + RoundRobinURIProvider uriProvider = new RoundRobinURIProvider(List.of(new URI(uri)), true); + int n = testCase._expectedUris.size(); + int previousIndex = -1; + int currentIndex; + for (int i = 0; i < 2 * n; i++) { + String actualUri = uriProvider.next().toString(); + currentIndex = testCase._expectedUris.indexOf(actualUri); + Assert.assertTrue(currentIndex != -1); + if (previousIndex != -1) { + Assert.assertEquals((previousIndex + 1) % n, currentIndex); + } + previousIndex = currentIndex; } - previousIndex = currentIndex; } } - } } static class TestCase {