Skip to content

Commit 4bd3845

Browse files
authored
Chore(network-chaos): Add jitter in pod-network-latency experiment (#478)
Signed-off-by: uditgaurav <[email protected]>
1 parent db95990 commit 4bd3845

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

chaoslib/litmus/network-chaos/lib/latency/latency.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ import (
1212
//PodNetworkLatencyChaos contains the steps to prepare and inject chaos
1313
func PodNetworkLatencyChaos(experimentsDetails *experimentTypes.ExperimentDetails, clients clients.ClientSets, resultDetails *types.ResultDetails, eventsDetails *types.EventDetails, chaosDetails *types.ChaosDetails) error {
1414

15-
args := "delay " + strconv.Itoa(experimentsDetails.NetworkLatency) + "ms"
15+
args := "delay " + strconv.Itoa(experimentsDetails.NetworkLatency) + "ms " + strconv.Itoa(experimentsDetails.Jitter) + "ms"
1616
return network_chaos.PrepareAndInjectChaos(experimentsDetails, clients, resultDetails, eventsDetails, chaosDetails, args)
1717
}

pkg/generic/network-chaos/environment/environment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func GetENV(experimentDetails *experimentTypes.ExperimentDetails) {
2828
experimentDetails.NetworkLatency, _ = strconv.Atoi(types.Getenv("NETWORK_LATENCY", "60000"))
2929
experimentDetails.NetworkPacketLossPercentage, _ = strconv.Atoi(types.Getenv("NETWORK_PACKET_LOSS_PERCENTAGE", "100"))
3030
experimentDetails.NetworkPacketCorruptionPercentage, _ = strconv.Atoi(types.Getenv("NETWORK_PACKET_CORRUPTION_PERCENTAGE", "100"))
31+
experimentDetails.Jitter, _ = strconv.Atoi(types.Getenv("JITTER", "0"))
3132
experimentDetails.NetworkInterface = types.Getenv("NETWORK_INTERFACE", "eth0")
3233
experimentDetails.TargetContainer = types.Getenv("TARGET_CONTAINER", "")
3334
experimentDetails.TCImage = types.Getenv("TC_IMAGE", "gaiadocker/iproute2")

pkg/generic/network-chaos/types/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ type ExperimentDetails struct {
3939
SocketPath string
4040
Sequence string
4141
TerminationGracePeriodSeconds int
42+
Jitter int
4243
}

0 commit comments

Comments
 (0)