Skip to content

Commit 8b9947e

Browse files
authored
Create downgrade and upgrade tests for NGINX Plus (#530)
1 parent b296755 commit 8b9947e

File tree

12 files changed

+409
-16
lines changed

12 files changed

+409
-16
lines changed

.github/workflows/molecule.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ jobs:
2222
scenario:
2323
- default
2424
- downgrade
25+
- downgrade_plus
2526
- module
2627
- plus
2728
- source
2829
- uninstall
2930
- uninstall_plus
3031
- upgrade
32+
- upgrade_plus
3133
steps:
3234
- name: Check out the codebase
3335
if: "!(contains(matrix.scenario, 'plus') && github.event.pull_request.head.repo.full_name != github.repository)"

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ BUG FIXES:
2222
* Always refresh the `yum` cache.
2323
* The role can now correctly upgrade NGINX to the latest release on Alpine Linux.
2424

25+
TESTS:
26+
27+
* Create downgrade and upgrade tests for NGINX Plus.
28+
2529
## 0.23.1 (April 6, 2022)
2630

2731
FEATURES:

molecule/downgrade/prepare.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,7 @@
11
---
22
- name: Prepare
33
hosts: all
4-
pre_tasks:
5-
- name: Set repo if Alpine
6-
ansible.builtin.set_fact:
7-
version: "=1.23.0-r1"
8-
when: ansible_facts['os_family'] == "Alpine"
9-
- name: Set repo if Debian
10-
ansible.builtin.set_fact:
11-
version: "=1.23.0-1~{{ ansible_facts['distribution_release'] }}"
12-
when: ansible_facts['os_family'] == "Debian"
13-
- name: Set repo if Red Hat
14-
ansible.builtin.set_fact:
15-
version: "-1.23.0-1.{{ (ansible_facts['distribution'] == 'Amazon') | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx"
16-
when: ansible_facts['os_family'] == "RedHat"
174
tasks:
185
- name: Install NGINX
196
ansible.builtin.include_role:
207
name: ansible-role-nginx
21-
vars:
22-
nginx_version: "{{ version }}"

molecule/downgrade_plus/converge.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
- name: Converge
3+
hosts: all
4+
pre_tasks:
5+
- name: Set repo if Alpine
6+
ansible.builtin.set_fact:
7+
version: "=26-r1"
8+
when: ansible_facts['os_family'] == "Alpine"
9+
- name: Set repo if Debian
10+
ansible.builtin.set_fact:
11+
version: "=26-1~{{ ansible_facts['distribution_release'] }}"
12+
when: ansible_facts['os_family'] == "Debian"
13+
- name: Set repo if Red Hat
14+
ansible.builtin.set_fact:
15+
version: "-26-1.{{ (ansible_facts['distribution'] == 'Amazon') | ternary('amzn2', ('el' + ansible_facts['distribution_major_version'] | string)) }}.ngx"
16+
when: ansible_facts['os_family'] == "RedHat"
17+
tasks:
18+
- name: Install NGINX
19+
ansible.builtin.include_role:
20+
name: ansible-role-nginx
21+
vars:
22+
nginx_type: plus
23+
nginx_license:
24+
certificate: license/nginx-repo.crt
25+
key: license/nginx-repo.key
26+
nginx_remove_license: false
27+
nginx_version: "{{ version }}"

molecule/downgrade_plus/molecule.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
driver:
3+
name: docker
4+
lint: |
5+
set -e
6+
yamllint .
7+
ansible-lint --force-color
8+
platforms: # Alpine 3.16 only has one version of NGINX Plus available (at the moment) so it's impossible to test the downgrade scenario
9+
- name: alpine-3.13
10+
image: alpine:3.13
11+
dockerfile: ../common/Dockerfile.j2
12+
privileged: true
13+
volumes:
14+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
15+
command: "/sbin/init"
16+
- name: alpine-3.14
17+
image: alpine:3.14
18+
dockerfile: ../common/Dockerfile.j2
19+
privileged: true
20+
volumes:
21+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
22+
command: "/sbin/init"
23+
- name: alpine-3.15
24+
image: alpine:3.15
25+
dockerfile: ../common/Dockerfile.j2
26+
privileged: true
27+
volumes:
28+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
29+
command: "/sbin/init"
30+
- name: amazonlinux-2
31+
image: amazonlinux:2
32+
dockerfile: ../common/Dockerfile.j2
33+
privileged: true
34+
volumes:
35+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
36+
command: "/usr/sbin/init"
37+
- name: centos-7
38+
image: centos:7
39+
dockerfile: ../common/Dockerfile.j2
40+
privileged: true
41+
volumes:
42+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
43+
command: "/usr/sbin/init"
44+
- name: rhel-7
45+
image: registry.access.redhat.com/ubi7/ubi:7.9
46+
dockerfile: ../common/Dockerfile.j2
47+
privileged: true
48+
volumes:
49+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
50+
command: "/usr/sbin/init"
51+
- name: rhel-8
52+
image: registry.access.redhat.com/ubi8/ubi:8.5
53+
dockerfile: ../common/Dockerfile.j2
54+
privileged: true
55+
volumes:
56+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
57+
command: "/usr/sbin/init"
58+
- name: rhel-9
59+
image: registry.access.redhat.com/ubi9/ubi:9.0.0
60+
dockerfile: ../common/Dockerfile.j2
61+
privileged: true
62+
volumes:
63+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
64+
command: "/usr/sbin/init"
65+
- name: debian-buster
66+
image: debian:buster-slim
67+
dockerfile: ../common/Dockerfile.j2
68+
privileged: true
69+
volumes:
70+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
71+
command: "/sbin/init"
72+
- name: debian-bullseye
73+
image: debian:bullseye-slim
74+
dockerfile: ../common/Dockerfile.j2
75+
privileged: true
76+
volumes:
77+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
78+
command: "/sbin/init"
79+
- name: ubuntu-bionic
80+
image: ubuntu:bionic
81+
dockerfile: ../common/Dockerfile.j2
82+
privileged: true
83+
volumes:
84+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
85+
command: "/sbin/init"
86+
- name: ubuntu-focal
87+
image: ubuntu:focal
88+
dockerfile: ../common/Dockerfile.j2
89+
privileged: true
90+
volumes:
91+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
92+
command: "/sbin/init"
93+
- name: ubuntu-jammy
94+
image: ubuntu:jammy
95+
dockerfile: ../common/Dockerfile.j2
96+
privileged: true
97+
volumes:
98+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
99+
command: "/sbin/init"
100+
provisioner:
101+
name: ansible
102+
playbooks:
103+
prepare: prepare.yml
104+
converge: converge.yml
105+
verify: verify.yml

molecule/downgrade_plus/prepare.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
- name: Prepare license
3+
hosts: localhost
4+
gather_facts: false
5+
tasks:
6+
- name: Create ephemeral license certificate file from b64 decoded env var
7+
ansible.builtin.copy:
8+
content: "{{ lookup('env','NGINX_CRT') | b64decode }}"
9+
dest: ../../files/license/nginx-repo.crt
10+
force: false
11+
mode: 0444
12+
13+
- name: Create ephemeral license key file from b64 decoded env var
14+
ansible.builtin.copy:
15+
content: "{{ lookup('env','NGINX_KEY') | b64decode }}"
16+
dest: ../../files/license/nginx-repo.key
17+
force: false
18+
mode: 0444
19+
20+
- name: Prepare NGINX Plus
21+
hosts: all
22+
tasks:
23+
- name: Install NGINX
24+
ansible.builtin.include_role:
25+
name: ansible-role-nginx
26+
vars:
27+
nginx_type: plus
28+
nginx_license:
29+
certificate: license/nginx-repo.crt
30+
key: license/nginx-repo.key

molecule/downgrade_plus/verify.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
- name: Verify
3+
hosts: all
4+
tasks:
5+
- name: Check if NGINX Plus is installed
6+
ansible.builtin.package:
7+
name: nginx-plus
8+
state: present
9+
check_mode: true
10+
register: install
11+
failed_when: (install is changed) or (install is failed)
12+
13+
- name: Check if NGINX Plus service is running
14+
ansible.builtin.service:
15+
name: nginx
16+
state: started
17+
enabled: true
18+
check_mode: true
19+
register: service
20+
failed_when: (service is changed) or (service is failed)
21+
22+
- name: Verify NGINX Plus is up and running
23+
ansible.builtin.uri:
24+
url: http://localhost
25+
status_code: 200
26+
27+
- name: Verify NGINX Plus has been downgraded
28+
ansible.builtin.command: nginx -v
29+
args:
30+
chdir: "{{ ((ansible_facts['system'] | lower is not search('bsd')) | ternary('/etc/nginx', '/usr/local/sbin')) }}"
31+
changed_when: false
32+
register: version
33+
failed_when: version is not search('26')

molecule/uninstall_plus/prepare.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
force: false
1818
mode: 0444
1919

20-
- name: Prepare NGINX
20+
- name: Prepare NGINX Plus
2121
hosts: all
2222
tasks:
2323
- name: Install NGINX

molecule/upgrade_plus/converge.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
- name: Converge
3+
hosts: all
4+
tasks:
5+
- name: Install NGINX Plus
6+
ansible.builtin.include_role:
7+
name: ansible-role-nginx
8+
vars:
9+
nginx_type: plus
10+
nginx_license:
11+
certificate: license/nginx-repo.crt
12+
key: license/nginx-repo.key
13+
nginx_remove_license: false
14+
nginx_setup: upgrade

molecule/upgrade_plus/molecule.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
driver:
3+
name: docker
4+
lint: |
5+
set -e
6+
yamllint .
7+
ansible-lint --force-color
8+
platforms: # Alpine 3.16 only has one version of NGINX Plus available (at the moment) so it's impossible to test the upgrade scenario
9+
- name: alpine-3.13
10+
image: alpine:3.13
11+
dockerfile: ../common/Dockerfile.j2
12+
privileged: true
13+
volumes:
14+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
15+
command: "/sbin/init"
16+
- name: alpine-3.14
17+
image: alpine:3.14
18+
dockerfile: ../common/Dockerfile.j2
19+
privileged: true
20+
volumes:
21+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
22+
command: "/sbin/init"
23+
- name: alpine-3.15
24+
image: alpine:3.15
25+
dockerfile: ../common/Dockerfile.j2
26+
privileged: true
27+
volumes:
28+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
29+
command: "/sbin/init"
30+
- name: amazonlinux-2
31+
image: amazonlinux:2
32+
dockerfile: ../common/Dockerfile.j2
33+
privileged: true
34+
volumes:
35+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
36+
command: "/usr/sbin/init"
37+
- name: centos-7
38+
image: centos:7
39+
dockerfile: ../common/Dockerfile.j2
40+
privileged: true
41+
volumes:
42+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
43+
command: "/usr/sbin/init"
44+
- name: rhel-7
45+
image: registry.access.redhat.com/ubi7/ubi:7.9
46+
dockerfile: ../common/Dockerfile.j2
47+
privileged: true
48+
volumes:
49+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
50+
command: "/usr/sbin/init"
51+
- name: rhel-8
52+
image: registry.access.redhat.com/ubi8/ubi:8.5
53+
dockerfile: ../common/Dockerfile.j2
54+
privileged: true
55+
volumes:
56+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
57+
command: "/usr/sbin/init"
58+
- name: rhel-9
59+
image: registry.access.redhat.com/ubi9/ubi:9.0.0
60+
dockerfile: ../common/Dockerfile.j2
61+
privileged: true
62+
volumes:
63+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
64+
command: "/usr/sbin/init"
65+
- name: debian-buster
66+
image: debian:buster-slim
67+
dockerfile: ../common/Dockerfile.j2
68+
privileged: true
69+
volumes:
70+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
71+
command: "/sbin/init"
72+
- name: debian-bullseye
73+
image: debian:bullseye-slim
74+
dockerfile: ../common/Dockerfile.j2
75+
privileged: true
76+
volumes:
77+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
78+
command: "/sbin/init"
79+
- name: ubuntu-bionic
80+
image: ubuntu:bionic
81+
dockerfile: ../common/Dockerfile.j2
82+
privileged: true
83+
volumes:
84+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
85+
command: "/sbin/init"
86+
- name: ubuntu-focal
87+
image: ubuntu:focal
88+
dockerfile: ../common/Dockerfile.j2
89+
privileged: true
90+
volumes:
91+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
92+
command: "/sbin/init"
93+
- name: ubuntu-jammy
94+
image: ubuntu:jammy
95+
dockerfile: ../common/Dockerfile.j2
96+
privileged: true
97+
volumes:
98+
- "/sys/fs/cgroup:/sys/fs/cgroup:rw"
99+
command: "/sbin/init"
100+
provisioner:
101+
name: ansible
102+
playbooks:
103+
prepare: prepare.yml
104+
converge: converge.yml
105+
verify: verify.yml

0 commit comments

Comments
 (0)