From f80148d2f9c59b35af61a4ee3d3d8cf8496ef237 Mon Sep 17 00:00:00 2001 From: yyfMichaelYan Date: Thu, 11 Nov 2021 23:31:40 -0600 Subject: [PATCH 1/3] Fix flaky test testAssembleLongPollRefreshUrlWithMultipleNamespaces. --- .../RemoteConfigLongPollServiceTest.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java b/apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java index 20ebc3139bd..b9c1fcc347f 100644 --- a/apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java +++ b/apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java @@ -532,11 +532,19 @@ public void testAssembleLongPollRefreshUrlWithMultipleNamespaces() throws Except assertTrue(longPollRefreshUrl.contains(someServerUrl + "/notifications/v2?")); assertTrue(longPollRefreshUrl.contains("appId=" + someAppId)); assertTrue(longPollRefreshUrl.contains("cluster=someCluster%2B+%26.-_someSign")); + String someNamespaceEntry = "%22namespaceName%22%3A%22" + someNamespace + "%22"; + String someNotificationIdEntry = "%22notificationId%22%3A" + someNotificationId; + String anotherNamespaceEntry = "%22namespaceName%22%3A%22" + anotherNamespace + "%22"; + String anotherNotificationIdEntry = "%22notificationId%22%3A" + anotherNotificationId; assertTrue( - longPollRefreshUrl.contains("notifications=%5B%7B%22namespaceName%22%3A%22" + someNamespace - + "%22%2C%22notificationId%22%3A" + someNotificationId - + "%7D%2C%7B%22namespaceName%22%3A%22" + anotherNamespace - + "%22%2C%22notificationId%22%3A" + anotherNotificationId + "%7D%5D")); + longPollRefreshUrl.contains("notifications=%5B%7B" + someNamespaceEntry + "%2C" + someNotificationIdEntry + + "%7D%2C%7B" + anotherNamespaceEntry + "%2C" + anotherNotificationIdEntry + "%7D%5D") + || longPollRefreshUrl.contains("notifications=%5B%7B" + someNotificationIdEntry + "%2C" + someNamespaceEntry + + "%7D%2C%7B" + anotherNotificationIdEntry + "%2C" + anotherNamespaceEntry + "%7D%5D") + || longPollRefreshUrl.contains("notifications=%5B%7B" + someNotificationIdEntry + "%2C" + someNamespaceEntry + + "%7D%2C%7B" + anotherNamespaceEntry + "%2C" + anotherNotificationIdEntry + "%7D%5D") + || longPollRefreshUrl.contains("notifications=%5B%7B" + someNamespaceEntry + "%2C" + someNotificationIdEntry + + "%7D%2C%7B" + anotherNotificationIdEntry + "%2C" + anotherNamespaceEntry + "%7D%5D")); } public static class MockConfigUtil extends ConfigUtil { From 582643683376af0b59363aa143db99a876302af2 Mon Sep 17 00:00:00 2001 From: yyfMichaelYan Date: Fri, 12 Nov 2021 00:17:13 -0600 Subject: [PATCH 2/3] Fix flaky test testAssembleLongPollRefreshUrl. --- .../apollo/internals/RemoteConfigLongPollServiceTest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java b/apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java index b9c1fcc347f..f01ade7c001 100644 --- a/apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java +++ b/apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java @@ -510,7 +510,10 @@ public void testAssembleLongPollRefreshUrl() throws Exception { assertTrue(longPollRefreshUrl.contains("cluster=someCluster%2B+%26.-_someSign")); assertTrue(longPollRefreshUrl.contains( "notifications=%5B%7B%22namespaceName%22%3A%22" + someNamespace - + "%22%2C%22notificationId%22%3A" + 1 + "%7D%5D")); + + "%22%2C%22notificationId%22%3A" + 1 + "%7D%5D") + || longPollRefreshUrl.contains( + "notifications=%5B%7B%22notificationId%22%3A" + 1 + + "%2C%22namespaceName%22%3A%22" + someNamespace + "%22%7D%5D")); } @Test From b6d985ee3f5f5f326c01040afaa0f3c85d153a1a Mon Sep 17 00:00:00 2001 From: yyfMichaelYan Date: Thu, 25 Nov 2021 11:49:24 -0600 Subject: [PATCH 3/3] Update assertions in testAssembleLongPollRefreshUrl and testAssembleLongPollRefreshUrlWithMultipleNamespaces. --- .../RemoteConfigLongPollServiceTest.java | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java b/apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java index f01ade7c001..6dfab334a4b 100644 --- a/apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java +++ b/apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigLongPollServiceTest.java @@ -508,12 +508,10 @@ public void testAssembleLongPollRefreshUrl() throws Exception { assertTrue(longPollRefreshUrl.contains(someServerUrl + "/notifications/v2?")); assertTrue(longPollRefreshUrl.contains("appId=" + someAppId)); assertTrue(longPollRefreshUrl.contains("cluster=someCluster%2B+%26.-_someSign")); - assertTrue(longPollRefreshUrl.contains( - "notifications=%5B%7B%22namespaceName%22%3A%22" + someNamespace - + "%22%2C%22notificationId%22%3A" + 1 + "%7D%5D") - || longPollRefreshUrl.contains( - "notifications=%5B%7B%22notificationId%22%3A" + 1 - + "%2C%22namespaceName%22%3A%22" + someNamespace + "%22%7D%5D")); + assertTrue(longPollRefreshUrl.contains("notifications=%5B%7B") + && longPollRefreshUrl.contains("%22namespaceName%22%3A%22" + someNamespace + "%22") + && longPollRefreshUrl.contains("%22notificationId%22%3A" + someNotificationId) + && longPollRefreshUrl.contains("%7D%5D")); } @Test @@ -535,19 +533,12 @@ public void testAssembleLongPollRefreshUrlWithMultipleNamespaces() throws Except assertTrue(longPollRefreshUrl.contains(someServerUrl + "/notifications/v2?")); assertTrue(longPollRefreshUrl.contains("appId=" + someAppId)); assertTrue(longPollRefreshUrl.contains("cluster=someCluster%2B+%26.-_someSign")); - String someNamespaceEntry = "%22namespaceName%22%3A%22" + someNamespace + "%22"; - String someNotificationIdEntry = "%22notificationId%22%3A" + someNotificationId; - String anotherNamespaceEntry = "%22namespaceName%22%3A%22" + anotherNamespace + "%22"; - String anotherNotificationIdEntry = "%22notificationId%22%3A" + anotherNotificationId; - assertTrue( - longPollRefreshUrl.contains("notifications=%5B%7B" + someNamespaceEntry + "%2C" + someNotificationIdEntry - + "%7D%2C%7B" + anotherNamespaceEntry + "%2C" + anotherNotificationIdEntry + "%7D%5D") - || longPollRefreshUrl.contains("notifications=%5B%7B" + someNotificationIdEntry + "%2C" + someNamespaceEntry - + "%7D%2C%7B" + anotherNotificationIdEntry + "%2C" + anotherNamespaceEntry + "%7D%5D") - || longPollRefreshUrl.contains("notifications=%5B%7B" + someNotificationIdEntry + "%2C" + someNamespaceEntry - + "%7D%2C%7B" + anotherNamespaceEntry + "%2C" + anotherNotificationIdEntry + "%7D%5D") - || longPollRefreshUrl.contains("notifications=%5B%7B" + someNamespaceEntry + "%2C" + someNotificationIdEntry - + "%7D%2C%7B" + anotherNotificationIdEntry + "%2C" + anotherNamespaceEntry + "%7D%5D")); + assertTrue(longPollRefreshUrl.contains("notifications=%5B%7B") + && longPollRefreshUrl.contains("%22namespaceName%22%3A%22" + someNamespace + "%22") + && longPollRefreshUrl.contains("%22notificationId%22%3A" + someNotificationId) + && longPollRefreshUrl.contains("%22namespaceName%22%3A%22" + anotherNamespace + "%22") + && longPollRefreshUrl.contains("%22notificationId%22%3A" + anotherNotificationId) + && longPollRefreshUrl.contains("%7D%5D")); } public static class MockConfigUtil extends ConfigUtil {