summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src
diff options
context:
space:
mode:
authorKavitha P <pkavitha@aarnanetworks.com>2021-08-25 16:12:18 +0530
committerKAPIL SINGAL <ks220y@att.com>2021-08-27 16:58:22 +0000
commit35481027b3fdf251a3b520ab5b1ae89c7d2d0e34 (patch)
tree8fe9d3fe117005d54b31e1a136ad334e419268e4 /ms/blueprintsprocessor/modules/inbounds/selfservice-api/src
parent6b6f2360e4e60d681a5ba0fc05477f9ac9bea051 (diff)
CCSDK-3434 CBA workflow status store
Change-Id: Iaeac6fa534c569bbc152e6c8a78c2dd23b6c4b1a Signed-off-by: Kavitha P <pkavitha@aarnanetworks.com> Issue-ID: CCSDK-3434
Diffstat (limited to 'ms/blueprintsprocessor/modules/inbounds/selfservice-api/src')
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt13
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt4
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt63
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/TestDatabaseConfiguration.kt4
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/application-test.properties4
5 files changed, 82 insertions, 6 deletions
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
index e604987a7..c2c7a60e9 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandler.kt
@@ -33,6 +33,7 @@ import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.SelfServiceMetricC
import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.SelfServiceMetricConstants.TIMER_PROCESS
import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.cbaMetricTags
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractServiceFunction
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit.StoreAuditService
import org.onap.ccsdk.cds.controllerblueprints.common.api.EventType
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration
@@ -50,6 +51,7 @@ class ExecutionServiceHandler(
private val bluePrintWorkflowExecutionService:
BluePrintWorkflowExecutionService<ExecutionServiceInput, ExecutionServiceOutput>,
private val publishAuditService: PublishAuditService,
+ private val storeAuditService: StoreAuditService,
private val meterRegistry: MeterRegistry
) {
@@ -102,6 +104,10 @@ class ExecutionServiceHandler(
// Audit input
publishAuditService.publishExecutionInput(executionServiceInput)
+ // store audit input details
+ val auditStoreId: Long = storeAuditService.storeExecutionInput(executionServiceInput)
+ log.info("StoreAuditService ID $auditStoreId")
+
val sample = Timer.start()
try {
/** Check Blueprint is needed for this request */
@@ -130,9 +136,14 @@ class ExecutionServiceHandler(
// Update process metrics
sample.stop(meterRegistry.timer(TIMER_PROCESS, cbaMetricTags(executionServiceInput)))
meterRegistry.counter(COUNTER_PROCESS, cbaMetricTags(executionServiceOutput)).increment()
-
// Audit output
publishAuditService.publishExecutionOutput(executionServiceInput.correlationUUID, executionServiceOutput)
+
+ // store audit input details
+ storeAuditService.storeExecutionOutput(
+ auditStoreId, executionServiceInput.correlationUUID,
+ executionServiceOutput
+ )
return executionServiceOutput
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt
index d7d7aaa2a..ebaa8bd7e 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceControllerTest.kt
@@ -23,6 +23,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit.DatabaseStoreAuditService
import org.onap.ccsdk.cds.controllerblueprints.core.compress
import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir
import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService
@@ -46,7 +47,8 @@ import kotlin.test.assertTrue
@ContextConfiguration(
classes = [
ExecutionServiceHandler::class, BluePrintCoreConfiguration::class,
- BluePrintCatalogService::class, SelfServiceApiTestConfiguration::class,
+ BluePrintCatalogService::class, DatabaseStoreAuditService::class,
+ SelfServiceApiTestConfiguration::class,
ErrorCatalogTestConfiguration::class, SimpleMeterRegistry::class
]
)
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt
index 0a89c5782..af3cbd89a 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/ExecutionServiceHandlerTest.kt
@@ -16,11 +16,14 @@
package org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api
+import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.databind.node.ObjectNode
import io.micrometer.core.instrument.MeterRegistry
import io.mockk.coVerify
import io.mockk.Runs
import io.mockk.coEvery
import io.mockk.coVerify
+import io.mockk.every
import io.mockk.just
import io.mockk.mockk
import kotlinx.coroutines.runBlocking
@@ -30,9 +33,13 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ActionIdentifiers
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit.DatabaseStoreAuditService
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit.db.BlueprintAuditStatusRepository
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit.db.BlueprintWorkflowAuditStatus
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractServiceFunction
import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.mock.mockito.MockBean
import org.springframework.context.ApplicationContext
@@ -60,6 +67,11 @@ class ExecutionServiceHandlerTest {
@Autowired
lateinit var applicationContext: ApplicationContext
+ private val blueprintAuditStatusRepository =
+ mockk<BlueprintAuditStatusRepository>()
+
+ private val testDatabaseStoreAuditService = DatabaseStoreAuditService(blueprintAuditStatusRepository)
+
@Before
fun init() {
BluePrintDependencyService.inject(applicationContext)
@@ -80,7 +92,7 @@ class ExecutionServiceHandlerTest {
}
}
runBlocking {
- val executionServiceHandler = ExecutionServiceHandler(mockk(), mockk(), mockk(), mockk(), mockk(relaxed = true))
+ val executionServiceHandler = ExecutionServiceHandler(mockk(), mockk(), mockk(), mockk(), testDatabaseStoreAuditService, mockk(relaxed = true))
val isServiceFunction = executionServiceHandler.checkServiceFunction(executionServiceInput)
assertTrue(isServiceFunction, "failed to checkServiceFunction")
val executionServiceOutput = executionServiceHandler.executeServiceFunction(executionServiceInput)
@@ -90,6 +102,10 @@ class ExecutionServiceHandlerTest {
@Test
fun testPublishAuditFunction() {
+
+ val jsonContent = JacksonUtils.getClassPathFileContent("execution-input/sample-payload.json")
+ val json: ObjectNode = ObjectMapper().readTree(jsonContent) as ObjectNode
+
val executionServiceInput = ExecutionServiceInput().apply {
commonHeader = CommonHeader().apply {
requestId = "1234"
@@ -100,20 +116,29 @@ class ExecutionServiceHandlerTest {
blueprintName = "default"
blueprintVersion = "1.0.0"
actionName = "mock-service-action"
+ mode = "async"
}
}
-
+ executionServiceInput.payload = json
val publishAuditService = mockk<KafkaPublishAuditService>(relaxed = true)
+ val wfAudit = createWorkflowAuditStatusRecord(1000)
+
val executionServiceHandler = ExecutionServiceHandler(
mockk(),
mockk(),
mockk(),
publishAuditService,
+ testDatabaseStoreAuditService,
mockk(relaxed = true)
)
-
+ var testOutput: Long = 1000
coEvery { publishAuditService.publishExecutionInput(ExecutionServiceInput()) } just Runs
+ runBlocking {
+ every { blueprintAuditStatusRepository.findById(testOutput) } returns wfAudit
+ every { blueprintAuditStatusRepository.saveAndFlush(any<BlueprintWorkflowAuditStatus>()) } returns wfAudit
+ }
+
var executionServiceOutput: ExecutionServiceOutput? = null
runBlocking {
executionServiceOutput = executionServiceHandler.doProcess(executionServiceInput)
@@ -122,8 +147,40 @@ class ExecutionServiceHandlerTest {
coVerify {
publishAuditService.publishExecutionInput(executionServiceInput)
publishAuditService.publishExecutionOutput(executionServiceInput.correlationUUID, executionServiceOutput!!)
+ testOutput = testDatabaseStoreAuditService.storeExecutionInput(executionServiceInput)
}
}
+
+ private fun createWorkflowAuditStatusRecord(
+ id: Long
+ ): BlueprintWorkflowAuditStatus {
+
+ var blueprintWorkflowAuditStatus: BlueprintWorkflowAuditStatus =
+ BlueprintWorkflowAuditStatus()
+ blueprintWorkflowAuditStatus.id = id
+ blueprintWorkflowAuditStatus.originatorId = "SDNC_DG"
+ blueprintWorkflowAuditStatus.requestMode = "sync"
+ blueprintWorkflowAuditStatus.requestId = "ab543-3asd4"
+ blueprintWorkflowAuditStatus.subRequestId = "81c9-4910"
+ blueprintWorkflowAuditStatus.status = "In progress"
+ blueprintWorkflowAuditStatus.blueprintName = "multi-steps"
+ blueprintWorkflowAuditStatus.blueprintVersion = "1.0.0"
+ blueprintWorkflowAuditStatus.workflowName = "multi-steps-workflow"
+ blueprintWorkflowAuditStatus.updatedBy = "CBA"
+ blueprintWorkflowAuditStatus.requestMode = "sync"
+ blueprintWorkflowAuditStatus.workflowTaskContent = "{\n" +
+ " \"multi-steps-workflow-request\": {\n" +
+ " \"multi-steps-workflow-properties\": {\n" +
+ " \"prop1\": \"testing\",\n" +
+ " \"prop2\": \"testing description\",\n" +
+ " \"prop3\": \"user name \",\n" +
+ " \"prop4\" : \"test project\"\n" +
+ " }\n" +
+ " }\n" +
+ " }"
+ blueprintWorkflowAuditStatus.workflowResponseContent = " "
+ return blueprintWorkflowAuditStatus
+ }
}
@Service("mock-service-action")
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/TestDatabaseConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/TestDatabaseConfiguration.kt
index bca05f68b..5a2c5e5db 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/TestDatabaseConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/TestDatabaseConfiguration.kt
@@ -33,7 +33,8 @@ import javax.sql.DataSource
@EnableJpaRepositories(
basePackages = [
"org.onap.ccsdk.cds.blueprintsprocessor.db.primary",
- "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution"
+ "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution",
+ "org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit"
],
entityManagerFactoryRef = "primaryEntityManager",
transactionManagerRef = "primaryTransactionManager"
@@ -46,6 +47,7 @@ open class TestDatabaseConfiguration(primaryDataSourceProperties: PrimaryDataSou
open fun primaryEntityManager(): LocalContainerEntityManagerFactoryBean {
return primaryEntityManager(
"org.onap.ccsdk.cds.blueprintsprocessor.db.primary",
+ "org.onap.ccsdk.cds.blueprintsprocessor.functions.workflow.audit",
"org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution"
)
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/application-test.properties b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/application-test.properties
index 77b61a421..8dfaf7896 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/application-test.properties
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/resources/application-test.properties
@@ -68,3 +68,7 @@ blueprintsprocessor.messageproducer.self-service-api.audit.response.type=kafka-b
blueprintsprocessor.messageproducer.self-service-api.audit.response.bootstrapServers=127.0.0.1:9092
blueprintsprocessor.messageproducer.self-service-api.audit.response.clientId=audit-response-producer-client-id
blueprintsprocessor.messageproducer.self-service-api.audit.response.topic=audit-response-producer.t
+
+#Workflow Audit store enable
+blueprintsprocessor.workflow.self-service-api.audit.storeEnable=true
+