Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
Signed-off-by: apostasie <[email protected]>
  • Loading branch information
apostasie committed Oct 18, 2024
1 parent eef0633 commit 5851c7c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ jobs:
- name: "Ensure that the IPv6 integration test suite is compatible with Docker"
run: ./hack/test-integration.sh -test.target=docker -test.only-ipv6
- name: "Ensure that the integration test suite is compatible with Docker (flaky only)"
run: /hack/test-integration.sh -test.target=docker -test.only-flaky
run: ./hack/test-integration.sh -test.target=docker -test.only-flaky

test-integration-windows:
timeout-minutes: 30
Expand Down
2 changes: 0 additions & 2 deletions hack/test-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ args=(--format=testname --jsonfile /tmp/test-integration.log --packages="$root"/
if [ "$#" == 0 ]; then
"$root"/test-integration.sh -test.only-flaky=false
"$root"/test-integration.sh -test.only-flaky=true
"$root"/test-integration.sh -test.only-ipv6
"$root"/test-integration.sh -test.only-kube
exit
fi

Expand Down
58 changes: 31 additions & 27 deletions pkg/testutil/nerdtest/registry/cesanta.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,34 +82,38 @@ func (cc *CesantaConfig) Save(path string) error {
return err
}

// FIXME: this is a copy of the utility method EnsureContainerStarted
// We cannot reference it (circular dep), so the copy.
// To be fixed later when we will be done migrating test helpers to the new framework and we can split them
// in meaningful subpackages.

func ensureContainerStarted(helpers test.Helpers, con string) {
const maxRetry = 5
const sleep = time.Second
success := false
for i := 0; i < maxRetry && !success; i++ {
time.Sleep(sleep)
count := i
cmd := helpers.Command("container", "inspect", con)
cmd.Run(&test.Expected{
Output: func(stdout string, info string, t *testing.T) {
var dc []dockercompat.Container
err := json.Unmarshal([]byte(stdout), &dc)
assert.NilError(t, err, "Unable to unmarshal output\n"+info)
assert.Equal(t, 1, len(dc), "Unexpectedly got multiple results\n"+info)
if dc[0].State.Running {
success = true
return
}
if count == maxRetry-1 {
// FIXME: there is currently no simple way to capture stderr
// Sometimes, it is convenient for debugging, like here
// Here we cheat with unbuffer which will bundle stderr and stdout together
// This is just bad
t.Error(helpers.Err("logs", con))
t.Fatalf("container %s still not running after %d retries", con, count)
}
},
})
started := false
for i := 0; i < 5 && !started; i++ {
helpers.Command("container", "inspect", con).
Run(&test.Expected{
ExitCode: -2,
Output: func(stdout string, info string, t *testing.T) {
var dc []dockercompat.Container
err := json.Unmarshal([]byte(stdout), &dc)
if err != nil || len(dc) == 0 {
return
}
assert.Equal(t, len(dc), 1, "Unexpectedly got multiple results\n"+info)
started = dc[0].State.Running
},
})
time.Sleep(time.Second)
}

if !started {
ins := helpers.Capture("container", "inspect", con)
lgs := helpers.Capture("logs", con)
ps := helpers.Capture("ps", "-a")
helpers.T().Log(ins)
helpers.T().Log(lgs)
helpers.T().Log(ps)
helpers.T().Fatalf("container %s still not running after %d retries", con, 5)
}
}

Expand Down
7 changes: 0 additions & 7 deletions pkg/testutil/nerdtest/utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,10 @@ func EnsureContainerStarted(helpers test.Helpers, con string) {
}

if !started {
var dckr string
helpers.Custom("sudo", "journalctl", "-u", "docker", "--no-pager").Run(&test.Expected{
Output: func(stdout string, info string, t *testing.T) {
dckr = stdout
},
})
ins := helpers.Capture("container", "inspect", con)
lgs := helpers.Capture("logs", con)
ps := helpers.Capture("ps", "-a")
helpers.T().Log(ins)
helpers.T().Log(dckr)
helpers.T().Log(lgs)
helpers.T().Log(ps)
helpers.T().Fatalf("container %s still not running after %d retries", con, maxRetry)
Expand Down

0 comments on commit 5851c7c

Please sign in to comment.