summaryrefslogtreecommitdiff
path: root/test/buildah-bud/buildah-tests.diff
blob: ad35e59269d8f01971e7661bf1ab86a67ebcb231 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
From a49a2e48421c6f3bb1a56ae372de1f3d1a45d1f1 Mon Sep 17 00:00:00 2001
From: Ed Santiago <santiago@redhat.com>
Date: Tue, 9 Feb 2021 17:28:05 -0700
Subject: [PATCH] tweaks for running buildah tests under podman

Signed-off-by: Ed Santiago <santiago@redhat.com>
---
 tests/bud.bats     | 26 ++++++++++++++++----------
 tests/helpers.bash | 28 ++++++++++++++++++++++++----
 2 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/tests/bud.bats b/tests/bud.bats
index cf55d9a4..60cb6f96 100644
--- a/tests/bud.bats
+++ b/tests/bud.bats
@@ -4,7 +4,7 @@ load helpers

 @test "bud with a path to a Dockerfile (-f) containing a non-directory entry" {
   run_buildah 125 bud -f ${TESTSDIR}/bud/non-directory-in-path/non-directory/Dockerfile
-  expect_output --substring "non-directory/Dockerfile: not a directory"
+  expect_output --substring "Error: context must be a directory:"
 }

 @test "bud with --dns* flags" {
@@ -117,6 +117,7 @@ symlink(subdir)"
 }

 @test "bud-flags-order-verification" {
+  skip "N/A under podman"
   run_buildah 125 bud /tmp/tmpdockerfile/ -t blabla
   check_options_flag_err "-t"

@@ -1416,13 +1417,13 @@ function _test_http() {
 @test "bud with dir for file but no Dockerfile in dir" {
   target=alpine-image
   run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/bud/empty-dir ${TESTSDIR}/bud/empty-dir
-  expect_output --substring "no such file or directory"
+  expect_output --substring "Error: context must be a directory:"
 }

 @test "bud with bad dir Dockerfile" {
   target=alpine-image
   run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json -t ${target} -f ${TESTSDIR}/baddirname ${TESTSDIR}/baddirname
-  expect_output --substring "no such file or directory"
+  expect_output --substring "Error: context must be a directory:"
 }

 @test "bud with ARG before FROM default value" {
@@ -1834,7 +1835,9 @@ _EOF
   run_buildah bud --signature-policy ${TESTSDIR}/policy.json --layers -t test-img-2 --build-arg TEST=foo -f Dockerfile4 ${TESTSDIR}/bud/build-arg
   run_buildah inspect -f '{{.FromImageID}}' test-img-2
   argsid="$output"
-  [[ "$argsid" != "$initialid" ]]
+  if [[ "$argsid" == "$initialid" ]]; then
+      die ".FromImageID of test-img-2 ($argsid) == same as test-img, it should be different"
+  fi

   # Set the build-arg via an ENV in the local environment and verify that the cached layers are not used
   export TEST=bar
@@ -1887,6 +1890,7 @@ _EOF
 }

 @test "bud without any arguments should succeed" {
+  skip "does not work under podman"
   cd ${TESTSDIR}/bud/from-scratch
   run_buildah bud --signature-policy ${TESTSDIR}/policy.json
 }
@@ -1894,7 +1898,7 @@ _EOF
 @test "bud without any arguments should fail when no Dockerfile exist" {
   cd $(mktemp -d)
   run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json
-  expect_output --substring "no such file or directory"
+  expect_output "Error: no context directory and no Containerfile specified"
 }

 @test "bud with specified context should fail if directory contains no Dockerfile" {
@@ -1907,16 +1911,17 @@ _EOF
   DIR=$(mktemp -d)
   mkdir -p "$DIR"/Dockerfile
   run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json "$DIR"
-  expect_output --substring "is not a file"
+  expect_output --substring "Error: open .*: no such file or directory"
 }

 @test "bud with specified context should fail if context contains not-existing Dockerfile" {
   DIR=$(mktemp -d)
   run_buildah 125 bud --signature-policy ${TESTSDIR}/policy.json "$DIR"/Dockerfile
-  expect_output --substring "no such file or directory"
+  expect_output --substring "context must be a directory"
 }

 @test "bud with specified context should succeed if context contains existing Dockerfile" {
+  skip "podman requires a directory, not a Dockerfile"
   DIR=$(mktemp -d)
   echo "FROM alpine" > "$DIR"/Dockerfile
   run_buildah 0 bud --signature-policy ${TESTSDIR}/policy.json "$DIR"/Dockerfile
@@ -1968,7 +1973,7 @@ _EOF

 @test "bud-squash-hardlinks" {
   _prefetch busybox
-  run_buildah bud --signature-policy ${TESTSDIR}/policy.json --squash ${TESTSDIR}/bud/layers-squash/Dockerfile.hardlinks
+  run_buildah bud --signature-policy ${TESTSDIR}/policy.json --squash -f Dockerfile.hardlinks ${TESTSDIR}/bud/layers-squash
 }

 @test "bud with additional directory of devices" {
@@ -2134,6 +2139,7 @@ _EOF
 }

 @test "bud with Containerfile should fail with nonexistent authfile" {
+  skip "FIXME: podman issue #9572"
   target=alpine-image
   run_buildah 125 bud --authfile /tmp/nonexistent --signature-policy ${TESTSDIR}/policy.json -t ${target} ${TESTSDIR}/bud/containerfile
 }
@@ -2261,6 +2267,7 @@ EOM
 }

 @test "bud with encrypted FROM image" {
+  skip "Too much effort to spin up a local registry"
   _prefetch busybox
   mkdir ${TESTDIR}/tmp
   openssl genrsa -out ${TESTDIR}/tmp/mykey.pem 1024
@@ -2333,8 +2340,6 @@ EOM
   _prefetch alpine
   run_buildah bud --timestamp=0 --quiet --pull=false --signature-policy ${TESTSDIR}/policy.json -t timestamp -f Dockerfile.1 ${TESTSDIR}/bud/cache-stages
   cid=$output
-  run_buildah inspect --format '{{ .Docker.Created }}' timestamp
-  expect_output --substring "1970-01-01"
   run_buildah inspect --format '{{ .OCIv1.Created }}' timestamp
   expect_output --substring "1970-01-01"
   run_buildah inspect --format '{{ .History }}' timestamp
@@ -2594,6 +2599,7 @@ _EOF
 }

 @test "bud with --arch flag" {
+  skip "FIXME: for podman, emergency skip to get CI going"
   _prefetch alpine
   mytmpdir=${TESTDIR}/my-dir
   mkdir -p ${mytmpdir}
diff --git a/tests/helpers.bash b/tests/helpers.bash
index b28fd2c3..d42a6b82 100644
--- a/tests/helpers.bash
+++ b/tests/helpers.bash
@@ -70,7 +70,7 @@ function _prefetch() {
             mkdir -p ${_BUILDAH_IMAGE_CACHEDIR}
         fi

-        local _podman_opts="--root ${TESTDIR}/root --storage-driver ${STORAGE_DRIVER}"
+        local _podman_opts="--root ${TESTDIR}/root --runroot ${TESTDIR}/runroot --storage-driver ${STORAGE_DRIVER}"

         for img in "$@"; do
             echo "# [checking for: $img]" >&2
@@ -138,15 +138,35 @@ function run_buildah() {
         --retry)         retry=3;        shift;;  # retry network flakes
     esac

+    local podman_or_buildah=${BUILDAH_BINARY}
+    if [[ $1 == "bud" || $1 == "build-using-dockerfile" ]]; then
+        shift
+        # podman defaults to --layers=true; buildah to --false.
+        # If command line includes explicit --layers, leave it untouched,
+        # but otherwise update command line so podman mimics buildah default.
+        if [[ "$*" =~ --layers || "$*" =~ --squash ]]; then
+            set "build" "--force-rm=false" "$@"
+        else
+            set "build" "--force-rm=false" "--layers=false" "$@"
+        fi
+        podman_or_buildah=${PODMAN_BINARY}
+
+        # podman always exits 125 where buildah exits 1 or 2
+        case $expected_rc in
+            1|2)   expected_rc=125 ;;
+        esac
+    fi
+    local cmd_basename=$(basename ${podman_or_buildah})
+
     # Remember command args, for possible use in later diagnostic messages
-    MOST_RECENT_BUILDAH_COMMAND="buildah $*"
+    MOST_RECENT_BUILDAH_COMMAND="$cmd_basename $*"

     while [ $retry -gt 0 ]; do
         retry=$(( retry - 1 ))

         # stdout is only emitted upon error; this echo is to help a debugger
-        echo "\$ $BUILDAH_BINARY $*"
-        run timeout --foreground --kill=10 $BUILDAH_TIMEOUT ${BUILDAH_BINARY} --registries-conf ${TESTSDIR}/registries.conf --root ${TESTDIR}/root --runroot ${TESTDIR}/runroot --storage-driver ${STORAGE_DRIVER} "$@"
+        echo "\$ $cmd_basename $*"
+        run timeout --foreground --kill=10 $BUILDAH_TIMEOUT ${podman_or_buildah} --registries-conf ${TESTSDIR}/registries.conf --root ${TESTDIR}/root --runroot ${TESTDIR}/runroot --storage-driver ${STORAGE_DRIVER} "$@"
         # without "quotes", multiple lines are glommed together into one
         if [ -n "$output" ]; then
             echo "$output"
--
2.30.2