Merge pull request #12304 from runcom/remove-job-logs

Remove job from logs
This commit is contained in:
Alexander Morozov
2015-04-13 08:38:46 -07:00
13 changed files with 151 additions and 197 deletions

View File

@@ -3,14 +3,15 @@ package main
import (
"bytes"
"encoding/json"
"github.com/docker/docker/api/types"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
"io"
"os/exec"
"strings"
"testing"
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
)
func TestContainerApiGetAll(t *testing.T) {
@@ -28,7 +29,7 @@ func TestContainerApiGetAll(t *testing.T) {
t.Fatalf("Error on container creation: %v, output: %q", err, out)
}
body, err := sockRequest("GET", "/containers/json?all=1", nil)
_, body, err := sockRequest("GET", "/containers/json?all=1", nil)
if err != nil {
t.Fatalf("GET all containers sockRequest failed: %v", err)
}
@@ -61,7 +62,7 @@ func TestContainerApiGetExport(t *testing.T) {
t.Fatalf("Error on container creation: %v, output: %q", err, out)
}
body, err := sockRequest("GET", "/containers/"+name+"/export", nil)
_, body, err := sockRequest("GET", "/containers/"+name+"/export", nil)
if err != nil {
t.Fatalf("GET containers/export sockRequest failed: %v", err)
}
@@ -98,7 +99,7 @@ func TestContainerApiGetChanges(t *testing.T) {
t.Fatalf("Error on container creation: %v, output: %q", err, out)
}
body, err := sockRequest("GET", "/containers/"+name+"/changes", nil)
_, body, err := sockRequest("GET", "/containers/"+name+"/changes", nil)
if err != nil {
t.Fatalf("GET containers/changes sockRequest failed: %v", err)
}
@@ -133,7 +134,7 @@ func TestContainerApiStartVolumeBinds(t *testing.T) {
"Volumes": map[string]struct{}{"/tmp": {}},
}
if _, err := sockRequest("POST", "/containers/create?name="+name, config); err != nil && !strings.Contains(err.Error(), "201 Created") {
if _, _, err := sockRequest("POST", "/containers/create?name="+name, config); err != nil && !strings.Contains(err.Error(), "201 Created") {
t.Fatal(err)
}
@@ -141,7 +142,7 @@ func TestContainerApiStartVolumeBinds(t *testing.T) {
config = map[string]interface{}{
"Binds": []string{bindPath + ":/tmp"},
}
if _, err := sockRequest("POST", "/containers/"+name+"/start", config); err != nil && !strings.Contains(err.Error(), "204 No Content") {
if _, _, err := sockRequest("POST", "/containers/"+name+"/start", config); err != nil && !strings.Contains(err.Error(), "204 No Content") {
t.Fatal(err)
}
@@ -166,7 +167,7 @@ func TestContainerApiStartDupVolumeBinds(t *testing.T) {
"Volumes": map[string]struct{}{"/tmp": {}},
}
if _, err := sockRequest("POST", "/containers/create?name="+name, config); err != nil && !strings.Contains(err.Error(), "201 Created") {
if _, _, err := sockRequest("POST", "/containers/create?name="+name, config); err != nil && !strings.Contains(err.Error(), "201 Created") {
t.Fatal(err)
}
@@ -176,7 +177,7 @@ func TestContainerApiStartDupVolumeBinds(t *testing.T) {
config = map[string]interface{}{
"Binds": []string{bindPath1 + ":/tmp", bindPath2 + ":/tmp"},
}
if body, err := sockRequest("POST", "/containers/"+name+"/start", config); err == nil {
if _, body, err := sockRequest("POST", "/containers/"+name+"/start", config); err == nil {
t.Fatal("expected container start to fail when duplicate volume binds to same container path")
} else {
if !strings.Contains(string(body), "Duplicate volume") {
@@ -201,14 +202,14 @@ func TestContainerApiStartVolumesFrom(t *testing.T) {
"Volumes": map[string]struct{}{volPath: {}},
}
if _, err := sockRequest("POST", "/containers/create?name="+name, config); err != nil && !strings.Contains(err.Error(), "201 Created") {
if _, _, err := sockRequest("POST", "/containers/create?name="+name, config); err != nil && !strings.Contains(err.Error(), "201 Created") {
t.Fatal(err)
}
config = map[string]interface{}{
"VolumesFrom": []string{volName},
}
if _, err := sockRequest("POST", "/containers/"+name+"/start", config); err != nil && !strings.Contains(err.Error(), "204 No Content") {
if _, _, err := sockRequest("POST", "/containers/"+name+"/start", config); err != nil && !strings.Contains(err.Error(), "204 No Content") {
t.Fatal(err)
}
@@ -245,7 +246,7 @@ func TestVolumesFromHasPriority(t *testing.T) {
"Volumes": map[string]struct{}{volPath: {}},
}
if _, err := sockRequest("POST", "/containers/create?name="+name, config); err != nil && !strings.Contains(err.Error(), "201 Created") {
if _, _, err := sockRequest("POST", "/containers/create?name="+name, config); err != nil && !strings.Contains(err.Error(), "201 Created") {
t.Fatal(err)
}
@@ -254,7 +255,7 @@ func TestVolumesFromHasPriority(t *testing.T) {
"VolumesFrom": []string{volName},
"Binds": []string{bindPath + ":/tmp"},
}
if _, err := sockRequest("POST", "/containers/"+name+"/start", config); err != nil && !strings.Contains(err.Error(), "204 No Content") {
if _, _, err := sockRequest("POST", "/containers/"+name+"/start", config); err != nil && !strings.Contains(err.Error(), "204 No Content") {
t.Fatal(err)
}
@@ -290,7 +291,7 @@ func TestGetContainerStats(t *testing.T) {
}
bc := make(chan b, 1)
go func() {
body, err := sockRequest("GET", "/containers/"+name+"/stats", nil)
_, body, err := sockRequest("GET", "/containers/"+name+"/stats", nil)
bc <- b{body, err}
}()
@@ -334,7 +335,7 @@ func TestGetStoppedContainerStats(t *testing.T) {
go func() {
// We'll never get return for GET stats from sockRequest as of now,
// just send request and see if panic or error would happen on daemon side.
_, err := sockRequest("GET", "/containers/"+name+"/stats", nil)
_, _, err := sockRequest("GET", "/containers/"+name+"/stats", nil)
if err != nil {
t.Fatal(err)
}
@@ -367,7 +368,7 @@ func TestBuildApiDockerfilePath(t *testing.T) {
t.Fatalf("failed to close tar archive: %v", err)
}
out, err := sockRequestRaw("POST", "/build?dockerfile=../Dockerfile", buffer, "application/x-tar")
_, out, err := sockRequestRaw("POST", "/build?dockerfile=../Dockerfile", buffer, "application/x-tar")
if err == nil {
t.Fatalf("Build was supposed to fail: %s", out)
}
@@ -391,7 +392,7 @@ RUN find /tmp/`,
}
defer server.Close()
buf, err := sockRequestRaw("POST", "/build?dockerfile=baz&remote="+server.URL()+"/testD", nil, "application/json")
_, buf, err := sockRequestRaw("POST", "/build?dockerfile=baz&remote="+server.URL()+"/testD", nil, "application/json")
if err != nil {
t.Fatalf("Build failed: %s", err)
}
@@ -417,7 +418,7 @@ RUN echo from dockerfile`,
}
defer git.Close()
buf, err := sockRequestRaw("POST", "/build?remote="+git.RepoURL, nil, "application/json")
_, buf, err := sockRequestRaw("POST", "/build?remote="+git.RepoURL, nil, "application/json")
if err != nil {
t.Fatalf("Build failed: %s\n%q", err, buf)
}
@@ -443,7 +444,7 @@ RUN echo from Dockerfile`,
defer git.Close()
// Make sure it tries to 'dockerfile' query param value
buf, err := sockRequestRaw("POST", "/build?dockerfile=baz&remote="+git.RepoURL, nil, "application/json")
_, buf, err := sockRequestRaw("POST", "/build?dockerfile=baz&remote="+git.RepoURL, nil, "application/json")
if err != nil {
t.Fatalf("Build failed: %s\n%q", err, buf)
}
@@ -470,7 +471,7 @@ RUN echo from dockerfile`,
defer git.Close()
// Make sure it tries to 'dockerfile' query param value
buf, err := sockRequestRaw("POST", "/build?remote="+git.RepoURL, nil, "application/json")
_, buf, err := sockRequestRaw("POST", "/build?remote="+git.RepoURL, nil, "application/json")
if err != nil {
t.Fatalf("Build failed: %s", err)
}
@@ -501,7 +502,7 @@ func TestBuildApiDockerfileSymlink(t *testing.T) {
t.Fatalf("failed to close tar archive: %v", err)
}
out, err := sockRequestRaw("POST", "/build", buffer, "application/x-tar")
_, out, err := sockRequestRaw("POST", "/build", buffer, "application/x-tar")
if err == nil {
t.Fatalf("Build was supposed to fail: %s", out)
}
@@ -537,7 +538,7 @@ func TestPostContainerBindNormalVolume(t *testing.T) {
}
bindSpec := map[string][]string{"Binds": {fooDir + ":/foo"}}
_, err = sockRequest("POST", "/containers/two/start", bindSpec)
_, _, err = sockRequest("POST", "/containers/two/start", bindSpec)
if err != nil && !strings.Contains(err.Error(), "204 No Content") {
t.Fatal(err)
}
@@ -565,7 +566,7 @@ func TestContainerApiPause(t *testing.T) {
}
ContainerID := strings.TrimSpace(out)
if _, err = sockRequest("POST", "/containers/"+ContainerID+"/pause", nil); err != nil && !strings.Contains(err.Error(), "204 No Content") {
if _, _, err = sockRequest("POST", "/containers/"+ContainerID+"/pause", nil); err != nil && !strings.Contains(err.Error(), "204 No Content") {
t.Fatalf("POST a container pause: sockRequest failed: %v", err)
}
@@ -579,7 +580,7 @@ func TestContainerApiPause(t *testing.T) {
t.Fatalf("there should be one paused container and not %d", len(pausedContainers))
}
if _, err = sockRequest("POST", "/containers/"+ContainerID+"/unpause", nil); err != nil && !strings.Contains(err.Error(), "204 No Content") {
if _, _, err = sockRequest("POST", "/containers/"+ContainerID+"/unpause", nil); err != nil && !strings.Contains(err.Error(), "204 No Content") {
t.Fatalf("POST a container pause: sockRequest failed: %v", err)
}