summaryrefslogtreecommitdiffstats
path: root/tests/roles/cli/tasks
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 /tests/roles/cli/tasks
parent4770dbb8bf1af8c6a58c2cc154838bc613d939e4 (diff)
downloadbuildah-619163f3a6ef9c19a644bd314382b0ff6edbddbc.tar.gz
buildah-619163f3a6ef9c19a644bd314382b0ff6edbddbc.tar.xz
buildah-619163f3a6ef9c19a644bd314382b0ff6edbddbc.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>
Diffstat (limited to 'tests/roles/cli/tasks')
-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
14 files changed, 404 insertions, 60 deletions
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 }}