-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 a system test to modify and import an exported container #11426
Add a system test to modify and import an exported container #11426
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contributing!
The file should probably be called 800-import.bats since scenario seems a bit generic.
I just have a couple of nits. @edsantiago is the mastermind behind the system tests, PTAL :)
test/system/800-scenario.bats
Outdated
|
||
load helpers | ||
|
||
alpine="quay.io/libpod/alpine" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's already an internal variable $IMAGE
which other tests are using. I suggest using that instead of $alpine
to reduce the number of pulls and hence speed up the test a bit.
test/system/800-scenario.bats
Outdated
dockerfile=$PODMAN_TMPDIR/Dockerfile | ||
|
||
cat >$dockerfile <<EOF | ||
FROM $alpine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FROM $IMAGE
test/system/800-scenario.bats
Outdated
run_podman ps -a --filter name=$a_cnt --format '{{.Status}}' | ||
is "$output" "Exited (33)" "Exit by non-TERM/KILL" | ||
|
||
run_podman rmi -fa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing all images may be a bit too much. It would be nice if we could keep $IMAGE
in the local storage.
test/system/800-scenario.bats
Outdated
|
||
alpine="quay.io/libpod/alpine" | ||
|
||
@test "Implied pull, build, export, modify, import, tag, run, kill" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "podman import / export" ?
test/system/800-scenario.bats
Outdated
|
||
# Build from Dockerfile FROM non-existing local image | ||
run_podman build -t $b_img $PODMAN_TMPDIR | ||
run_podman run -d --name $b_cnt --stop-signal SIGKILL $b_img sleep 60 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using podman create
instead of run
would be cheaper.
test/system/800-scenario.bats
Outdated
|
||
# Export built container as tarball | ||
run_podman export -o $PODMAN_TMPDIR/$b_cnt.tar $b_cnt | ||
run_podman rm -fa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing all containers seems a bit too much. Could we just remove $b_cnt
?
test/system/800-scenario.bats
Outdated
iid=$output | ||
|
||
# Tag imported image | ||
run_podman tag $iid $a_img |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: podman import $PODMAN_TMPDIR/$b_cnt.tar ... $a_img
would tag the imported image.
test/system/800-scenario.bats
Outdated
|
||
# Kill can send non-TERM/KILL signal to container to exit | ||
run_podman kill --signal 2 $a_cnt | ||
run_podman wait $a_cnt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going via podman logs
works but I think that using podman exec
may be easier. We could start a container, then do podman exec $ctr cat ...
and check the output.
I'd expect it to be less work and easier to brain parse.
@vrothberg Thank you for your comment. |
Thank you, @fj-tsubasa!
I think so, yes. But I suggest to wait for @edsantiago's review first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't actually work with TMPDIR=/something-other-than-slash-tmp
. Suggestion:
index c738d4433..29fd1c03c 100644
--- a/test/system/800-scenario.bats
+++ b/test/system/800-scenario.bats
@@ -9,8 +9,9 @@ load helpers
@test "podman import / export" {
# Create a test file following test
+ mkdir $PODMAN_TMPDIR/tmp
touch $PODMAN_TMPDIR/testfile1
- echo "modified tar file" >> $PODMAN_TMPDIR/testfile2
+ echo "modified tar file" >> $PODMAN_TMPDIR/tmp/testfile2
# Create Dockerfile for test
dockerfile=$PODMAN_TMPDIR/Dockerfile
@@ -36,7 +37,7 @@ EOF
# Modify tarball contents
tar --delete -f $PODMAN_TMPDIR/$b_cnt.tar tmp/testfile1
- tar -rf $PODMAN_TMPDIR/$b_cnt.tar $PODMAN_TMPDIR/testfile2
+ tar -C $PODMAN_TMPDIR -rf $PODMAN_TMPDIR/$b_cnt.tar tmp/testfile2
# Import tarball and Tag imported image
run_podman import -q $PODMAN_TMPDIR/$b_cnt.tar \
@@ -48,11 +49,11 @@ EOF
run_podman run --name $a_cnt -d $a_img
# Confirm testfile1 is deleted from tarball
- run_podman 1 exec $a_cnt cat $PODMAN_TMPDIR/testfile1 2>&1
- is "$output" ".*can't open '$PODMAN_TMPDIR/testfile1': No such file or directory"
+ run_podman 1 exec $a_cnt cat /tmp/testfile1
+ is "$output" ".*can't open '/tmp/testfile1': No such file or directory"
# Confirm testfile2 is added to tarball
- run_podman exec $a_cnt cat $PODMAN_TMPDIR/testfile2
+ run_podman exec $a_cnt cat /tmp/testfile2
is "$output" "modified tar file" "modify tarball content"
# Kill can send non-TERM/KILL signal to container to exit
I agree with your suggestion to include this in 125-import
, or at least somewhere in the 12x
space (with a better name than "scenario").
I am OOTO on Tuesday and cannot follow up until late at night or Wednesday morning - sorry.
This is very nice work, thank you!
test/system/800-scenario.bats
Outdated
run_podman run --name $a_cnt -d $a_img | ||
|
||
# Confirm testfile1 is deleted from tarball | ||
run_podman 1 exec $a_cnt cat $PODMAN_TMPDIR/testfile1 2>&1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 2>&1
here is unnecessary (and misleading)
test/system/800-scenario.bats
Outdated
|
||
@test "podman import / export" { | ||
|
||
# Create a test file following test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with every other test script, would you mind using 4-space indentation?
test/system/800-scenario.bats
Outdated
|
||
load helpers | ||
|
||
@test "podman import / export" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about: @test "podman export, alter tarball, re-import"
?
@edsantiago Thank you for your comment !! |
LGTM but please squash your commits; that should fix the long-commit and trailing-whitespace errors. |
576954e
to
4ccb4f8
Compare
This test has completed one of TODO items in test/system/TODO.md. The item is "Implied pull, build, export, modify, import, tag, run, kill" Signed-off-by: Tsubasa Watanabe <[email protected]>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: edsantiago, fj-tsubasa The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm Thank you, @fj-tsubasa ! |
@edsantiago @vrothberg |
An absolute pleasure, @fj-tsubasa. Thank you for contributing! |
Podman system test has a TODO list written in test/system/TODO.md.
This requesting test completed "Implied pull, build, export, modify, import, tag, run, kill" in the list.
The workflows written in TODO.md have multiple commands and therefore
the test file has been created apart from others as 800-scenario.bats.
800-scenario.bats has the workflow like the following,
and is different from the existing test 125-import.bats from the point of view of a purpose.
800-scenario.bats is more systematic than 125-import.bats
because it is not composed of a single command but user workflow oriented.
Please add this test 800-scenario.bats to the system tests.
Additionally, I would like to confirm that TODO.md is still valid.
(*) This test has the following WORKFLOW