From cb96f9f51aa6e4259bd204fc00bcbfe6da1f979b Mon Sep 17 00:00:00 2001
From: ZhongShengping <chdzsp@163.com>
Date: Mon, 12 Feb 2018 14:42:55 +0800
Subject: [PATCH] Switch libraries jobs to Zuul v3

Change-Id: I9f4bb7c93a31b64285ab1342e8ade20320ed172a
---
 .zuul.yaml                                | 90 +++++++++++++++++++++++
 playbooks/prepare-node-unit.yaml          |  3 -
 playbooks/run-libraries-beaker-tests.yaml | 31 ++++++++
 playbooks/run-libraries-lint-tests.yaml   | 10 +++
 playbooks/run-libraries-syntax-tests.yaml | 11 +++
 playbooks/run-libraries-unit-tests.yaml   | 10 +++
 6 files changed, 152 insertions(+), 3 deletions(-)
 create mode 100644 playbooks/run-libraries-beaker-tests.yaml
 create mode 100644 playbooks/run-libraries-lint-tests.yaml
 create mode 100644 playbooks/run-libraries-syntax-tests.yaml
 create mode 100644 playbooks/run-libraries-unit-tests.yaml

diff --git a/.zuul.yaml b/.zuul.yaml
index ce6adc56b..63debcd9a 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -27,10 +27,12 @@
       - openstack/puppet-manila
       - openstack/puppet-mistral
       - openstack/puppet-monasca
+      - openstack/puppet-modulesync-configs
       - openstack/puppet-murano
       - openstack/puppet-neutron
       - openstack/puppet-nova
       - openstack/puppet-octavia
+      - openstack/puppet-openstack-cookiecutter
       - openstack/puppet-openstack-integration
       - openstack/puppet-openstack_extras
       - openstack/puppet-openstacklib
@@ -436,3 +438,91 @@
       jobs:
         - puppet-openstack-beaker-centos-7
         - puppet-openstack-beaker-xenial
+
+- job:
+    name: puppet-openstack-libraries-puppet-beaker-rspec-centos-7
+    parent: puppet-openstack-integration-base
+    pre-run: playbooks/prepare-node-beaker.yaml
+    post-run: playbooks/upload-logs.yaml
+    run: playbooks/run-libraries-beaker-tests.yaml
+    timeout: 3600
+    nodeset: centos-7
+    irrelevant-files:
+      - ^.*\.md$
+      - ^.*\.rst$
+      - ^doc/.*$
+      - ^etc/.*$
+      - ^metadata.json$
+      - ^releasenotes/.*$
+      - ^test-requirements.txt$
+
+- job:
+    name: puppet-openstack-libraries-puppet-lint-centos-7
+    parent: puppet-openstack-integration-base
+    run: playbooks/run-libraries-lint-tests.yaml
+    pre-run: playbooks/prepare-node-unit.yaml
+    timeout: 3600
+    nodeset: centos-7
+
+- job:
+    name: puppet-openstack-libraries-puppet-syntax
+    parent: puppet-openstack-integration-base
+    run: playbooks/run-libraries-syntax-tests.yaml
+    pre-run: playbooks/prepare-node-unit.yaml
+    timeout: 3600
+    irrelevant-files:
+      - ^.*\.md$
+      - ^.*\.rst$
+      - ^doc/.*$
+      - ^etc/.*$
+      - ^metadata.json$
+      - ^releasenotes/.*$
+      - ^test-requirements.txt$
+
+- job:
+    name: puppet-openstack-libraries-puppet-syntax-3-centos-7
+    parent: puppet-openstack-libraries-puppet-syntax
+    nodeset: centos-7
+    branches: ^(stable/(newton|ocata)).*$
+    vars:
+      puppet: 3
+
+- job:
+    name: puppet-openstack-libraries-puppet-syntax-4-centos-7
+    parent: puppet-openstack-libraries-puppet-syntax
+    nodeset: centos-7
+    vars:
+      puppet: 4
+
+- job:
+    name: puppet-openstack-libraries-puppet-unit-centos-7
+    parent: puppet-openstack-integration-base
+    run: playbooks/run-libraries-unit-tests.yaml
+    pre-run: playbooks/prepare-node-unit.yaml
+    timeout: 3600
+    nodeset: centos-7
+    irrelevant-files:
+      - ^.*\.md$
+      - ^.*\.rst$
+      - ^doc/.*$
+      - ^etc/.*$
+      - ^metadata.json$
+      - ^releasenotes/.*$
+      - ^test-requirements.txt$
+
+- project-template:
+    name: puppet-openstack-library-jobs
+    check:
+      jobs:
+        - puppet-openstack-libraries-puppet-lint-centos-7
+        - puppet-openstack-libraries-puppet-syntax-3-centos-7
+        - puppet-openstack-libraries-puppet-syntax-4-centos-7
+        - puppet-openstack-libraries-puppet-unit-centos-7
+        - puppet-openstack-libraries-puppet-beaker-rspec-centos-7
+    gate:
+      jobs:
+        - puppet-openstack-libraries-puppet-lint-centos-7
+        - puppet-openstack-libraries-puppet-syntax-3-centos-7
+        - puppet-openstack-libraries-puppet-syntax-4-centos-7
+        - puppet-openstack-libraries-puppet-unit-centos-7
+        - puppet-openstack-libraries-puppet-beaker-rspec-centos-7
diff --git a/playbooks/prepare-node-unit.yaml b/playbooks/prepare-node-unit.yaml
index 5c1ed55eb..86ba32444 100644
--- a/playbooks/prepare-node-unit.yaml
+++ b/playbooks/prepare-node-unit.yaml
@@ -31,6 +31,3 @@
 
     - include_role:
         name: bindep
-
-    - include_role:
-        name: revoke-sudo
diff --git a/playbooks/run-libraries-beaker-tests.yaml b/playbooks/run-libraries-beaker-tests.yaml
new file mode 100644
index 000000000..2f76df850
--- /dev/null
+++ b/playbooks/run-libraries-beaker-tests.yaml
@@ -0,0 +1,31 @@
+- hosts: all
+  tasks:
+    - shell:
+        cmd: |
+          echo "" | sudo tee -a /etc/ssh/sshd_config
+          echo "Match address 127.0.0.1" | sudo tee -a /etc/ssh/sshd_config
+          echo "    PermitRootLogin without-password" | sudo tee -a /etc/ssh/sshd_config
+          echo "" | sudo tee -a /etc/ssh/sshd_config
+          echo "Match address ::1" | sudo tee -a /etc/ssh/sshd_config
+          echo "    PermitRootLogin without-password" | sudo tee -a /etc/ssh/sshd_config
+          mkdir -p .ssh
+          ssh-keygen -f ~/.ssh/id_rsa -b 2048 -P ""
+          sudo mkdir -p /root/.ssh
+          cat ~/.ssh/id_rsa.pub | sudo tee -a /root/.ssh/authorized_keys
+          if [ -f /usr/bin/yum ]; then
+              sudo systemctl reload sshd
+          elif [ -f /usr/bin/apt-get ]; then
+              sudo service ssh restart
+          fi
+        executable: /bin/bash
+        chdir: '{{ ansible_user_dir }}/workspace'
+      environment: '{{ zuul | zuul_legacy_vars }}'
+    - shell:
+        cmd: |
+          set -e
+          set -x
+          trap "{{ ansible_user_dir }}/workspace/openstack/puppet-openstack-integration/copy_logs.sh" EXIT
+          ./run_beaker_tests.sh
+        executable: /bin/bash
+        chdir: '{{ ansible_user_dir }}/workspace'
+      environment: '{{ zuul | zuul_legacy_vars }}'
diff --git a/playbooks/run-libraries-lint-tests.yaml b/playbooks/run-libraries-lint-tests.yaml
new file mode 100644
index 000000000..c2a6b76c1
--- /dev/null
+++ b/playbooks/run-libraries-lint-tests.yaml
@@ -0,0 +1,10 @@
+- hosts: all
+  tasks:
+    - shell:
+        cmd: |
+          set -e
+          set -x
+          ./run_lint_tests.sh
+        executable: /bin/bash
+        chdir: '{{ ansible_user_dir }}/workspace'
+      environment: '{{ zuul | zuul_legacy_vars }}'
diff --git a/playbooks/run-libraries-syntax-tests.yaml b/playbooks/run-libraries-syntax-tests.yaml
new file mode 100644
index 000000000..00d5cbf4e
--- /dev/null
+++ b/playbooks/run-libraries-syntax-tests.yaml
@@ -0,0 +1,11 @@
+- hosts: all
+  tasks:
+    - shell:
+        cmd: |
+          set -e
+          set -x
+          export PUPPET_VERSION="{{ puppet }}"
+          ./run_syntax_tests.sh
+        executable: /bin/bash
+        chdir: '{{ ansible_user_dir }}/workspace'
+      environment: '{{ zuul | zuul_legacy_vars }}'
diff --git a/playbooks/run-libraries-unit-tests.yaml b/playbooks/run-libraries-unit-tests.yaml
new file mode 100644
index 000000000..4e0d2e403
--- /dev/null
+++ b/playbooks/run-libraries-unit-tests.yaml
@@ -0,0 +1,10 @@
+- hosts: all
+  tasks:
+    - shell:
+        cmd: |
+          set -e
+          set -x
+          ./run_unit_tests.sh
+        executable: /bin/bash
+        chdir: '{{ ansible_user_dir }}/workspace'
+      environment: '{{ zuul | zuul_legacy_vars }}'