diff --git a/chaoslib/litmus/node-cpu-hog/lib/node-cpu-hog.go b/chaoslib/litmus/node-cpu-hog/lib/node-cpu-hog.go index 74db3a6b4..b6204c528 100644 --- a/chaoslib/litmus/node-cpu-hog/lib/node-cpu-hog.go +++ b/chaoslib/litmus/node-cpu-hog/lib/node-cpu-hog.go @@ -244,6 +244,8 @@ func createHelperPod(experimentsDetails *experimentTypes.ExperimentDetails, chao Args: []string{ "--cpu", strconv.Itoa(experimentsDetails.NodeCPUcores), + "--cpu-load", + strconv.Itoa(experimentsDetails.CPULoad), "--timeout", strconv.Itoa(experimentsDetails.ChaosDuration), }, diff --git a/chaoslib/litmus/stress-chaos/helper/stress-helper.go b/chaoslib/litmus/stress-chaos/helper/stress-helper.go index 89fde479e..0aa25d249 100644 --- a/chaoslib/litmus/stress-chaos/helper/stress-helper.go +++ b/chaoslib/litmus/stress-chaos/helper/stress-helper.go @@ -238,6 +238,7 @@ func prepareStressor(experimentDetails *experimentTypes.ExperimentDetails) []str "Timeout": experimentDetails.ChaosDuration, }) stressArgs = append(stressArgs, "--cpu "+strconv.Itoa(experimentDetails.CPUcores)) + stressArgs = append(stressArgs, " --cpu-load "+strconv.Itoa(experimentDetails.CPULoad)) case "pod-memory-stress": @@ -510,6 +511,7 @@ func getENV(experimentDetails *experimentTypes.ExperimentDetails) { experimentDetails.ContainerRuntime = types.Getenv("CONTAINER_RUNTIME", "") experimentDetails.SocketPath = types.Getenv("SOCKET_PATH", "") experimentDetails.CPUcores, _ = strconv.Atoi(types.Getenv("CPU_CORES", "")) + experimentDetails.CPULoad, _ = strconv.Atoi(types.Getenv("CPU_LOAD", "")) experimentDetails.FilesystemUtilizationPercentage, _ = strconv.Atoi(types.Getenv("FILESYSTEM_UTILIZATION_PERCENTAGE", "")) experimentDetails.FilesystemUtilizationBytes, _ = strconv.Atoi(types.Getenv("FILESYSTEM_UTILIZATION_BYTES", "")) experimentDetails.NumberOfWorkers, _ = strconv.Atoi(types.Getenv("NUMBER_OF_WORKERS", "")) diff --git a/chaoslib/litmus/stress-chaos/lib/stress-chaos.go b/chaoslib/litmus/stress-chaos/lib/stress-chaos.go index 9bceeac10..9621af6d0 100644 --- a/chaoslib/litmus/stress-chaos/lib/stress-chaos.go +++ b/chaoslib/litmus/stress-chaos/lib/stress-chaos.go @@ -291,6 +291,7 @@ func getPodEnv(experimentsDetails *experimentTypes.ExperimentDetails, podName st SetEnv("EXPERIMENT_NAME", experimentsDetails.ExperimentName). SetEnv("SOCKET_PATH", experimentsDetails.SocketPath). SetEnv("CPU_CORES", strconv.Itoa(experimentsDetails.CPUcores)). + SetEnv("CPU_LOAD", strconv.Itoa(experimentsDetails.CPULoad)). SetEnv("FILESYSTEM_UTILIZATION_PERCENTAGE", strconv.Itoa(experimentsDetails.FilesystemUtilizationPercentage)). SetEnv("FILESYSTEM_UTILIZATION_BYTES", strconv.Itoa(experimentsDetails.FilesystemUtilizationBytes)). SetEnv("NUMBER_OF_WORKERS", strconv.Itoa(experimentsDetails.NumberOfWorkers)). diff --git a/pkg/generic/node-cpu-hog/environment/environment.go b/pkg/generic/node-cpu-hog/environment/environment.go index 88cb82bf2..4935b98e5 100644 --- a/pkg/generic/node-cpu-hog/environment/environment.go +++ b/pkg/generic/node-cpu-hog/environment/environment.go @@ -23,6 +23,7 @@ func GetENV(experimentDetails *experimentTypes.ExperimentDetails) { experimentDetails.InstanceID = types.Getenv("INSTANCE_ID", "") experimentDetails.ChaosPodName = types.Getenv("POD_NAME", "") experimentDetails.NodeCPUcores, _ = strconv.Atoi(types.Getenv("NODE_CPU_CORE", "0")) + experimentDetails.CPULoad, _ = strconv.Atoi(types.Getenv("CPU_LOAD", "100")) experimentDetails.LIBImage = types.Getenv("LIB_IMAGE", "litmuschaos/go-runner:latest") experimentDetails.LIBImagePullPolicy = types.Getenv("LIB_IMAGE_PULL_POLICY", "Always") experimentDetails.AuxiliaryAppInfo = types.Getenv("AUXILIARY_APPINFO", "") diff --git a/pkg/generic/node-cpu-hog/types/types.go b/pkg/generic/node-cpu-hog/types/types.go index 697423ff9..56c4bb7cb 100644 --- a/pkg/generic/node-cpu-hog/types/types.go +++ b/pkg/generic/node-cpu-hog/types/types.go @@ -20,6 +20,7 @@ type ExperimentDetails struct { ChaosNamespace string ChaosPodName string NodeCPUcores int + CPULoad int RunID string LIBImage string LIBImagePullPolicy string diff --git a/pkg/generic/stress-chaos/environment/environment.go b/pkg/generic/stress-chaos/environment/environment.go index 5165f4833..205585f1b 100644 --- a/pkg/generic/stress-chaos/environment/environment.go +++ b/pkg/generic/stress-chaos/environment/environment.go @@ -38,7 +38,8 @@ func GetENV(experimentDetails *experimentTypes.ExperimentDetails, expName string switch expName { case "pod-cpu-hog": - experimentDetails.CPUcores, _ = strconv.Atoi(types.Getenv("CPU_CORES", "1")) + experimentDetails.CPUcores, _ = strconv.Atoi(types.Getenv("CPU_CORES", "0")) + experimentDetails.CPULoad, _ = strconv.Atoi(types.Getenv("CPU_LOAD", "100")) experimentDetails.StressType = "pod-cpu-stress" case "pod-memory-hog": diff --git a/pkg/generic/stress-chaos/types/types.go b/pkg/generic/stress-chaos/types/types.go index 6a65003cc..93c6b5bc6 100644 --- a/pkg/generic/stress-chaos/types/types.go +++ b/pkg/generic/stress-chaos/types/types.go @@ -33,6 +33,7 @@ type ExperimentDetails struct { Sequence string TerminationGracePeriodSeconds int CPUcores int + CPULoad int FilesystemUtilizationPercentage int FilesystemUtilizationBytes int NumberOfWorkers int