Browse Source

Adds molecule testing for undercloud-heat-purge-deleted

Change-Id: I24bb60777b685954b7fd369642b59a7f1924ef85
(cherry picked from commit 3ba8931a58)
changes/39/680939/1
Cédric Jeanneret 1 month ago
parent
commit
a249c16158

+ 37
- 0
roles/undercloud-heat-purge-deleted/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"]

+ 51
- 0
roles/undercloud-heat-purge-deleted/molecule/default/molecule.yml View File

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

+ 54
- 0
roles/undercloud-heat-purge-deleted/molecule/default/playbook.yml View File

@@ -0,0 +1,54 @@
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
+  gather_facts: no
21
+
22
+  tasks:
23
+    - name: working detection
24
+      include_role:
25
+        name: undercloud-heat-purge-deleted
26
+
27
+    - name: Validate failure
28
+      block:
29
+        - name: Override container_cli
30
+          copy:
31
+            dest: /undercloud.conf
32
+            content: |
33
+              [DEFAULT]
34
+              container_cli = docker
35
+
36
+        - name: run validation
37
+          include_role:
38
+            name: undercloud-heat-purge-deleted
39
+      rescue:
40
+        - name: Clear host errors
41
+          meta: clear_host_errors
42
+
43
+        - name: Test output
44
+          debug:
45
+            msg: The validation works! Ending play.
46
+
47
+        - name: End play
48
+          meta: end_play
49
+
50
+    - name: Fail the validation at this point
51
+      fail:
52
+        msg: |
53
+          The undercloud-heat-purge-deleted validation failed to detect
54
+          missing cron job.

+ 98
- 0
roles/undercloud-heat-purge-deleted/molecule/default/prepare.yml View File

@@ -0,0 +1,98 @@
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: install hiera
24
+      package:
25
+        name: hiera
26
+
27
+    - name: create hiera tree
28
+      file:
29
+        path: /etc/puppet
30
+        state: directory
31
+
32
+    - name: populate hiera.yaml
33
+      copy:
34
+        dest: /etc/puppet/hiera.yaml
35
+        content: |
36
+          :backends:
37
+            - yaml
38
+          :yaml:
39
+            :datadir: "/etc/puppet/"
40
+          :hierarchy:
41
+            - "common"
42
+
43
+    - name: populate hiera content
44
+      copy:
45
+        dest: /etc/puppet/common.yaml
46
+        content: |
47
+          tripleo_undercloud_conf_file: /undercloud.conf
48
+
49
+    - name: populate undercloud.conf
50
+      copy:
51
+        dest: /undercloud.conf
52
+        content: |
53
+          [DEFAULT]
54
+          container_cli = podman
55
+
56
+    - name: Populate successful podman CLI
57
+      copy:
58
+        dest: /usr/bin/podman
59
+        mode: 0755
60
+        content: |
61
+          #!/bin/bash
62
+          action="$1"
63
+          shift
64
+          container="$1"
65
+          shift
66
+          command="$@"
67
+
68
+          case $container in
69
+            'heat_api_cron')
70
+              echo '# This is a comment that should be ignored'
71
+              echo '0 12 14 2 * heat-manage purge_deleted'
72
+              ;;
73
+            *)
74
+              echo "Unknown container ${container}"
75
+              ;;
76
+          esac
77
+
78
+    - name: Populate buggy docker CLI
79
+      copy:
80
+        dest: /usr/bin/docker
81
+        mode: 0755
82
+        content: |
83
+          #!/bin/bash
84
+          action="$1"
85
+          shift
86
+          container="$1"
87
+          shift
88
+          command="$@"
89
+
90
+          case $container in
91
+            'heat_api_cron')
92
+              echo '# This is a comment that should be ignored'
93
+              echo '0 12 14 2 * some-other command'
94
+              ;;
95
+            *)
96
+              echo "Unknown container ${container}"
97
+              ;;
98
+          esac

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

@@ -18,6 +18,7 @@
18 18
       - tripleo-validations-centos-7-molecule-nova-status
19 19
       - tripleo-validations-centos-7-molecule-image-serve
20 20
       - tripleo-validations-centos-7-molecule-check-network-gateway
21
+      - tripleo-validations-centos-7-molecule-undercloud-heat-purge-deleted
21 22
     gate:
22 23
       queue: integrated
23 24
       jobs:
@@ -36,6 +37,7 @@
36 37
       - tripleo-validations-centos-7-molecule-nova-status
37 38
       - tripleo-validations-centos-7-molecule-image-serve
38 39
       - tripleo-validations-centos-7-molecule-check-network-gateway
40
+      - tripleo-validations-centos-7-molecule-undercloud-heat-purge-deleted
39 41
     name: tripleo-validations-molecule-jobs
40 42
 - job:
41 43
     files:
@@ -143,3 +145,10 @@
143 145
     parent: tripleo-validations-centos-7-base
144 146
     vars:
145 147
       tripleo_validations_role_name: check-network-gateway
148
+- job:
149
+    files:
150
+    - ^roles/undercloud-heat-purge-deleted/.*
151
+    name: tripleo-validations-centos-7-molecule-undercloud-heat-purge-deleted
152
+    parent: tripleo-validations-centos-7-base
153
+    vars:
154
+      tripleo_validations_role_name: undercloud-heat-purge-deleted

Loading…
Cancel
Save