diff --git a/contrib/test/integration/README.md b/contrib/test/integration/README.md index c90a5eac..f7220005 100644 --- a/contrib/test/integration/README.md +++ b/contrib/test/integration/README.md @@ -4,6 +4,16 @@ This directory contains playbooks to set up for and run the integration and end-to-end tests for CRI-O on RHEL and Fedora hosts. The expected entry-point is the ``main.yml`` Ansible playbook. +##Definitions: + + Control-host: The system from which the ``ansible-playbook`` or + ``venv-ansible-playbook.sh`` command is executed. + + Subject-host(s): The target systems, on which actual playbook tasks are + being carried out. + +##Topology: + The control-host: - May be the subject. @@ -11,13 +21,17 @@ The control-host: - Runs ``main.yml`` from within the cri-o repository already in the desired state for testing. -The subject host(s): +The subject-host(s): - May be the control-host. - May be executing the ``main.yml`` playbook against itself. - If RHEL-like, has the ``server``, ``extras``, and ``EPEL`` repositories available and enabled. - - Has remote password-less ssh configured for direct or sudo access to the root user. + - Has remote password-less ssh configured for access by the control-host. + - When ssh-access is for a regular user, that user has password-less + sudo access to root. + +##Runtime Requirements: Execution of the ``main.yml`` playbook: @@ -31,19 +45,34 @@ Execution of the ``main.yml`` playbook: stage-caching). - ``integration``: Assumes 'setup' previously completed successfully. May be executed from cached-state of ``setup``. - Not required to execute conicident with other tags. + Not required to execute coincident with other tags. Must build CRI-O from source and run the integration test suite. - ``e2e``: Assumes 'setup' previously completed successfully. May be executed - from cached-state of ``setup``. Not required to execute conicident with + from cached-state of ``setup``. Not required to execute coincident with other tags. Must build CRI-O from source and run Kubernetes node E2E tests. ``cri-o/contrib/test/venv-ansible-playbook.sh`` Wrapper: - - Must accepts all of the valid Ansible command-line options. - - Must use version-locked & hashed dependencies as written in ``requirements.txt``. - - Must fully sandbox it's own execution environment except for the following - required packages (or equivalent): ``python2-virtualenv gcc openssl-devel + - May be executed on the control-host to both hide and version-lock playbook + execution dependencies, ansible and otherwise. + - Must accept all of the valid Ansible command-line options. + - Must sandbox dependencies under a python virtual environment ``.cri-o_venv`` + with packages as specified in ``requirements.txt``. + - Requires the control-host has the following fundamental dependencies installed + (or equivalent): ``python2-virtualenv gcc openssl-devel redhat-rpm-config libffi-devel python-devel libselinux-python rsync yum-utils python3-pycurl python-simplejson``. + +For example: + +Given a populated '/path/to/inventory' file, a control-host could run: + +./venv-ansible-playbook.sh -i /path/to/inventory ./integration/main.yml + +-or- + +From a subject-host without an inventory: + +./venv-ansible-playbook.sh -i localhost, ./integration/main.yml diff --git a/contrib/test/integration/ansible.cfg b/contrib/test/integration/ansible.cfg index 120419f5..33adb106 100644 --- a/contrib/test/integration/ansible.cfg +++ b/contrib/test/integration/ansible.cfg @@ -292,8 +292,16 @@ ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o UserKnownHostsFile=/de # Example: # control_path = %(directory)s/%%h-%%r #control_path = %(directory)s/ansible-ssh-%%h-%%p-%%r +# Using ssh's ControlPersist feature is desireable because of wide +# compatibility and not needing to mess with /etc/sudoers +# for pipelining (see below). Unfortunately, in cloud environments, +# auto-assigned VM hostnames tend to be rather longs. Worse, in a CI +# context, the default home-directory path may also be lengthy. Fix +# this to a short name, so Ansible doesn't fall back to opening new +# connections for every task. control_path = /tmp/crio-%%n-%%p + # Enabling pipelining reduces the number of SSH operations required to # execute a module on the remote server. This can result in a significant # performance improvement when enabled, however when using "sudo:" you must @@ -303,7 +311,6 @@ control_path = /tmp/crio-%%n-%%p # sudoers configurations that have requiretty (the default on many distros). # #pipelining = False -pipelining=True # if True, make ansible use scp if the connection type is ssh # (default is sftp) diff --git a/contrib/test/integration/build/cri-o.yml b/contrib/test/integration/build/cri-o.yml index 29172866..3c7b2c16 100644 --- a/contrib/test/integration/build/cri-o.yml +++ b/contrib/test/integration/build/cri-o.yml @@ -3,12 +3,12 @@ - name: stat the expected cri-o directory and Makefile exists stat: path: "{{ cri_o_dest_path }}/Makefile" - register: dir_stat + register: crio_stat - name: Verify cri-o Makefile exists in expected location fail: - msg: "Expected cri-o to be cloned at {{ cri_o_dest_path }} but it wasn't!" - when: not dir_stat.stat.exists or not dir_stat.stat.isreg + msg: "Expected cri-o to be cloned at {{ cri_o_dest_path }}, but its 'Makefile' seems to be missing." + when: not crio_stat.stat.exists or not crio_stat.stat.isreg - name: install cri-o tools make: diff --git a/contrib/test/integration/golang.yml b/contrib/test/integration/golang.yml index 39be5aa1..037fe851 100644 --- a/contrib/test/integration/golang.yml +++ b/contrib/test/integration/golang.yml @@ -18,14 +18,14 @@ - name: set up directories file: - path: "{{ go_path }}/{{ item }}" + path: "{{ go_path }}/src/github.com/{{ item }}" state: directory with_items: - - "src/github.com/containernetworking" - - "src/github.com/kubernetes-incubator" - - "src/github.com/k8s.io" - - "src/github.com/sstephenson" - - "src/github.com/opencontainers" + - "containernetworking" + - "kubernetes-incubator" + - "k8s.io" + - "sstephenson" + - "opencontainers" - name: install Go tools and dependencies shell: /usr/bin/go get -u "github.com/{{ item }}" diff --git a/contrib/test/integration/main.yml b/contrib/test/integration/main.yml index 869c6626..c68cea23 100644 --- a/contrib/test/integration/main.yml +++ b/contrib/test/integration/main.yml @@ -4,15 +4,35 @@ gather_facts: False # Requires low-level ansible-dependencies # Cannot use vars.yml - it references magic variables from setup module tags: - - setup + - always tasks: - - name: Ensure low-level ansible-dependencies are installed - raw: $(type -P dnf || type -P yum) install -y python2 python2-dnf libselinux-python git rsync + - name: Ansible setup-module dependencies are installed, ignoring errors (setup runs next). + raw: $(type -P dnf || type -P yum) install -y python2 python2-dnf libselinux-python + ignore_errors: True - name: Gather only networking facts for speed setup: gather_subset: network + - name: Variables from vars.yml are hauled in after setup + include_vars: "{{ playbook_dir }}/vars.yml" + + - name: Global environment are defined, but can be overriden on a task-by-task basis. + set_fact: + extra_storage_opts: > + {%- if ansible_distribution in ["RedHat", "CentOS"] -%} + "--storage-opt overlay.override_kernel_check=1" + {%- else -%} + "" + {%- endif -%} + environment_variables: + PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:{{ go_path }}/bin:/usr/local/go/bin" + GOPATH: "{{ go_path }}" + KUBERNETES_PROVIDER: "local" + KUBECONFIG: "/var/run/kubernetes/admin.kubeconfig" + CGROUP_MANAGER: "cgroupfs" + STORAGE_OPTS: '--storage-driver=overlay {{ extra_storage_opts | default("") | trim }}' + - hosts: '{{ subjects | default("none") }}' vars_files: diff --git a/contrib/test/integration/test.yml b/contrib/test/integration/test.yml index da814b17..1834aa7c 100644 --- a/contrib/test/integration/test.yml +++ b/contrib/test/integration/test.yml @@ -10,11 +10,6 @@ regexp: ' go test \"\$' state: present -- name: set extra storage options - set_fact: - extra_storage_opts: " --storage-opt overlay.override_kernel_check=1" - when: ansible_distribution == 'RedHat' or ansible_distribution == 'CentOS' - - name: ensure directory exists for integration results file: path: "{{ artifacts }}" diff --git a/contrib/test/integration/vars.yml b/contrib/test/integration/vars.yml index 3382caf6..fa8665db 100644 --- a/contrib/test/integration/vars.yml +++ b/contrib/test/integration/vars.yml @@ -3,8 +3,7 @@ # When swap setup is necessary, make it this size swapfileGB: 8 -# When False, turn off all swapping on the system only during -# particular tests. +# When False, turn off all swapping on the system during indicated test. integration_swap_enabled: False e2e_swap_enabled: True @@ -13,7 +12,7 @@ e2e_swap_enabled: True integration_selinux_enabled: True e2e_selinux_enabled: False -# Path to encode into /etc/environment on all hosts +# Base directory for all go-related source, build, and install. go_path: "/go" # Absolute path on control-host where the cri-o source exists @@ -22,15 +21,6 @@ cri_o_src_path: "{{ playbook_dir }}/../../../" # Absolute path on subjects where cri-o source is expected cri_o_dest_path: "{{ go_path }}/src/github.com/kubernetes-incubator/cri-o" -# Global environment variables to use for all tasks -environment_variables: - PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:{{ go_path }}/bin:/usr/local/go/bin" - GOPATH: "{{ go_path }}" - KUBERNETES_PROVIDER: "local" - KUBECONFIG: "/var/run/kubernetes/admin.kubeconfig" - CGROUP_MANAGER: "cgroupfs" - STORAGE_OPTS: '--storage-driver=overlay{{ extra_storage_opts | default("") }}' - # For results.yml Paths use rsync 'source' conventions artifacts: "/tmp/artifacts" # Base-directory for collection crio_integration_filepath: "{{ artifacts }}/testout.txt"