Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/avaakash/litmus-go into d…
Browse files Browse the repository at this point in the history
…isk-fill-helper
  • Loading branch information
avaakash committed Nov 18, 2022
2 parents 137d73e + 39bbdbb commit ea36101
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 43 deletions.
4 changes: 2 additions & 2 deletions experiments/generic/disk-fill/experiment/disk-fill.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func DiskFill(clients clients.ClientSets) {
result.RecordAfterFailure(&chaosDetails, &resultDetails, failStep, clients, &eventsDetails)
return
}
common.GetStatusMessage(chaosDetails.DefaultHealthCheck, "AUT: Running", "Successful")
msg = common.GetStatusMessage(chaosDetails.DefaultHealthCheck, "AUT: Running", "Successful")
}
// generating the events for the pre-chaos check
types.SetEngineEventAttributes(&eventsDetails, types.PreChaosCheck, msg, "Normal", &chaosDetails)
Expand Down Expand Up @@ -155,7 +155,7 @@ func DiskFill(clients clients.ClientSets) {
result.RecordAfterFailure(&chaosDetails, &resultDetails, failStep, clients, &eventsDetails)
return
}
common.GetStatusMessage(chaosDetails.DefaultHealthCheck, "AUT: Running", "Successful")
msg = common.GetStatusMessage(chaosDetails.DefaultHealthCheck, "AUT: Running", "Successful")
}

// generating post chaos event
Expand Down
4 changes: 2 additions & 2 deletions experiments/generic/pod-delete/experiment/pod-delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func PodDelete(clients clients.ClientSets) {
result.RecordAfterFailure(&chaosDetails, &resultDetails, failStep, clients, &eventsDetails)
return
}
common.GetStatusMessage(chaosDetails.DefaultHealthCheck, "AUT: Running", "Successful")
msg = common.GetStatusMessage(chaosDetails.DefaultHealthCheck, "AUT: Running", "Successful")
}
// generating the events for the pre-chaos check
types.SetEngineEventAttributes(&eventsDetails, types.PreChaosCheck, msg, "Normal", &chaosDetails)
Expand Down Expand Up @@ -162,7 +162,7 @@ func PodDelete(clients clients.ClientSets) {
result.RecordAfterFailure(&chaosDetails, &resultDetails, failStep, clients, &eventsDetails)
return
}
common.GetStatusMessage(chaosDetails.DefaultHealthCheck, "AUT: Running", "Successful")
msg = common.GetStatusMessage(chaosDetails.DefaultHealthCheck, "AUT: Running", "Successful")
}

// generating post chaos event
Expand Down
62 changes: 23 additions & 39 deletions pkg/spring-boot/spring-boot-chaos/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func GetENV(experimentDetails *experimentTypes.ExperimentDetails, expName string
experimentDetails.ChaosMonkeyPort = types.Getenv("CM_PORT", "8080")

level, _ := strconv.Atoi(types.Getenv("CM_LEVEL", "1"))
deterministic, _ := strconv.ParseBool(types.Getenv("CM_DETERMINISTIC", "true"))
deterministic := true
watchedCustomServices := strings.Split(types.Getenv("CM_WATCHED_CUSTOM_SERVICES", ""), ",")

switch expName {
Expand All @@ -51,64 +51,48 @@ func GetENV(experimentDetails *experimentTypes.ExperimentDetails, expName string
Deterministic: deterministic,
WatchedCustomServices: watchedCustomServices,
KillApplicationActive: true,
KillApplicationCron: "*/1 * * * * ?",
}
assault.KillApplicationCron = types.Getenv("CM_KILL_APPLICATION_CRON", "OFF")
log.InfoWithValues("[Info]: Chaos monkeys app-kill assaults details", logrus.Fields{
"KillApplicationCron": assault.KillApplicationCron,
})
experimentDetails.ChaosMonkeyAssault, _ = json.Marshal(assault)
case "spring-boot-latency":
latency, _ := strconv.Atoi(types.Getenv("LATENCY", "2000"))
// Latency assault
assault := experimentTypes.LatencyAssault{
Level: level,
Deterministic: deterministic,
WatchedCustomServices: watchedCustomServices,
LatencyActive: true,
LatencyRangeStart: latency,
LatencyRangeEnd: latency,
}
assault.LatencyRangeStart, _ = strconv.Atoi(types.Getenv("CM_LATENCY_RANGE_START", "500"))
assault.LatencyRangeEnd, _ = strconv.Atoi(types.Getenv("CM_LATENCY_RANGE_END", "500"))
log.InfoWithValues("[Info]: Chaos monkeys latency assaults details", logrus.Fields{
"LatencyRangeStart": assault.LatencyRangeStart,
"LatencyRangeEnd": assault.LatencyRangeEnd,
})
experimentDetails.ChaosMonkeyAssault, _ = json.Marshal(assault)
case "spring-boot-memory-stress":
memoryFillPercentage, _ := strconv.ParseFloat(types.Getenv("MEMORY_FILL_FRACTION", "0.7"), 64)
// Memory assault
assault := experimentTypes.MemoryStressAssault{
Level: level,
Deterministic: deterministic,
WatchedCustomServices: watchedCustomServices,
MemoryActive: true,
Level: level,
Deterministic: deterministic,
WatchedCustomServices: watchedCustomServices,
MemoryActive: true,
MemoryMillisecondsHoldFilledMemory: experimentDetails.ChaosDuration * 1000,
MemoryMillisecondsWaitNextIncrease: 1000,
MemoryFillIncrementFraction: 1.0,
MemoryCron: "*/1 * * * * ?",
MemoryFillTargetFraction: memoryFillPercentage,
}
assault.MemoryMillisecondsHoldFilledMemory, _ = strconv.Atoi(types.Getenv("CM_MEMORY_MS_HOLD_FILLED_MEM", "90000"))
assault.MemoryMillisecondsWaitNextIncrease, _ = strconv.Atoi(types.Getenv("CM_MEMORY_MS_NEXT_INCREASE", "1000"))
assault.MemoryFillIncrementFraction, _ = strconv.ParseFloat(types.Getenv("CM_MEMORY_FILL_INC_FRACTION", "0.15"), 64)
assault.MemoryFillTargetFraction, _ = strconv.ParseFloat(types.Getenv("CM_MEMORY_FILL_TARGET_FRACTION", "0.25"), 64)
assault.MemoryCron = types.Getenv("CM_MEMORY_CRON", "OFF")
log.InfoWithValues("[Info]: Chaos monkeys memory-stress assaults details", logrus.Fields{
"MemoryMillisecondsHoldFilledMemory": assault.MemoryMillisecondsHoldFilledMemory,
"MemoryMillisecondsWaitNextIncrease": assault.MemoryMillisecondsWaitNextIncrease,
"MemoryFillIncrementFraction": assault.MemoryFillIncrementFraction,
"MemoryFillTargetFraction": assault.MemoryFillTargetFraction,
"MemoryCron": assault.MemoryCron,
})
experimentDetails.ChaosMonkeyAssault, _ = json.Marshal(assault)
case "spring-boot-cpu-stress":
cpuLoadTargetFraction, _ := strconv.ParseFloat(types.Getenv("CPU_LOAD_FRACTION", "0.9"), 64)
// CPU assault
assault := experimentTypes.CPUStressAssault{
Level: level,
Deterministic: deterministic,
WatchedCustomServices: watchedCustomServices,
CPUActive: true,
Level: level,
Deterministic: deterministic,
WatchedCustomServices: watchedCustomServices,
CPUActive: true,
CPUMillisecondsHoldLoad: experimentDetails.ChaosDuration * 1000,
CPULoadTargetFraction: cpuLoadTargetFraction,
CPUCron: "*/1 * * * * ?",
}
assault.CPUMillisecondsHoldLoad, _ = strconv.Atoi(types.Getenv("CM_CPU_MS_HOLD_LOAD", "90000"))
assault.CPULoadTargetFraction, _ = strconv.ParseFloat(types.Getenv("CM_CPU_LOAD_TARGET_FRACTION", "0.9"), 64)
assault.CPUCron = types.Getenv("CM_CPU_CRON", "OFF")
log.InfoWithValues("[Info]: Chaos monkeys cpu-stress assaults details", logrus.Fields{
"CPUMillisecondsHoldLoad": assault.CPUMillisecondsHoldLoad,
"CPULoadTargetFraction": assault.CPULoadTargetFraction,
"CPUCron": assault.CPUCron,
})
experimentDetails.ChaosMonkeyAssault, _ = json.Marshal(assault)
case "spring-boot-exceptions":
// Exception assault
Expand Down

0 comments on commit ea36101

Please sign in to comment.