diff --git a/provisioning/requirements.yml b/provisioning/requirements.yml index eb9025a06..9cf08a844 100644 --- a/provisioning/requirements.yml +++ b/provisioning/requirements.yml @@ -1,6 +1,6 @@ --- - src: arknoll.selenium - version: 2.0.0 + version: 2.1.0 - src: thom8.php-upload-progress version: 1.0.1 - src: franklinkim.newrelic diff --git a/provisioning/roles/arknoll.selenium/.travis.yml b/provisioning/roles/arknoll.selenium/.travis.yml index cb75c496a..cc071973c 100644 --- a/provisioning/roles/arknoll.selenium/.travis.yml +++ b/provisioning/roles/arknoll.selenium/.travis.yml @@ -11,6 +11,9 @@ env: - distro: ubuntu1604 init: /lib/systemd/systemd run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" + - distro: debian8 + init: /lib/systemd/systemd + run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro" - distro: ubuntu1404 init: /sbin/init run_opts: "--privileged" @@ -27,6 +30,9 @@ script: # Run container in detached state. - 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"' + # Install dependencies. + - 'sudo docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml' + # Ansible syntax check. - 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check' diff --git a/provisioning/roles/arknoll.selenium/tasks/main.yml b/provisioning/roles/arknoll.selenium/tasks/main.yml index 283332562..f9dc23e1e 100644 --- a/provisioning/roles/arknoll.selenium/tasks/main.yml +++ b/provisioning/roles/arknoll.selenium/tasks/main.yml @@ -23,9 +23,24 @@ when: selenium_install_firefox tags: [configuration, selenium, selenium-firefox] +- name: Add Chrome key (if configured, Debian) + apt_key: + url: "https://dl-ssl.google.com/linux/linux_signing_key.pub" + state: present + when: ansible_os_family == 'Debian' and selenium_install_chrome + tags: [configuration, selenium, selenium-chrome] + +- name: Add Chrome repo (if configured, Debian) + apt_repository: + repo: "deb http://dl.google.com/linux/chrome/deb/ stable main" + state: present + update_cache: yes + when: ansible_os_family == 'Debian' and selenium_install_chrome + tags: [configuration, selenium, selenium-chrome] + - name: Install Chrome (if configured, Debian) apt: - deb: https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb + name: google-chrome-stable state: present when: ansible_os_family == 'Debian' and selenium_install_chrome tags: [configuration, selenium, selenium-chrome] @@ -67,6 +82,32 @@ mode: 0755 tags: [configuration, selenium, selenium-install] +- name: Install systemd unit file (for systemd systems) + template: + src: "selenium-unit.j2" + dest: /etc/systemd/system/selenium.service + owner: root + group: root + mode: 0755 + when: > + (ansible_distribution == 'Ubuntu' and ansible_distribution_version.split(".")[0]|int >= 16) or + (ansible_distribution == 'Debian' and ansible_distribution_version.split(".")[0]|int >= 8) or + (ansible_distribution == 'CentOS' and ansible_distribution_version.split(".")[0]|int >= 7) or + (ansible_distribution == 'Fedora') + tags: [configuration, selenium, selenium-install] + +- name: Register systemd service status (for systemd systems) + shell: 'systemctl status selenium | grep "active (running)"' + when: > + (ansible_distribution == 'Ubuntu' and ansible_distribution_version.split(".")[0]|int >= 16) or + (ansible_distribution == 'Debian' and ansible_distribution_version.split(".")[0]|int >= 8) or + (ansible_distribution == 'CentOS' and ansible_distribution_version.split(".")[0]|int >= 7) or + (ansible_distribution == 'Fedora') + register: selenium_running + ignore_errors: yes + changed_when: false + - name: Ensure selenium is running service: name=selenium state=started enabled=yes tags: [configuration, selenium, selenium-run] + when: selenium_running.failed is defined and selenium_running.failed == true diff --git a/provisioning/roles/arknoll.selenium/templates/selenium-unit.j2 b/provisioning/roles/arknoll.selenium/templates/selenium-unit.j2 new file mode 100644 index 000000000..ff1053615 --- /dev/null +++ b/provisioning/roles/arknoll.selenium/templates/selenium-unit.j2 @@ -0,0 +1,11 @@ +[Unit] +Description=selenium test framework +After=syslog.target network.target + +[Service] +ExecStart=/usr/bin/xvfb-run /usr/bin/java -client -jar {{ selenium_install_dir }}/selenium/selenium-server-standalone-{{ selenium_version }}.jar +Restart=on-failure +RestartSec=20s + +[Install] +WantedBy=multi-user.target diff --git a/provisioning/roles/arknoll.selenium/tests/requirements.yml b/provisioning/roles/arknoll.selenium/tests/requirements.yml new file mode 100644 index 000000000..8fbe7cb66 --- /dev/null +++ b/provisioning/roles/arknoll.selenium/tests/requirements.yml @@ -0,0 +1,2 @@ +--- +- src: geerlingguy.java diff --git a/provisioning/roles/arknoll.selenium/tests/test.yml b/provisioning/roles/arknoll.selenium/tests/test.yml index fa569fc01..4fb579e31 100644 --- a/provisioning/roles/arknoll.selenium/tests/test.yml +++ b/provisioning/roles/arknoll.selenium/tests/test.yml @@ -4,8 +4,17 @@ pre_tasks: - name: Update apt cache. - apt: update_cache=yes + apt: update_cache=yes cache_valid_time=3600 when: ansible_os_family == 'Debian' + - name: Don't install Chrome on old OSes. + set_fact: + selenium_install_firefox: yes + selenium_install_chrome: no + when: > + (ansible_distribution == 'Ubuntu' and ansible_distribution_version == '12.04') + or (ansible_os_family == 'RedHat' and ansible_distribution_version.split('.')[0] == '6') + roles: + - geerlingguy.java - role_under_test