summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuohua Ouyang <gouyang@redhat.com>2018-04-19 21:43:06 +0800
committerGuohua Ouyang <gouyang@redhat.com>2018-04-19 21:43:06 +0800
commit619163f3a6ef9c19a644bd314382b0ff6edbddbc (patch)
treeb620ef957f3ccf2de3c3e60a2165244707ccdf0f
parent4770dbb8bf1af8c6a58c2cc154838bc613d939e4 (diff)
downloadbuildah-master.tar.gz
buildah-master.tar.xz
buildah-master.zip
Sync new tests from upstreamfirstHEADmaster
* the tests is quite old since it moved from upstreamfirst * lots of new cases are added, like option 'run', 'inspect' etc * save log to TEST_ARTIFACTS when the variable is set * always run tests with latest runc built from source Signed-off-by: Guohua Ouyang <gouyang@redhat.com>
-rw-r--r--tests/binary.yml10
-rw-r--r--tests/callback_plugins/log.py64
-rwxr-xr-xtests/github.sh1
-rw-r--r--tests/github.yml19
-rw-r--r--tests/roles/cli/tasks/add.yaml27
-rw-r--r--tests/roles/cli/tasks/bud.yaml105
-rw-r--r--tests/roles/cli/tasks/cleanup.yaml13
-rw-r--r--tests/roles/cli/tasks/commit.yaml59
-rw-r--r--tests/roles/cli/tasks/config.yaml50
-rw-r--r--tests/roles/cli/tasks/copy.yaml19
-rw-r--r--tests/roles/cli/tasks/from.yaml27
-rw-r--r--tests/roles/cli/tasks/images.yaml65
-rw-r--r--tests/roles/cli/tasks/inspect.yaml25
-rw-r--r--tests/roles/cli/tasks/main.yaml36
-rw-r--r--tests/roles/cli/tasks/push.yaml7
-rw-r--r--tests/roles/cli/tasks/run.yaml10
-rw-r--r--tests/roles/cli/tasks/tag.yaml7
-rw-r--r--tests/roles/cli/tasks/version.yaml14
-rw-r--r--tests/roles/github-buildah/tasks/main.yml21
-rw-r--r--tests/roles/github-runc/tasks/main.yml16
-rw-r--r--tests/roles/prepare-env/tasks/main.yml24
-rw-r--r--tests/roles/tear-down/tasks/main.yml3
-rw-r--r--tests/rpm.yml9
-rwxr-xr-xtests/test.sh1
-rwxr-xr-xtests/test_binary.sh1
-rwxr-xr-xtests/test_rpm.sh1
-rw-r--r--tests/tests.yml8
27 files changed, 532 insertions, 110 deletions
diff --git a/tests/binary.yml b/tests/binary.yml
deleted file mode 100644
index 1c7803d..0000000
--- a/tests/binary.yml
+++ /dev/null
@@ -1,10 +0,0 @@
----
-# test buildah
-- hosts: all
- become: true
- tags:
- - classic
- roles:
- - binary
- - prepare-env
- - cli
diff --git a/tests/callback_plugins/log.py b/tests/callback_plugins/log.py
index f4f1ce9..c7d4d98 100644
--- a/tests/callback_plugins/log.py
+++ b/tests/callback_plugins/log.py
@@ -24,8 +24,14 @@ except ImportError: # < ansible 2.1
BASECLASS = DEFAULT_MODULE.CallbackModule
import os, sys
+try:
+ reload # Python 2.7
+except NameError:
+ try:
+ from importlib import reload # Python 3.4+
+ except ImportError:
+ from imp import reload
reload(sys)
-sys.setdefaultencoding('utf-8')
try:
import simplejson as json
@@ -50,7 +56,10 @@ class CallbackModule(CallbackBase):
def __init__(self, *args, **kwargs):
# pylint: disable=non-parent-init-called
BASECLASS.__init__(self, *args, **kwargs)
- self.artifacts = './artifacts'
+ if os.getenv("TEST_ARTIFACTS") is not None:
+ self.artifacts = os.getenv("TEST_ARTIFACTS")
+ else:
+ self.artifacts = './artifacts'
self.result_file = os.path.join(self.artifacts, 'test.log')
if not os.path.exists(self.artifacts):
os.makedirs(self.artifacts)
@@ -58,27 +67,34 @@ class CallbackModule(CallbackBase):
def human_log(self, data, taskname, status):
if type(data) == dict:
- with open('./artifacts/test.log', 'a') as f:
- f.write("\n\n")
+ with open(self.result_file, 'a') as f:
+ f.write("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n")
f.write("# TASK NAME: %s \n" % taskname)
- f.write("# STATUS: %s \n\n" % status)
- f.write("Outputs: \n\n")
- for field in FIELDS:
- no_log = data.get('_ansible_no_log', False)
- if field in data.keys() and data[field] and no_log != True:
- output = self._format_output(data[field])
- # The following two lines are a hack to make it work with UTF-8 characters
- if type(output) != list:
- output = output.encode('utf-8', 'replace')
- #self._display.display("\n{0}:\n{1}".format(field, output.replace("\\n","\n")), log_only=False)
- with open('./artifacts/test.log', 'a') as f:
- f.write("{0}: {1}".format(field, output.replace("\\n","\n"))+"\n")
-
-
- def _format_output(self, output):
+ f.write("# STATUS: %s \n" % status)
+ f.write("Outputs: \n")
+ for field in FIELDS:
+ no_log = data.get('_ansible_no_log', False)
+ if field in data.keys() and data[field] and no_log != True:
+ output = self._format_output(data[field], field)
+ # The following two lines are a hack to make it work with UTF-8 characters
+ if type(output) != list:
+ output = output.encode('utf-8', 'replace')
+ if type(output) == bytes:
+ output = output.decode('utf-8')
+
+ if field == "stdout":
+ f.write("{0}: {1}".format(field, "\n"+output.replace("\\n","\n"))+"\n")
+ else:
+ f.write("{0}: {1}".format(field, output.replace("\\n","\n"))+"\n")
+
+
+ def _format_output(self, output, field):
# Strip unicode
- if type(output) == unicode:
- output = output.encode(sys.getdefaultencoding(), 'replace')
+ try:
+ if type(output) == unicode:
+ output = output.encode(sys.getdefaultencoding(), 'replace')
+ except NameError:
+ pass
# If output is a dict
if type(output) == dict:
@@ -94,12 +110,14 @@ class CallbackModule(CallbackBase):
if type(item) == dict:
for field in FIELDS:
if field in item.keys():
- copy[field] = self._format_output(item[field])
+ copy[field] = self._format_output(item[field], field)
real_output.append(copy)
return json.dumps(output, indent=2, sort_keys=True)
# If output is a list of strings
if type(output) == list and type(output[0]) != dict:
+ if field == "cmd":
+ return ' '.join(output)
return '\n'.join(output)
# Otherwise it's a string, (or an int, float, etc.) just return it
@@ -113,6 +131,8 @@ class CallbackModule(CallbackBase):
self.human_log(result._result, result._task.name, "fail")
def v2_runner_on_ok(self, result):
+ if result._task.name == "":
+ return
self.human_log(result._result, result._task.name, "pass")
def v2_runner_on_skipped(self, result):
diff --git a/tests/github.sh b/tests/github.sh
new file mode 100755
index 0000000..4e448cf
--- /dev/null
+++ b/tests/github.sh
@@ -0,0 +1 @@
+ansible-playbook -i inventory github.yml "$@"
diff --git a/tests/github.yml b/tests/github.yml
new file mode 100644
index 0000000..8cbe881
--- /dev/null
+++ b/tests/github.yml
@@ -0,0 +1,19 @@
+---
+# test buildah
+- hosts: localhost
+ become: true
+ tags:
+ - classic
+ roles:
+ - role: prepare-env
+ tags:
+ - env
+ - role: github-buildah
+ tags:
+ - github-buildah
+ - role: github-runc
+ tags:
+ - github-runc
+ - role: cli
+ tags:
+ - cli
diff --git a/tests/roles/cli/tasks/add.yaml b/tests/roles/cli/tasks/add.yaml
index 0bd6498..94ad716 100644
--- a/tests/roles/cli/tasks/add.yaml
+++ b/tests/roles/cli/tasks/add.yaml
@@ -23,19 +23,36 @@
- name: check buildah add URL to destination
command: ls {{mount.stdout}}/home/README.md
+- name: create /tmp/buildah/addcopy
+ file: path=/tmp/buildah/addcopy state=directory
+
- name: Download buildah README.md
get_url:
url: https://github.com/projectatomic/buildah/raw/master/README.md
- dest: /tmp/buildah/
+ dest: /tmp/buildah/addcopy/
- name: buildah add dir
- command: buildah add nginxc /tmp
+ command: buildah add nginxc /tmp/buildah
- name: check buildah add dir
- command: ls {{mount.stdout}}/buildah/README.md
+ command: ls {{mount.stdout}}/addcopy/README.md
- name: buildah add dir to destination
- command: buildah add nginxc /tmp /home
+ command: buildah add nginxc /tmp/buildah /home
- name: check buildah add dir to destination
- command: ls {{mount.stdout}}/home/buildah/README.md
+ command: ls {{mount.stdout}}/home/addcopy/README.md
+
+- name: buildah add a tarball file
+ command: buildah add nginxc /var/www/html/bud/Dockerfile.tar.gz /home
+
+- name: check buildah has added content of tarball to container
+ command: ls {{mount.stdout}}/home/hello
+
+- name: buildah add with option chown
+ command: buildah add --chown bin:bin nginxc /tmp/buildah/bud /home
+
+- name: check user after add with option chown
+ raw: buildah run nginxc -- ls -l /home/hello
+ register: ast
+ failed_when: '"bin" not in ast.stdout'
diff --git a/tests/roles/cli/tasks/bud.yaml b/tests/roles/cli/tasks/bud.yaml
index 1f1c678..6dc42fa 100644
--- a/tests/roles/cli/tasks/bud.yaml
+++ b/tests/roles/cli/tasks/bud.yaml
@@ -1,24 +1,103 @@
---
-- name: buildah bud localfile
- command: buildah bud -t testing/nginx --pull /tmp/buildah/bud
+- name: buildah bud with image's format oci
+ command: buildah bud --format=oci --tag testing/fmtoci /tmp/buildah/bud
+
+- name: buildah bud with image's format docker
+ command: buildah bud -t testing/fmtdocker --format=docker /tmp/buildah/bud
-- name: check bud images with buildah images command
- shell: buildah images | grep testing/nginx
+- name: buildah bud localfile
+ command: buildah bud -t testing/hello --pull /tmp/buildah/bud
- name: buildah bud -f localfile
- command: buildah bud -t testing/nginx2 -f /tmp/buildah/bud/Dockerfile .
+ command: buildah bud -t testing/hello2 -f /tmp/buildah/bud/Dockerfile /tmp/buildah/bud
- name: buildah bud URL
- command: buildah bud -t testing/nginx3 http://localhost/bud/Dockerfile.tar.gz
+ command: buildah bud -t testing/hello3 http://localhost/bud/Dockerfile.tar.gz
- name: buildah build-using-dockerfile localfile
- command: buildah build-using-dockerfile -t testing/nginx4 /tmp/buildah/bud
+ command: buildah build-using-dockerfile -t testing/hello4 /tmp/buildah/bud
+
+- lineinfile:
+ path: /tmp/buildah/bud/Dockerfile
+ regexp: '^COPY'
+ line: 'COPY $foo /'
+
+- name: buildah bud with build-arg
+ command: buildah bud -t testing/hello5 --build-arg foo=hello /tmp/buildah/bud
+
+- name: create container from bud images
+ command: buildah from docker.io/testing/{{ item }}
+ with_items:
+ - hello
+ - hello2
+ - hello3
+ - hello4
+ - hello5
+
+- name: list containers
+ command: buildah containers
+ register: ctrs
+
+- name: run containers from bud images
+ command: buildah run {{ item }}-working-container
+ register: hello
+ with_items:
+ - hello
+ - hello2
+ - hello3
+ - hello4
+ - hello5
+
+- name: verify string hello in container hellos
+ fail:
+ msg: '"Hello from Docker" not found after container run'
+ when: '"Hello from Docker" not in item.stdout'
+ with_items: "{{ hello.results }}"
+
+- name: buildah rm containers of hello
+ command: buildah rm {{ item }}-working-container
+ with_items:
+ - hello
+ - hello2
+ - hello3
+ - hello4
+ - hello5
+
+
+- name: buildah bud --quiet
+ command: buildah bud --quiet -t testing/hello6 /tmp/buildah/bud
+ register: budquiet
+ failed_when: '"STEP" in budquiet.stdout'
+
+- name: buildah bud -q
+ command: buildah bud -q -t testing/hello7 /tmp/buildah/bud
+ register: budq
+ failed_when: '"STEP" in budq.stdout'
+
+- lineinfile:
+ path: /tmp/buildah/bud/Dockerfile
+ regexp: "^FROM"
+ line: "FROM localhost:5000/buildah/busybox"
-- name: buildah build-using-dockerfile -f localfile
- command: buildah build-using-dockerfile -t testing/nginx5 --file /tmp/buildah/bud/Dockerfile .
+- name: verify bud image from local docker registry without tls-verify is failed
+ command: buildah bud -t testing/hellofail /tmp/buildah/bud
+ register: st
+ failed_when: st.rc != 1
-- name: buildah build-using-dockerfile URL
- command: buildah build-using-dockerfile --tag testing/nginx6 http://localhost/bud/Dockerfile.tar.gz
+- name: buildah bud image from local docker registry is successful
+ command: buildah bud --tls-verify=false -t testing/hello8 /tmp/buildah/bud
-- name: buildah rmi
- command: buildah rmi testing/nginx{2..6}
+- name: buildah rmi hello images
+ command: buildah rmi {{ item }}
+ with_items:
+ - testing/hello
+ - testing/hello2
+ - testing/hello3
+ - testing/hello4
+ - testing/hello5
+ - testing/hello6
+ - testing/hello7
+ - testing/hello8
+ - testing/fmtoci
+ - testing/fmtdocker
+ - localhost:5000/buildah/busybox
diff --git a/tests/roles/cli/tasks/cleanup.yaml b/tests/roles/cli/tasks/cleanup.yaml
index 45f31d5..e14ffb1 100644
--- a/tests/roles/cli/tasks/cleanup.yaml
+++ b/tests/roles/cli/tasks/cleanup.yaml
@@ -1,4 +1,11 @@
---
-- name: remove buildah containers after testing
- command: buildah rm busybox nginxc nginxc-2
- ignore_errors: true
+- block:
+ - name: remove all buildah containers after testing
+ command: buildah rm -a
+
+ - name: remove all images after testing
+ command: buildah rmi -a
+
+ always:
+ - include_role:
+ name: tear-down
diff --git a/tests/roles/cli/tasks/commit.yaml b/tests/roles/cli/tasks/commit.yaml
new file mode 100644
index 0000000..06f3505
--- /dev/null
+++ b/tests/roles/cli/tasks/commit.yaml
@@ -0,0 +1,59 @@
+---
+- name: buildah commit an image by name
+ command: buildah commit nginxc-2 commitbyname/nginxbyname
+
+- name: check commit images by name is existed
+ command: buildah images commitbyname/nginxbyname
+
+- name: get container ID
+ shell: buildah containers | grep nginxc-2 | awk '{print $1}'
+ register: cid
+
+- name: buildah commit an image by ID
+ command: buildah commit {{ cid.stdout }} commitbyid/nginxbyid
+
+- name: check commit images by ID is existed
+ command: buildah images commitbyid/nginxbyid
+
+- name: buildah from commit image
+ command: buildah from docker.io/commitbyid/nginxbyid
+
+- name: check container nginxbyid exists by inspect
+ command: buildah inspect nginxbyid-working-container
+
+- name: buildah commit to docker-distribution
+ command: buildah commit --tls-verify=false nginxbyid-working-container docker://localhost:5000/commit/nginx
+
+- name: buildah commit quiet
+ command: buildah commit --quiet --tls-verify=false nginxbyid-working-container docker://localhost:5000/commit/nginx
+ register: quietcommit
+ failed_when: '"Getting" in quietcommit.stdout'
+
+- name: create container from commit images on docker-distribution
+ command: buildah from --tls-verify=false docker://localhost:5000/commit/nginx
+
+- name: buildah commit with rm container
+ command: buildah commit --rm -q --tls-verify=false nginxbyid-working-container docker://localhost:5000/commit/nginx
+
+- name: verify the container is removed after commit
+ command: buildah inspect nginxbyid-working-container
+ register: commitrm
+ failed_when: commitrm.rc != 1
+
+- name: buildah commit format oci
+ command: buildah commit --disable-compression --format=oci nginx-working-container nginxoci
+
+- name: buildah commit format docker
+ command: buildah commit -D -f docker nginx-working-container nginxdocker
+
+- name: remove containers from commit images
+ command: buildah rm nginx-working-container
+
+- name: remove images from commit
+ command: buildah rmi {{ item }}
+ with_items:
+ - localhost:5000/commit/nginx
+ - commitbyid/nginxbyid
+ - commitbyname/nginxbyname
+ - nginxoci
+ - nginxdocker
diff --git a/tests/roles/cli/tasks/config.yaml b/tests/roles/cli/tasks/config.yaml
index 91e8bc3..d1e88bd 100644
--- a/tests/roles/cli/tasks/config.yaml
+++ b/tests/roles/cli/tasks/config.yaml
@@ -1,16 +1,48 @@
---
+- name: buildah config annotation
+ command: buildah config --annotation annotation=test-annotation nginxc
+
+- name: buildah config arch
+ command: buildah config --arch x86_64 nginxc
+
+- name: buildah config author
+ command: buildah config --author "Guohua Ouyang" nginxc
+
+- name: buildah config cmd
+ command: buildah config --cmd "nginx -g 'daemon off;'" nginxc
+
+- name: buildah config createdby
+ command: buildah config --created-by "manualcreated" nginxc
+
+- name: buildah config label
+ command: buildah config --label label=test-label nginxc
+
+- name: buildah config port
+ command: buildah config --port 8001 nginxc
+
+- name: buildah config user
+ command: buildah config --user www-data nginxc
+
- name: buildah config workingdir
command: buildah config --workingdir /opt nginxc
-- name: get buildah config workingdir
- command: buildah run nginxc "pwd"
- register: checkworkingdir
- failed_when: "'/opt' not in checkworkingdir.stdout"
-
- name: buildah config env
command: buildah config --env foo=bar nginxc
-- name: get buildah config env
- command: buildah run nginxc env
- register: env
- failed_when: "'foo=bar' not in env.stdout"
+- name: buildah config os
+ command: buildah config --os unix nginxc
+
+- name: verify the container after config
+ shell: buildah inspect nginxc | grep '{{ item }}'
+ with_items:
+ - test-annotation
+ - x86_64
+ - test-label
+ - Ouyang
+ - daemon off
+ - manualcreated
+ - 8001
+ - www-data
+ - opt
+ - foo=bar
+ - unix
diff --git a/tests/roles/cli/tasks/copy.yaml b/tests/roles/cli/tasks/copy.yaml
index 3f0d8c5..fd6253a 100644
--- a/tests/roles/cli/tasks/copy.yaml
+++ b/tests/roles/cli/tasks/copy.yaml
@@ -23,19 +23,22 @@
- name: check buildah copy URL to destination
command: ls {{mount.stdout}}/home/README.md
-- name: Download buildah README.md
- get_url:
- url: https://github.com/projectatomic/buildah/raw/master/README.md
- dest: /tmp/buildah/
-
- name: buildah copy dir
command: buildah copy nginxc-2 /tmp/buildah
- name: check buildah copy dir
- command: ls {{mount.stdout}}/README.md
+ command: ls {{mount.stdout}}/addcopy/README.md
- name: buildah copy dir to destination
- command: buildah copy nginxc-2 /tmp /home
+ command: buildah copy nginxc-2 /tmp/buildah /home
- name: check buildah copy dir to destination
- command: ls {{mount.stdout}}/home/buildah/README.md
+ command: ls {{mount.stdout}}/home/addcopy/README.md
+
+- name: buildah copy with option chown
+ command: buildah copy --chown nginx:nginx nginxc-2 /tmp/buildah/bud /home
+
+- name: check user after copy with option chown
+ command: buildah run nginxc-2 -- ls -l /home/hello
+ register: cst
+ failed_when: '"nginx" not in cst.stdout'
diff --git a/tests/roles/cli/tasks/from.yaml b/tests/roles/cli/tasks/from.yaml
index e694b10..7dac3e7 100644
--- a/tests/roles/cli/tasks/from.yaml
+++ b/tests/roles/cli/tasks/from.yaml
@@ -1,12 +1,23 @@
---
-- name: buildah from pull
- command: buildah from --pull nginx
+- name: remove all containers before pull
+ command: buildah rm --all
-- name: buildah from pull always
- command: buildah from --pull-always nginx
+- name: buildah from without pull
+ command: buildah from --name nginxc docker.io/nginx
-- name: buildah from with name
- command: buildah from --name nginx nginx
+- name: buildah from with pull
+ command: buildah from --pull --name nginxc-2 docker.io/nginx
-- name: clean from testings
- command: buildah delete nginx nginx-working-container nginx-working-container-2
+- name: buildah from with pull always
+ command: buildah from --pull-always docker.io/busybox
+
+- name: remove busybox-working-container
+ command: buildah rm busybox-working-container
+
+- name: remove exist image so it will pull again
+ command: buildah rmi busybox
+
+- name: buildah from with quiet
+ command: buildah from --quiet docker.io/busybox
+ register: quietpull
+ failed_when: '"Getting" in quietpull.stdout'
diff --git a/tests/roles/cli/tasks/images.yaml b/tests/roles/cli/tasks/images.yaml
new file mode 100644
index 0000000..f113ba0
--- /dev/null
+++ b/tests/roles/cli/tasks/images.yaml
@@ -0,0 +1,65 @@
+---
+- name: verify buildah images digests
+ command: buildah images --digests
+ register: digest
+ failed_when: '"sha256" not in digest.stdout'
+
+- name: verify buildah images output json
+ command: buildah images --json
+ register: json
+ failed_when: '"id" not in json.stdout'
+
+- name: verify buildah images noheading
+ command: buildah images --noheading
+ register: head
+ failed_when: '"IMAGE" in head.stdout'
+
+- name: verify buildah images quiet
+ command: buildah images --quiet
+ register: quiet
+ failed_when: '"NAME" in quiet.stdout'
+
+- name: verify buildah images format output
+ command: buildah images --format "{% raw %}{{.ID}} {{.Name}} {{.CreatedAt}} {{.Size}}{% endraw %}"
+ register: format
+
+- lineinfile:
+ path: /tmp/buildah/bud/Dockerfile
+ insertafter: '^FROM'
+ line: 'LABEL project=buildah'
+
+- name: buildah bud with LABEL in Dockerfile
+ command: buildah bud --tls-verify=false -t testing/label /tmp/buildah/bud
+
+- name: verify buildah images filter by label
+ command: buildah images -f "label=project=buildah"
+ register: label
+ failed_when: '"testing/label" not in label.stdout'
+
+- name: buildah bud an image to test filter since/before
+ command: buildah bud -t testing/since /tmp/buildah/bud
+
+- name: verify buildah images filter by since
+ command: buildah images -f "since=label"
+ register: since
+ failed_when: '"testing/label" in since.stdout and "testing/since" in since.stdout'
+
+- name: verify buildah images filter by before
+ command: buildah images -f "before=since"
+ register: before
+ failed_when: '"testing/label" not in before.stdout and "testing/since" in before.stdout'
+
+- name: buildah build an image to test filter dangling
+ command: buildah bud -t testing/label /tmp/buildah/bud
+
+- name: verify buildah images filter by dangling
+ command: buildah images -f "dangling=true" -q
+ register: dangling
+
+- name: remove testing images after buildah images
+ command: buildah rmi {{ item }}
+ with_items:
+ - testing/label
+ - testing/since
+ - "{{ dangling.stdout }}"
+ - localhost:5000/buildah/busybox
diff --git a/tests/roles/cli/tasks/inspect.yaml b/tests/roles/cli/tasks/inspect.yaml
new file mode 100644
index 0000000..d1d8024
--- /dev/null
+++ b/tests/roles/cli/tasks/inspect.yaml
@@ -0,0 +1,25 @@
+---
+- name: buildah inspect an image by name
+ command: buildah inspect docker.io/library/nginx:latest
+
+- name: get image ID
+ command: buildah images -q docker.io/library/nginx:latest
+ register: imgid
+
+- name: buildah inspect an image by ID
+ command: buildah inspect --type image {{ imgid.stdout }}
+
+- name: buildah inspect image with format
+ command: buildah inspect -t image -f {% raw %}'{{ .FromImageID }}'{% endraw %} {{ imgid.stdout }}
+ register: inspectid
+ failed_when: 'inspectid.stdout != imgid.stdout'
+
+- name: buildah inspect container by name
+ command: buildah inspect -t container nginxc-2
+
+- name: buildah inspect container with format
+ shell: buildah inspect -f {% raw %}'{{ .ContainerID }}'{% endraw %} nginxc-2
+ register: inspectcid
+
+- name: buildah inspect container by ID
+ command: buildah inspect {{ inspectcid.stdout }}
diff --git a/tests/roles/cli/tasks/main.yaml b/tests/roles/cli/tasks/main.yaml
index f709887..4586cd7 100644
--- a/tests/roles/cli/tasks/main.yaml
+++ b/tests/roles/cli/tasks/main.yaml
@@ -1,20 +1,20 @@
---
- block:
- - name: prepare containers nginxc
- import_tasks: prepare-containers.yaml
+ - name: buildah version
+ import_tasks: version.yaml
tags:
- - nginxc
-
- - name: buildah containers
- import_tasks: containers.yaml
- tags:
- - ctr
+ - version
- name: buildah from
import_tasks: from.yaml
tags:
- from
+ - name: buildah containers
+ import_tasks: containers.yaml
+ tags:
+ - ctr
+
- name: buildah mount
import_tasks: mount.yaml
tags:
@@ -30,6 +30,16 @@
tags:
- config
+ - name: buildah commit
+ import_tasks: commit.yaml
+ tags:
+ - commit
+
+ - name: buildah inspect
+ import_tasks: inspect.yaml
+ tags:
+ - inspect
+
- name: buildah push
import_tasks: push.yaml
tags:
@@ -40,5 +50,15 @@
tags:
- bud
+ - name: buildah images
+ import_tasks: images.yaml
+ tags:
+ - images
+
+ - name: buildah run
+ import_tasks: run.yaml
+ tags:
+ - run
+
always:
- import_tasks: cleanup.yaml
diff --git a/tests/roles/cli/tasks/push.yaml b/tests/roles/cli/tasks/push.yaml
index cc38b51..f16112b 100644
--- a/tests/roles/cli/tasks/push.yaml
+++ b/tests/roles/cli/tasks/push.yaml
@@ -1,6 +1,6 @@
---
- name: pull busybox before push
- command: buildah from --pull --name busybox busybox
+ command: buildah from --pull --name busybox docker.io/busybox
- name: buildah push image to containers-storage
command: buildah push docker.io/busybox:latest containers-storage:docker.io/busybox:latest
@@ -46,15 +46,20 @@
- name: init default ostree repo
command: ostree --repo=/ostree/repo init
+ when: not ansible_distribution == "CentOS"
- name: create /tmp/buildah/ostree/repo
file: path=/tmp/buildah/ostree/repo state=directory
+ when: not ansible_distribution == "CentOS"
- name: init tmp ostree repo
command: ostree --repo=/tmp/buildah/ostree/repo init
+ when: not ansible_distribution == "CentOS"
- name: buildah push image to ostree
command: buildah push docker.io/busybox:latest ostree:busybox:latest
+ when: not ansible_distribution == "CentOS"
- name: buildah push image to non-default ostree repo
command: buildah push docker.io/busybox:latest ostree:busybox:latest@/tmp/buildah/ostree/repo
+ when: not ansible_distribution == "CentOS"
diff --git a/tests/roles/cli/tasks/run.yaml b/tests/roles/cli/tasks/run.yaml
new file mode 100644
index 0000000..d80a823
--- /dev/null
+++ b/tests/roles/cli/tasks/run.yaml
@@ -0,0 +1,10 @@
+---
+- name: buildah run with option hostname
+ command: buildah run --hostname example.buildah.com nginxc -- hostname
+ register: hostname
+ failed_when: '"example.buildah.com" not in hostname.stdout'
+
+- name: buildah run with option volume
+ command: buildah run --volume /tmp/buildah/bud:/home nginxc ls /home
+ register: volume
+ failed_when: '"hello" not in volume.stdout'
diff --git a/tests/roles/cli/tasks/tag.yaml b/tests/roles/cli/tasks/tag.yaml
index 32767ba..6b638bb 100644
--- a/tests/roles/cli/tasks/tag.yaml
+++ b/tests/roles/cli/tasks/tag.yaml
@@ -1,7 +1,4 @@
---
-- name: buildah from --pull busybox
- command: buildah from busybox
-
- name: buildah tag by name
command: buildah tag busybox busybox1
@@ -19,7 +16,7 @@
shell: buildah images | grep busybox2
- name: buildah from tagged image
- command: buildah from busybox1
+ command: buildah from docker.io/busybox1
- name: mount the container which using tagged image
command: buildah mount busybox1-working-container
@@ -34,7 +31,7 @@
command: buildah rm busybox1-working-container
- name: buildah rmi tagged image
- command: buildah rmi busybox{1..2}
+ shell: buildah rmi busybox{1..2}
- name: check image busybox is not deleted
shell: buildah images | grep busybox
diff --git a/tests/roles/cli/tasks/version.yaml b/tests/roles/cli/tasks/version.yaml
new file mode 100644
index 0000000..05616a5
--- /dev/null
+++ b/tests/roles/cli/tasks/version.yaml
@@ -0,0 +1,14 @@
+---
+- name: check version of buildah rpm package
+ command: rpm -q buildah
+ register: rpmver
+ args:
+ warn: no
+
+- debug: msg={{ rpmver.stdout }}
+
+- name: check version of command buildah version
+ command: buildah version
+ register: ver
+
+- debug: msg={{ ver.stdout }}
diff --git a/tests/roles/github-buildah/tasks/main.yml b/tests/roles/github-buildah/tasks/main.yml
new file mode 100644
index 0000000..71edef8
--- /dev/null
+++ b/tests/roles/github-buildah/tasks/main.yml
@@ -0,0 +1,21 @@
+---
+- name: pull latest buildah source from github
+ git:
+ repo: https://github.com/projectatomic/buildah
+ dest: "{{ ansible_env.HOME }}/go/src/github.com/projectatomic/buildah"
+
+- name: make binary for buildah
+ command: make
+ args:
+ chdir: "{{ ansible_env.HOME }}/go/src/github.com/projectatomic/buildah"
+
+- name: install buildah to /usr/local/bin
+ command: make install
+ args:
+ chdir: "{{ ansible_env.HOME }}/go/src/github.com/projectatomic/buildah"
+
+- name: copy buildah to /usr/bin
+ copy:
+ remote_src: True
+ src: "{{ ansible_env.HOME }}/go/src/github.com/projectatomic/buildah/buildah"
+ dest: /usr/bin/buildah
diff --git a/tests/roles/github-runc/tasks/main.yml b/tests/roles/github-runc/tasks/main.yml
new file mode 100644
index 0000000..1752a24
--- /dev/null
+++ b/tests/roles/github-runc/tasks/main.yml
@@ -0,0 +1,16 @@
+---
+- name: pull latest runc source from github
+ git:
+ repo: https://github.com/opencontainers/runc
+ dest: "{{ ansible_env.HOME }}/go/src/github.com/opencontainers/runc"
+
+- name: building runc for buildah runtime
+ command: make
+ args:
+ chdir: "{{ ansible_env.HOME }}/go/src/github.com/opencontainers/runc"
+
+- name: copy runc to /usr/bin
+ copy:
+ remote_src: True
+ src: "{{ ansible_env.HOME }}/go/src/github.com/opencontainers/runc/runc"
+ dest: /usr/bin/runc
diff --git a/tests/roles/prepare-env/tasks/main.yml b/tests/roles/prepare-env/tasks/main.yml
index bc46794..ff92b87 100644
--- a/tests/roles/prepare-env/tasks/main.yml
+++ b/tests/roles/prepare-env/tasks/main.yml
@@ -11,6 +11,9 @@
- ostree
- httpd
- libselinux-python
+ - golang
+ - make
+ - libseccomp-devel
- name: start docker daemon
systemd: state=started name=docker
@@ -21,21 +24,32 @@
- name: ensure docker-distribution service is running
systemd: state=started name=docker-distribution
-- name: creates directory buildah testing
+- name: create tmp directory for buildah testing
file: path=/tmp/buildah/bud state=directory
-- name: download Dockerfile
+- name: download Dockerfile for hello-world from github
get_url:
- url: https://github.com/fedora-cloud/Fedora-Dockerfiles/raw/master/nginx/Dockerfile
+ url: https://raw.githubusercontent.com/docker-library/hello-world/master/amd64/hello-world/Dockerfile
dest: /tmp/buildah/bud/Dockerfile
+ force: yes
-- name: creates a bud directory in /var/www/html
+- name: download hello for the Dockerfile
+ get_url:
+ url: https://github.com/docker-library/hello-world/raw/master/amd64/hello-world/hello
+ dest: /tmp/buildah/bud/hello
+ force: yes
+ mode: 0755
+
+- name: create a bud directory in /var/www/html
file: path=/var/www/html/bud state=directory
- name: archive dockerfile into httpd directory
- command: tar zcvf /var/www/html/bud/Dockerfile.tar.gz Dockerfile
+ command: tar zcvf /var/www/html/bud/Dockerfile.tar.gz Dockerfile hello
args:
chdir: /tmp/buildah/bud
+ # Disables the following warning:
+ # Consider using unarchive module rather than running tar
+ warn: no
- name: start httpd service
systemd: state=started name=httpd
diff --git a/tests/roles/tear-down/tasks/main.yml b/tests/roles/tear-down/tasks/main.yml
index f54186d..091971d 100644
--- a/tests/roles/tear-down/tasks/main.yml
+++ b/tests/roles/tear-down/tasks/main.yml
@@ -4,3 +4,6 @@
- name: stop httpd service
systemd: state=stopped name=httpd
+
+- name: remove /tmp/buildah
+ file: path=/tmp/buildah state=absent
diff --git a/tests/rpm.yml b/tests/rpm.yml
deleted file mode 100644
index 27a9349..0000000
--- a/tests/rpm.yml
+++ /dev/null
@@ -1,9 +0,0 @@
----
-# test buildah
-- hosts: all
- become: true
- tags:
- - classic
- roles:
- - prepare-env
- - cli
diff --git a/tests/test.sh b/tests/test.sh
new file mode 100755
index 0000000..d4149f5
--- /dev/null
+++ b/tests/test.sh
@@ -0,0 +1 @@
+ansible-playbook -i inventory tests.yml "$@"
diff --git a/tests/test_binary.sh b/tests/test_binary.sh
deleted file mode 100755
index 1290479..0000000
--- a/tests/test_binary.sh
+++ /dev/null
@@ -1 +0,0 @@
-ansible-playbook -i inventory binary.yml "$@"
diff --git a/tests/test_rpm.sh b/tests/test_rpm.sh
deleted file mode 100755
index 3634f61..0000000
--- a/tests/test_rpm.sh
+++ /dev/null
@@ -1 +0,0 @@
-ansible-playbook -i inventory buildah_rpm.yml "$@"
diff --git a/tests/tests.yml b/tests/tests.yml
index 74f63e8..76e3e43 100644
--- a/tests/tests.yml
+++ b/tests/tests.yml
@@ -5,8 +5,12 @@
tags:
- classic
roles:
- - prepare-env
+ - role: prepare-env
+ tags:
+ - env
+ - role: github-runc
+ tags:
+ - github-runc
- role: cli
tags:
- cli
- - tear-down