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

Replace blobstore TestLargeAmountOfData with config lookup #685

Merged
merged 2 commits into from Jan 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/helper.go
Expand Up @@ -117,7 +117,7 @@ func (h *Helper) createApp(t *c.C) (*ct.App, *ct.Release) {
t.Assert(client.CreateApp(app), c.IsNil)
debugf(t, "created app %s (%s)", app.Name, app.ID)

artifact := &ct.Artifact{Type: "docker", URI: testImageURI}
artifact := &ct.Artifact{Type: "docker", URI: imageURIs["test-apps"]}
t.Assert(client.CreateArtifact(artifact), c.IsNil)

release := &ct.Release{
Expand Down
31 changes: 18 additions & 13 deletions test/main.go
Expand Up @@ -39,9 +39,6 @@ var flynnrc string
var routerIP string
var testCluster *cluster.Cluster
var httpClient *http.Client
var testImageURI string

const testImageName = "flynn/test-apps"

func init() {
args = arg.Parse()
Expand All @@ -52,11 +49,10 @@ func init() {
}

func main() {
id, err := lookupTestImageID()
if err != nil {
log.Fatalf("could not determine test image ID: %s", err)
var err error
if err = lookupImageURIs(); err != nil {
log.Fatalf("could not determine image ID: %s", err)
}
testImageURI = fmt.Sprintf("https://example.com/%s?id=%s", testImageName, id)

var res *check.Result
// defer exiting here so it runs after all other defers
Expand Down Expand Up @@ -133,16 +129,25 @@ func main() {
fmt.Println(res)
}

func lookupTestImageID() (string, error) {
var imageURIs = map[string]string{
"test-apps": "",
"postgresql": "",
}

func lookupImageURIs() error {
d, err := docker.NewClient("unix:///var/run/docker.sock")
if err != nil {
return "", err
return err
}
image, err := d.InspectImage(testImageName)
if err != nil {
return "", err
for name := range imageURIs {
fullName := "flynn/" + name
image, err := d.InspectImage(fullName)
if err != nil {
return err
}
imageURIs[name] = fmt.Sprintf("https://example.com/%s?id=%s", fullName, image.ID)
}
return image.ID, nil
return nil
}

type sshData struct {
Expand Down
42 changes: 0 additions & 42 deletions test/test_blobstore.go

This file was deleted.

2 changes: 1 addition & 1 deletion test/test_cli.go
Expand Up @@ -481,7 +481,7 @@ func (s *CLISuite) TestRelease(t *c.C) {
file.Close()

app := s.newCliTestApp(t)
t.Assert(app.flynn("release", "add", "-f", file.Name(), testImageURI), Succeeds)
t.Assert(app.flynn("release", "add", "-f", file.Name(), imageURIs["test-apps"]), Succeeds)

r, err := s.controller.GetAppRelease(app.name)
t.Assert(err, c.IsNil)
Expand Down
4 changes: 2 additions & 2 deletions test/test_host.go
Expand Up @@ -36,7 +36,7 @@ func (s *HostSuite) TestAttachFinishedInteractiveJob(t *c.C) {
cluster := s.clusterClient(t)

// run a quick interactive job
cmd := exec.CommandUsingCluster(cluster, exec.DockerImage(testImageURI), "/bin/true")
cmd := exec.CommandUsingCluster(cluster, exec.DockerImage(imageURIs["test-apps"]), "/bin/true")
cmd.TTY = true
err := cmd.Run()
t.Assert(err, c.IsNil)
Expand Down Expand Up @@ -68,7 +68,7 @@ func (s *HostSuite) TestNetworkedPersistentJob(t *c.C) {

// run a job that accepts tcp connections and performs tasks we ask of it in its container
serviceName := "ish-service-" + random.String(6)
cmd := exec.JobUsingCluster(cluster, exec.DockerImage(testImageURI), &host.Job{
cmd := exec.JobUsingCluster(cluster, exec.DockerImage(imageURIs["test-apps"]), &host.Job{
Config: host.ContainerConfig{
Cmd: []string{"/bin/ish"},
Ports: []host.Port{{Proto: "tcp"}},
Expand Down
36 changes: 36 additions & 0 deletions test/test_postgres.go
@@ -0,0 +1,36 @@
package main

import (
"bytes"
"time"

c "github.com/flynn/flynn/Godeps/_workspace/src/github.com/flynn/go-check"
"github.com/flynn/flynn/pkg/exec"
)

type PostgresSuite struct {
Helper
}

var _ = c.ConcurrentSuite(&PostgresSuite{})

// Check postgres config to avoid regressing on https://github.com/flynn/flynn/issues/101
func (s *PostgresSuite) TestSSLRenegotiationLimit(t *c.C) {
services, err := s.discoverdClient(t).Services("pg", 5*time.Second)
t.Assert(err, c.IsNil)

cmd := exec.Command(exec.DockerImage(imageURIs["postgresql"]),
"--tuples-only", "--command", "show ssl_renegotiation_limit;")
cmd.Entrypoint = []string{"psql"}
cmd.Env = map[string]string{
"PGDATABASE": "postgres",
"PGHOST": services[0].Host,
"PGPORT": services[0].Port,
"PGUSER": services[0].Attrs["username"],
"PGPASSWORD": services[0].Attrs["password"],
}

res, err := cmd.CombinedOutput()
t.Assert(err, c.IsNil)
t.Assert(string(bytes.TrimSpace(res)), c.Equals, "0")
}