Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the ability to call out to a script at key points in a phase #28

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/sibench/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ type Job struct {

/* extra */
useBytes bool // Boolean value to specify if you want the output in Bytes and not Bits
script string // An optional script to be invoked at key points within each phase
}

18 changes: 13 additions & 5 deletions src/sibench/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ type Arguments struct {
SliceSize int
SliceCount int

// Script options
Script string

// Synthesized options
Bucket string
BandwidthInBits uint64
Expand All @@ -107,29 +110,32 @@ Usage:
sibench rados run [-v LEVEL] [-p PORT] [-o FILE] [--individual-stats]
[-s SIZE] [-c COUNT] [-b BW] [-x MIX] [-r TIME] [-u TIME] [-d TIME] [-w FACTOR]
[-g GEN] [--slice-dir DIR] [--slice-count COUNT] [--slice-size BYTES] [--use-bytes]
[--ceph-pool POOL] [--ceph-user USER] (--ceph-key KEY)
[--ceph-pool POOL] [--ceph-user USER] (--ceph-key KEY) [--script SCRIPT]
[--clean-up] [--skip-read-verification] [--servers SERVERS] <targets> ...
sibench cephfs run [-v LEVEL] [-p PORT] [-o FILE] [--individual-stats]
[-s SIZE] [-c COUNT] [-b BW] [-x MIX] [-r TIME] [-u TIME] [-d TIME] [-w FACTOR]
[-g GEN] [--slice-dir DIR] [--slice-count COUNT] [--slice-size BYTES] [--use-bytes]
[-m DIR] [--ceph-dir DIR] [--ceph-user USER] (--ceph-key KEY)
[-m DIR] [--ceph-dir DIR] [--ceph-user USER] (--ceph-key KEY) [--script SCRIPT]
[--clean-up] [--skip-read-verification] [--servers SERVERS] <targets> ...
sibench rbd run [-v LEVEL] [-p PORT] [-o FILE] [--individual-stats]
[-s SIZE] [-c COUNT] [-b BW] [-x MIX] [-r TIME] [-u TIME] [-d TIME] [-w FACTOR]
[-g GEN] [--slice-dir DIR] [--slice-count COUNT] [--slice-size BYTES] [--use-bytes]
[--ceph-pool POOL] [--ceph-datapool POOL] [--ceph-user USER] (--ceph-key KEY)
[--clean-up] [--skip-read-verification] [--servers SERVERS] <targets> ...`
[--script SCRIPT] [--clean-up] [--skip-read-verification] [--servers SERVERS]
<targets> ...`
}

s += `
sibench block run [-v LEVEL] [-p PORT] [-o FILE] [--individual-stats]
[-s SIZE] [-c COUNT] [-b BW] [-x MIX] [-r TIME] [-u TIME] [-d TIME] [-w FACTOR]
[-g GEN] [--slice-dir DIR] [--slice-count COUNT] [--slice-size BYTES] [--use-bytes]
[--block-device DEVICE] [--clean-up] [--skip-read-verification] [--servers SERVERS]
[--block-device DEVICE] [--script SCRIPT] [--clean-up]
[--skip-read-verification] [--servers SERVERS]
sibench file run [-v LEVEL] [-p PORT] [-o FILE] [--individual-stats]
[-s SIZE] [-c COUNT] [-b BW] [-x MIX] [-r TIME] [-u TIME] [-d TIME] [-w FACTOR]
[-g GEN] [--slice-dir DIR] [--slice-count COUNT] [--slice-size BYTES] [--use-bytes]
[--file-dir DIR] [--clean-up] [--skip-read-verification] [--servers SERVERS]
[--script SCRIPT] [--file-dir DIR] [--clean-up] [--skip-read-verification]
[--servers SERVERS]
sibench -h | --help

Options:
Expand Down Expand Up @@ -167,6 +173,7 @@ Options:
--slice-count COUNT The number of slices to construct for workload generation [default: 10000]
--slice-size BYTES The size of each slice in bytes. [default: 4097]
--profile-prefix FILE Enable profiling, using tne given prefix for any output.
--script SCRIPT Specifies a script to be run at key points in each phase.
`
return s
}
Expand Down Expand Up @@ -353,6 +360,7 @@ func startRun(args *Arguments) {
j.rampUp = uint64(args.RampUp)
j.rampDown = uint64(args.RampDown)
j.useBytes = args.UseBytes
j.script = args.Script

j.order.JobId = 1
j.order.CleanUpOnClose = args.CleanUp
Expand Down
34 changes: 32 additions & 2 deletions src/sibench/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io"
"logger"
"os"
"os/exec"
"os/signal"
"strings"
"syscall"
Expand Down Expand Up @@ -137,6 +138,25 @@ func banner(msg string, padChar byte) string {
}


/**
* Runs a script, if we have one, at key points in the run.
*/
func (m *Manager) runScript(phase string, event string) {
if m.job.script == "" {
return
}

logger.Debugf("Running phase script: '%s %s %s'\n", m.job.script, phase, event)

cmd := exec.Command(m.job.script, phase, event)
err := cmd.Run()

if err != nil {
logger.Errorf("Failure running phase script: '%s %s %ws' - %v\n", m.job.script, phase, event, err)
}
}


/*
* Sends an operation request to the servers.
* If waitForResponse is true, then we block until all the servers have responded.
Expand Down Expand Up @@ -404,9 +424,19 @@ func (m *Manager) runPhaseForTime(msg string, secs uint64, startOp Opcode, stopO
logger.Infof("%v: %v\n", i, summary.String(m.job.order.ObjectSize, m.job.useBytes))
i++

// Draw some lines to indicate the ramp-up/ramp-down demarcation.
if (uint64(i) == m.job.rampUp) || (uint64(i) == m.job.rampUp + m.job.runTime) {
isRampUp := (uint64(i) == m.job.rampUp)
isRampDown := (uint64(i) == m.job.rampUp + m.job.runTime)

if isRampUp || isRampDown {
// Draw some lines to indicate the ramp-up/ramp-down demarcation.
logger.Infof("-----------------------------------------------------------\n")

// Run the script (if we have one) with suitable args.
if isRampUp {
go m.runScript(msg, "UP")
} else {
go m.runScript(msg, "DOWN")
}
}

summary.Zero()
Expand Down