Merge component 'engine' from git@github.com:moby/moby master
This commit is contained in:
@ -32,10 +32,10 @@
|
||||
# the case. Therefore, you don't have to disable it anymore.
|
||||
#
|
||||
|
||||
FROM golang:1.10.1 AS base
|
||||
FROM golang:1.10.2 AS base
|
||||
# FIXME(vdemeester) this is kept for other script depending on it to not fail right away
|
||||
# Remove this once the other scripts uses something else to detect the version
|
||||
ENV GO_VERSION 1.10.1
|
||||
ENV GO_VERSION 1.10.2
|
||||
# allow replacing httpredir or deb mirror
|
||||
ARG APT_MIRROR=deb.debian.org
|
||||
RUN sed -ri "s/(httpredir|deb).debian.org/$APT_MIRROR/g" /etc/apt/sources.list
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
## Step 1: Build tests
|
||||
FROM golang:1.10.1-alpine3.7 as builder
|
||||
FROM golang:1.10.2-alpine3.7 as builder
|
||||
|
||||
RUN apk add --update \
|
||||
bash \
|
||||
|
||||
@ -42,7 +42,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
# will need updating, to avoid errors. Ping #docker-maintainers on IRC
|
||||
# with a heads-up.
|
||||
# IMPORTANT: When updating this please note that stdlib archive/tar pkg is vendored
|
||||
ENV GO_VERSION 1.10.1
|
||||
ENV GO_VERSION 1.10.2
|
||||
RUN curl -fsSL "https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz" \
|
||||
| tar -xzC /usr/local
|
||||
ENV PATH /go/bin:/usr/local/go/bin:$PATH
|
||||
|
||||
@ -161,7 +161,7 @@ SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPref
|
||||
# Environment variable notes:
|
||||
# - GO_VERSION must be consistent with 'Dockerfile' used by Linux.
|
||||
# - FROM_DOCKERFILE is used for detection of building within a container.
|
||||
ENV GO_VERSION=1.10.1 `
|
||||
ENV GO_VERSION=1.10.2 `
|
||||
GIT_VERSION=2.11.1 `
|
||||
GOPATH=C:\go `
|
||||
FROM_DOCKERFILE=1
|
||||
|
||||
@ -18,6 +18,7 @@ import (
|
||||
"github.com/docker/docker/internal/test/request"
|
||||
"github.com/docker/docker/pkg/stdcopy"
|
||||
"github.com/go-check/check"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/websocket"
|
||||
)
|
||||
|
||||
@ -176,7 +177,6 @@ func (s *DockerSuite) TestPostContainersAttach(c *check.C) {
|
||||
expectTimeout(conn, br, "stdout")
|
||||
|
||||
// Test the client API
|
||||
// Make sure we don't see "hello" if Logs is false
|
||||
client, err := client.NewEnvClient()
|
||||
c.Assert(err, checker.IsNil)
|
||||
defer client.Close()
|
||||
@ -184,10 +184,13 @@ func (s *DockerSuite) TestPostContainersAttach(c *check.C) {
|
||||
cid, _ = dockerCmd(c, "run", "-di", "busybox", "/bin/sh", "-c", "echo hello; cat")
|
||||
cid = strings.TrimSpace(cid)
|
||||
|
||||
// Make sure we don't see "hello" if Logs is false
|
||||
attachOpts := types.ContainerAttachOptions{
|
||||
Stream: true,
|
||||
Stdin: true,
|
||||
Stdout: true,
|
||||
Stderr: true,
|
||||
Logs: false,
|
||||
}
|
||||
|
||||
resp, err := client.ContainerAttach(context.Background(), cid, attachOpts)
|
||||
@ -205,10 +208,15 @@ func (s *DockerSuite) TestPostContainersAttach(c *check.C) {
|
||||
_, err = resp.Conn.Write([]byte("success"))
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
actualStdout := new(bytes.Buffer)
|
||||
actualStderr := new(bytes.Buffer)
|
||||
stdcopy.StdCopy(actualStdout, actualStderr, resp.Reader)
|
||||
c.Assert(actualStdout.Bytes(), checker.DeepEquals, []byte("hello\nsuccess"), check.Commentf("Attach didn't return the expected data from stdout"))
|
||||
var outBuf, errBuf bytes.Buffer
|
||||
_, err = stdcopy.StdCopy(&outBuf, &errBuf, resp.Reader)
|
||||
if err != nil && errors.Cause(err).(net.Error).Timeout() {
|
||||
// ignore the timeout error as it is expected
|
||||
err = nil
|
||||
}
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(errBuf.String(), checker.Equals, "")
|
||||
c.Assert(outBuf.String(), checker.Equals, "hello\nsuccess")
|
||||
}
|
||||
|
||||
// SockRequestHijack creates a connection to specified host (with method, contenttype, …) and returns a hijacked connection
|
||||
|
||||
@ -136,6 +136,21 @@ func ServiceWithName(name string) ServiceSpecOpt {
|
||||
}
|
||||
}
|
||||
|
||||
// ServiceWithNetwork sets the network of the service
|
||||
func ServiceWithNetwork(network string) ServiceSpecOpt {
|
||||
return func(spec *swarmtypes.ServiceSpec) {
|
||||
spec.TaskTemplate.Networks = append(spec.TaskTemplate.Networks,
|
||||
swarmtypes.NetworkAttachmentConfig{Target: network})
|
||||
}
|
||||
}
|
||||
|
||||
// ServiceWithEndpoint sets the Endpoint of the service
|
||||
func ServiceWithEndpoint(endpoint *swarmtypes.EndpointSpec) ServiceSpecOpt {
|
||||
return func(spec *swarmtypes.ServiceSpec) {
|
||||
spec.EndpointSpec = endpoint
|
||||
}
|
||||
}
|
||||
|
||||
// GetRunningTasks gets the list of running tasks for a service
|
||||
func GetRunningTasks(t *testing.T, d *daemon.Daemon, serviceID string) []swarmtypes.Task {
|
||||
t.Helper()
|
||||
|
||||
@ -35,16 +35,13 @@ func TestInspectNetwork(t *testing.T) {
|
||||
|
||||
var instances uint64 = 4
|
||||
serviceName := "TestService"
|
||||
// FIXME(vdemeester) consolidate with swarm.CreateService
|
||||
serviceSpec := swarmServiceSpec(serviceName, instances)
|
||||
serviceSpec.TaskTemplate.Networks = append(serviceSpec.TaskTemplate.Networks, swarmtypes.NetworkAttachmentConfig{Target: overlayName})
|
||||
|
||||
serviceResp, err := client.ServiceCreate(context.Background(), serviceSpec, types.ServiceCreateOptions{
|
||||
QueryRegistry: false,
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
serviceID := swarm.CreateService(t, d,
|
||||
swarm.ServiceWithReplicas(instances),
|
||||
swarm.ServiceWithName(serviceName),
|
||||
swarm.ServiceWithNetwork(overlayName),
|
||||
)
|
||||
|
||||
serviceID := serviceResp.ID
|
||||
poll.WaitOn(t, serviceRunningTasksCount(client, serviceID, instances), swarm.ServicePoll)
|
||||
|
||||
_, _, err = client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
|
||||
@ -78,12 +75,12 @@ func TestInspectNetwork(t *testing.T) {
|
||||
poll.WaitOn(t, serviceIsRemoved(client, serviceID), swarm.ServicePoll)
|
||||
poll.WaitOn(t, noTasks(client), swarm.ServicePoll)
|
||||
|
||||
serviceResp, err = client.ServiceCreate(context.Background(), serviceSpec, types.ServiceCreateOptions{
|
||||
QueryRegistry: false,
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
serviceID2 := swarm.CreateService(t, d,
|
||||
swarm.ServiceWithReplicas(instances),
|
||||
swarm.ServiceWithName(serviceName),
|
||||
swarm.ServiceWithNetwork(overlayName),
|
||||
)
|
||||
|
||||
serviceID2 := serviceResp.ID
|
||||
poll.WaitOn(t, serviceRunningTasksCount(client, serviceID2, instances), swarm.ServicePoll)
|
||||
|
||||
err = client.ServiceRemove(context.Background(), serviceID2)
|
||||
@ -98,25 +95,6 @@ func TestInspectNetwork(t *testing.T) {
|
||||
poll.WaitOn(t, networkIsRemoved(client, overlayID), poll.WithTimeout(1*time.Minute), poll.WithDelay(10*time.Second))
|
||||
}
|
||||
|
||||
func swarmServiceSpec(name string, replicas uint64) swarmtypes.ServiceSpec {
|
||||
return swarmtypes.ServiceSpec{
|
||||
Annotations: swarmtypes.Annotations{
|
||||
Name: name,
|
||||
},
|
||||
TaskTemplate: swarmtypes.TaskSpec{
|
||||
ContainerSpec: &swarmtypes.ContainerSpec{
|
||||
Image: "busybox:latest",
|
||||
Command: []string{"/bin/top"},
|
||||
},
|
||||
},
|
||||
Mode: swarmtypes.ServiceMode{
|
||||
Replicated: &swarmtypes.ReplicatedService{
|
||||
Replicas: &replicas,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func serviceRunningTasksCount(client client.ServiceAPIClient, serviceID string, instances uint64) func(log poll.LogT) poll.Result {
|
||||
return func(log poll.LogT) poll.Result {
|
||||
filter := filters.NewArgs()
|
||||
|
||||
@ -202,18 +202,16 @@ func TestServiceWithPredefinedNetwork(t *testing.T) {
|
||||
hostName := "host"
|
||||
var instances uint64 = 1
|
||||
serviceName := "TestService"
|
||||
serviceSpec := swarmServiceSpec(serviceName, instances)
|
||||
serviceSpec.TaskTemplate.Networks = append(serviceSpec.TaskTemplate.Networks, swarmtypes.NetworkAttachmentConfig{Target: hostName})
|
||||
|
||||
serviceResp, err := client.ServiceCreate(context.Background(), serviceSpec, types.ServiceCreateOptions{
|
||||
QueryRegistry: false,
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
serviceID := swarm.CreateService(t, d,
|
||||
swarm.ServiceWithReplicas(instances),
|
||||
swarm.ServiceWithName(serviceName),
|
||||
swarm.ServiceWithNetwork(hostName),
|
||||
)
|
||||
|
||||
serviceID := serviceResp.ID
|
||||
poll.WaitOn(t, serviceRunningCount(client, serviceID, instances), swarm.ServicePoll)
|
||||
|
||||
_, _, err = client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
|
||||
_, _, err := client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
|
||||
err = client.ServiceRemove(context.Background(), serviceID)
|
||||
@ -232,26 +230,24 @@ func TestServiceRemoveKeepsIngressNetwork(t *testing.T) {
|
||||
poll.WaitOn(t, swarmIngressReady(client), swarm.NetworkPoll)
|
||||
|
||||
var instances uint64 = 1
|
||||
serviceSpec := swarmServiceSpec(t.Name()+"-service", instances)
|
||||
serviceSpec.EndpointSpec = &swarmtypes.EndpointSpec{
|
||||
Ports: []swarmtypes.PortConfig{
|
||||
{
|
||||
Protocol: swarmtypes.PortConfigProtocolTCP,
|
||||
TargetPort: 80,
|
||||
PublishMode: swarmtypes.PortConfigPublishModeIngress,
|
||||
|
||||
serviceID := swarm.CreateService(t, d,
|
||||
swarm.ServiceWithReplicas(instances),
|
||||
swarm.ServiceWithName(t.Name()+"-service"),
|
||||
swarm.ServiceWithEndpoint(&swarmtypes.EndpointSpec{
|
||||
Ports: []swarmtypes.PortConfig{
|
||||
{
|
||||
Protocol: swarmtypes.PortConfigProtocolTCP,
|
||||
TargetPort: 80,
|
||||
PublishMode: swarmtypes.PortConfigPublishModeIngress,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
||||
serviceResp, err := client.ServiceCreate(context.Background(), serviceSpec, types.ServiceCreateOptions{
|
||||
QueryRegistry: false,
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
|
||||
serviceID := serviceResp.ID
|
||||
poll.WaitOn(t, serviceRunningCount(client, serviceID, instances), swarm.ServicePoll)
|
||||
|
||||
_, _, err = client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
|
||||
_, _, err := client.ServiceInspectWithRaw(context.Background(), serviceID, types.ServiceInspectOptions{})
|
||||
assert.NilError(t, err)
|
||||
|
||||
err = client.ServiceRemove(context.Background(), serviceID)
|
||||
|
||||
Reference in New Issue
Block a user