summaryrefslogtreecommitdiffstats
path: root/cps-service/src
diff options
context:
space:
mode:
authorBruno Sakoto <bruno.sakoto@bell.ca>2021-08-25 14:00:35 +0000
committerGerrit Code Review <gerrit@onap.org>2021-08-25 14:00:35 +0000
commit7b433410a35049130b5ec27239c3b00783fe1ff8 (patch)
tree3de14e08d536cc12995302449caa6c5aea7f7f8d /cps-service/src
parent90fc8dc16f07d6e039edf1c0a4d6883388cf9004 (diff)
parent8b935c7f04b76ba8203ff6ccab4790a2c2612ff1 (diff)
Merge "Add timeout to async test-cases"
Diffstat (limited to 'cps-service/src')
-rw-r--r--cps-service/src/main/java/org/onap/cps/config/AsyncConfig.java2
-rw-r--r--cps-service/src/main/java/org/onap/cps/notification/NotificationService.java1
-rw-r--r--cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy18
3 files changed, 14 insertions, 7 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/config/AsyncConfig.java b/cps-service/src/main/java/org/onap/cps/config/AsyncConfig.java
index 3ae675e214..4c961598e4 100644
--- a/cps-service/src/main/java/org/onap/cps/config/AsyncConfig.java
+++ b/cps-service/src/main/java/org/onap/cps/config/AsyncConfig.java
@@ -42,7 +42,7 @@ public class AsyncConfig {
@Min(2)
private int maxPoolSize = 10;
@Min(0)
- private int queueCapacity = 2147483647;
+ private int queueCapacity = Integer.MAX_VALUE;
private boolean waitForTasksToCompleteOnShutdown = true;
private String threadNamePrefix = "Async-";
diff --git a/cps-service/src/main/java/org/onap/cps/notification/NotificationService.java b/cps-service/src/main/java/org/onap/cps/notification/NotificationService.java
index 9ed8b65ad7..4745739a4f 100644
--- a/cps-service/src/main/java/org/onap/cps/notification/NotificationService.java
+++ b/cps-service/src/main/java/org/onap/cps/notification/NotificationService.java
@@ -79,6 +79,7 @@ public class NotificationService {
*
* @param dataspaceName dataspace name
* @param anchorName anchor name
+ * @return future
*/
@Async("notificationExecutor")
public Future<Void> processDataUpdatedEvent(final String dataspaceName, final String anchorName) {
diff --git a/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy b/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy
index 0a2d3d9988..ab727671e1 100644
--- a/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy
+++ b/cps-service/src/test/groovy/org/onap/cps/notification/NotificationServiceSpec.groovy
@@ -32,6 +32,8 @@ import org.springframework.test.context.ContextConfiguration
import spock.lang.Shared
import spock.lang.Specification
+import java.util.concurrent.TimeUnit
+
@SpringBootTest
@EnableAsync
@EnableConfigurationProperties
@@ -71,9 +73,11 @@ class NotificationServiceSpec extends Specification {
mockCpsDataUpdatedEventFactory.createCpsDataUpdatedEvent(dataspaceName, myAnchorName) >> cpsDataUpdatedEvent
when: 'dataUpdatedEvent is received'
def future = objectUnderTest.processDataUpdatedEvent(dataspaceName, myAnchorName)
- and: 'async processing is completed'
- future.get()
- then: 'notification is sent'
+ and: 'wait for async processing is completed'
+ future.get(10, TimeUnit.SECONDS)
+ then: 'async process completed successfully'
+ future.isDone()
+ and: 'notification is sent'
expectedSendNotificationCount * mockNotificationPublisher.sendNotification(cpsDataUpdatedEvent)
where:
scenario | dataspaceName || expectedSendNotificationCount
@@ -89,9 +93,11 @@ class NotificationServiceSpec extends Specification {
{ throw new Exception("Could not create event") }
when: 'event is sent for processing'
def future = objectUnderTest.processDataUpdatedEvent(myDataspacePublishedName, myAnchorName)
- and: 'async processing is completed'
- future.get()
- then: 'error is handled and not thrown to caller'
+ and: 'wait for async processing is completed'
+ future.get(10, TimeUnit.SECONDS)
+ then: 'async process completed successfully'
+ future.isDone()
+ and: 'error is handled and not thrown to caller'
notThrown Exception
1 * spyNotificationErrorHandler.onException(_, _, _, _)
}