Browse code

Moved last build tests to integration-cli

Also removed skipped tests on "viz" and "tree" because they
blocked integration/buildfile_test.go removing.

Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)

LK4D4 authored on 2014/07/06 20:36:34
Showing 3 changed files
... ...
@@ -1564,3 +1564,170 @@ func TestDockerignoringDockerfile(t *testing.T) {
1564 1564
 	}
1565 1565
 	logDone("build - test .dockerignore of Dockerfile")
1566 1566
 }
1567
+
1568
+func TestBuildLineBreak(t *testing.T) {
1569
+	name := "testbuildlinebreak"
1570
+	defer deleteImages(name)
1571
+	_, err := buildImage(name,
1572
+		`FROM  busybox
1573
+RUN    sh -c 'echo root:testpass \
1574
+	> /tmp/passwd'
1575
+RUN    mkdir -p /var/run/sshd
1576
+RUN    [ "$(cat /tmp/passwd)" = "root:testpass" ]
1577
+RUN    [ "$(ls -d /var/run/sshd)" = "/var/run/sshd" ]`,
1578
+		true)
1579
+	if err != nil {
1580
+		t.Fatal(err)
1581
+	}
1582
+	logDone("build - line break with \\")
1583
+}
1584
+
1585
+func TestBuildEOLInLine(t *testing.T) {
1586
+	name := "testbuildeolinline"
1587
+	defer deleteImages(name)
1588
+	_, err := buildImage(name,
1589
+		`FROM   busybox
1590
+RUN    sh -c 'echo root:testpass > /tmp/passwd'
1591
+RUN    echo "foo \n bar"; echo "baz"
1592
+RUN    mkdir -p /var/run/sshd
1593
+RUN    [ "$(cat /tmp/passwd)" = "root:testpass" ]
1594
+RUN    [ "$(ls -d /var/run/sshd)" = "/var/run/sshd" ]`,
1595
+		true)
1596
+	if err != nil {
1597
+		t.Fatal(err)
1598
+	}
1599
+	logDone("build - end of line in dockerfile instruction")
1600
+}
1601
+
1602
+func TestBuildCommentsShebangs(t *testing.T) {
1603
+	name := "testbuildcomments"
1604
+	defer deleteImages(name)
1605
+	_, err := buildImage(name,
1606
+		`FROM busybox
1607
+# This is an ordinary comment.
1608
+RUN { echo '#!/bin/sh'; echo 'echo hello world'; } > /hello.sh
1609
+RUN [ ! -x /hello.sh ]
1610
+# comment with line break \
1611
+RUN chmod +x /hello.sh
1612
+RUN [ -x /hello.sh ]
1613
+RUN [ "$(cat /hello.sh)" = $'#!/bin/sh\necho hello world' ]
1614
+RUN [ "$(/hello.sh)" = "hello world" ]`,
1615
+		true)
1616
+	if err != nil {
1617
+		t.Fatal(err)
1618
+	}
1619
+	logDone("build - comments and shebangs")
1620
+}
1621
+
1622
+func TestBuildUsersAndGroups(t *testing.T) {
1623
+	name := "testbuildusers"
1624
+	defer deleteImages(name)
1625
+	_, err := buildImage(name,
1626
+		`FROM busybox
1627
+
1628
+# Make sure our defaults work
1629
+RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)" = '0:0/root:root' ]
1630
+
1631
+# TODO decide if "args.user = strconv.Itoa(syscall.Getuid())" is acceptable behavior for changeUser in sysvinit instead of "return nil" when "USER" isn't specified (so that we get the proper group list even if that is the empty list, even in the default case of not supplying an explicit USER to run as, which implies USER 0)
1632
+USER root
1633
+RUN [ "$(id -G):$(id -Gn)" = '0 10:root wheel' ]
1634
+
1635
+# Setup dockerio user and group
1636
+RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd
1637
+RUN echo 'dockerio:x:1001:' >> /etc/group
1638
+
1639
+# Make sure we can switch to our user and all the information is exactly as we expect it to be
1640
+USER dockerio
1641
+RUN id -G
1642
+RUN id -Gn
1643
+RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1001:1001/dockerio:dockerio/1001:dockerio' ]
1644
+
1645
+# Switch back to root and double check that worked exactly as we might expect it to
1646
+USER root
1647
+RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '0:0/root:root/0 10:root wheel' ]
1648
+
1649
+# Add a "supplementary" group for our dockerio user
1650
+RUN echo 'supplementary:x:1002:dockerio' >> /etc/group
1651
+
1652
+# ... and then go verify that we get it like we expect
1653
+USER dockerio
1654
+RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1001:1001/dockerio:dockerio/1001 1002:dockerio supplementary' ]
1655
+USER 1001
1656
+RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1001:1001/dockerio:dockerio/1001 1002:dockerio supplementary' ]
1657
+
1658
+# super test the new "user:group" syntax
1659
+USER dockerio:dockerio
1660
+RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1001:1001/dockerio:dockerio/1001:dockerio' ]
1661
+USER 1001:dockerio
1662
+RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1001:1001/dockerio:dockerio/1001:dockerio' ]
1663
+USER dockerio:1001
1664
+RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1001:1001/dockerio:dockerio/1001:dockerio' ]
1665
+USER 1001:1001
1666
+RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1001:1001/dockerio:dockerio/1001:dockerio' ]
1667
+USER dockerio:supplementary
1668
+RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1001:1002/dockerio:supplementary/1002:supplementary' ]
1669
+USER dockerio:1002
1670
+RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1001:1002/dockerio:supplementary/1002:supplementary' ]
1671
+USER 1001:supplementary
1672
+RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1001:1002/dockerio:supplementary/1002:supplementary' ]
1673
+USER 1001:1002
1674
+RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1001:1002/dockerio:supplementary/1002:supplementary' ]
1675
+
1676
+# make sure unknown uid/gid still works properly
1677
+USER 1042:1043
1678
+RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1042:1043/1042:1043/1043:1043' ]`,
1679
+		true)
1680
+	if err != nil {
1681
+		t.Fatal(err)
1682
+	}
1683
+	logDone("build - users and groups")
1684
+}
1685
+
1686
+func TestBuildEnvUsage(t *testing.T) {
1687
+	name := "testbuildenvusage"
1688
+	defer deleteImages(name)
1689
+	dockerfile := `FROM busybox
1690
+ENV    FOO /foo/baz
1691
+ENV    BAR /bar
1692
+ENV    BAZ $BAR
1693
+ENV    FOOPATH $PATH:$FOO
1694
+RUN    [ "$BAR" = "$BAZ" ]
1695
+RUN    [ "$FOOPATH" = "$PATH:/foo/baz" ]
1696
+ENV	   FROM hello/docker/world
1697
+ENV    TO /docker/world/hello
1698
+ADD    $FROM $TO
1699
+RUN    [ "$(cat $TO)" = "hello" ]`
1700
+	ctx, err := fakeContext(dockerfile, map[string]string{
1701
+		"hello/docker/world": "hello",
1702
+	})
1703
+	if err != nil {
1704
+		t.Fatal(err)
1705
+	}
1706
+	_, err = buildImageFromContext(name, ctx, true)
1707
+	if err != nil {
1708
+		t.Fatal(err)
1709
+	}
1710
+	logDone("build - environment variables usage")
1711
+}
1712
+
1713
+func TestBuildAddScript(t *testing.T) {
1714
+	name := "testbuildaddscript"
1715
+	defer deleteImages(name)
1716
+	dockerfile := `
1717
+FROM busybox
1718
+ADD test /test
1719
+RUN ["chmod","+x","/test"]
1720
+RUN ["/test"]
1721
+RUN [ "$(cat /testfile)" = 'test!' ]`
1722
+	ctx, err := fakeContext(dockerfile, map[string]string{
1723
+		"test": "#!/bin/sh\necho 'test!' > /testfile",
1724
+	})
1725
+	if err != nil {
1726
+		t.Fatal(err)
1727
+	}
1728
+	_, err = buildImageFromContext(name, ctx, true)
1729
+	if err != nil {
1730
+		t.Fatal(err)
1731
+	}
1732
+	logDone("build - add and run script")
1733
+}
1567 1734
deleted file mode 100644
... ...
@@ -1,414 +0,0 @@
1
-package docker
2
-
3
-import (
4
-	"bytes"
5
-	"encoding/json"
6
-	"fmt"
7
-	"io/ioutil"
8
-	"net"
9
-	"net/http"
10
-	"net/http/httptest"
11
-	"strings"
12
-	"testing"
13
-
14
-	"github.com/dotcloud/docker/archive"
15
-	"github.com/dotcloud/docker/engine"
16
-	"github.com/dotcloud/docker/image"
17
-	"github.com/dotcloud/docker/server"
18
-	"github.com/dotcloud/docker/utils"
19
-)
20
-
21
-// A testContextTemplate describes a build context and how to test it
22
-type testContextTemplate struct {
23
-	// Contents of the Dockerfile
24
-	dockerfile string
25
-	// Additional files in the context, eg [][2]string{"./passwd", "gordon"}
26
-	files [][2]string
27
-	// Additional remote files to host on a local HTTP server.
28
-	remoteFiles [][2]string
29
-}
30
-
31
-func (context testContextTemplate) Archive(dockerfile string, t *testing.T) archive.Archive {
32
-	input := []string{"Dockerfile", dockerfile}
33
-	for _, pair := range context.files {
34
-		input = append(input, pair[0], pair[1])
35
-	}
36
-	a, err := archive.Generate(input...)
37
-	if err != nil {
38
-		t.Fatal(err)
39
-	}
40
-	return a
41
-}
42
-
43
-// A table of all the contexts to build and test.
44
-// A new docker runtime will be created and torn down for each context.
45
-var testContexts = []testContextTemplate{
46
-	{
47
-		`
48
-from   {IMAGE}
49
-run    sh -c 'echo root:testpass > /tmp/passwd'
50
-run    mkdir -p /var/run/sshd
51
-run    [ "$(cat /tmp/passwd)" = "root:testpass" ]
52
-run    [ "$(ls -d /var/run/sshd)" = "/var/run/sshd" ]
53
-`,
54
-		nil,
55
-		nil,
56
-	},
57
-
58
-	// Exactly the same as above, except uses a line split with a \ to test
59
-	// multiline support.
60
-	{
61
-		`
62
-from   {IMAGE}
63
-run    sh -c 'echo root:testpass \
64
-	> /tmp/passwd'
65
-run    mkdir -p /var/run/sshd
66
-run    [ "$(cat /tmp/passwd)" = "root:testpass" ]
67
-run    [ "$(ls -d /var/run/sshd)" = "/var/run/sshd" ]
68
-`,
69
-		nil,
70
-		nil,
71
-	},
72
-
73
-	// Line containing literal "\n"
74
-	{
75
-		`
76
-from   {IMAGE}
77
-run    sh -c 'echo root:testpass > /tmp/passwd'
78
-run    echo "foo \n bar"; echo "baz"
79
-run    mkdir -p /var/run/sshd
80
-run    [ "$(cat /tmp/passwd)" = "root:testpass" ]
81
-run    [ "$(ls -d /var/run/sshd)" = "/var/run/sshd" ]
82
-`,
83
-		nil,
84
-		nil,
85
-	},
86
-	{
87
-		`
88
-from {IMAGE}
89
-add foo /usr/lib/bla/bar
90
-run [ "$(cat /usr/lib/bla/bar)" = 'hello' ]
91
-add http://{SERVERADDR}/baz /usr/lib/baz/quux
92
-run [ "$(cat /usr/lib/baz/quux)" = 'world!' ]
93
-`,
94
-		[][2]string{{"foo", "hello"}},
95
-		[][2]string{{"/baz", "world!"}},
96
-	},
97
-
98
-	{
99
-		`
100
-from {IMAGE}
101
-add f /
102
-run [ "$(cat /f)" = "hello" ]
103
-add f /abc
104
-run [ "$(cat /abc)" = "hello" ]
105
-add f /x/y/z
106
-run [ "$(cat /x/y/z)" = "hello" ]
107
-add f /x/y/d/
108
-run [ "$(cat /x/y/d/f)" = "hello" ]
109
-add d /
110
-run [ "$(cat /ga)" = "bu" ]
111
-add d /somewhere
112
-run [ "$(cat /somewhere/ga)" = "bu" ]
113
-add d /anotherplace/
114
-run [ "$(cat /anotherplace/ga)" = "bu" ]
115
-add d /somewheeeere/over/the/rainbooow
116
-run [ "$(cat /somewheeeere/over/the/rainbooow/ga)" = "bu" ]
117
-`,
118
-		[][2]string{
119
-			{"f", "hello"},
120
-			{"d/ga", "bu"},
121
-		},
122
-		nil,
123
-	},
124
-
125
-	{
126
-		`
127
-from {IMAGE}
128
-add http://{SERVERADDR}/x /a/b/c
129
-run [ "$(cat /a/b/c)" = "hello" ]
130
-add http://{SERVERADDR}/x?foo=bar /
131
-run [ "$(cat /x)" = "hello" ]
132
-add http://{SERVERADDR}/x /d/
133
-run [ "$(cat /d/x)" = "hello" ]
134
-add http://{SERVERADDR} /e
135
-run [ "$(cat /e)" = "blah" ]
136
-`,
137
-		nil,
138
-		[][2]string{{"/x", "hello"}, {"/", "blah"}},
139
-	},
140
-
141
-	// Comments, shebangs, and executability, oh my!
142
-	{
143
-		`
144
-FROM {IMAGE}
145
-# This is an ordinary comment.
146
-RUN { echo '#!/bin/sh'; echo 'echo hello world'; } > /hello.sh
147
-RUN [ ! -x /hello.sh ]
148
-RUN chmod +x /hello.sh
149
-RUN [ -x /hello.sh ]
150
-RUN [ "$(cat /hello.sh)" = $'#!/bin/sh\necho hello world' ]
151
-RUN [ "$(/hello.sh)" = "hello world" ]
152
-`,
153
-		nil,
154
-		nil,
155
-	},
156
-
157
-	// Users and groups
158
-	{
159
-		`
160
-FROM {IMAGE}
161
-
162
-# Make sure our defaults work
163
-RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)" = '0:0/root:root' ]
164
-
165
-# TODO decide if "args.user = strconv.Itoa(syscall.Getuid())" is acceptable behavior for changeUser in sysvinit instead of "return nil" when "USER" isn't specified (so that we get the proper group list even if that is the empty list, even in the default case of not supplying an explicit USER to run as, which implies USER 0)
166
-USER root
167
-RUN [ "$(id -G):$(id -Gn)" = '0:root' ]
168
-
169
-# Setup dockerio user and group
170
-RUN echo 'dockerio:x:1000:1000::/bin:/bin/false' >> /etc/passwd
171
-RUN echo 'dockerio:x:1000:' >> /etc/group
172
-
173
-# Make sure we can switch to our user and all the information is exactly as we expect it to be
174
-USER dockerio
175
-RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1000:1000/dockerio:dockerio/1000:dockerio' ]
176
-
177
-# Switch back to root and double check that worked exactly as we might expect it to
178
-USER root
179
-RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '0:0/root:root/0:root' ]
180
-
181
-# Add a "supplementary" group for our dockerio user
182
-RUN echo 'supplementary:x:1001:dockerio' >> /etc/group
183
-
184
-# ... and then go verify that we get it like we expect
185
-USER dockerio
186
-RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1000:1000/dockerio:dockerio/1000 1001:dockerio supplementary' ]
187
-USER 1000
188
-RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1000:1000/dockerio:dockerio/1000 1001:dockerio supplementary' ]
189
-
190
-# super test the new "user:group" syntax
191
-USER dockerio:dockerio
192
-RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1000:1000/dockerio:dockerio/1000:dockerio' ]
193
-USER 1000:dockerio
194
-RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1000:1000/dockerio:dockerio/1000:dockerio' ]
195
-USER dockerio:1000
196
-RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1000:1000/dockerio:dockerio/1000:dockerio' ]
197
-USER 1000:1000
198
-RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1000:1000/dockerio:dockerio/1000:dockerio' ]
199
-USER dockerio:supplementary
200
-RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1000:1001/dockerio:supplementary/1001:supplementary' ]
201
-USER dockerio:1001
202
-RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1000:1001/dockerio:supplementary/1001:supplementary' ]
203
-USER 1000:supplementary
204
-RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1000:1001/dockerio:supplementary/1001:supplementary' ]
205
-USER 1000:1001
206
-RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1000:1001/dockerio:supplementary/1001:supplementary' ]
207
-
208
-# make sure unknown uid/gid still works properly
209
-USER 1042:1043
210
-RUN [ "$(id -u):$(id -g)/$(id -un):$(id -gn)/$(id -G):$(id -Gn)" = '1042:1043/1042:1043/1043:1043' ]
211
-`,
212
-		nil,
213
-		nil,
214
-	},
215
-
216
-	// Environment variable
217
-	{
218
-		`
219
-from   {IMAGE}
220
-env    FOO BAR
221
-run    [ "$FOO" = "BAR" ]
222
-`,
223
-		nil,
224
-		nil,
225
-	},
226
-
227
-	// Environment overwriting
228
-	{
229
-		`
230
-from   {IMAGE}
231
-env    FOO BAR
232
-run    [ "$FOO" = "BAR" ]
233
-env    FOO BAZ
234
-run    [ "$FOO" = "BAZ" ]
235
-`,
236
-		nil,
237
-		nil,
238
-	},
239
-
240
-	{
241
-		`
242
-from {IMAGE}
243
-ENTRYPOINT /bin/echo
244
-CMD Hello world
245
-`,
246
-		nil,
247
-		nil,
248
-	},
249
-
250
-	{
251
-		`
252
-from {IMAGE}
253
-VOLUME /test
254
-CMD Hello world
255
-`,
256
-		nil,
257
-		nil,
258
-	},
259
-
260
-	{
261
-		`
262
-from {IMAGE}
263
-env    FOO /foo/baz
264
-env    BAR /bar
265
-env    BAZ $BAR
266
-env    FOOPATH $PATH:$FOO
267
-run    [ "$BAR" = "$BAZ" ]
268
-run    [ "$FOOPATH" = "$PATH:/foo/baz" ]
269
-`,
270
-		nil,
271
-		nil,
272
-	},
273
-
274
-	{
275
-		`
276
-from {IMAGE}
277
-env    FOO /bar
278
-env    TEST testdir
279
-env    BAZ /foobar
280
-add    testfile $BAZ/
281
-add    $TEST $FOO
282
-run    [ "$(cat /foobar/testfile)" = "test1" ]
283
-run    [ "$(cat /bar/withfile)" = "test2" ]
284
-`,
285
-		[][2]string{
286
-			{"testfile", "test1"},
287
-			{"testdir/withfile", "test2"},
288
-		},
289
-		nil,
290
-	},
291
-
292
-	// JSON!
293
-	{
294
-		`
295
-FROM {IMAGE}
296
-RUN ["/bin/echo","hello","world"]
297
-CMD ["/bin/true"]
298
-ENTRYPOINT ["/bin/echo","your command -->"]
299
-`,
300
-		nil,
301
-		nil,
302
-	},
303
-	{
304
-		`
305
-FROM {IMAGE}
306
-ADD test /test
307
-RUN ["chmod","+x","/test"]
308
-RUN ["/test"]
309
-RUN [ "$(cat /testfile)" = 'test!' ]
310
-`,
311
-		[][2]string{
312
-			{"test", "#!/bin/sh\necho 'test!' > /testfile"},
313
-		},
314
-		nil,
315
-	},
316
-	{
317
-		`
318
-FROM {IMAGE}
319
-# what \
320
-RUN mkdir /testing
321
-RUN touch /testing/other
322
-`,
323
-		nil,
324
-		nil,
325
-	},
326
-}
327
-
328
-// FIXME: test building with 2 successive overlapping ADD commands
329
-
330
-func constructDockerfile(template string, ip net.IP, port string) string {
331
-	serverAddr := fmt.Sprintf("%s:%s", ip, port)
332
-	replacer := strings.NewReplacer("{IMAGE}", unitTestImageID, "{SERVERADDR}", serverAddr)
333
-	return replacer.Replace(template)
334
-}
335
-
336
-func mkTestingFileServer(files [][2]string) (*httptest.Server, error) {
337
-	mux := http.NewServeMux()
338
-	for _, file := range files {
339
-		name, contents := file[0], file[1]
340
-		mux.HandleFunc(name, func(w http.ResponseWriter, r *http.Request) {
341
-			w.Write([]byte(contents))
342
-		})
343
-	}
344
-
345
-	// This is how httptest.NewServer sets up a net.Listener, except that our listener must accept remote
346
-	// connections (from the container).
347
-	listener, err := net.Listen("tcp", ":0")
348
-	if err != nil {
349
-		return nil, err
350
-	}
351
-
352
-	s := httptest.NewUnstartedServer(mux)
353
-	s.Listener = listener
354
-	s.Start()
355
-	return s, nil
356
-}
357
-
358
-func TestBuild(t *testing.T) {
359
-	for _, ctx := range testContexts {
360
-		_, err := buildImage(ctx, t, nil, true)
361
-		if err != nil {
362
-			t.Fatal(err)
363
-		}
364
-	}
365
-}
366
-
367
-func buildImage(context testContextTemplate, t *testing.T, eng *engine.Engine, useCache bool) (*image.Image, error) {
368
-	if eng == nil {
369
-		eng = NewTestEngine(t)
370
-		runtime := mkDaemonFromEngine(eng, t)
371
-		// FIXME: we might not need runtime, why not simply nuke
372
-		// the engine?
373
-		defer nuke(runtime)
374
-	}
375
-	srv := mkServerFromEngine(eng, t)
376
-
377
-	httpServer, err := mkTestingFileServer(context.remoteFiles)
378
-	if err != nil {
379
-		t.Fatal(err)
380
-	}
381
-	defer httpServer.Close()
382
-
383
-	idx := strings.LastIndex(httpServer.URL, ":")
384
-	if idx < 0 {
385
-		t.Fatalf("could not get port from test http server address %s", httpServer.URL)
386
-	}
387
-	port := httpServer.URL[idx+1:]
388
-
389
-	iIP := eng.Hack_GetGlobalVar("httpapi.bridgeIP")
390
-	if iIP == nil {
391
-		t.Fatal("Legacy bridgeIP field not set in engine")
392
-	}
393
-	ip, ok := iIP.(net.IP)
394
-	if !ok {
395
-		panic("Legacy bridgeIP field in engine does not cast to net.IP")
396
-	}
397
-	dockerfile := constructDockerfile(context.dockerfile, ip, port)
398
-
399
-	buildfile := server.NewBuildFile(srv, ioutil.Discard, ioutil.Discard, false, useCache, false, false, ioutil.Discard, utils.NewStreamFormatter(false), nil, nil)
400
-	id, err := buildfile.Build(context.Archive(dockerfile, t))
401
-	if err != nil {
402
-		return nil, err
403
-	}
404
-
405
-	job := eng.Job("image_inspect", id)
406
-	buffer := bytes.NewBuffer(nil)
407
-	image := &image.Image{}
408
-	job.Stdout.Add(buffer)
409
-	if err := job.Run(); err != nil {
410
-		return nil, err
411
-	}
412
-	err = json.NewDecoder(buffer).Decode(image)
413
-	return image, err
414
-}
... ...
@@ -7,7 +7,6 @@ import (
7 7
 	"io/ioutil"
8 8
 	"os"
9 9
 	"path"
10
-	"regexp"
11 10
 	"strings"
12 11
 	"testing"
13 12
 	"time"
... ...
@@ -15,7 +14,6 @@ import (
15 15
 	"github.com/dotcloud/docker/api/client"
16 16
 	"github.com/dotcloud/docker/daemon"
17 17
 	"github.com/dotcloud/docker/engine"
18
-	"github.com/dotcloud/docker/image"
19 18
 	"github.com/dotcloud/docker/pkg/term"
20 19
 	"github.com/dotcloud/docker/utils"
21 20
 )
... ...
@@ -604,132 +602,6 @@ func TestRunErrorBindNonExistingSource(t *testing.T) {
604 604
 	})
605 605
 }
606 606
 
607
-func TestImagesViz(t *testing.T) {
608
-	t.Skip("Image viz is deprecated")
609
-	stdout, stdoutPipe := io.Pipe()
610
-
611
-	cli := client.NewDockerCli(nil, stdoutPipe, ioutil.Discard, testDaemonProto, testDaemonAddr, nil)
612
-	defer cleanup(globalEngine, t)
613
-
614
-	image := buildTestImages(t, globalEngine)
615
-
616
-	c := make(chan struct{})
617
-	go func() {
618
-		defer close(c)
619
-		if err := cli.CmdImages("--viz"); err != nil {
620
-			t.Fatal(err)
621
-		}
622
-		stdoutPipe.Close()
623
-	}()
624
-
625
-	setTimeout(t, "Reading command output time out", 2*time.Second, func() {
626
-		cmdOutputBytes, err := ioutil.ReadAll(bufio.NewReader(stdout))
627
-		if err != nil {
628
-			t.Fatal(err)
629
-		}
630
-		cmdOutput := string(cmdOutputBytes)
631
-
632
-		regexpStrings := []string{
633
-			"digraph docker {",
634
-			fmt.Sprintf("base -> \"%s\" \\[style=invis]", unitTestImageIDShort),
635
-			fmt.Sprintf("label=\"%s\\\\n%s:latest\"", unitTestImageIDShort, unitTestImageName),
636
-			fmt.Sprintf("label=\"%s\\\\n%s:%s\"", utils.TruncateID(image.ID), "test", "latest"),
637
-			"base \\[style=invisible]",
638
-		}
639
-
640
-		compiledRegexps := []*regexp.Regexp{}
641
-		for _, regexpString := range regexpStrings {
642
-			regexp, err := regexp.Compile(regexpString)
643
-			if err != nil {
644
-				fmt.Println("Error in regex string: ", err)
645
-				return
646
-			}
647
-			compiledRegexps = append(compiledRegexps, regexp)
648
-		}
649
-
650
-		for _, regexp := range compiledRegexps {
651
-			if !regexp.MatchString(cmdOutput) {
652
-				t.Fatalf("images --viz content '%s' did not match regexp '%s'", cmdOutput, regexp)
653
-			}
654
-		}
655
-	})
656
-}
657
-
658
-func TestImagesTree(t *testing.T) {
659
-	t.Skip("Image tree is deprecated")
660
-	stdout, stdoutPipe := io.Pipe()
661
-
662
-	cli := client.NewDockerCli(nil, stdoutPipe, ioutil.Discard, testDaemonProto, testDaemonAddr, nil)
663
-	defer cleanup(globalEngine, t)
664
-
665
-	image := buildTestImages(t, globalEngine)
666
-
667
-	c := make(chan struct{})
668
-	go func() {
669
-		defer close(c)
670
-		if err := cli.CmdImages("--tree"); err != nil {
671
-			t.Fatal(err)
672
-		}
673
-		stdoutPipe.Close()
674
-	}()
675
-
676
-	setTimeout(t, "Reading command output time out", 2*time.Second, func() {
677
-		cmdOutputBytes, err := ioutil.ReadAll(bufio.NewReader(stdout))
678
-		if err != nil {
679
-			t.Fatal(err)
680
-		}
681
-		cmdOutput := string(cmdOutputBytes)
682
-		regexpStrings := []string{
683
-			fmt.Sprintf("└─%s Virtual Size: \\d+.\\d+ MB Tags: %s:latest", unitTestImageIDShort, unitTestImageName),
684
-			"(?m)   └─[0-9a-f]+.*",
685
-			"(?m)    └─[0-9a-f]+.*",
686
-			"(?m)      └─[0-9a-f]+.*",
687
-			fmt.Sprintf("(?m)^        └─%s Virtual Size: \\d+.\\d+ MB Tags: test:latest", utils.TruncateID(image.ID)),
688
-		}
689
-
690
-		compiledRegexps := []*regexp.Regexp{}
691
-		for _, regexpString := range regexpStrings {
692
-			regexp, err := regexp.Compile(regexpString)
693
-			if err != nil {
694
-				fmt.Println("Error in regex string: ", err)
695
-				return
696
-			}
697
-			compiledRegexps = append(compiledRegexps, regexp)
698
-		}
699
-
700
-		for _, regexp := range compiledRegexps {
701
-			if !regexp.MatchString(cmdOutput) {
702
-				t.Fatalf("images --tree content '%s' did not match regexp '%s'", cmdOutput, regexp)
703
-			}
704
-		}
705
-	})
706
-}
707
-
708
-func buildTestImages(t *testing.T, eng *engine.Engine) *image.Image {
709
-
710
-	var testBuilder = testContextTemplate{
711
-		`
712
-from   {IMAGE}
713
-run    sh -c 'echo root:testpass > /tmp/passwd'
714
-run    mkdir -p /var/run/sshd
715
-run    [ "$(cat /tmp/passwd)" = "root:testpass" ]
716
-run    [ "$(ls -d /var/run/sshd)" = "/var/run/sshd" ]
717
-`,
718
-		nil,
719
-		nil,
720
-	}
721
-	image, err := buildImage(testBuilder, t, eng, true)
722
-	if err != nil {
723
-		t.Fatal(err)
724
-	}
725
-
726
-	if err := eng.Job("tag", image.ID, "test").Run(); err != nil {
727
-		t.Fatal(err)
728
-	}
729
-
730
-	return image
731
-}
732
-
733 607
 // #2098 - Docker cidFiles only contain short version of the containerId
734 608
 //sudo docker run --cidfile /tmp/docker_test.cid ubuntu echo "test"
735 609
 // TestRunCidFile tests that run --cidfile returns the longid