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

System tests: add podman run --tz #7832

Merged
merged 1 commit into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions test/system/030-run.bats
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,28 @@ json-file | f
run_podman rm myctr
}

@test "podman run --tz" {
# This file will always have a constant reference timestamp
local testfile=/home/podman/testimage-id

run_podman run --rm $IMAGE date -r $testfile
is "$output" "Sun Sep 13 12:26:40 UTC 2020" "podman run with no TZ"

run_podman run --rm --tz=MST7MDT $IMAGE date -r $testfile
is "$output" "Sun Sep 13 06:26:40 MDT 2020" "podman run with --tz=MST7MDT"

# --tz=local pays attention to /etc/localtime, not $TZ. We set TZ anyway,
# to make sure podman ignores it; and, because this test is locale-
# dependent, we pick an obscure zone (+1245) that is unlikely to
# collide with any of our testing environments.
#
# To get a reference timestamp we run 'date' locally; note the explicit
# strftime() format. We can't use --iso=seconds because GNU date adds
# a colon to the TZ offset (eg -07:00) whereas alpine does not (-0700).
run date --date=@1600000000 +%Y-%m-%dT%H:%M:%S%z
expect="$output"
TZ=Pacific/Chatham run_podman run --rm --tz=local $IMAGE date -Iseconds -r $testfile
is "$output" "$expect" "podman run with --tz=local, matches host"
}

# vim: filetype=sh
7 changes: 7 additions & 0 deletions test/system/build-testimage
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ cd $tmpdir
# 'image mount' test will confirm that this file exists and has our YMD tag
echo $YMD >testimage-id

# ...but set the timestamp on the file itself to a constant well-known
# value, for use by the 'run --tz' test. Date value chosen for nerdiness
# and because it's in the past. (Much as I'd love FFFFFFFF, we can't
# use any future date because of unpredictable leap second adjustments).
touch --date=@1600000000 testimage-id

# 'pod' test will use this for --infra-command
cat >pause <<EOF
#!/bin/sh
Expand All @@ -49,6 +55,7 @@ EOF
chmod 755 pause

# alpine because it's small and light and reliable
# - check for updates @ https://hub.docker.com/_/alpine
# busybox-extras provides httpd needed in 500-networking.bats
cat >Containerfile <<EOF
FROM docker.io/library/alpine:3.12.0
Expand Down
2 changes: 1 addition & 1 deletion test/system/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PODMAN=${PODMAN:-podman}
PODMAN_TEST_IMAGE_REGISTRY=${PODMAN_TEST_IMAGE_REGISTRY:-"quay.io"}
PODMAN_TEST_IMAGE_USER=${PODMAN_TEST_IMAGE_USER:-"libpod"}
PODMAN_TEST_IMAGE_NAME=${PODMAN_TEST_IMAGE_NAME:-"testimage"}
PODMAN_TEST_IMAGE_TAG=${PODMAN_TEST_IMAGE_TAG:-"20200917"}
PODMAN_TEST_IMAGE_TAG=${PODMAN_TEST_IMAGE_TAG:-"20200929"}
PODMAN_TEST_IMAGE_FQN="$PODMAN_TEST_IMAGE_REGISTRY/$PODMAN_TEST_IMAGE_USER/$PODMAN_TEST_IMAGE_NAME:$PODMAN_TEST_IMAGE_TAG"

# Because who wants to spell that out each time?
Expand Down