Skip to content

Commit

Permalink
etcdctl/check: create new check command for memory usage
Browse files Browse the repository at this point in the history
Create a new command similar to check perf that can check the memory
consumption for putting different workloads on a given endpoint. If no endpoint
is provided, localhost will be used. Return user with a message that whether
there are enough memory for a given workload with pass or fail.

Fixed #9121
  • Loading branch information
spzala committed Feb 16, 2018
1 parent 58392d0 commit b69af6f
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions etcdctl/ctlv3/command/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,22 +400,15 @@ func newCheckDatascaleCommand(cmd *cobra.Command, args []string) {
}

bytesUsed := bytesAfter - bytesBefore
mbUsed := bytesUsed / (1024 * 1024)

ok = true
if len(s.ErrorDist) != 0 {
fmt.Println("FAIL: too many errors")
for k, v := range s.ErrorDist {
fmt.Printf("FAIL: ERROR(%v) -> %d\n", k, v)
}
ok = false
}

mbUsed := bytesUsed / (1024 * 1024)

if ok {
fmt.Println(fmt.Sprintf("PASS: Approximate system memory used : %v MB.", strconv.FormatFloat(float64(mbUsed), 'f', 2, 64)))
} else {
fmt.Println("FAIL: Memory usage could not be determined.")
os.Exit(ExitError)
} else {
fmt.Println(fmt.Sprintf("PASS: Approximate system memory used : %v MB.", strconv.FormatFloat(float64(mbUsed), 'f', 2, 64)))
}
}

0 comments on commit b69af6f

Please sign in to comment.