Skip to content

Commit

Permalink
Allow to specify custom image in benchmarks (#941)
Browse files Browse the repository at this point in the history
  • Loading branch information
fkorotkov authored Nov 8, 2024
1 parent 02f9472 commit cd0f238
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion benchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tart comes with a Golang-based benchmarking utility that allows one to easily co
Currently, only Flexible I/O tester workloads are supported. To run them, [install Golang](https://go.dev/) and run the following command from this (`benchmark/`) directory:

```shell
go run cmd/main.go fio
go run cmd/main.go fio --image ghcr.io/cirruslabs/macos-sonoma-base:latest
```

You can also enable the debugging output to diagnose issues:
Expand Down
4 changes: 3 additions & 1 deletion benchmark/internal/command/fio/fio.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
)

var debug bool
var image string

func NewCommand() *cobra.Command {
cmd := &cobra.Command{
Expand All @@ -24,6 +25,7 @@ func NewCommand() *cobra.Command {
}

cmd.Flags().BoolVar(&debug, "debug", false, "enable debug logging")
cmd.Flags().StringVar(&image, "image", "ghcr.io/cirruslabs/macos-sonoma-base:latest", "image to use for testing")

return cmd
}
Expand Down Expand Up @@ -111,7 +113,7 @@ func initializeExecutors(ctx context.Context, logger *zap.Logger) ([]executor.Ex

logger.Info("initializing Tart executor")

tart, err := tart.New(ctx, logger)
tart, err := tart.New(ctx, image, logger)
if err != nil {
return nil, err
}
Expand Down
8 changes: 3 additions & 5 deletions benchmark/internal/executor/tart/tart.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,24 @@ import (
"time"
)

const baseImage = "ghcr.io/cirruslabs/macos-sonoma-base:latest"

type Tart struct {
vmRunCancel context.CancelFunc
vmName string
sshClient *ssh.Client
logger *zap.Logger
}

func New(ctx context.Context, logger *zap.Logger) (*Tart, error) {
func New(ctx context.Context, image string, logger *zap.Logger) (*Tart, error) {
tart := &Tart{
vmName: fmt.Sprintf("tart-benchmark-%s", uuid.NewString()),
logger: logger,
}

if err := Cmd(ctx, tart.logger, "pull", baseImage); err != nil {
if err := Cmd(ctx, tart.logger, "pull", image); err != nil {
return nil, err
}

if err := Cmd(ctx, tart.logger, "clone", baseImage, tart.vmName); err != nil {
if err := Cmd(ctx, tart.logger, "clone", image, tart.vmName); err != nil {
return nil, err
}

Expand Down
2 changes: 1 addition & 1 deletion benchmark/internal/executor/tart/tart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func TestTart(t *testing.T) {
ctx := context.Background()

tart, err := tart.New(ctx, zap.NewNop())
tart, err := tart.New(ctx, "ghcr.io/cirruslabs/macos-sonoma-base:latest", zap.NewNop())
require.NoError(t, err)

output, err := tart.Run(ctx, "echo \"this is a test\"")
Expand Down

0 comments on commit cd0f238

Please sign in to comment.