Add a configurable delay to the DMI stub
Added realistic default delay to application.yaml
Added realistic default delay to docker-compose.yml
Issue-ID: CPS-2053
Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech>
Change-Id: I756774e9538926aa341f1338fcb6882951ce3e69
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 a4f7111..772eb05 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 @@
@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 @@
@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 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 @@
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 @@
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 8e39a4e..de097a6 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 @@
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}