summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSourabh Sourabh <sourabh.sourabh@est.tech>2024-02-13 10:08:11 +0000
committerGerrit Code Review <gerrit@onap.org>2024-02-13 10:08:11 +0000
commit8801b297e389378eab9068250fcfa63d682f1441 (patch)
treed6aa4d4dae77db9bc24c1c01d164882cd5477ab7
parentc5a80679a015cfacca17773927259bc14f4efa61 (diff)
parent1516fa0e387bf26c93d04d0444d8365d17cd1226 (diff)
Merge "Add a configurable delay to the DMI stub"
-rw-r--r--dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java21
-rw-r--r--dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/resources/application.yml5
-rw-r--r--docker-compose/docker-compose.yml3
3 files changed, 29 insertions, 0 deletions
diff --git a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java
index a4f7111324..772eb050c6 100644
--- a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java
+++ b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/java/org/onap/cps/ncmp/dmi/rest/stub/controller/DmiRestStubController.java
@@ -69,6 +69,15 @@ public class DmiRestStubController {
@Value("${app.ncmp.async-m2m.topic}")
private String ncmpAsyncM2mTopic;
+ @Value("${delay.module-references-delay-ms}")
+ private long moduleReferencesDelayMs;
+
+ @Value("${delay.module-resources-delay-ms}")
+ private long moduleResourcesDelayMs;
+
+ @Value("${delay.data-for-cm-handle-delay-ms}")
+ private long dataForCmHandleDelayMs;
+
private String dataOperationEventType = "org.onap.cps.ncmp.events.async1_0_0.DataOperationEvent";
/**
@@ -82,6 +91,7 @@ public class DmiRestStubController {
@PostMapping("/v1/ch/{cmHandleId}/modules")
public ResponseEntity<String> getModuleReferences(@PathVariable final String cmHandleId,
@RequestBody final Object moduleReferencesRequest) {
+ delay(moduleReferencesDelayMs);
final String moduleResponseContent = getModuleResourceResponse(cmHandleId,
"ModuleResponse.json");
log.info("cm handle: {} requested for modules", cmHandleId);
@@ -100,6 +110,7 @@ public class DmiRestStubController {
public ResponseEntity<String> retrieveModuleResources(
@PathVariable final String cmHandleId,
@RequestBody final Object moduleResourcesReadRequest) {
+ delay(moduleResourcesDelayMs);
final String moduleResourcesResponseContent = getModuleResourceResponse(cmHandleId,
"ModuleResourcesResponse.json");
log.info("cm handle: {} requested for modules resources", cmHandleId);
@@ -121,6 +132,7 @@ public class DmiRestStubController {
final String requestId,
@RequestBody final DmiDataOperationRequest
dmiDataOperationRequest) {
+ delay(dataForCmHandleDelayMs);
try {
log.info("Request received from the NCMP to DMI Plugin: {}",
objectMapper.writeValueAsString(dmiDataOperationRequest));
@@ -199,4 +211,13 @@ public class DmiRestStubController {
return ResourceFileReaderUtil.getResourceFileContent(applicationContext.getResource(
ResourceLoader.CLASSPATH_URL_PREFIX + "module/ietfYang" + moduleResponseType));
}
+
+ private void delay(final long milliseconds) {
+ try {
+ Thread.sleep(milliseconds);
+ } catch (final InterruptedException e) {
+ log.error("Thread sleep interrupted: {}", e.getMessage());
+ Thread.currentThread().interrupt();
+ }
+ }
}
diff --git a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/resources/application.yml b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/resources/application.yml
index 8e39a4e71c..de097a67b4 100644
--- a/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/resources/application.yml
+++ b/dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service/src/main/resources/application.yml
@@ -40,3 +40,8 @@ app:
ncmp:
async-m2m:
topic: ${NCMP_ASYNC_M2M_TOPIC:ncmp-async-m2m}
+
+delay:
+ module-references-delay-ms: ${MODULE_REFERENCES_DELAY_MS:100}
+ module-resources-delay-ms: ${MODULE_RESOURCES_DELAY_MS:1000}
+ data-for-cm-handle-delay-ms: ${DATA_FOR_CM_HANDLE_DELAY_MS:2500}
diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml
index 906945de4b..9ccb64b95b 100644
--- a/docker-compose/docker-compose.yml
+++ b/docker-compose/docker-compose.yml
@@ -129,6 +129,9 @@ services:
KAFKA_BOOTSTRAP_SERVER: kafka:29092
NCMP_CONSUMER_GROUP_ID: ncmp-group
NCMP_ASYNC_M2M_TOPIC: ncmp-async-m2m
+ MODULE_REFERENCES_DELAY_MS: 100
+ MODULE_RESOURCES_DELAY_MS: 1000
+ DATA_FOR_CM_HANDLE_DELAY_MS: 2500
restart: unless-stopped
profiles:
- dmi-stub