Skip to content

Commit 5851c7c

Browse files
committed
debugging
Signed-off-by: apostasie <[email protected]>
1 parent eef0633 commit 5851c7c

File tree

4 files changed

+32
-37
lines changed

4 files changed

+32
-37
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ jobs:
287287
- name: "Ensure that the IPv6 integration test suite is compatible with Docker"
288288
run: ./hack/test-integration.sh -test.target=docker -test.only-ipv6
289289
- name: "Ensure that the integration test suite is compatible with Docker (flaky only)"
290-
run: /hack/test-integration.sh -test.target=docker -test.only-flaky
290+
run: ./hack/test-integration.sh -test.target=docker -test.only-flaky
291291

292292
test-integration-windows:
293293
timeout-minutes: 30

hack/test-integration.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ args=(--format=testname --jsonfile /tmp/test-integration.log --packages="$root"/
2828
if [ "$#" == 0 ]; then
2929
"$root"/test-integration.sh -test.only-flaky=false
3030
"$root"/test-integration.sh -test.only-flaky=true
31-
"$root"/test-integration.sh -test.only-ipv6
32-
"$root"/test-integration.sh -test.only-kube
3331
exit
3432
fi
3533

pkg/testutil/nerdtest/registry/cesanta.go

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -82,34 +82,38 @@ func (cc *CesantaConfig) Save(path string) error {
8282
return err
8383
}
8484

85+
// FIXME: this is a copy of the utility method EnsureContainerStarted
86+
// We cannot reference it (circular dep), so the copy.
87+
// To be fixed later when we will be done migrating test helpers to the new framework and we can split them
88+
// in meaningful subpackages.
89+
8590
func ensureContainerStarted(helpers test.Helpers, con string) {
86-
const maxRetry = 5
87-
const sleep = time.Second
88-
success := false
89-
for i := 0; i < maxRetry && !success; i++ {
90-
time.Sleep(sleep)
91-
count := i
92-
cmd := helpers.Command("container", "inspect", con)
93-
cmd.Run(&test.Expected{
94-
Output: func(stdout string, info string, t *testing.T) {
95-
var dc []dockercompat.Container
96-
err := json.Unmarshal([]byte(stdout), &dc)
97-
assert.NilError(t, err, "Unable to unmarshal output\n"+info)
98-
assert.Equal(t, 1, len(dc), "Unexpectedly got multiple results\n"+info)
99-
if dc[0].State.Running {
100-
success = true
101-
return
102-
}
103-
if count == maxRetry-1 {
104-
// FIXME: there is currently no simple way to capture stderr
105-
// Sometimes, it is convenient for debugging, like here
106-
// Here we cheat with unbuffer which will bundle stderr and stdout together
107-
// This is just bad
108-
t.Error(helpers.Err("logs", con))
109-
t.Fatalf("container %s still not running after %d retries", con, count)
110-
}
111-
},
112-
})
91+
started := false
92+
for i := 0; i < 5 && !started; i++ {
93+
helpers.Command("container", "inspect", con).
94+
Run(&test.Expected{
95+
ExitCode: -2,
96+
Output: func(stdout string, info string, t *testing.T) {
97+
var dc []dockercompat.Container
98+
err := json.Unmarshal([]byte(stdout), &dc)
99+
if err != nil || len(dc) == 0 {
100+
return
101+
}
102+
assert.Equal(t, len(dc), 1, "Unexpectedly got multiple results\n"+info)
103+
started = dc[0].State.Running
104+
},
105+
})
106+
time.Sleep(time.Second)
107+
}
108+
109+
if !started {
110+
ins := helpers.Capture("container", "inspect", con)
111+
lgs := helpers.Capture("logs", con)
112+
ps := helpers.Capture("ps", "-a")
113+
helpers.T().Log(ins)
114+
helpers.T().Log(lgs)
115+
helpers.T().Log(ps)
116+
helpers.T().Fatalf("container %s still not running after %d retries", con, 5)
113117
}
114118
}
115119

pkg/testutil/nerdtest/utilities.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,10 @@ func EnsureContainerStarted(helpers test.Helpers, con string) {
111111
}
112112

113113
if !started {
114-
var dckr string
115-
helpers.Custom("sudo", "journalctl", "-u", "docker", "--no-pager").Run(&test.Expected{
116-
Output: func(stdout string, info string, t *testing.T) {
117-
dckr = stdout
118-
},
119-
})
120114
ins := helpers.Capture("container", "inspect", con)
121115
lgs := helpers.Capture("logs", con)
122116
ps := helpers.Capture("ps", "-a")
123117
helpers.T().Log(ins)
124-
helpers.T().Log(dckr)
125118
helpers.T().Log(lgs)
126119
helpers.T().Log(ps)
127120
helpers.T().Fatalf("container %s still not running after %d retries", con, maxRetry)

0 commit comments

Comments
 (0)