Skip to content

Commit

Permalink
[TEST]: #5504: Storm: Updating network topology manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuliia Miroshnychenko committed Dec 4, 2023
1 parent 9ae5526 commit f46445f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -110,18 +111,22 @@ 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()
def srcBlockData = lockKeeper.knockoutSwitch(islUnderTest.srcSwitch, RW)
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

Expand All @@ -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) {
Expand Down

0 comments on commit f46445f

Please sign in to comment.