Skip to content

integration: fix disk usage test for c8d#46570

Merged
rumpl merged 1 commit intomoby:masterfrom
dmcgowan:fix-disk-usage-test
Oct 20, 2023
Merged

integration: fix disk usage test for c8d#46570
rumpl merged 1 commit intomoby:masterfrom
dmcgowan:fix-disk-usage-test

Conversation

@dmcgowan
Copy link
Member

Check for accurate values that may contain content sizes unknown to the usage test in the calculation. Avoid asserting using deep equals when only the expected value range is known to the test.

Always use familiarized string in images output.

@dmcgowan dmcgowan changed the title Fix disk usage test integration: fix disk usage test for c8d Sep 29, 2023
@dmcgowan dmcgowan force-pushed the fix-disk-usage-test branch from 87cb322 to a2f7bdc Compare October 2, 2023 23:30
@rumpl rumpl added the containerd-integration Issues and PRs related to containerd integration label Oct 2, 2023
Copy link
Contributor

@vvoland vvoland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I just have some nits.

assert.Equal(t, len(du.Images[0].RepoTags), 1)
assert.Equal(t, du.Images[0].RepoTags[0], "busybox:latest")

//Image size is layer size + content size, should be greater than total layer size
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//Image size is layer size + content size, should be greater than total layer size
// Image size is layer size + content size, should be greater than total layer size

BuildCache: []*types.BuildCache{},
})
assert.Equal(t, len(du.Images[0].RepoTags), 1)
assert.Equal(t, du.Images[0].RepoTags[0], "busybox:latest")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert.Equal(t, du.Images[0].RepoTags[0], "busybox:latest")
assert.Check(t, is.Equal(du.Images[0].RepoTags[0], "busybox:latest"))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We tend to use gotest.tools/v3/assert/cmp-style asserts whenever it's possible.

// If size is greater, than content exists and should have a repodigest
if du.Images[0].Size > du.LayersSize {
assert.Equal(t, len(du.Images[0].RepoDigests), 1)
assert.Assert(t, strings.HasPrefix(du.Images[0].RepoDigests[0], "busybox@"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an assertion failure is "safe" (won't cause a panic later), it's better to use assert.Check instead of assert.Assert as it won't abort immediately and will continue with other asserts.

assert.Equal(t, du.Containers[0].Image, "busybox")
assert.Equal(t, du.Containers[0].ImageID, prev.Images[0].ID)

// The rootfs size shouldbe equivalent to all the layers,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// The rootfs size shouldbe equivalent to all the layers,
// The rootfs size should be equivalent to all the layers,

@laurazard
Copy link
Member

laurazard commented Oct 16, 2023

Does this fully fix the issue? I see in https://github.com/moby/moby/actions/runs/6506688442/job/17672826153 that the empty case is also broken:

 disk_usage_test.go:39: assertion failed: 
        --- du
        +++ →
          types.DiskUsage{
        - 	LayersSize: 4096,
        + 	LayersSize: 0,
          	Images:     {},
          	Containers: {},
          	... // 3 identical fields
          }

Nevermind, that's probably due to something else broken that didn't get cleaned up properly.

Copy link
Member

@laurazard laurazard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending @vvoland's comments

Check for accurate values that may contain content sizes unknown to the
usage test in the calculation. Avoid asserting using deep equals when
only the expected value range is known to the test.

Signed-off-by: Derek McGowan <derek@mcg.dev>
@dmcgowan dmcgowan force-pushed the fix-disk-usage-test branch from a2f7bdc to e97716a Compare October 19, 2023 04:28
Copy link
Member

@laurazard laurazard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/testing containerd-integration Issues and PRs related to containerd integration status/2-code-review

Projects

Development

Successfully merging this pull request may close these issues.

4 participants