mirror of
https://github.com/cirruslabs/tart.git
synced 2026-09-30 03:01:12 +02:00
Allow to specify custom image in benchmarks (#941)
This commit is contained in:
+1
-1
@@ -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:
|
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
|
```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:
|
You can also enable the debugging output to diagnose issues:
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var debug bool
|
var debug bool
|
||||||
|
var image string
|
||||||
|
|
||||||
func NewCommand() *cobra.Command {
|
func NewCommand() *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
@@ -24,6 +25,7 @@ func NewCommand() *cobra.Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd.Flags().BoolVar(&debug, "debug", false, "enable debug logging")
|
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
|
return cmd
|
||||||
}
|
}
|
||||||
@@ -111,7 +113,7 @@ func initializeExecutors(ctx context.Context, logger *zap.Logger) ([]executor.Ex
|
|||||||
|
|
||||||
logger.Info("initializing Tart executor")
|
logger.Info("initializing Tart executor")
|
||||||
|
|
||||||
tart, err := tart.New(ctx, logger)
|
tart, err := tart.New(ctx, image, logger)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const baseImage = "ghcr.io/cirruslabs/macos-sonoma-base:latest"
|
|
||||||
|
|
||||||
type Tart struct {
|
type Tart struct {
|
||||||
vmRunCancel context.CancelFunc
|
vmRunCancel context.CancelFunc
|
||||||
vmName string
|
vmName string
|
||||||
@@ -23,17 +21,17 @@ type Tart struct {
|
|||||||
logger *zap.Logger
|
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{
|
tart := &Tart{
|
||||||
vmName: fmt.Sprintf("tart-benchmark-%s", uuid.NewString()),
|
vmName: fmt.Sprintf("tart-benchmark-%s", uuid.NewString()),
|
||||||
logger: logger,
|
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
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
func TestTart(t *testing.T) {
|
func TestTart(t *testing.T) {
|
||||||
ctx := context.Background()
|
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)
|
require.NoError(t, err)
|
||||||
|
|
||||||
output, err := tart.Run(ctx, "echo \"this is a test\"")
|
output, err := tart.Run(ctx, "echo \"this is a test\"")
|
||||||
|
|||||||
Reference in New Issue
Block a user