diff options
author | JvD_Ericsson <jeff.van.dam@est.tech> | 2024-01-31 13:47:28 +0000 |
---|---|---|
committer | JvD_Ericsson <jeff.van.dam@est.tech> | 2024-02-12 11:04:11 +0000 |
commit | 1516fa0e387bf26c93d04d0444d8365d17cd1226 (patch) | |
tree | 49e6a1462388e6f16d90935ce91dd65fe69a48f0 /dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service | |
parent | 4fa8d653abfd59e48d3b7461e67e5cb965ad8406 (diff) |
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
Diffstat (limited to 'dmi-plugin-demo-and-csit-stub/dmi-plugin-demo-and-csit-stub-service')
2 files changed, 26 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} |