From 61b08aabfe613d61509be584923344528292b855 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 20 2017 17:35:59 +0000 Subject: [PATCH 1/7] First pass on the gc tests --- diff --git a/gc/.gitignore b/gc/.gitignore new file mode 100644 index 0000000..a8b42eb --- /dev/null +++ b/gc/.gitignore @@ -0,0 +1 @@ +*.retry diff --git a/gc/files/Dockerfile b/gc/files/Dockerfile new file mode 100644 index 0000000..ece9c2e --- /dev/null +++ b/gc/files/Dockerfile @@ -0,0 +1,11 @@ +FROM registry.fedoraproject.org/fedora:FEDORA_VERSION +MAINTAINER Package maintainer + +VOLUME ["/code"] + +RUN curl -o /tmp/tst-gc.c https://upstreamfirst.fedorainfracloud.org/gc/raw/master/f/smoke-test/tst-gc.c +RUN dnf install -y gcc gc-devel + +WORKDIR /tmp/ + +ENTRYPOINT ["gcc", "-lgc", "tst-gc.c", "-o", "/code/tst-gc"] diff --git a/gc/files/tst-gc.c b/gc/files/tst-gc.c new file mode 100644 index 0000000..79afb91 --- /dev/null +++ b/gc/files/tst-gc.c @@ -0,0 +1,23 @@ +/* Example program snagged from gc's homepage: +http://www.hboehm.info/gc/simple_example.html */ + +#include "gc.h" +#include +#include + +int main() +{ + int i; + + GC_INIT(); /* Optional on Linux/X86; see below. */ + for (i = 0; i < 10000000; ++i) + { + int **p = (int **) GC_MALLOC(sizeof(int *)); + int *q = (int *) GC_MALLOC_ATOMIC(sizeof(int)); + assert(*p == 0); + *p = (int *) GC_REALLOC(q, 2 * sizeof(int)); + if (i % 100000 == 0) + printf("Heap size = %d\n", GC_get_heap_size()); + } + return 0; +} diff --git a/gc/tests.yml b/gc/tests.yml new file mode 100644 index 0000000..8734528 --- /dev/null +++ b/gc/tests.yml @@ -0,0 +1,116 @@ +# Tests for gc following the standard test interface defined at: +# https://fedoraproject.org/wiki/CI + +--- +# Tests for Docker and Classic Context +- hosts: localhost + gather_facts: yes + remote_user: root + vars: + artifacts: "{{ lookup('env', 'TEST_ARTIFACTS')|default('./artifacts', true) }}" + subjects: "{{ lookup('env', 'TEST_SUBJECTS')}}" + tags: + - classic + - container + + tasks: + - name: Make artifacts directory + file: path={{ artifacts }} state=directory + owner=root mode=755 recurse=yes + + - name: Install the required packages + package: + name: "{{ item }}" + state: present + with_items: + - gcc + - gc-devel + - gc + + - name: Install the test files + copy: src=tst-gc.c dest={{ artifacts }} mode=0755 + + - name: Compile the test file + shell: gcc -lgc tst-gc.c -o tst-gc + args: + chdir: "{{ artifacts }}" + + - name: Run the test file + shell: ./tst-gc > out + args: + chdir: "{{ artifacts }}" + + - name: Check/grep the output + shell: grep "Heap size = [1-9][0-9]*" out + args: + chdir: "{{ artifacts }}" + + +# Tests for Atomic host +- hosts: localhost + gather_facts: yes + remote_user: root + vars: + artifacts: "{{ lookup('env', 'TEST_ARTIFACTS')|default('./artifacts', true) }}" + subjects: "{{ lookup('env', 'TEST_SUBJECTS')}}" + tags: + - atomic + + tasks: + - name: Get the OS version running + shell: grep VERSION_ID /etc/os-release | sed -e 's/VERSION_ID=//' + register: os_rel + + - name: Create a tmp folder to operate in + shell: mktemp -d + register: tmp_dir + + - name: Make artifacts directory + file: path={{ artifacts }} state=directory + owner=root mode=755 recurse=yes + + - name: Copy the Dockerfile + copy: src=Dockerfile dest={{ tmp_dir.stdout }} mode=0644 + + - name: Update the Dockerfile to pull {{ os_rel.stdout }} + shell: sed -i -e 's/FEDORA_VERSION/{{ os_rel.stdout}}/' Dockerfile + args: + chdir: "{{ tmp_dir.stdout }}" + + # Check changes + #- name: check the dockerfile + #shell: cat Dockerfile + #args: + #chdir: "{{ tmp_dir.stdout }}" + #register: tmp + + #- debug: msg="{{ tmp.stdout }}" + + - name: Build the container + shell: docker build -f {{ tmp_dir.stdout }}/Dockerfile . -t dockahbuild + args: + chdir: "{{ tmp_dir.stdout }}" + + - name: Run the container so we can get the binary + shell: docker run -v /tmp/build:/code:Z dockahbuild + args: + chdir: "{{ tmp_dir.stdout }}" + + - name: Get the binary + shell: cp /tmp/build/tst-gc {{ artifacts }} + + - name: Run the test file + shell: ./tst-gc > out + args: + chdir: "{{ artifacts }}" + + - name: Check/grep the output + shell: grep "Heap size = [1-9][0-9]*" out + args: + chdir: "{{ artifacts }}" + + +# curl -Lo atomic.qcow2 https://ftp-stud.hs-esslingen.de/pub/Mirrors/alt.fedoraproject.org/atomic/stable/Fedora-Atomic-26-20170707.1/CloudImages/x86_64/images/Fedora-Atomic-26-20170707.1.x86_64.qcow2 +# export ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory) +# export TEST_SUBJECTS=$PWD/atomic.qcow2 +# ansible-playbook --tags=atomic tests.yml From 42ec4e78dec41416bc4fd33246ee0cdb4d1c9940 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 21 2017 10:22:20 +0000 Subject: [PATCH 2/7] Have ansible install the tst-gc.c file and make it accessible in the container --- diff --git a/gc/files/Dockerfile b/gc/files/Dockerfile index ece9c2e..abce35b 100644 --- a/gc/files/Dockerfile +++ b/gc/files/Dockerfile @@ -3,9 +3,8 @@ MAINTAINER Package maintainer VOLUME ["/code"] -RUN curl -o /tmp/tst-gc.c https://upstreamfirst.fedorainfracloud.org/gc/raw/master/f/smoke-test/tst-gc.c RUN dnf install -y gcc gc-devel -WORKDIR /tmp/ +WORKDIR /code ENTRYPOINT ["gcc", "-lgc", "tst-gc.c", "-o", "/code/tst-gc"] diff --git a/gc/tests.yml b/gc/tests.yml index 8734528..dfd8eb8 100644 --- a/gc/tests.yml +++ b/gc/tests.yml @@ -65,12 +65,18 @@ shell: mktemp -d register: tmp_dir - - name: Make artifacts directory - file: path={{ artifacts }} state=directory + - name: Make directories we use + file: path={{ item }} state=directory owner=root mode=755 recurse=yes + with_items: + - "{{ artifacts }}" + - "/tmp/build" - - name: Copy the Dockerfile - copy: src=Dockerfile dest={{ tmp_dir.stdout }} mode=0644 + - name: Copy the Dockerfile and the test-gc.c file + copy: src={{ item.name}} dest={{ item.dest }} mode=0644 + with_items: + - {name: Dockerfile, dest: "{{ tmp_dir.stdout }}"} + - {name: tst-gc.c, dest: "/tmp/build"} - name: Update the Dockerfile to pull {{ os_rel.stdout }} shell: sed -i -e 's/FEDORA_VERSION/{{ os_rel.stdout}}/' Dockerfile From 70d55307b4842dd165c5d413ef133dff16f01e45 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 21 2017 11:13:55 +0000 Subject: [PATCH 3/7] Use a block construct and sync the artifacts outside --- diff --git a/gc/tests.yml b/gc/tests.yml index dfd8eb8..0da99e5 100644 --- a/gc/tests.yml +++ b/gc/tests.yml @@ -8,16 +8,11 @@ remote_user: root vars: artifacts: "{{ lookup('env', 'TEST_ARTIFACTS')|default('./artifacts', true) }}" - subjects: "{{ lookup('env', 'TEST_SUBJECTS')}}" tags: - classic - container tasks: - - name: Make artifacts directory - file: path={{ artifacts }} state=directory - owner=root mode=755 recurse=yes - - name: Install the required packages package: name: "{{ item }}" @@ -35,15 +30,27 @@ args: chdir: "{{ artifacts }}" - - name: Run the test file - shell: ./tst-gc > out - args: - chdir: "{{ artifacts }}" + - block: + - name: Make artifacts directory + file: path=/tmp/artifacts state=directory + owner=root mode=755 recurse=yes - - name: Check/grep the output - shell: grep "Heap size = [1-9][0-9]*" out - args: - chdir: "{{ artifacts }}" + - name: Run the test file + shell: ./tst-gc > out + args: + chdir: /tmp/artifacts + + - name: Check/grep the output + shell: grep "Heap size = [1-9][0-9]*" out + args: + chdir: /tmp/artifacts + + always: + - name: Pull out the logs + synchronize: + dest: "{{ artifacts }}" + src: "/tmp/artifacts/./" + mode: pull # Tests for Atomic host @@ -52,7 +59,6 @@ remote_user: root vars: artifacts: "{{ lookup('env', 'TEST_ARTIFACTS')|default('./artifacts', true) }}" - subjects: "{{ lookup('env', 'TEST_SUBJECTS')}}" tags: - atomic @@ -69,7 +75,7 @@ file: path={{ item }} state=directory owner=root mode=755 recurse=yes with_items: - - "{{ artifacts }}" + - "/tmp/artifacts" - "/tmp/build" - name: Copy the Dockerfile and the test-gc.c file @@ -103,17 +109,25 @@ chdir: "{{ tmp_dir.stdout }}" - name: Get the binary - shell: cp /tmp/build/tst-gc {{ artifacts }} - - - name: Run the test file - shell: ./tst-gc > out - args: - chdir: "{{ artifacts }}" - - - name: Check/grep the output - shell: grep "Heap size = [1-9][0-9]*" out - args: - chdir: "{{ artifacts }}" + shell: cp /tmp/build/tst-gc /tmp/artifacts + + - block: + - name: Run the test file + shell: ./tst-gc > out + args: + chdir: /tmp/artifacts + + - name: Check/grep the output + shell: grep "Heap size = [1-9][0-9]*" out + args: + chdir: /tmp/artifacts + + always: + - name: Pull out the logs + synchronize: + dest: "{{ artifacts }}" + src: "/tmp/artifacts/./" + mode: pull # curl -Lo atomic.qcow2 https://ftp-stud.hs-esslingen.de/pub/Mirrors/alt.fedoraproject.org/atomic/stable/Fedora-Atomic-26-20170707.1/CloudImages/x86_64/images/Fedora-Atomic-26-20170707.1.x86_64.qcow2 From 99ca2654e65788c43c2cc309df3907720d5adef1 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 21 2017 11:41:13 +0000 Subject: [PATCH 4/7] Restructure the playbook to be more linear --- diff --git a/gc/tests.yml b/gc/tests.yml index 0da99e5..265e94d 100644 --- a/gc/tests.yml +++ b/gc/tests.yml @@ -2,115 +2,77 @@ # https://fedoraproject.org/wiki/CI --- -# Tests for Docker and Classic Context - hosts: localhost gather_facts: yes remote_user: root vars: artifacts: "{{ lookup('env', 'TEST_ARTIFACTS')|default('./artifacts', true) }}" - tags: - - classic - - container tasks: - - name: Install the required packages - package: - name: "{{ item }}" - state: present + - name: Make directories we use + file: path={{ item }} state=directory + owner=root mode=755 recurse=yes with_items: - - gcc - - gc-devel - - gc - - - name: Install the test files - copy: src=tst-gc.c dest={{ artifacts }} mode=0755 - - - name: Compile the test file - shell: gcc -lgc tst-gc.c -o tst-gc - args: - chdir: "{{ artifacts }}" + - /tmp/artifacts + tags: + - classic + - container + - atomic + # Classic and container block, install and compile the test program - block: - - name: Make artifacts directory - file: path=/tmp/artifacts state=directory - owner=root mode=755 recurse=yes + tags: + - classic + - container - - name: Run the test file - shell: ./tst-gc > out - args: - chdir: /tmp/artifacts + - name: Install the required packages + package: + name: "{{ item }}" + state: present + with_items: + - gcc + - gc-devel + - gc - - name: Check/grep the output - shell: grep "Heap size = [1-9][0-9]*" out + - name: Install the test files + copy: src=tst-gc.c dest="/tmp/artifacts" mode=0755 + + - name: Compile the test file + shell: gcc -lgc tst-gc.c -o tst-gc args: chdir: /tmp/artifacts - always: - - name: Pull out the logs - synchronize: - dest: "{{ artifacts }}" - src: "/tmp/artifacts/./" - mode: pull - - -# Tests for Atomic host -- hosts: localhost - gather_facts: yes - remote_user: root - vars: - artifacts: "{{ lookup('env', 'TEST_ARTIFACTS')|default('./artifacts', true) }}" - tags: - - atomic - - tasks: - - name: Get the OS version running - shell: grep VERSION_ID /etc/os-release | sed -e 's/VERSION_ID=//' - register: os_rel - - - name: Create a tmp folder to operate in - shell: mktemp -d - register: tmp_dir - - - name: Make directories we use - file: path={{ item }} state=directory - owner=root mode=755 recurse=yes - with_items: - - "/tmp/artifacts" - - "/tmp/build" - - - name: Copy the Dockerfile and the test-gc.c file - copy: src={{ item.name}} dest={{ item.dest }} mode=0644 - with_items: - - {name: Dockerfile, dest: "{{ tmp_dir.stdout }}"} - - {name: tst-gc.c, dest: "/tmp/build"} - - - name: Update the Dockerfile to pull {{ os_rel.stdout }} - shell: sed -i -e 's/FEDORA_VERSION/{{ os_rel.stdout}}/' Dockerfile - args: - chdir: "{{ tmp_dir.stdout }}" + # Atomic specific block, build the test program in a container + - block: + tags: + - atomic - # Check changes - #- name: check the dockerfile - #shell: cat Dockerfile - #args: - #chdir: "{{ tmp_dir.stdout }}" - #register: tmp + - name: Get the OS version running + shell: grep VERSION_ID /etc/os-release | sed -e 's/VERSION_ID=//' + register: os_rel - #- debug: msg="{{ tmp.stdout }}" + - name: Copy the Dockerfile and the test-gc.c file + copy: src={{ item }} dest="/tmp/artifacts" mode=0644 + with_items: + - Dockerfile + - tst-gc.c - - name: Build the container - shell: docker build -f {{ tmp_dir.stdout }}/Dockerfile . -t dockahbuild - args: - chdir: "{{ tmp_dir.stdout }}" + - name: Update the Dockerfile to pull from fedora:{{ os_rel.stdout }} + shell: sed -i -e 's/FEDORA_VERSION/{{ os_rel.stdout}}/' Dockerfile + args: + chdir: /tmp/artifacts - - name: Run the container so we can get the binary - shell: docker run -v /tmp/build:/code:Z dockahbuild - args: - chdir: "{{ tmp_dir.stdout }}" + - name: Build the container + shell: docker build -f /tmp/artifacts/Dockerfile . -t dockahbuild + args: + chdir: /tmp/artifacts - - name: Get the binary - shell: cp /tmp/build/tst-gc /tmp/artifacts + - name: Run the container so we can get the binary + shell: docker run -v /tmp/artifacts:/code:Z dockahbuild + args: + chdir: /tmp/artifacts + # Generic block, run the test program, check its output and sync the artifacts - block: - name: Run the test file shell: ./tst-gc > out @@ -122,7 +84,7 @@ args: chdir: /tmp/artifacts - always: + always: - name: Pull out the logs synchronize: dest: "{{ artifacts }}" From 166eccd785a07a17a011d7bd0c3042f561e01614 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 21 2017 11:47:51 +0000 Subject: [PATCH 5/7] Drop couple of un-needed instructions --- diff --git a/gc/tests.yml b/gc/tests.yml index 265e94d..1480e4f 100644 --- a/gc/tests.yml +++ b/gc/tests.yml @@ -3,8 +3,6 @@ --- - hosts: localhost - gather_facts: yes - remote_user: root vars: artifacts: "{{ lookup('env', 'TEST_ARTIFACTS')|default('./artifacts', true) }}" From 6eeb1f3b963a7a02cea144384b59e6133d02ade8 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 21 2017 11:54:59 +0000 Subject: [PATCH 6/7] Adjust/fix the tag situation --- diff --git a/gc/tests.yml b/gc/tests.yml index 1480e4f..7e8d3f7 100644 --- a/gc/tests.yml +++ b/gc/tests.yml @@ -13,15 +13,10 @@ with_items: - /tmp/artifacts tags: - - classic - - container - - atomic + - always # Classic and container block, install and compile the test program - block: - tags: - - classic - - container - name: Install the required packages package: @@ -40,11 +35,12 @@ args: chdir: /tmp/artifacts - # Atomic specific block, build the test program in a container - - block: tags: - - atomic + - classic + - container + # Atomic specific block, build the test program in a container + - block: - name: Get the OS version running shell: grep VERSION_ID /etc/os-release | sed -e 's/VERSION_ID=//' register: os_rel @@ -70,6 +66,9 @@ args: chdir: /tmp/artifacts + tags: + - atomic + # Generic block, run the test program, check its output and sync the artifacts - block: - name: Run the test file @@ -82,6 +81,9 @@ args: chdir: /tmp/artifacts + tags: + - always + always: - name: Pull out the logs synchronize: From 31209d905a7c96d7a35b2719f92a84fcfa038012 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 21 2017 14:47:53 +0000 Subject: [PATCH 7/7] Build the container locally, speeds things up quite a bit --- diff --git a/gc/tests.yml b/gc/tests.yml index 7e8d3f7..b85a0a3 100644 --- a/gc/tests.yml +++ b/gc/tests.yml @@ -7,7 +7,7 @@ artifacts: "{{ lookup('env', 'TEST_ARTIFACTS')|default('./artifacts', true) }}" tasks: - - name: Make directories we use + - name: Create /tmp/artifacts file: path={{ item }} state=directory owner=root mode=755 recurse=yes with_items: @@ -15,6 +15,17 @@ tags: - always + - name: Create the {{ artifacts }} directory locally + local_action: + module: file + args: path="{{ artifacts }}" + state=directory + owner=root + mode=755 + recurse=yes + tags: + - always + # Classic and container block, install and compile the test program - block: @@ -39,32 +50,60 @@ - classic - container - # Atomic specific block, build the test program in a container + # Atomic specific block, build the test program in a container (hosted locally) - block: - name: Get the OS version running - shell: grep VERSION_ID /etc/os-release | sed -e 's/VERSION_ID=//' + shell: grep VERSION_ID /etc/os-release | sed -e 's/VERSION_ID=//' register: os_rel + - name: Create /tmp/gc_test/ locally + local_action: + module: file + args: + path: /tmp/gc_test/ + state: directory + - name: Copy the Dockerfile and the test-gc.c file - copy: src={{ item }} dest="/tmp/artifacts" mode=0644 + local_action: copy src={{ item }} dest="/tmp/gc_test/" mode=0644 with_items: - Dockerfile - tst-gc.c - name: Update the Dockerfile to pull from fedora:{{ os_rel.stdout }} - shell: sed -i -e 's/FEDORA_VERSION/{{ os_rel.stdout}}/' Dockerfile + local_action: shell sed -i -e 's/FEDORA_VERSION/{{ os_rel.stdout}}/' Dockerfile args: - chdir: /tmp/artifacts + chdir: /tmp/gc_test + + - name: Make sure docker is started locally + local_action: + module: service + args: + name: docker + state: started - name: Build the container - shell: docker build -f /tmp/artifacts/Dockerfile . -t dockahbuild + local_action: shell docker build -f /tmp/gc_test/Dockerfile . -t dockahbuild args: - chdir: /tmp/artifacts + chdir: /tmp/gc_test - name: Run the container so we can get the binary - shell: docker run -v /tmp/artifacts:/code:Z dockahbuild + local_action: shell docker run -v /tmp/gc_test:/code:Z dockahbuild args: - chdir: /tmp/artifacts + chdir: /tmp/gc_test + + - name: Move the test files from the local host into the atomic host + synchronize: + src: /tmp/gc_test/ + dest: /tmp/artifacts/ + mode: push + ssh_args: "-o UserKnownHostsFile=/dev/null" + + - name: Move the files into the artifacts directory for safe keeping + local_action: + module: copy + args: + src="/tmp/gc_test/" + dest="{{ artifacts }}" tags: - atomic @@ -87,8 +126,8 @@ always: - name: Pull out the logs synchronize: - dest: "{{ artifacts }}" src: "/tmp/artifacts/./" + dest: "{{ artifacts }}" mode: pull