-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: inject control plane node network latency
Signed-off-by: Yang Chiu <[email protected]>
- Loading branch information
Showing
8 changed files
with
90 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from network.network import setup_control_plane_network_latency | ||
from network.network import cleanup_control_plane_network_latency | ||
|
||
class network_keywords: | ||
|
||
def setup_control_plane_network_latency(self): | ||
setup_control_plane_network_latency() | ||
|
||
def cleanup_control_plane_network_latency(self): | ||
cleanup_control_plane_network_latency() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from robot.libraries.BuiltIn import BuiltIn | ||
from utility.utility import get_control_plane_nodes | ||
from node_exec import NodeExec | ||
|
||
def get_control_plane_node_network_latency_in_ms(): | ||
latency_in_ms = int(BuiltIn().get_variable_value("${CONTROL_PLANE_NODE_NETWORK_LATENCY_IN_MS}")) | ||
return latency_in_ms | ||
|
||
def setup_control_plane_network_latency(): | ||
latency_in_ms = get_control_plane_node_network_latency_in_ms() | ||
if latency_in_ms != 0: | ||
nodes = get_control_plane_nodes() | ||
for node in nodes: | ||
cmd = f"tc qdisc replace dev eth0 root netem delay {latency_in_ms}ms" | ||
res = NodeExec.get_instance().issue_cmd(node, cmd) | ||
cmd = f"tc qdisc show dev eth0 | grep delay" | ||
res = NodeExec.get_instance().issue_cmd(node, cmd) | ||
assert res, "setup control plane network latency failed" | ||
|
||
def cleanup_control_plane_network_latency(): | ||
latency_in_ms = get_control_plane_node_network_latency_in_ms() | ||
if latency_in_ms != 0: | ||
nodes = get_control_plane_nodes() | ||
for node in nodes: | ||
cmd = "tc qdisc del dev eth0 root" | ||
res = NodeExec.get_instance().issue_cmd(node, cmd) | ||
cmd = f"tc qdisc show dev eth0 | grep -v delay" | ||
res = NodeExec.get_instance().issue_cmd(node, cmd) | ||
assert res, "cleanup control plane network failed" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters