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

test/system: Add a test case for automount with multi images #23301

Merged
merged 1 commit into from
Jul 29, 2024

Conversation

ypu
Copy link
Contributor

@ypu ypu commented Jul 17, 2024

This test check the automount feature with multi images for following item:

  1. multi images can be auotmounted with yaml file.
  2. if there are same path exist in the images, the last one should trumps.
  3. the volume is mounted readonly in the container.
  4. the volumes are only mounted in the specific container, but not the whole pods.

Does this PR introduce a user-facing change?

NONE

@openshift-ci openshift-ci bot added the do-not-merge/release-note-label-needed Enforce release-note requirement, even if just None label Jul 17, 2024
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

Can you merge the test with the other one above and reuse that image there. Building is slow and we are actively working on increasing the performance of system test so every second matters.

@@ -1035,3 +1035,72 @@ spec:
run_podman rm -f -t 0 -a
run_podman rmi automount_test
}

@test "podman ply with multi automount volume" {
Copy link
Member

Choose a reason for hiding this comment

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

typo play

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it.

Comment on lines 1042 to 1044
RUN mkdir /test1 /test_same
RUN touch /test1/a /test1/b /test1/c
RUN echo "I am from test1 image" > /test_same/hello_world
Copy link
Member

Choose a reason for hiding this comment

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

please chain them via && \ instead of desperate RUN instructions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. Will update this.

Comment on lines 1051 to 1053
RUN mkdir /test2 /test_same
RUN touch /test2/asdf /test2/ejgre /test2/lteghe
RUN echo "I am from test2 image" > /test_same/hello_world
Copy link
Member

Choose a reason for hiding this comment

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

same here

metadata:
labels:
app: test
name: test_pod
Copy link
Member

Choose a reason for hiding this comment

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

Do not hardcore the names please, see
#23280 and #23275

I know this is the case today but we must stop doing that.

Copy link
Member

Choose a reason for hiding this comment

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

700-play is next on my list for refactoring. @ypu if you wait maybe a week or so, until my (not-yet-filed) PR merges, you will have a much better base to work with.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @Luap99 and @edsantiago . Will wait for Ed’s PR for refactoring the script.

@ypu
Copy link
Contributor Author

ypu commented Jul 17, 2024

Thanks @Luap99 and @edsantiago for your comments. And will work with the test case after Ed’s refactor for the script get done.

Copy link
Member

@edsantiago edsantiago left a comment

Choose a reason for hiding this comment

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

Please rebase, and take a look at the new 700-play.bats. In particular, the way there are no longer any hardcoded names. I've added a few suggestions inline. Thank you!

Comment on lines 1058 to 1059
run_podman build -t test1 -f $PODMAN_TMPDIR/Containerfile1
run_podman build -t test2 -f $PODMAN_TMPDIR/Containerfile2
Copy link
Member

Choose a reason for hiding this comment

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

    img1="i1-$(safename)"
    img2="i2-$(safename)"
    build -t $img1 ...

test/system/700-play.bats Show resolved Hide resolved
run_podman kube play $fname

run_podman run --rm test1 ls /test1
run_out_test1="$output"
Copy link
Member

Choose a reason for hiding this comment

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

Please check this for validity. Comparing the ls output is not useful if both show mistaken results.

run_podman exec test_pod-testctr cat /test_same/hello_world
assert "I am from test2 image" "test_same should from image2"

run_podman 1 exec test_pod-testctr touch /test1/readonly
Copy link
Member

Choose a reason for hiding this comment

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

Error message check please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it.

@ypu
Copy link
Contributor Author

ypu commented Jul 25, 2024

/release-note-none

@openshift-ci openshift-ci bot added release-note-none and removed do-not-merge/release-note-label-needed Enforce release-note requirement, even if just None labels Jul 25, 2024
@ypu
Copy link
Contributor Author

ypu commented Jul 25, 2024

Hi @edsantiago and @Luap99 pullreq updated. Can you help to review it again? Thanks a lot!

Copy link
Member

@edsantiago edsantiago left a comment

Choose a reason for hiding this comment

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

First pass review. I'm still having trouble understanding everything that is happening here; there may be other issues I've missed. Please address these, rebase, and I'll take another look.

Comment on lines 1023 to 1024
run_podman run --rm $imgname1 ls -x /
run_podman run --rm $imgname2 ls -x /
Copy link
Member

Choose a reason for hiding this comment

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

Are these debugging leftovers? If so please remove.

Comment on lines 1064 to 1065
run_podman exec "$podname_file-$ctrname_file" ls -x /test1
assert "a b c" "ls /test1 on image"
Copy link
Member

Choose a reason for hiding this comment

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

No, this is now wrong. "on image" means "this is a test being run on the image itself, via podman run". You changed it to "podman exec", which is on the container. It is necessary to do both.

assert "$output" =~ "Read-only file system" "image mounted as readonly"

run_podman exec "$podname_file-$ctrname_file_not_mounted" ls /
assert "test" !~ "$output" "No volume should be mounted in $podname_file-$ctrname_file_not_mounted"
Copy link
Member

Choose a reason for hiding this comment

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

Wrong order, it should be assert "$output" !~ "test".

Suggestion: just "No volume should be mounted in the no-mount container". There's no reason to include the entire actual container name, that just makes for a hard-to-read error message.

Comment on lines 991 to 992
imgname1="automount-test-$(safename)1"
imgname2="automount-test-$(safename)2"
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: automount-test1-$(safename) and -test2-. The way they are now, 1 and 2 appear at the end of a random string, making it impossible for a human to see the difference between them.

Comment on lines 995 to 996
podname_file="p-$(safename)-file"
ctrname_file="c-$(safename)-file"
Copy link
Member

Choose a reason for hiding this comment

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

When I see a variable of the form xxx_file, my brain thinks "this references a file path". Even after staring at this code for half an hour, I still can't get used to the fact that this means "pod and container that have something to do with a file". Could you think of variable names that better reflect the nature of the test being run?


run_podman run --rm $imgname1 cat /test_same/hello_world
assert "$output" = "I am from test1 image" "cat /test_same/hello_world on image"
run_out_test2="$output"
Copy link
Member

Choose a reason for hiding this comment

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

eek, no, bad variable name. This needs to be test1

These test steps check the automount feature with multi images for
following item:
  1. multi images can be auotmounted with yaml file.
  2. if there are same path exist in the images, the last one
should trumps.
  3. the volume is mounted readonly in the container.
  4. the volumes are only mounted in the specific container, but
not the whole pods.

Signed-off-by: Yiqiao Pu <ypu@redhat.com>
@ypu
Copy link
Contributor Author

ypu commented Jul 26, 2024

Hi @edsantiago sorry to not consider the variable names and assert messages when combine two tests. Now I just remove the debug line, update the variables and assert messages. Can you help to check it again? Thanks a lot!

@edsantiago
Copy link
Member

LGTM, thank you!

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 29, 2024
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 29, 2024
Copy link
Contributor

openshift-ci bot commented Jul 29, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: edsantiago, Luap99, ypu

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit c7f00b6 into containers:main Jul 29, 2024
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants