-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathstore_test.go
More file actions
131 lines (121 loc) · 4.09 KB
/
store_test.go
File metadata and controls
131 lines (121 loc) · 4.09 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package tests
import (
"fmt"
"testing"
"time"
"github.com/deis/deis/tests/dockercli"
"github.com/deis/deis/tests/etcdutils"
"github.com/deis/deis/tests/utils"
)
func TestStore(t *testing.T) {
hostname := utils.Hostname()
var err error
// Set up etcd, which will be used by all containers
tag, etcdPort := utils.BuildTag(), utils.RandomPort()
etcdName := "deis-etcd-" + tag
cli, stdout, stdoutPipe := dockercli.NewClient()
dockercli.RunTestEtcd(t, etcdName, etcdPort)
defer cli.CmdRm("-f", etcdName)
host := utils.HostAddress()
// prep etcd with the monitor hostname -- this is done in an ExecStartPre in the monitor unit
etcdutils.SetSingle(t, "/deis/store/hosts/"+host, hostname, etcdPort)
// since we're only running one OSD, our default of 128 placement groups is too large
etcdutils.SetSingle(t, "/deis/store/pgNum", "64", etcdPort)
// test deis-store-monitor
fmt.Printf("--- Run deis/store-monitor:%s at %s\n", tag, host)
name := "deis-store-monitor-" + tag
defer cli.CmdRm("-f", name)
go func() {
_ = cli.CmdRm("-f", name)
err = dockercli.RunContainer(cli,
"--name", name,
"--rm",
"-e", "HOST="+host,
"-e", "ETCD_PORT="+etcdPort,
"-e", "NUM_STORES=1",
"--net=host",
"deis/store-monitor:"+tag)
}()
dockercli.PrintToStdout(t, stdout, stdoutPipe, "monmap e1: 1 mons at")
if err != nil {
t.Fatal(err)
}
// FIXME: Wait until etcd keys are published
time.Sleep(5000 * time.Millisecond)
dockercli.DeisServiceTest(t, name, "6789", "tcp")
etcdutils.VerifyEtcdKey(t, "/deis/store/monKeyring", etcdPort)
etcdutils.VerifyEtcdKey(t, "/deis/store/adminKeyring", etcdPort)
etcdutils.VerifyEtcdValue(t, "/deis/store/monSetupComplete", "youBetcha", etcdPort)
// test deis-store-daemon
fmt.Printf("--- Run deis/store-daemon:%s at %s\n", tag, host)
name = "deis-store-daemon-" + tag
cli2, stdout2, stdoutPipe2 := dockercli.NewClient()
defer cli2.CmdRm("-f", "-v", name)
go func() {
_ = cli2.CmdRm("-f", "-v", name)
err = dockercli.RunContainer(cli2,
"--name", name,
"--rm",
"-e", "HOST="+host,
"-e", "ETCD_PORT="+etcdPort,
"--net=host",
"deis/store-daemon:"+tag)
}()
dockercli.PrintToStdout(t, stdout2, stdoutPipe2, "journal close /var/lib/ceph/osd/ceph-0/journal")
if err != nil {
t.Fatal(err)
}
// FIXME: Wait until etcd keys are published
time.Sleep(5000 * time.Millisecond)
dockercli.DeisServiceTest(t, name, "6800", "tcp")
etcdutils.VerifyEtcdValue(t, "/deis/store/osds/"+host, "0", etcdPort)
// test deis-store-metadata
fmt.Printf("--- Run deis/store-metadata:%s at %s\n", tag, host)
name = "deis-store-metadata-" + tag
cli3, stdout3, stdoutPipe3 := dockercli.NewClient()
defer cli3.CmdRm("-f", "-v", name)
go func() {
_ = cli3.CmdRm("-f", "-v", name)
err = dockercli.RunContainer(cli3,
"--name", name,
"--rm",
"-e", "HOST="+host,
"-e", "ETCD_PORT="+etcdPort,
"--net=host",
"deis/store-metadata:"+tag)
}()
dockercli.PrintToStdout(t, stdout3, stdoutPipe3, "mds.0.1 active_start")
if err != nil {
t.Fatal(err)
}
// test deis-store-gateway
port := utils.RandomPort()
fmt.Printf("--- Run deis/store-gateway:%s at %s:%s\n", tag, host, port)
name = "deis-store-gateway-" + tag
cli4, stdout4, stdoutPipe4 := dockercli.NewClient()
defer cli4.CmdRm("-f", name)
go func() {
_ = cli4.CmdRm("-f", name)
err = dockercli.RunContainer(cli4,
"--name", name,
"--rm",
"-h", "deis-store-gateway",
"-p", port+":8888",
"-e", "HOST="+host,
"-e", "EXTERNAL_PORT="+port,
"-e", "ETCD_PORT="+etcdPort,
"deis/store-gateway:"+tag)
}()
dockercli.PrintToStdout(t, stdout4, stdoutPipe4, "deis-store-gateway running...")
if err != nil {
t.Fatal(err)
}
// FIXME: Wait until etcd keys are published
time.Sleep(5000 * time.Millisecond)
dockercli.DeisServiceTest(t, name, port, "http")
etcdutils.VerifyEtcdValue(t, "/deis/store/gateway/host", host, etcdPort)
etcdutils.VerifyEtcdValue(t, "/deis/store/gateway/port", port, etcdPort)
etcdutils.VerifyEtcdKey(t, "/deis/store/gatewayKeyring", etcdPort)
etcdutils.VerifyEtcdKey(t, "/deis/store/gateway/accessKey", etcdPort)
etcdutils.VerifyEtcdKey(t, "/deis/store/gateway/secretKey", etcdPort)
}