-
Notifications
You must be signed in to change notification settings - Fork 47
/
main.go
69 lines (61 loc) · 1.56 KB
/
main.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"encoding/json"
"flag"
"io/ioutil"
"os"
"github.com/matrix-org/complement/internal/config"
"github.com/matrix-org/complement/internal/docker"
)
var (
flagName = flag.String("name", "", "The name to attach to this homeserver run. E.g 'dendrite 0.6.4'.")
flagSeed = flag.Int64("seed", 0, "The seed to use for deterministic tests. This allows homeservers to be compared.")
flagImage = flag.String("image", "", "Required. The complement-compatible homserver image to use.")
flagOutput = flag.String("output", "output.json", "Where to write the output data")
)
type Output struct {
Name string
Snapshots []Snapshot
Seed int64
BaseImage string
}
type Config struct {
BaseImage string
Seed int64
}
func main() {
flag.Parse()
cfg := Config{
BaseImage: *flagImage,
Seed: *flagSeed,
}
// initialise complement
complementConfig := config.NewConfigFromEnvVars("perf", cfg.BaseImage)
complementConfig.DebugLoggingEnabled = true
builder, err := docker.NewBuilder(complementConfig)
if err != nil {
panic(err)
}
builder.Cleanup() // remove any previous runs
deployer, err := docker.NewDeployer("perf", complementConfig)
if err != nil {
panic(err)
}
// run the test
snapshots, err := runTest("my_test", builder, deployer, cfg.Seed)
if err != nil {
panic(err)
}
b, err := json.Marshal(Output{
Snapshots: snapshots,
Seed: *flagSeed,
BaseImage: *flagImage,
Name: *flagName,
})
if err != nil {
panic(err)
}
if err = ioutil.WriteFile(*flagOutput, b, os.ModePerm); err != nil {
panic(err)
}
}