Commit 38b1a312 by Jason Song Committed by GitHub

Merge pull request #281 from nobodyiam/notification-ut-fix

fix notification ut
parents 5359d441 47aa81fd
...@@ -50,7 +50,7 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati ...@@ -50,7 +50,7 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati
@Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) @Sql(scripts = "/integration-test/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD)
public void testPollNotificationWithDefaultNamespace() throws Exception { public void testPollNotificationWithDefaultNamespace() throws Exception {
AtomicBoolean stop = new AtomicBoolean(); AtomicBoolean stop = new AtomicBoolean();
perodicSendMessage(assembleKey(someAppId, someCluster, defaultNamespace), stop); periodicSendMessage(assembleKey(someAppId, someCluster, defaultNamespace), stop);
ResponseEntity<ApolloConfigNotification> result = restTemplate.getForEntity( ResponseEntity<ApolloConfigNotification> result = restTemplate.getForEntity(
"{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}", "{baseurl}/notifications?appId={appId}&cluster={clusterName}&namespace={namespace}",
...@@ -104,7 +104,7 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati ...@@ -104,7 +104,7 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati
String publicAppId = "somePublicAppId"; String publicAppId = "somePublicAppId";
AtomicBoolean stop = new AtomicBoolean(); AtomicBoolean stop = new AtomicBoolean();
perodicSendMessage(assembleKey(publicAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, somePublicNamespace), stop); periodicSendMessage(assembleKey(publicAppId, ConfigConsts.CLUSTER_NAME_DEFAULT, somePublicNamespace), stop);
ResponseEntity<ApolloConfigNotification> result = restTemplate ResponseEntity<ApolloConfigNotification> result = restTemplate
.getForEntity( .getForEntity(
...@@ -128,7 +128,7 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati ...@@ -128,7 +128,7 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati
String someDC = "someDC"; String someDC = "someDC";
AtomicBoolean stop = new AtomicBoolean(); AtomicBoolean stop = new AtomicBoolean();
perodicSendMessage(assembleKey(publicAppId, someDC, somePublicNamespace), stop); periodicSendMessage(assembleKey(publicAppId, someDC, somePublicNamespace), stop);
ResponseEntity<ApolloConfigNotification> result = restTemplate ResponseEntity<ApolloConfigNotification> result = restTemplate
.getForEntity( .getForEntity(
...@@ -165,7 +165,7 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati ...@@ -165,7 +165,7 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati
return Joiner.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR).join(appId, cluster, namespace); return Joiner.on(ConfigConsts.CLUSTER_NAMESPACE_SEPARATOR).join(appId, cluster, namespace);
} }
private void perodicSendMessage(String message, AtomicBoolean stop) { private void periodicSendMessage(String message, AtomicBoolean stop) {
executorService.submit((Runnable) () -> { executorService.submit((Runnable) () -> {
//wait for the request connected to server //wait for the request connected to server
while (!stop.get() && !Thread.currentThread().isInterrupted()) { while (!stop.get() && !Thread.currentThread().isInterrupted()) {
...@@ -174,6 +174,11 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati ...@@ -174,6 +174,11 @@ public class NotificationControllerIntegrationTest extends AbstractBaseIntegrati
} catch (InterruptedException e) { } catch (InterruptedException e) {
} }
//double check
if (stop.get()) {
break;
}
ReleaseMessage releaseMessage = new ReleaseMessage(message); ReleaseMessage releaseMessage = new ReleaseMessage(message);
releaseMessageRepository.save(releaseMessage); releaseMessageRepository.save(releaseMessage);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment