Skip to content

Commit a72e8e7

Browse files
lhaskinssykesm
authored andcommitted
[FAB-9659] Update fsouza/go-dockerclient to v1.0.0
This supports Docker API version 1.23 and contains network function needed by the e2e tests. Change-Id: I524cc14050170905ee14f499bfc870cea5de00e6 Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
1 parent db0c395 commit a72e8e7

File tree

586 files changed

+47162
-98932
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

586 files changed

+47162
-98932
lines changed

Gopkg.lock

+120-25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ignored = [
2929

3030
[[constraint]]
3131
name = "github.com/fsouza/go-dockerclient"
32-
version = "docker-1.9/go-1.4"
32+
version = "1.0.0"
3333

3434
[[constraint]]
3535
branch = "master"

integration/runner/couchdb.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func (c *CouchDB) Run(sigCh <-chan os.Signal, ready chan<- struct{}) error {
9595
}
9696

9797
hostConfig := &docker.HostConfig{
98+
AutoRemove: true,
9899
PortBindings: map[docker.Port][]docker.PortBinding{
99100
c.ContainerPort: []docker.PortBinding{{
100101
HostIP: c.HostIP,
@@ -134,10 +135,9 @@ func (c *CouchDB) Run(sigCh <-chan os.Signal, ready chan<- struct{}) error {
134135
c.ContainerPort.Port(),
135136
)
136137

137-
err = c.streamLogs()
138-
if err != nil {
139-
return err
140-
}
138+
streamCtx, streamCancel := context.WithCancel(context.Background())
139+
defer streamCancel()
140+
go c.streamLogs(streamCtx)
141141

142142
containerExit := c.wait()
143143
ctx, cancel := context.WithTimeout(context.Background(), c.StartTimeout)
@@ -211,20 +211,25 @@ func (c *CouchDB) wait() <-chan error {
211211
return exitCh
212212
}
213213

214-
func (c *CouchDB) streamLogs() error {
214+
func (c *CouchDB) streamLogs(ctx context.Context) {
215215
if c.ErrorStream == nil && c.OutputStream == nil {
216-
return nil
216+
return
217217
}
218218

219219
logOptions := docker.LogsOptions{
220+
Context: ctx,
220221
Container: c.containerID,
222+
Follow: true,
221223
ErrorStream: c.ErrorStream,
222224
OutputStream: c.OutputStream,
223225
Stderr: c.ErrorStream != nil,
224226
Stdout: c.OutputStream != nil,
225227
}
226228

227-
return c.Client.Logs(logOptions)
229+
err := c.Client.Logs(logOptions)
230+
if err != nil {
231+
fmt.Fprintf(c.ErrorStream, "log stream ended with error: %s", err)
232+
}
228233
}
229234

230235
// Address returns the address successfully used by the readiness check.
@@ -275,10 +280,5 @@ func (c *CouchDB) Stop() error {
275280
return err
276281
}
277282

278-
return c.Client.RemoveContainer(
279-
docker.RemoveContainerOptions{
280-
ID: c.containerID,
281-
Force: true,
282-
},
283-
)
283+
return nil
284284
}

integration/runner/couchdb_test.go

+14-27
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ var _ = Describe("CouchDB Runner", func() {
4040
stopResponse string
4141
waitStatus int
4242
waitResponse string
43-
deleteStatus int
44-
deleteResponse string
4543

4644
waitChan chan struct{}
4745
client *docker.Client
@@ -70,6 +68,13 @@ var _ = Describe("CouchDB Runner", func() {
7068
dockerServer = ghttp.NewServer()
7169
dockerServer.Writer = GinkgoWriter
7270

71+
dockerServer.RouteToHandler("GET", "/version", ghttp.CombineHandlers(
72+
ghttp.VerifyRequest("GET", "/version"),
73+
ghttp.RespondWithJSONEncoded(http.StatusOK, map[string]string{
74+
"ApiVersion": "1.29",
75+
}),
76+
))
77+
7378
createStatus = http.StatusCreated
7479
createResponse = &docker.Container{
7580
ID: "container-id",
@@ -104,7 +109,7 @@ var _ = Describe("CouchDB Runner", func() {
104109

105110
logsStatus = http.StatusOK
106111
dockerServer.RouteToHandler("GET", "/containers/container-id/logs", ghttp.CombineHandlers(
107-
ghttp.VerifyRequest("GET", "/containers/container-id/logs", "stderr=1&stdout=1&tail=all"),
112+
ghttp.VerifyRequest("GET", "/containers/container-id/logs", "follow=1&stderr=1&stdout=1&tail=all"),
108113
ghttp.RespondWithPtr(&logsStatus, &logsResponse),
109114
))
110115

@@ -125,12 +130,6 @@ var _ = Describe("CouchDB Runner", func() {
125130
func(w http.ResponseWriter, r *http.Request) { <-waitChan },
126131
))
127132

128-
deleteStatus = http.StatusNoContent
129-
dockerServer.RouteToHandler("DELETE", "/containers/container-id", ghttp.CombineHandlers(
130-
ghttp.VerifyRequest("DELETE", "/containers/container-id", "force=1"),
131-
ghttp.RespondWithPtr(&deleteStatus, &deleteResponse),
132-
))
133-
134133
client, err = docker.NewClient(dockerServer.URL())
135134
Expect(err).NotTo(HaveOccurred())
136135

@@ -203,7 +202,7 @@ var _ = Describe("CouchDB Runner", func() {
203202
It("can be started and stopped with ifrit", func() {
204203
process = ifrit.Invoke(couchDB)
205204
Eventually(process.Ready()).Should(BeClosed())
206-
Expect(dockerServer.ReceivedRequests()).To(HaveLen(5))
205+
Expect(dockerServer.ReceivedRequests()).To(HaveLen(6))
207206

208207
process.Signal(syscall.SIGTERM)
209208
Eventually(process.Wait()).Should(Receive())
@@ -214,7 +213,7 @@ var _ = Describe("CouchDB Runner", func() {
214213
It("can be started and stopped without ifrit", func() {
215214
err := couchDB.Start()
216215
Expect(err).NotTo(HaveOccurred())
217-
Expect(dockerServer.ReceivedRequests()).To(HaveLen(5))
216+
Expect(dockerServer.ReceivedRequests()).To(HaveLen(6))
218217

219218
err = couchDB.Stop()
220219
Expect(err).NotTo(HaveOccurred())
@@ -232,6 +231,7 @@ var _ = Describe("CouchDB Runner", func() {
232231
Image: "hyperledger/fabric-couchdb:latest",
233232
},
234233
HostConfig: &docker.HostConfig{
234+
AutoRemove: true,
235235
PortBindings: map[docker.Port][]docker.PortBinding{
236236
docker.Port("5984/tcp"): []docker.PortBinding{{
237237
HostIP: "127.0.0.1",
@@ -336,9 +336,10 @@ var _ = Describe("CouchDB Runner", func() {
336336
logsStatus = http.StatusConflict
337337
})
338338

339-
It("returns an error", func() {
339+
It("it records the error", func() {
340340
err := couchDB.Start()
341-
Expect(err).To(HaveOccurred())
341+
Expect(err).NotTo(HaveOccurred())
342+
Eventually(errBuffer).Should(gbytes.Say(`log stream ended with error: API error`))
342343
})
343344
})
344345

@@ -399,20 +400,6 @@ var _ = Describe("CouchDB Runner", func() {
399400
})
400401
})
401402

402-
Context("when removing the container fails", func() {
403-
BeforeEach(func() {
404-
deleteStatus = http.StatusNotFound
405-
})
406-
407-
It("returns an error", func() {
408-
err := couchDB.Start()
409-
Expect(err).NotTo(HaveOccurred())
410-
411-
err = couchDB.Stop()
412-
Expect(err).To(HaveOccurred())
413-
})
414-
})
415-
416403
Context("when startup times out", func() {
417404
BeforeEach(func() {
418405
couchDB.StartTimeout = 50 * time.Millisecond

0 commit comments

Comments
 (0)