-
Notifications
You must be signed in to change notification settings - Fork 1
/
BashoBench.go
54 lines (44 loc) · 1.24 KB
/
BashoBench.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/client"
"github.com/docker/docker/api/types"
"context"
"github.com/docker/docker/api/types/network"
)
func runBashoBench(configPath string) error {
image := "antidotedb:bashobench"
containerConfig := &container.Config{
Image: image,
Cmd: []string{"bash", "-c", "cd /opt && ./basho_bench antidote_pb.config && cat tests/current/update-only-txn_latencies.csv"},
}
hostConfig := &container.HostConfig{
Mounts: []mount.Mount{
{
Type: mount.TypeBind,
Source: configPath,
Target: "/opt/antidote_pb.config",
ReadOnly: true,
},
},
}
ctx := context.Background()
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
return err
}
resp, err := cli.ContainerCreate(ctx, containerConfig, hostConfig, nil, "")
if err != nil {
return err
}
if err := cli.NetworkConnect(ctx, "benchmark_default", resp.ID, &network.EndpointSettings{}); err != nil {
return err
}
if err := cli.ContainerStart(ctx, resp.ID, types.ContainerStartOptions{}); err != nil {
return err
}
outputLog(resp.ID)
stopContainer(resp.ID)
return nil
}