2828package main
2929
3030import (
31- "fmt"
32- "io/ioutil"
33- "log"
3431 "os"
35- "os/exec"
3632 "path/filepath"
37- "strings"
3833 "testing"
3934 "time"
4035
@@ -65,7 +60,7 @@ func (s *E2eSuite) TestContextDefault() {
6560 output := s .NewDockerCommand ("context" , "show" ).ExecOrDie ()
6661 Expect (output ).To (ContainSubstring ("default" ))
6762 output = s .NewCommand ("docker" , "context" , "ls" ).ExecOrDie ()
68- golden .Assert (s .T (), output , "ls-out-default.golden" )
63+ golden .Assert (s .T (), output , GoldenFile ( "ls-out-default" ) )
6964 })
7065}
7166
@@ -106,7 +101,7 @@ func (s *E2eSuite) TestSetupError() {
106101 It ("should display an error if cannot shell out to docker-classic" , func () {
107102 err := os .Setenv ("PATH" , s .BinDir )
108103 Expect (err ).To (BeNil ())
109- err = os .Remove (filepath .Join (s .BinDir , "docker-classic" ))
104+ err = os .Remove (filepath .Join (s .BinDir , DockerClassicExecutable () ))
110105 Expect (err ).To (BeNil ())
111106 output , err := s .NewDockerCommand ("ps" ).Exec ()
112107 Expect (output ).To (ContainSubstring ("docker-classic" ))
@@ -115,37 +110,6 @@ func (s *E2eSuite) TestSetupError() {
115110 })
116111}
117112
118- func (s * E2eSuite ) TestKillChildOnCancel () {
119- It ("should kill docker-classic if parent command is cancelled" , func () {
120- out := s .ListProcessesCommand ().ExecOrDie ()
121- Expect (out ).NotTo (ContainSubstring ("docker-classic" ))
122-
123- dir := s .ConfigDir
124- Expect (ioutil .WriteFile (filepath .Join (dir , "Dockerfile" ), []byte (`FROM alpine:3.10
125- RUN sleep 100` ), 0644 )).To (Succeed ())
126- shutdown := make (chan time.Time )
127- errs := make (chan error )
128- ctx := s .NewDockerCommand ("build" , "--no-cache" , "-t" , "test-sleep-image" , "." ).WithinDirectory (dir ).WithTimeout (shutdown )
129- go func () {
130- _ , err := ctx .Exec ()
131- errs <- err
132- }()
133- err := WaitFor (time .Second , 10 * time .Second , errs , func () bool {
134- out := s .ListProcessesCommand ().ExecOrDie ()
135- return strings .Contains (out , "docker-classic" )
136- })
137- Expect (err ).NotTo (HaveOccurred ())
138- log .Println ("Killing docker process" )
139-
140- close (shutdown )
141- err = WaitFor (time .Second , 12 * time .Second , nil , func () bool {
142- out := s .ListProcessesCommand ().ExecOrDie ()
143- return ! strings .Contains (out , "docker-classic" )
144- })
145- Expect (err ).NotTo (HaveOccurred ())
146- })
147- }
148-
149113func (s * E2eSuite ) TestLegacy () {
150114 It ("should list all legacy commands" , func () {
151115 output := s .NewDockerCommand ("--help" ).ExecOrDie ()
@@ -159,7 +123,7 @@ func (s *E2eSuite) TestLegacy() {
159123
160124 It ("should run local container in less than 10 secs" , func () {
161125 s .NewDockerCommand ("pull" , "hello-world" ).ExecOrDie ()
162- output := s .NewDockerCommand ("run" , "--rm" , "hello-world" ).WithTimeout (time .NewTimer (10 * time .Second ).C ).ExecOrDie ()
126+ output := s .NewDockerCommand ("run" , "--rm" , "hello-world" ).WithTimeout (time .NewTimer (20 * time .Second ).C ).ExecOrDie ()
163127 Expect (output ).To (ContainSubstring ("Hello from Docker!" ))
164128 })
165129}
@@ -187,7 +151,7 @@ func (s *E2eSuite) TestMockBackend() {
187151 currentContext := s .NewDockerCommand ("context" , "use" , "test-example" ).ExecOrDie ()
188152 Expect (currentContext ).To (ContainSubstring ("test-example" ))
189153 output := s .NewDockerCommand ("context" , "ls" ).ExecOrDie ()
190- golden .Assert (s .T (), output , "ls-out-test-example.golden" )
154+ golden .Assert (s .T (), output , GoldenFile ( "ls-out-test-example" ) )
191155 output = s .NewDockerCommand ("context" , "show" ).ExecOrDie ()
192156 Expect (output ).To (ContainSubstring ("test-example" ))
193157 })
@@ -222,40 +186,6 @@ func (s *E2eSuite) TestMockBackend() {
222186 })
223187}
224188
225- func (s * E2eSuite ) TestAPIServer () {
226- _ , err := exec .LookPath ("yarn" )
227- if err != nil || os .Getenv ("SKIP_NODE" ) != "" {
228- s .T ().Skip ("skipping, yarn not installed" )
229- }
230- It ("can run 'serve' command" , func () {
231- cName := "test-example"
232- s .NewDockerCommand ("context" , "create" , cName , "example" ).ExecOrDie ()
233-
234- sPath := fmt .Sprintf ("unix:///%s/docker.sock" , s .ConfigDir )
235- server , err := serveAPI (s .ConfigDir , sPath )
236- Expect (err ).To (BeNil ())
237- defer killProcess (server )
238-
239- s .NewCommand ("yarn" , "install" ).WithinDirectory ("../node-client" ).ExecOrDie ()
240- output := s .NewCommand ("yarn" , "run" , "start" , cName , sPath ).WithinDirectory ("../node-client" ).ExecOrDie ()
241- Expect (output ).To (ContainSubstring ("nginx" ))
242- })
243- }
244-
245189func TestE2e (t * testing.T ) {
246190 suite .Run (t , new (E2eSuite ))
247191}
248-
249- func killProcess (process * os.Process ) {
250- err := process .Kill ()
251- Expect (err ).To (BeNil ())
252- }
253-
254- func serveAPI (configDir string , address string ) (* os.Process , error ) {
255- cmd := exec .Command ("../../bin/docker" , "--config" , configDir , "serve" , "--address" , address )
256- err := cmd .Start ()
257- if err != nil {
258- return nil , err
259- }
260- return cmd .Process , nil
261- }
0 commit comments