Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
feat(tests): only pull test-postgresql if it is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
mboersma committed Jul 18, 2014
1 parent cd1c542 commit 07383e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 32 deletions.
19 changes: 0 additions & 19 deletions tests/dockercliutils/dockercliutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,24 +284,6 @@ func stopContainers(t *testing.T, sliceContainerIds []string) {
PrintToStdout(t, stdout, stdoutPipe, "removing container")
}

func removeImages(t *testing.T, sliceImageIds []string) {
cli, stdout, stdoutPipe := GetNewClient()
go func() {
for _, value := range sliceImageIds {
err := cli.CmdRmi("-f", value)
if err != nil {
if !((strings.Contains(fmt.Sprintf("%s", err), "No such image")) || (strings.Contains(fmt.Sprintf("%s", err), "one or more"))) {
t.Fatalf("removeImages %s", err)
}
}
}
if err := CloseWrap(stdout, stdoutPipe); err != nil {
t.Fatalf("remove Images %s", err)
}
}()
PrintToStdout(t, stdout, stdoutPipe, "removing container")
}

// ClearTestSession cleans up after a typical test session.
func ClearTestSession(t *testing.T, uid string) {
fmt.Println("--- Clear test session", uid)
Expand Down Expand Up @@ -342,7 +324,6 @@ func RunEtcdTest(t *testing.T, uid string, port string) {
return
}
}
// PullImage(t, cli, "deis/test-etcd:latest")
done2 <- true
err = RunContainer(cli,
"--name", "deis-etcd-"+uid,
Expand Down
27 changes: 14 additions & 13 deletions tests/mockserviceutils/mockserviceutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@ func RunMockDatabase(t *testing.T, uid string, etcdPort string, dbPort string) {
var err error
cli, stdout, stdoutPipe := dockercliutils.GetNewClient()
done := make(chan bool, 1)
var imageID string
var imageTag string
dbImage := "paintedfox/postgresql:latest"
ipaddr := utils.GetHostIPAddress()
fmt.Println("starting Mock Database")
done <- true
go func() {
<-done
dockercliutils.PullImage(t, cli, "paintedfox/postgresql")
imageID = dockercliutils.GetImageID(t, "paintedfox/postgresql")
imageTag = "deis/test-database:" + uid
cli.CmdTag(imageID, imageTag)
fmt.Printf("--- Check that %s is present\n", dbImage)
if err = cli.CmdHistory("-q", dbImage); err != nil {
err = nil
if err = cli.CmdPull(dbImage); err != nil {
dockercliutils.CloseWrap(stdout, stdoutPipe)
return
}
}
err = dockercliutils.RunContainer(cli,
"--name", "deis-test-database-"+uid,
"--rm",
Expand All @@ -35,16 +37,15 @@ func RunMockDatabase(t *testing.T, uid string, etcdPort string, dbPort string) {
"-e", "USER=deis",
"-e", "DB=deis",
"-e", "PASS=deis",
"deis/test-database:"+uid)
dbImage)
}()
time.Sleep(1000 * time.Millisecond)
dockercliutils.PrintToStdout(t, stdout, stdoutPipe, "Starting")
// docker run --name="deis-database" -p -e PUBLISH=5432
// -e HOST=172.17.8.100 -e USER="super" -e DB="deis"
// -e PASS="jaffa" deis/database
setkeys := []string{"/deis/database/user",
setkeys := []string{
"/deis/database/user",
"/deis/database/password",
"/deis/database/name"}
"/deis/database/name",
}
setdir := []string{}
dbhandler := etcdutils.InitetcdValues(setdir, setkeys, etcdPort)
etcdutils.Publishvalues(t, dbhandler)
Expand Down

0 comments on commit 07383e6

Please sign in to comment.