From 493a72bbc965bca5e1308af4e7d7e78a6afd3f29 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Tue, 26 Sep 2017 07:27:18 -0400 Subject: [PATCH] integration: Use vars_files in plays It's unsightly and hard to maintain collections of references and long lists across multiple playbooks/include files. Centralize them all in ``vars.yml``, then include that in all plays. Minor: Update all files with a newline at the start and end. Signed-off-by: Chris Evich --- contrib/test/integration/build/bats.yml | 3 +- contrib/test/integration/build/cri-o.yml | 3 +- contrib/test/integration/build/cri-tools.yml | 3 +- contrib/test/integration/build/kubernetes.yml | 3 +- contrib/test/integration/build/plugins.yml | 3 +- contrib/test/integration/build/runc.yml | 3 +- contrib/test/integration/e2e.yml | 6 +- contrib/test/integration/golang.yml | 3 +- contrib/test/integration/main.yml | 16 +++-- contrib/test/integration/results.yml | 9 +-- contrib/test/integration/system.yml | 59 +--------------- contrib/test/integration/test.yml | 9 +-- contrib/test/integration/vars.yml | 67 +++++++++++++++++++ 13 files changed, 101 insertions(+), 86 deletions(-) create mode 100644 contrib/test/integration/vars.yml diff --git a/contrib/test/integration/build/bats.yml b/contrib/test/integration/build/bats.yml index b1621e40..e321c3bf 100644 --- a/contrib/test/integration/build/bats.yml +++ b/contrib/test/integration/build/bats.yml @@ -1,4 +1,5 @@ --- + - name: clone bats source repo git: repo: "https://github.com/sstephenson/bats.git" @@ -14,4 +15,4 @@ file: src: /usr/local/bin/bats dest: /usr/bin/bats - state: link \ No newline at end of file + state: link diff --git a/contrib/test/integration/build/cri-o.yml b/contrib/test/integration/build/cri-o.yml index b0ed43bf..8f6cee92 100644 --- a/contrib/test/integration/build/cri-o.yml +++ b/contrib/test/integration/build/cri-o.yml @@ -1,4 +1,5 @@ --- + - name: stat the expected cri-o directory stat: path: "{{ ansible_env.GOPATH }}/src/github.com/kubernetes-incubator/cri-o" @@ -75,4 +76,4 @@ insertafter: 'storage_option = \[' regexp: 'overlay2\.override_kernel_check=1' state: present - when: ansible_distribution == 'RedHat' or ansible_distribution == 'CentOS' \ No newline at end of file + when: ansible_distribution == 'RedHat' or ansible_distribution == 'CentOS' diff --git a/contrib/test/integration/build/cri-tools.yml b/contrib/test/integration/build/cri-tools.yml index a2c2b755..2bdb9e46 100644 --- a/contrib/test/integration/build/cri-tools.yml +++ b/contrib/test/integration/build/cri-tools.yml @@ -1,4 +1,5 @@ --- + - name: clone cri-tools source repo git: repo: "https://github.com/kubernetes-incubator/cri-tools.git" @@ -12,4 +13,4 @@ file: src: "{{ ansible_env.GOPATH }}/bin/crictl" dest: /usr/bin/crictl - state: link \ No newline at end of file + state: link diff --git a/contrib/test/integration/build/kubernetes.yml b/contrib/test/integration/build/kubernetes.yml index 2f4dedee..9c837cc2 100644 --- a/contrib/test/integration/build/kubernetes.yml +++ b/contrib/test/integration/build/kubernetes.yml @@ -1,4 +1,5 @@ --- + - name: clone kubernetes source repo git: repo: "https://github.com/runcom/kubernetes.git" @@ -58,4 +59,4 @@ dest: /etc/environment line: 'KUBECONFIG=/var/run/kubernetes/admin.kubeconfig' regexp: 'KUBECONFIG=' - state: present \ No newline at end of file + state: present diff --git a/contrib/test/integration/build/plugins.yml b/contrib/test/integration/build/plugins.yml index 29a5dc54..e342a0b9 100644 --- a/contrib/test/integration/build/plugins.yml +++ b/contrib/test/integration/build/plugins.yml @@ -1,4 +1,5 @@ --- + - name: clone plugins source repo git: repo: "https://github.com/containernetworking/plugins.git" @@ -46,4 +47,4 @@ src: "{{ ansible_env.GOPATH }}/src/github.com/containernetworking/plugins/bin/bridge" dest: "/opt/cni/bin/bridge-custom" mode: "o=rwx,g=rx,o=rx" - remote_src: yes \ No newline at end of file + remote_src: yes diff --git a/contrib/test/integration/build/runc.yml b/contrib/test/integration/build/runc.yml index b146e5b7..8ec09c4c 100644 --- a/contrib/test/integration/build/runc.yml +++ b/contrib/test/integration/build/runc.yml @@ -1,4 +1,5 @@ --- + - name: clone runc source repo git: repo: "https://github.com/opencontainers/runc.git" @@ -18,4 +19,4 @@ file: src: /usr/local/sbin/runc dest: /usr/bin/runc - state: link \ No newline at end of file + state: link diff --git a/contrib/test/integration/e2e.yml b/contrib/test/integration/e2e.yml index 58064df4..878fd3ce 100644 --- a/contrib/test/integration/e2e.yml +++ b/contrib/test/integration/e2e.yml @@ -1,4 +1,5 @@ --- + - name: enable and start CRI-O systemd: name: crio @@ -31,11 +32,6 @@ retries: 100 delay: 30 -- name: Buffer location for e2e output and reports - set_fact: - # N/B: This need manual coordination with results.yml - artifacts: "{{ ansible_env.GOPATH }}/src/k8s.io/kubernetes/artifacts" - - name: ensure directory exists for e2e reports file: path: "{{ artifacts }}" diff --git a/contrib/test/integration/golang.yml b/contrib/test/integration/golang.yml index bc6ef440..0653d1d4 100644 --- a/contrib/test/integration/golang.yml +++ b/contrib/test/integration/golang.yml @@ -1,4 +1,5 @@ --- + - name: set up GOPATH if it is not already set lineinfile: dest: /etc/environment @@ -37,4 +38,4 @@ - onsi/ginkgo/ginkgo - onsi/gomega - cloudflare/cfssl/cmd/... - - jteeuwen/go-bindata/go-bindata \ No newline at end of file + - jteeuwen/go-bindata/go-bindata diff --git a/contrib/test/integration/main.yml b/contrib/test/integration/main.yml index f2e1ce66..ce4a206f 100644 --- a/contrib/test/integration/main.yml +++ b/contrib/test/integration/main.yml @@ -1,7 +1,7 @@ - hosts: all remote_user: root - vars: - xunit: false + vars_files: + - "{{ playbook_dir }}/vars.yml" tags: - setup tasks: @@ -28,8 +28,8 @@ - hosts: all remote_user: root - vars: - xunit: false + vars_files: + - "{{ playbook_dir }}/vars.yml" tags: - integration - e2e @@ -39,8 +39,8 @@ - hosts: all remote_user: root - vars: - xunit: false + vars_files: + - "{{ playbook_dir }}/vars.yml" tags: - integration tasks: @@ -49,8 +49,10 @@ - hosts: all remote_user: root + vars_files: + - "{{ playbook_dir }}/vars.yml" tags: - e2e tasks: - name: run k8s e2e tests - include: e2e.yml \ No newline at end of file + include: e2e.yml diff --git a/contrib/test/integration/results.yml b/contrib/test/integration/results.yml index 7573e4a8..c9a96abb 100644 --- a/contrib/test/integration/results.yml +++ b/contrib/test/integration/results.yml @@ -2,14 +2,9 @@ # vim-syntax: ansible - hosts: '{{ hosts | default("all") }}' + vars_files: + - "{{ playbook_dir }}/vars.yml" vars: - # Paths use rsync 'source' conventions - crio_integration_filepath: "/root/src/github.com/kubernetes-incubator/cri-o/testout.txt" - # N/B: This needs coordination with e2e.yml - crio_node_e2e_filepath: "/root/go-tools/src/k8s.io/kubernetes/artifacts/" # everything - # Treat empty env. var as "undefined and use default() - result_dest_basedir: '{{ lookup("env","WORKSPACE") | - default(playbook_dir, True) }}/artifacts' _result_filepaths: [] # do not use _dstfnbuff: [] # do not use tasks: diff --git a/contrib/test/integration/system.yml b/contrib/test/integration/system.yml index d94b582d..9f787be7 100644 --- a/contrib/test/integration/system.yml +++ b/contrib/test/integration/system.yml @@ -1,4 +1,5 @@ --- + - name: register a repo for Golang yum_repository: name: 'centos-paas-sig-openshift-origin37-rpms' @@ -14,61 +15,7 @@ package: name: "{{ item }}" state: present - with_items: - - btrfs-progs-devel - - container-selinux - - curl - - device-mapper-devel - - expect - - findutils - - gcc - - git - - glib2-devel - - glibc-devel - - glibc-static - - golang - - gpgme-devel - - hostname - - iproute - - iptables - - krb5-workstation - - libassuan-devel - - libffi-devel - - libgpg-error-devel - - libguestfs-tools - - libseccomp-devel - - libvirt-client - - libvirt-python - - libxml2-devel - - libxslt-devel - - make - - mlocate - - nfs-utils - - nmap-ncat - - npm - - oci-register-machine - - oci-systemd-hook - - oci-umount - - openssl - - openssl-devel - - ostree-devel - - pkgconfig - - python - - python2-boto - - python2-crypto - - python2-mock - - python-click - - python-devel - - python-virtualenv - - PyYAML - - redhat-rpm-config - - rpcbind - - rsync - - sed - - skopeo-containers - - socat - - tar - - wget + with_items: "{{ rpm_pkgs }}" async: 600 poll: 10 @@ -116,4 +63,4 @@ state: present - name: Flush the iptables - command: iptables -F \ No newline at end of file + command: iptables -F diff --git a/contrib/test/integration/test.yml b/contrib/test/integration/test.yml index d9b9a2c3..b079cd02 100644 --- a/contrib/test/integration/test.yml +++ b/contrib/test/integration/test.yml @@ -1,4 +1,5 @@ --- + - name: Change test_runner.sh to use bats xunit output lineinfile: dest: "{{ ansible_env.GOPATH }}/src/github.com/kubernetes-incubator/cri-o/test/test_runner.sh" @@ -21,7 +22,7 @@ - name: set extra shell for non-xunit tests set_fact: - extra_shell_suffix: " >testout.txt 2>&1" + extra_shell_suffix: " &> {{ artifacts }}/testout.txt" when: not xunit - name: run integration tests @@ -35,16 +36,16 @@ - name: Make testing output directory file: - path: "{{ ansible_env.GOPATH }}/src/github.com/kubernetes-incubator/cri-o/reports" + path: "{{ artifacts }}" state: directory ignore_errors: yes when: xunit - name: Move all xunit files into one dir to scp - shell: "mv {{ ansible_env.GOPATH }}/src/github.com/kubernetes-incubator/cri-o/test/TestReport-bats*.xml {{ ansible_env.GOPATH }}/src/github.com/kubernetes-incubator/cri-o/reports/" + shell: "mv {{ ansible_env.GOPATH }}/src/github.com/kubernetes-incubator/cri-o/test/TestReport-bats*.xml {{ artifacts }}" when: xunit - name: ensure we fail on bad tests fail: msg: Integration tests failed! - when: "'not ok' in integration_test.stdout" \ No newline at end of file + when: "'not ok' in integration_test.stdout" diff --git a/contrib/test/integration/vars.yml b/contrib/test/integration/vars.yml new file mode 100644 index 00000000..552fa7e3 --- /dev/null +++ b/contrib/test/integration/vars.yml @@ -0,0 +1,67 @@ +--- + +# Enable using BATS to output integration-test xunit output (FIXME: broken? Kill it?) +xunit: false + +rpm_pkgs: + - btrfs-progs-devel + - container-selinux + - curl + - device-mapper-devel + - expect + - findutils + - gcc + - git + - glib2-devel + - glibc-devel + - glibc-static + - golang + - gpgme-devel + - hostname + - iproute + - iptables + - krb5-workstation + - libassuan-devel + - libffi-devel + - libgpg-error-devel + - libguestfs-tools + - libseccomp-devel + - libvirt-client + - libvirt-python + - libxml2-devel + - libxslt-devel + - make + - mlocate + - nfs-utils + - nmap-ncat + - npm + - oci-register-machine + - oci-systemd-hook + - oci-umount + - openssl + - openssl-devel + - ostree-devel + - pkgconfig + - python + - python2-boto + - python2-crypto + - python2-mock + - python-click + - python-devel + - python-virtualenv + - PyYAML + - redhat-rpm-config + - rpcbind + - rsync + - sed + - skopeo-containers + - socat + - tar + - wget + +# For results.yml Paths use rsync 'source' conventions +artifacts: "/tmp/artifacts" # Base-directory for collection +crio_integration_filepath: "{{ artifacts }}/testout.txt" +crio_node_e2e_filepath: "{{ artifacts }}/junit_01.xml" +result_dest_basedir: '{{ lookup("env","WORKSPACE") | + default(playbook_dir, True) }}/artifacts'