Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some tests and test steps for buildah #1966

Closed
wants to merge 10 commits into from
Prev Previous commit
Next Next commit
Tests: Add container name and id check in containers test steps
Add some checkpoint for checking container name and id inside
the tests.

Signed-off-by: Yiqiao Pu <[email protected]>
  • Loading branch information
ypu committed Nov 9, 2019
commit 5e8fc71f9d8c04a2a2a39c12dd338921bd9ba7cb
6 changes: 6 additions & 0 deletions tests/containers.bats
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ load helpers
cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error containers --format "{{.ContainerName}}"
expect_line_count 2
expect_output --from="${lines[0]}" "alpine-working-container"
expect_output --from="${lines[1]}" "busybox-working-container"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice. Thanks.


buildah rm -a
buildah rmi -a -f
Expand All @@ -45,6 +47,7 @@ load helpers
cid2=$(buildah from --pull=false --signature-policy ${TESTSDIR}/policy.json busybox)
run_buildah --log-level=error containers --noheading
expect_line_count 2
[[ "$output" != "NAME"* ]]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This does not do what you think it does.

It's clear that I need to add a 'not in output' test. Until I do so, please use:

    if [[ $output =~ NAME ]]; then
        expect_output "[no instance of 'NAME']" "buildah containers --noheading"
    fi

Likewise with lines 62-63 below.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please address this. As I wrote, this does not work: it does not do what you think it does. What it does is pass if $output does not begin with NAME. This will always pass, always, even if for some reason buildah emits a heading, because the heading does not begin with NAME - it begins with CONTAINER ID. What you want to do is make sure that NAME does not appear anywhere in the output. Again, please look into this more closely - this is a fundamental misunderstanding that is repeated in a few other places in your PR.


buildah rm -a
buildah rmi -a -f
Expand All @@ -56,6 +59,9 @@ load helpers
run_buildah --log-level=error containers --quiet
expect_line_count 2

[[ "${lines[0]}" != "$cid1"* ]]
[[ "${lines[1]}" != "$cid2"* ]]
Copy link
Collaborator

Choose a reason for hiding this comment

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

See line 50


buildah rm -a
buildah rmi -a -f
}