From f46445f44ee847bb26ea2920831b43a9d5307bc6 Mon Sep 17 00:00:00 2001 From: Yuliia Miroshnychenko Date: Mon, 4 Dec 2023 17:53:54 +0100 Subject: [PATCH] [TEST]: #5504: Storm: Updating network topology manipulation --- .../functionaltests/helpers/DockerHelper.groovy | 8 ++++++++ .../helpers/WfmManipulator.groovy | 16 ++++++++++++++++ .../helpers/model/ContainerName.groovy | 3 ++- .../spec/xresilience/StormLcmSpec.groovy | 11 ++++++++--- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src-java/testing/functional-tests/src/main/groovy/org/openkilda/functionaltests/helpers/DockerHelper.groovy b/src-java/testing/functional-tests/src/main/groovy/org/openkilda/functionaltests/helpers/DockerHelper.groovy index 7aa99edc38b..9c3b0c65a7c 100644 --- a/src-java/testing/functional-tests/src/main/groovy/org/openkilda/functionaltests/helpers/DockerHelper.groovy +++ b/src-java/testing/functional-tests/src/main/groovy/org/openkilda/functionaltests/helpers/DockerHelper.groovy @@ -59,4 +59,12 @@ class DockerHelper { private String getNetworkName() { dockerClient.listNetworks()*.name().find { it.contains('_default') && it.contains('kilda') } } + + String execute(String containerId, String [] command) { + def execCreation = dockerClient.execCreate(containerId, command, + DockerClient.ExecCreateParam.attachStdout(), DockerClient.ExecCreateParam.attachStderr()) + def output = dockerClient.execStart(execCreation.id()) + def execOutput = output.readFully() + return execOutput + } } diff --git a/src-java/testing/functional-tests/src/main/groovy/org/openkilda/functionaltests/helpers/WfmManipulator.groovy b/src-java/testing/functional-tests/src/main/groovy/org/openkilda/functionaltests/helpers/WfmManipulator.groovy index ddb1201c0a2..6782942e5f3 100644 --- a/src-java/testing/functional-tests/src/main/groovy/org/openkilda/functionaltests/helpers/WfmManipulator.groovy +++ b/src-java/testing/functional-tests/src/main/groovy/org/openkilda/functionaltests/helpers/WfmManipulator.groovy @@ -1,5 +1,8 @@ package org.openkilda.functionaltests.helpers +import java.util.regex.Pattern + +import static org.openkilda.functionaltests.helpers.model.ContainerName.STORM import static org.openkilda.functionaltests.helpers.model.ContainerName.WFM import com.spotify.docker.client.DockerClient @@ -39,14 +42,27 @@ class WfmManipulator { } } + String getStormActualNetworkTopology() { + String stormUIContainerId = dockerHelper."get container by name"(STORM).id() + String[] topologiesList = ["sh", "-c", "PATH=\${PATH}:/opt/storm/bin; storm list | grep network"] + String commandOutput = dockerHelper.execute(stormUIContainerId, topologiesList) + Pattern pattern = ~/network\w*/ + assert pattern.matcher(commandOutput).find(), "Something went wrong, network topology name has not been retrieved: \n $commandOutput" + //in the blue/green mode, all topologies have a name format: topologyName_mode (mode: blue/green, ex.: network_blue) + // to deploy/kill topology use the format topologyName-mode (ex. network-blue) + return pattern.matcher(commandOutput).findAll().first().toString().replace("_", "-") + } + def killTopology(String topologyName) { log.warn "Killing wfm $topologyName topology" manipulateTopology("kill", topologyName) + log.info "WFM $topologyName topology has been deleted" } def deployTopology(String topologyName) { log.warn "Deploying wfm $topologyName topology" manipulateTopology("deploy", topologyName) + log.info("WFM $topologyName topology has been deployed") } private def manipulateTopology(String action, String topologyName) { diff --git a/src-java/testing/functional-tests/src/main/groovy/org/openkilda/functionaltests/helpers/model/ContainerName.groovy b/src-java/testing/functional-tests/src/main/groovy/org/openkilda/functionaltests/helpers/model/ContainerName.groovy index 97da2d1a621..41a460e509f 100644 --- a/src-java/testing/functional-tests/src/main/groovy/org/openkilda/functionaltests/helpers/model/ContainerName.groovy +++ b/src-java/testing/functional-tests/src/main/groovy/org/openkilda/functionaltests/helpers/model/ContainerName.groovy @@ -3,7 +3,8 @@ package org.openkilda.functionaltests.helpers.model enum ContainerName { GRPC("grpc-speaker"), GRPC_STUB("grpc-stub"), - WFM("wfm") + WFM("wfm"), + STORM("storm-ui") private final String id; diff --git a/src-java/testing/functional-tests/src/test/groovy/org/openkilda/functionaltests/spec/xresilience/StormLcmSpec.groovy b/src-java/testing/functional-tests/src/test/groovy/org/openkilda/functionaltests/spec/xresilience/StormLcmSpec.groovy index 98abb763851..ef181362064 100644 --- a/src-java/testing/functional-tests/src/test/groovy/org/openkilda/functionaltests/spec/xresilience/StormLcmSpec.groovy +++ b/src-java/testing/functional-tests/src/test/groovy/org/openkilda/functionaltests/spec/xresilience/StormLcmSpec.groovy @@ -21,6 +21,7 @@ import org.openkilda.testing.Constants import org.springframework.beans.factory.annotation.Value import spock.lang.Ignore import spock.lang.Isolated +import spock.lang.Issue import spock.lang.Narrative import spock.lang.Shared @@ -110,10 +111,14 @@ class StormLcmSpec extends HealthCheckSpecification { } @Ignore + @Issue("https://github.com/telstra/open-kilda/issues/5506 (ISL between deactivated switches is in a DISCOVERED state)") @Tags(LOW_PRIORITY) def "System's able to fail an ISL if switches on both ends go offline during restart of network topology"() { + given: "Actual network topology" + String networkTopologyName = wfmManipulator.getStormActualNetworkTopology() + when: "Kill network topology" - wfmManipulator.killTopology("network") + wfmManipulator.killTopology(networkTopologyName) and: "Disconnect switches on both ends of ISL" def islUnderTest = topology.islsForActiveSwitches.first() @@ -121,7 +126,7 @@ class StormLcmSpec extends HealthCheckSpecification { def dstBlockData = lockKeeper.knockoutSwitch(islUnderTest.dstSwitch, RW) and: "Deploy network topology back" - wfmManipulator.deployTopology("network") + wfmManipulator.deployTopology(networkTopologyName) def networkDeployed = true TimeUnit.SECONDS.sleep(45) //after deploy topology needs more time to actually begin working @@ -139,7 +144,7 @@ class StormLcmSpec extends HealthCheckSpecification { } cleanup: - !networkDeployed && wfmManipulator.deployTopology("network") + networkTopologyName && !networkDeployed && wfmManipulator.deployTopology(networkTopologyName) srcBlockData && lockKeeper.reviveSwitch(islUnderTest.srcSwitch, srcBlockData) dstBlockData && lockKeeper.reviveSwitch(islUnderTest.dstSwitch, dstBlockData) Wrappers.wait(discoveryTimeout + WAIT_OFFSET * 3) {