Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 93984f8

Browse files
committed
Removed test requiring linux containers
1 parent 5258906 commit 93984f8

File tree

5 files changed

+135
-94
lines changed

5 files changed

+135
-94
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
core.autocrlf false
2-
*.golden text eol=lf
2+
*.golden text eol=lf

.github/workflows/ci.yml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Run golangci-lint
2222
run: |
2323
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b . v1.27.0
24-
./golangci-lint run
24+
./golangci-lint run --timeout 10m0s
2525
2626
build:
2727
name: Build
@@ -63,7 +63,6 @@ jobs:
6363
- name: E2E Test
6464
run: make e2e-local
6565

66-
6766
windows-build:
6867
name: Windows Build
6968
runs-on: windows-latest
@@ -92,14 +91,5 @@ jobs:
9291
- name: Build
9392
run: make -f builder.Makefile cli
9493

95-
- name: Install Protoc
96-
uses: arduino/setup-protoc@master
97-
with:
98-
version: "3.9.1"
99-
100-
- uses: actions/setup-node@v1
101-
with:
102-
node-version: "10.x"
103-
10494
- name: E2E Test
105-
run: make e2e-local
95+
run: make e2e-win-ci

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ cli: ## Compile the cli
3737
--output ./bin
3838

3939
e2e-local: ## Run End to end local tests
40-
go test -v ./tests/e2e ./moby/e2e
40+
go test -v ./tests/e2e ./tests/skip-win-ci-e2e ./moby/e2e
41+
42+
e2e-win-ci: ## Run End to end local tests on windows CI, no docker for linux containers available ATM
43+
go test -v ./tests/e2e
4144

4245
e2e-aci: ## Run End to end ACI tests (requires azure login)
4346
go test -v ./tests/aci-e2e

tests/e2e/e2e_test.go

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,8 @@
2828
package main
2929

3030
import (
31-
"fmt"
32-
"io/ioutil"
33-
"log"
3431
"os"
35-
"os/exec"
3632
"path/filepath"
37-
"strings"
3833
"testing"
3934
"time"
4035

@@ -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-
149113
func (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
}
@@ -222,49 +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-
sPath, cliAddress := s.getGrpcServerAndCLientAddress()
236-
server, err := serveAPI(s.ConfigDir, sPath)
237-
Expect(err).To(BeNil())
238-
defer killProcess(server)
239-
240-
s.NewCommand("yarn", "install").WithinDirectory("../node-client").ExecOrDie()
241-
output := s.NewCommand("yarn", "run", "start", cName, cliAddress).WithinDirectory("../node-client").ExecOrDie()
242-
Expect(output).To(ContainSubstring("nginx"))
243-
})
244-
}
245-
246-
func (s *E2eSuite) getGrpcServerAndCLientAddress() (string, string) {
247-
if IsWindows() {
248-
return "npipe:////./pipe/clibackend", "unix:////./pipe/clibackend"
249-
}
250-
socketName := fmt.Sprintf("unix:///%s/docker.sock", s.ConfigDir)
251-
return socketName, socketName
252-
}
253-
254189
func TestE2e(t *testing.T) {
255190
suite.Run(t, new(E2eSuite))
256191
}
257-
258-
func killProcess(process *os.Process) {
259-
err := process.Kill()
260-
Expect(err).To(BeNil())
261-
}
262-
263-
func serveAPI(configDir string, address string) (*os.Process, error) {
264-
cmd := exec.Command("../../bin/docker", "--config", configDir, "serve", "--address", address)
265-
err := cmd.Start()
266-
if err != nil {
267-
return nil, err
268-
}
269-
return cmd.Process, nil
270-
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/*
2+
Copyright (c) 2020 Docker Inc.
3+
4+
Permission is hereby granted, free of charge, to any person
5+
obtaining a copy of this software and associated documentation
6+
files (the "Software"), to deal in the Software without
7+
restriction, including without limitation the rights to use, copy,
8+
modify, merge, publish, distribute, sublicense, and/or sell copies
9+
of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be
13+
included in all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED,
17+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20+
HOLDERS BE LIABLE FOR ANY CLAIM,
21+
DAMAGES OR OTHER LIABILITY,
22+
WHETHER IN AN ACTION OF CONTRACT,
23+
TORT OR OTHERWISE,
24+
ARISING FROM, OUT OF OR IN CONNECTION WITH
25+
THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26+
*/
27+
28+
package main
29+
30+
import (
31+
"fmt"
32+
"io/ioutil"
33+
"log"
34+
"os"
35+
"os/exec"
36+
"path/filepath"
37+
"strings"
38+
"testing"
39+
"time"
40+
41+
. "github.com/onsi/gomega"
42+
"github.com/stretchr/testify/suite"
43+
44+
. "github.com/docker/api/tests/framework"
45+
)
46+
47+
type NonWinCIE2eSuite struct {
48+
Suite
49+
}
50+
51+
func (s *NonWinCIE2eSuite) TestKillChildOnCancel() {
52+
It("should kill docker-classic if parent command is cancelled", func() {
53+
out := s.ListProcessesCommand().ExecOrDie()
54+
Expect(out).NotTo(ContainSubstring("docker-classic"))
55+
56+
dir := s.ConfigDir
57+
Expect(ioutil.WriteFile(filepath.Join(dir, "Dockerfile"), []byte(`FROM alpine:3.10
58+
RUN sleep 100`), 0644)).To(Succeed())
59+
shutdown := make(chan time.Time)
60+
errs := make(chan error)
61+
ctx := s.NewDockerCommand("build", "--no-cache", "-t", "test-sleep-image", ".").WithinDirectory(dir).WithTimeout(shutdown)
62+
go func() {
63+
_, err := ctx.Exec()
64+
errs <- err
65+
}()
66+
err := WaitFor(time.Second, 10*time.Second, errs, func() bool {
67+
out := s.ListProcessesCommand().ExecOrDie()
68+
return strings.Contains(out, "docker-classic")
69+
})
70+
Expect(err).NotTo(HaveOccurred())
71+
log.Println("Killing docker process")
72+
73+
close(shutdown)
74+
err = WaitFor(time.Second, 12*time.Second, nil, func() bool {
75+
out := s.ListProcessesCommand().ExecOrDie()
76+
return !strings.Contains(out, "docker-classic")
77+
})
78+
Expect(err).NotTo(HaveOccurred())
79+
})
80+
}
81+
82+
func (s *NonWinCIE2eSuite) TestAPIServer() {
83+
_, err := exec.LookPath("yarn")
84+
if err != nil || os.Getenv("SKIP_NODE") != "" {
85+
s.T().Skip("skipping, yarn not installed")
86+
}
87+
It("can run 'serve' command", func() {
88+
cName := "test-example"
89+
s.NewDockerCommand("context", "create", cName, "example").ExecOrDie()
90+
91+
//sPath := fmt.Sprintf("unix:///%s/docker.sock", s.ConfigDir)
92+
sPath, cliAddress := s.getGrpcServerAndCLientAddress()
93+
server, err := serveAPI(s.ConfigDir, sPath)
94+
Expect(err).To(BeNil())
95+
defer killProcess(server)
96+
97+
s.NewCommand("yarn", "install").WithinDirectory("../node-client").ExecOrDie()
98+
output := s.NewCommand("yarn", "run", "start", cName, cliAddress).WithinDirectory("../node-client").ExecOrDie()
99+
Expect(output).To(ContainSubstring("nginx"))
100+
})
101+
}
102+
103+
func (s *NonWinCIE2eSuite) getGrpcServerAndCLientAddress() (string, string) {
104+
if IsWindows() {
105+
return "npipe:////./pipe/clibackend", "unix:////./pipe/clibackend"
106+
}
107+
socketName := fmt.Sprintf("unix:///%s/docker.sock", s.ConfigDir)
108+
return socketName, socketName
109+
}
110+
111+
func TestE2e(t *testing.T) {
112+
suite.Run(t, new(NonWinCIE2eSuite))
113+
}
114+
115+
func killProcess(process *os.Process) {
116+
err := process.Kill()
117+
Expect(err).To(BeNil())
118+
}
119+
120+
func serveAPI(configDir string, address string) (*os.Process, error) {
121+
cmd := exec.Command("../../bin/docker", "--config", configDir, "serve", "--address", address)
122+
err := cmd.Start()
123+
if err != nil {
124+
return nil, err
125+
}
126+
return cmd.Process, nil
127+
}

0 commit comments

Comments
 (0)