Skip to content

Commit 450817d

Browse files
committed
Extend testAttach delayOnceReader grace duration
Signed-off-by: apostasie <[email protected]>
1 parent 3e12ba0 commit 450817d

File tree

5 files changed

+36
-28
lines changed

5 files changed

+36
-28
lines changed

Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ FROM base AS test-integration
280280
ARG DEBIAN_FRONTEND=noninteractive
281281
# `expect` package contains `unbuffer(1)`, which is used for emulating TTY for testing
282282
RUN apt-get update -qq && apt-get install -qq --no-install-recommends \
283+
make \
283284
expect \
284285
git
285286
COPY --from=goversion /GOVERSION /GOVERSION
@@ -290,6 +291,7 @@ ARG GOTESTSUM_VERSION
290291
RUN GOBIN=/usr/local/bin go install gotest.tools/gotestsum@${GOTESTSUM_VERSION}
291292
COPY . /go/src/github.com/containerd/nerdctl
292293
WORKDIR /go/src/github.com/containerd/nerdctl
294+
RUN git config --global --add safe.directory /go/src/github.com/containerd/nerdctl
293295
VOLUME /tmp
294296
ENV CGO_ENABLED=0
295297
# copy cosign binary for integration test
@@ -318,8 +320,7 @@ RUN curl -o nydus-static.tgz -fsSL --proto '=https' --tlsv1.2 "https://github.co
318320
tar xzf nydus-static.tgz && \
319321
mv nydus-static/nydus-image nydus-static/nydusd nydus-static/nydusify /usr/bin/ && \
320322
rm nydus-static.tgz
321-
CMD ["gotestsum", "--format=testname", "--packages=./cmd/nerdctl/...", \
322-
"--", "-timeout=60m", "-p", "1", "-args", "-test.allow-kill-daemon"]
323+
CMD ["make", "test"]
323324

324325
FROM test-integration AS test-integration-rootless
325326
# Install SSH for creating systemd user session.
@@ -342,9 +343,7 @@ RUN systemctl disable test-integration-ipfs-offline
342343
VOLUME /home/rootless/.local/share
343344
COPY ./Dockerfile.d/test-integration-rootless.sh /
344345
RUN chmod a+rx /test-integration-rootless.sh
345-
CMD ["/test-integration-rootless.sh", \
346-
"gotestsum", "--format=testname", "--packages=./cmd/nerdctl/...", \
347-
"--", "-timeout=60m", "-p", "1", "-args", "-test.allow-kill-daemon"]
346+
CMD ["/test-integration-rootless.sh", "make", "test"]
348347

349348
# test for CONTAINERD_ROOTLESS_ROOTLESSKIT_PORT_DRIVER=slirp4netns
350349
FROM test-integration-rootless AS test-integration-rootless-port-slirp4netns

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ lint-yaml:
8686
lint-shell: $(call recursive_wildcard,$(MAKEFILE_DIR)/,*.sh)
8787
shellcheck -a -x $^
8888

89+
test: test-no-retry test-flaky
90+
91+
test-flaky:
92+
gotestsum --rerun-fails=2 --format=testname --packages=./cmd/nerdctl/builder,./cmd/nerdctl/compose,./cmd/nerdctl/container,./cmd/nerdctl/ipfs,./cmd/nerdctl/image -- -timeout=60m -p 1 -args -test.allow-kill-daemon
93+
94+
test-no-retry:
95+
go test $(shell go list ./cmd/nerdctl/... | grep -v nerdctl/builder | grep -v nerdctl/compose | grep -v nerdctl/container | grep -v nerdctl/ipfs | grep -v nerdctl/image) -timeout=60m -p 1 -args -test.allow-kill-daemon
96+
8997
binaries: nerdctl
9098

9199
install:

cmd/nerdctl/completion/completion_linux_test.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func TestCompletion(t *testing.T) {
3131
Description: "Base completion",
3232
Require: test.Not(nerdtest.Docker),
3333
Setup: func(data test.Data, helpers test.Helpers) {
34+
helpers.Ensure("pull", testutil.AlpineImage)
3435
helpers.Ensure("network", "create", data.Identifier())
3536
helpers.Ensure("volume", "create", data.Identifier())
3637
data.Set("identifier", data.Identifier())
@@ -176,23 +177,6 @@ func TestCompletion(t *testing.T) {
176177
},
177178
Expected: test.Expects(0, nil, test.Contains("run\t")),
178179
},
179-
},
180-
}
181-
182-
testCase.Run(t)
183-
}
184-
185-
// Test is privatized so that we can guarantee the image will not get rmi-ed
186-
func TestCompletionPrivate(t *testing.T) {
187-
nerdtest.Setup()
188-
189-
testCase := &test.Case{
190-
Description: "With an image",
191-
Require: test.Require(nerdtest.Private, test.Not(nerdtest.Docker)),
192-
Setup: func(data test.Data, helpers test.Helpers) {
193-
helpers.Ensure("pull", testutil.AlpineImage)
194-
},
195-
SubTests: []*test.Case{
196180
{
197181
Description: "run -i",
198182
Command: test.RunCommand("__complete", "run", "-i", ""),

pkg/testutil/nerdtest/test.go

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ func nerdctlSetup(testCase *test.Case, t *testing.T) test.Command {
194194
testCase.Env["DOCKER_CONFIG"] = testCase.Data.TempDir()
195195
testCase.Env["NERDCTL_TOML"] = filepath.Join(testCase.Data.TempDir(), "nerdctl.toml")
196196
dt.WithConfig(HostsDir, test.ConfigValue(testCase.Data.TempDir()))
197-
dt.WithConfig(DataRoot, test.ConfigValue(testCase.Data.TempDir()))
197+
// Setting data root is more trouble than anything and does not significantly increase isolation
198+
// dt.WithConfig(DataRoot, test.ConfigValue(testCase.Data.TempDir()))
198199
}
199200
testUtilBase = testutil.NewBaseWithNamespace(t, pvNamespace)
200201
if testUtilBase.Target == testutil.Docker {
@@ -237,12 +238,28 @@ func nerdctlSetup(testCase *test.Case, t *testing.T) test.Command {
237238
}
238239

239240
// If we were in a custom namespace, not inherited - make sure we clean up the namespace
240-
// FIXME: this is broken, and custom namespaces are not cleaned properly
241241
if testUtilBase.Target == testutil.Nerdctl && pvNamespace != "" && !inherited {
242242
cleanup := func() {
243-
cl := baseCommand.Clone()
244-
cl.WithArgs("namespace", "remove", pvNamespace)
245-
cl.Run(nil)
243+
// Stop all containers, then prune everything
244+
containerList := baseCommand.Clone()
245+
containerList.WithArgs("ps", "-q")
246+
containerList.Run(&test.Expected{
247+
Output: func(stdout string, info string, t *testing.T) {
248+
if stdout != "" {
249+
containerRm := baseCommand.Clone()
250+
containerRm.WithArgs("rm", "-f", stdout)
251+
containerRm.Run(&test.Expected{})
252+
}
253+
},
254+
})
255+
256+
systemPrune := baseCommand.Clone()
257+
systemPrune.WithArgs("system", "prune", "-f", "--all", "--volumes")
258+
systemPrune.Run(&test.Expected{})
259+
260+
cleanNamespace := baseCommand.Clone()
261+
cleanNamespace.WithArgs("namespace", "remove", pvNamespace)
262+
cleanNamespace.Run(nil)
246263
}
247264
cleanup()
248265
t.Cleanup(cleanup)

pkg/testutil/testutil_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func NewDelayOnceReader(wrapped io.Reader) io.Reader {
126126

127127
func (r *delayOnceReader) Read(p []byte) (int, error) {
128128
// FIXME: this is obviously not exact science. At 1 second, it will fail regularly on the CI under load.
129-
r.once.Do(func() { time.Sleep(2 * time.Second) })
129+
r.once.Do(func() { time.Sleep(5 * time.Second) })
130130
n, err := r.wrapped.Read(p)
131131
if errors.Is(err, io.EOF) {
132132
time.Sleep(time.Second)

0 commit comments

Comments
 (0)