summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test
diff options
context:
space:
mode:
authorJozsef Csongvai <jozsef.csongvai@bell.ca>2021-03-14 19:13:35 -0400
committerJozsef Csongvai <jozsef.csongvai@bell.ca>2021-03-23 22:37:21 +0000
commit42bea4afb523db0215fc2446b078c6c1824ee1ea (patch)
treefe7dd6dda920745c72eb111c0d71c8ae2835efa1 /ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test
parent6e45f5ce5743013e6c37f3848517bb88700aeab7 (diff)
Prohibit cycles in imperative workflows
Issue-ID: CCSDK-3221 Change-Id: I767003dde40c0fc53a673c4a41cb2430624d7b04 Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca> (cherry picked from commit 2c7207526c37166a0d0ccc5008aaae0ae325064e)
Diffstat (limited to 'ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test')
-rw-r--r--ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctionsTest.kt71
1 files changed, 71 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctionsTest.kt b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctionsTest.kt
index 86cb473ae..ba4115f02 100644
--- a/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctionsTest.kt
+++ b/ms/blueprintsprocessor/modules/blueprints/blueprint-core/src/test/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/GraphExtensionFunctionsTest.kt
@@ -18,7 +18,9 @@ package org.onap.ccsdk.cds.controllerblueprints.core
import org.junit.Test
import org.onap.ccsdk.cds.controllerblueprints.core.data.EdgeLabel
+import kotlin.test.assertFalse
import kotlin.test.assertNotNull
+import kotlin.test.assertTrue
class GraphExtensionFunctionsTest {
@@ -34,4 +36,73 @@ class GraphExtensionFunctionsTest {
val nodePath = graph.nodes["p"]!!.neighbors(EdgeLabel.SUCCESS)
assertNotNull(nodePath, "failed to nodePath from graph for 'p' node 'SUCCESS' label")
}
+
+ @Test
+ fun `isAcyclic should return false`() {
+ assertFalse(
+ """[
+ assign>deploy/SUCCESS,
+ deploy>assign/FAILURE
+ ]""".toGraph().isAcyclic()
+ )
+
+ assertFalse(
+ """[
+ assign>deploy/SUCCESS,
+ deploy>recover/FAILURE,
+ recover>deploy/SUCCESS
+ ]""".toGraph().isAcyclic()
+ )
+
+ assertFalse(
+ """[
+ assign>deploy/SUCCESS,
+ assign>recover/FAILURE,
+ recover>deploy/SUCCESS,
+ deploy>finalize/SUCCESS,
+ deploy>recover/FAILURE
+ ]""".toGraph().isAcyclic()
+ )
+
+ assertFalse(
+ """[
+ A>B/SUCCESS,
+ A>C/SUCCESS,
+ B>E/SUCCESS,
+ B>D/FAILURE,
+ D>B/FAILURE,
+ C>E/SUCCESS
+ ]""".toGraph().isAcyclic()
+ )
+ }
+
+ @Test
+ fun `isAcyclic should return true`() {
+ assertTrue(
+ """[
+ assign>deploy/SUCCESS,
+ deploy>recover/FAILURE
+ ]""".toGraph().isAcyclic()
+ )
+
+ assertTrue(
+ """[
+ A>C/SUCCESS,
+ A>B/FAILURE,
+ C>B/SUCCESS
+ ]""".toGraph().isAcyclic()
+ )
+
+ assertTrue(
+ """[
+ assign>execute1/SUCCESS,
+ assign>execute2/SUCCESS,
+ execute1>finalize/SUCCESS,
+ execute2>finalize/SUCCESS,
+ execute1>cleanup/FAILURE,
+ execute2>cleanup/FAILURE,
+ finalize>cleanup/SUCCESS
+ ]""".toGraph().isAcyclic()
+ )
+ }
}