Allow to specify custom image in benchmarks (#941)

This commit is contained in:
Fedor Korotkov 2024-11-08 11:41:05 -05:00 committed by GitHub
parent 02f94720c5
commit cd0f238a67
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 8 deletions

View File

@ -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:

View File

@ -15,6 +15,7 @@ import (
)
var debug bool
var image string
func NewCommand() *cobra.Command {
cmd := &cobra.Command{
@ -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
}
@ -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
}

View File

@ -14,8 +14,6 @@ import (
"time"
)
const baseImage = "ghcr.io/cirruslabs/macos-sonoma-base:latest"
type Tart struct {
vmRunCancel context.CancelFunc
vmName string
@ -23,17 +21,17 @@ type Tart struct {
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
}

View File

@ -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\"")