Browse Source

Adds molecule testing for stonith-exists

Change-Id: I432d68fbed4f5a5f0dd96e0fc465650068c984a2
(cherry picked from commit 352dadd850)
changes/42/680942/1
Cédric Jeanneret 1 month ago
parent
commit
a716e48a69

+ 37
- 0
roles/stonith-exists/molecule/default/Dockerfile.j2 View File

@@ -0,0 +1,37 @@
1
+# Molecule managed
2
+# Copyright 2019 Red Hat, Inc.
3
+# All Rights Reserved.
4
+#
5
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+# not use this file except in compliance with the License. You may obtain
7
+# a copy of the License at
8
+#
9
+#     http://www.apache.org/licenses/LICENSE-2.0
10
+#
11
+# Unless required by applicable law or agreed to in writing, software
12
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+# License for the specific language governing permissions and limitations
15
+# under the License.
16
+
17
+
18
+{% if item.registry is defined %}
19
+FROM {{ item.registry.url }}/{{ item.image }}
20
+{% else %}
21
+FROM {{ item.image }}
22
+{% endif %}
23
+
24
+RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
25
+    elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash {{ item.pkg_extras | default('') }} && dnf clean all; \
26
+    elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
27
+    elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml {{ item.pkg_extras | default('') }} && zypper clean -a; \
28
+    elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \
29
+    elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi
30
+
31
+{% for pkg in item.easy_install | default([]) %}
32
+# install pip for centos where there is no python-pip rpm in default repos
33
+RUN easy_install {{ pkg }}
34
+{% endfor %}
35
+
36
+
37
+CMD ["sh", "-c", "while true; do sleep 10000; done"]

+ 46
- 0
roles/stonith-exists/molecule/default/molecule.yml View File

@@ -0,0 +1,46 @@
1
+---
2
+driver:
3
+  name: docker
4
+
5
+log: true
6
+
7
+platforms:
8
+  - name: centos7
9
+    hostname: centos7
10
+    image: centos:7
11
+    pkg_extras: python-setuptools
12
+    easy_install:
13
+      - pip
14
+    environment: &env
15
+      http_proxy: "{{ lookup('env', 'http_proxy') }}"
16
+      https_proxy: "{{ lookup('env', 'https_proxy') }}"
17
+
18
+  - name: fedora28
19
+    hostname: fedora28
20
+    image: fedora:28
21
+    pkg_extras: python*-setuptools
22
+    environment:
23
+      <<: *env
24
+
25
+provisioner:
26
+  name: ansible
27
+  log: true
28
+  env:
29
+    ANSIBLE_STDOUT_CALLBACK: yaml
30
+
31
+scenario:
32
+  test_sequence:
33
+    - destroy
34
+    - create
35
+    - prepare
36
+    - converge
37
+    - verify
38
+    - destroy
39
+
40
+lint:
41
+  enabled: false
42
+
43
+verifier:
44
+  name: testinfra
45
+  lint:
46
+    name: flake8

+ 56
- 0
roles/stonith-exists/molecule/default/playbook.yml View File

@@ -0,0 +1,56 @@
1
+---
2
+# Copyright 2019 Red Hat, Inc.
3
+# All Rights Reserved.
4
+#
5
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+# not use this file except in compliance with the License. You may obtain
7
+# a copy of the License at
8
+#
9
+#     http://www.apache.org/licenses/LICENSE-2.0
10
+#
11
+# Unless required by applicable law or agreed to in writing, software
12
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+# License for the specific language governing permissions and limitations
15
+# under the License.
16
+
17
+
18
+- name: Converge
19
+  hosts: all
20
+
21
+  tasks:
22
+    - name: Safe run
23
+      include_role:
24
+        name: stonith-exists
25
+
26
+    - name: Fail the validation
27
+      block:
28
+        - name: Faulty pcs script
29
+          copy:
30
+            dest: /usr/bin/pcs
31
+            mode: 0755
32
+            content: |
33
+              #!/bin/sh
34
+              echo "NO stonith devices configured"
35
+              exit 0
36
+
37
+        - name: Run validation
38
+          include_role:
39
+            name: stonith-exists
40
+
41
+      rescue:
42
+        - name: Clear host errors
43
+          meta: clear_host_errors
44
+
45
+        - name: Test output
46
+          debug:
47
+            msg: The validation works! End play
48
+
49
+        - name: End play
50
+          meta: end_play
51
+
52
+    - name: Fail playbook if reached
53
+      fail:
54
+        msg: |
55
+          The stonith-exists validation didn't properly detect failed
56
+          stonith config

+ 30
- 0
roles/stonith-exists/molecule/default/prepare.yml View File

@@ -0,0 +1,30 @@
1
+---
2
+# Copyright 2019 Red Hat, Inc.
3
+# All Rights Reserved.
4
+#
5
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
6
+# not use this file except in compliance with the License. You may obtain
7
+# a copy of the License at
8
+#
9
+#     http://www.apache.org/licenses/LICENSE-2.0
10
+#
11
+# Unless required by applicable law or agreed to in writing, software
12
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+# License for the specific language governing permissions and limitations
15
+# under the License.
16
+
17
+
18
+- name: Prepare
19
+  hosts: all
20
+  gather_facts: no
21
+
22
+  tasks:
23
+    - name: Populate successful stonith
24
+      copy:
25
+        dest: /usr/bin/pcs
26
+        mode: 0755
27
+        content: |
28
+          #!/bin/sh
29
+          echo "Stonith service configured"
30
+          exit 0

+ 9
- 0
zuul.d/molecule.yaml View File

@@ -21,6 +21,7 @@
21 21
       - tripleo-validations-centos-7-molecule-undercloud-heat-purge-deleted
22 22
       - tripleo-validations-centos-7-molecule-undercloud-tokenflush
23 23
       - tripleo-validations-centos-7-molecule-rabbitmq-limits
24
+      - tripleo-validations-centos-7-molecule-stonith-exists
24 25
     gate:
25 26
       queue: integrated
26 27
       jobs:
@@ -42,6 +43,7 @@
42 43
       - tripleo-validations-centos-7-molecule-undercloud-heat-purge-deleted
43 44
       - tripleo-validations-centos-7-molecule-undercloud-tokenflush
44 45
       - tripleo-validations-centos-7-molecule-rabbitmq-limits
46
+      - tripleo-validations-centos-7-molecule-stonith-exists
45 47
     name: tripleo-validations-molecule-jobs
46 48
 - job:
47 49
     files:
@@ -170,3 +172,10 @@
170 172
     parent: tripleo-validations-centos-7-base
171 173
     vars:
172 174
       tripleo_validations_role_name: rabbitmq-limits
175
+- job:
176
+    files:
177
+    - ^roles/stonith-exists/.*
178
+    name: tripleo-validations-centos-7-molecule-stonith-exists
179
+    parent: tripleo-validations-centos-7-base
180
+    vars:
181
+      tripleo_validations_role_name: stonith-exists

Loading…
Cancel
Save