-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathdatabase_test.go
More file actions
55 lines (51 loc) · 1.68 KB
/
database_test.go
File metadata and controls
55 lines (51 loc) · 1.68 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
package tests
import (
"fmt"
"testing"
"github.com/deis/deis/tests/dockercliutils"
"github.com/deis/deis/tests/utils"
)
func runDeisDatabaseTest(
t *testing.T, testSessionUID string, etcdPort string, servicePort string) {
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
done := make(chan bool, 1)
err := dockercliutils.BuildImage(t, "../", "deis/database:"+testSessionUID)
if err != nil {
t.Fatal(err)
}
dockercliutils.RunDeisDataTest(t, "--name", "deis-database-data",
"-v", "/var/lib/postgresql", "deis/base", "true")
ipaddr := utils.GetHostIPAddress()
done <- true
go func() {
<-done
//docker run --name deis-database -p 5432:5432 -e PUBLISH=5432
// -e HOST=${COREOS_PRIVATE_IPV4}
// --volumes-from deis-database-data deis/database
err = dockercliutils.RunContainer(cli,
"--name", "deis-database-"+testSessionUID,
"--rm",
"-p", servicePort+":5432",
"-e", "PUBLISH="+servicePort,
"-e", "HOST="+ipaddr,
"-e", "ETCD_PORT="+etcdPort,
"--volumes-from", "deis-database-data",
"deis/database:"+testSessionUID)
}()
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "deis-database running")
if err != nil {
t.Fatal(err)
}
}
func TestDatabase(t *testing.T) {
var testSessionUID = utils.NewUuid()
fmt.Println("UUID for the session Cache Test :" + testSessionUID)
etcdPort := utils.GetRandomPort()
servicePort := utils.GetRandomPort()
dockercliutils.RunEtcdTest(t, testSessionUID, etcdPort)
fmt.Println("starting Database component test:")
runDeisDatabaseTest(t, testSessionUID, etcdPort, servicePort)
dockercliutils.DeisServiceTest(
t, "deis-database-"+testSessionUID, servicePort, "tcp")
dockercliutils.ClearTestSession(t, testSessionUID)
}