Skip to content

Commit e73cf44

Browse files
authored
CI Integration tests need to know what test cluster supports (#194)
CI Integration tests need to know what test cluster supports Refactor integration-config.yml to signal what can be tested on a cluster. This depends on HyperCore version. We need to know if cluster name can be changed, version can be upgraded, and if virtual disk feature is supported. It also depends on test cluster being a real physical cluster or a virtual (single node) system. Part of integration tests was refactored based on this - cluster_name, virtual_disk, version_update_info, vm_replication. If virtual_disk is supported, the same test code is run as before. If virtual_disk is not supported, a new test was added to check module fails with correct error message. The same logic is applied to other tests. Regarding vm_replication_info, replication is configured only on one of 3 test clusters. Now we test module behaves correctly if replication is enabled or if replication is not enabled. Signed-off-by: Justin Cinkelj <justin.cinkelj@xlab.si>
1 parent 805f13e commit e73cf44

File tree

18 files changed

+651
-513
lines changed

18 files changed

+651
-513
lines changed

.github/actions/make-integ-config/action.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,11 @@
22
name: 'Create ansible-test integration_config.yml'
33
description: 'Create ansible-test integration_config.yml'
44
inputs:
5-
ci_config_all:
6-
description: 'CI config for all HyperCore hosts'
7-
required: true
85
sc_host: # id of input
96
description: 'SC_HOST environ variable'
107
required: true
118
# default: 'World'
129
# Node with IP .50 is our physical node.
13-
sc_username_50:
14-
description: 'sc_username variable to access physical nodes'
15-
required: true
1610
sc_password_50:
1711
description: 'sc_password variable to access physical nodes'
1812
required: true
@@ -33,7 +27,7 @@ runs:
3327
- run: |
3428
cd ${{ inputs.working_directory }}
3529
cat <<EOF >integ_config_vars.yml
36-
sc_username_50: ${{ inputs.sc_username_50 }}
30+
sc_username_50: xlab
3731
sc_password_50: ${{ inputs.sc_password_50 }}
3832
smb_username: ;administrator
3933
smb_password: ${{ inputs.smb_password }}

.github/workflows/integ-test.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ on:
2323
List integration tests to exclude.
2424
Use "*" to exclude all tests.
2525
Use regex like 'node|^git_issue|^dns_config$' to exclude only a subset.
26-
default: "^dns_config$|^cluster_shutdown$|^version_update$|^oidc_config$|^smtp$|^role_cluster_config$|^version_update_single_node$"
26+
default: "^dns_config$|^cluster_shutdown$|^version_update$|^oidc_config$|^smtp$|^role_cluster_config$|^role_version_update_single_node$"
2727
env:
2828
INTEG_TESTS_INCLUDE_SCHEDULE: "*"
29-
INTEG_TESTS_EXCLUDE_SCHEDULE: "^dns_config$|^cluster_shutdown$|^version_update$|^oidc_config$|^smtp$|^role_cluster_config$|^version_update_single_node$"
29+
INTEG_TESTS_EXCLUDE_SCHEDULE: "^dns_config$|^cluster_shutdown$|^version_update$|^oidc_config$|^smtp$|^role_cluster_config$|^role_version_update_single_node$"
3030
# ansible-test needs special directory structure.
3131
# WORKDIR is a subdir of GITHUB_WORKSPACE
3232
WORKDIR: work-dir/ansible_collections/scale_computing/hypercore
@@ -62,9 +62,7 @@ jobs:
6262
- run: ansible-galaxy collection list
6363
- uses: ./work-dir/ansible_collections/scale_computing/hypercore/.github/actions/make-integ-config
6464
with:
65-
ci_config_all: ${{ vars.CI_CONFIG_HC_IP50 }}
6665
sc_host: ${{ matrix.sc_host }}
67-
sc_username_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_USERNAME }}
6866
sc_password_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }}
6967
smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}
7068
oidc_client_secret: ${{ secrets.OIDC_CLIENT_SECRET }}
@@ -157,9 +155,7 @@ jobs:
157155
# ${{ env.WORKDIR }} cannot be used
158156
- uses: ./work-dir/ansible_collections/scale_computing/hypercore/.github/actions/make-integ-config
159157
with:
160-
ci_config_all: ${{ vars.CI_CONFIG_HC_IP50 }}
161158
sc_host: https://10.5.11.200
162-
sc_username_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_USERNAME }}
163159
sc_password_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }}
164160
smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}
165161
oidc_client_secret: ${{ secrets.OIDC_CLIENT_SECRET }}
@@ -190,19 +186,29 @@ jobs:
190186
strategy:
191187
fail-fast: false
192188
matrix:
193-
ansible: [2.13.0]
189+
# ansible: [2.13.0]
194190
# python: [3.11]
195191
# test_name: [user_info]
196192
test_name: ${{ fromJson(needs.integ-matrix.outputs.matrix) }}
197193
sc_host:
198194
- https://10.5.11.200
199195
- https://10.5.11.201
196+
include:
197+
- sc_host: https://10.5.11.50
198+
test_name: vm_replication
199+
- sc_host: https://10.5.11.50
200+
test_name: vm_replication_info
201+
exclude:
202+
- sc_host: https://10.5.11.200
203+
test_name: vm_replication
204+
- sc_host: https://10.5.11.201
205+
test_name: vm_replication
200206
steps:
201207
- name: Checkout
202208
uses: actions/checkout@v3
203209
with:
204210
path: ${{ env.WORKDIR }}
205-
- run: pip install ansible-core~=${{ matrix.ansible }}
211+
- run: pip install ansible-core~=2.13.0
206212
# We have ansible.cfg "for testing" in git repo
207213
# (it is excluded in galaxy.yml, so it is not part of collection artifact)
208214
# But it does affect ansible-galaxy and ansible-test commands.
@@ -211,9 +217,7 @@ jobs:
211217
# ${{ env.WORKDIR }} cannot be used
212218
- uses: ./work-dir/ansible_collections/scale_computing/hypercore/.github/actions/make-integ-config
213219
with:
214-
ci_config_all: ${{ vars.CI_CONFIG_HC_IP50 }}
215220
sc_host: ${{ matrix.sc_host }}
216-
sc_username_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_USERNAME }}
217221
sc_password_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }}
218222
smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}
219223
oidc_client_secret: ${{ secrets.OIDC_CLIENT_SECRET }}
@@ -240,9 +244,7 @@ jobs:
240244
# ${{ env.WORKDIR }} cannot be used
241245
- uses: ./work-dir/ansible_collections/scale_computing/hypercore/.github/actions/make-integ-config
242246
with:
243-
ci_config_all: ${{ vars.CI_CONFIG_HC_IP50 }}
244247
sc_host: https://10.5.11.200
245-
sc_username_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_USERNAME }}
246248
sc_password_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }}
247249
smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}
248250
oidc_client_secret: ${{ secrets.OIDC_CLIENT_SECRET }}
@@ -266,9 +268,7 @@ jobs:
266268
# ${{ env.WORKDIR }} cannot be used
267269
- uses: ./work-dir/ansible_collections/scale_computing/hypercore/.github/actions/make-integ-config
268270
with:
269-
ci_config_all: ${{ vars.CI_CONFIG_HC_IP50 }}
270271
sc_host: https://10.5.11.200
271-
sc_username_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_USERNAME }}
272272
sc_password_50: ${{ secrets.CI_CONFIG_HC_IP50_SC_PASSWORD }}
273273
smb_password: ${{ secrets.CI_CONFIG_HC_IP50_SMB_PASSWORD }}
274274
oidc_client_secret: ${{ secrets.OIDC_CLIENT_SECRET }}

tests/integration/integration_config.yml.j2

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ smb_share: "{{ smb_share }}"
1515
smb_username: "{{ smb_username }}"
1616
smb_password: "{{ smb_password }}"
1717

18+
__base_smtp: &base_smtp
19+
host: smtp-relay.gmail.com
20+
port: 25
21+
use_ssl: false
22+
# from_address: PUB5@scalecomputing.com
23+
use_auth: false
24+
auth_user: ""
25+
auth_password: ""
26+
27+
1828
# sc_config is specific for each test cluster
1929
# The values should be set after tests, to ensure cluster is left in functional state.
2030
sc_config:
@@ -35,14 +45,7 @@ sc_config:
3545
contact: Alex Nicholson
3646
email: email_hidden@scalecomputing.com
3747
phone: "123 456 7890"
38-
smtp: &base_smtp
39-
host: smtp-relay.gmail.com
40-
port: 25
41-
use_ssl: false
42-
# from_address: PUB5@scalecomputing.com
43-
use_auth: false
44-
auth_user: ""
45-
auth_password: ""
48+
# smtp: ...
4649
email_alert:
4750
- email_hidden@scalecomputing.com
4851
oidc:
@@ -65,6 +68,7 @@ sc_config:
6568
sc_username: "{{ sc_username_50 }}"
6669
sc_password: "{{ sc_password_50 }}"
6770
# Only .50 is configured with remote replication.
71+
# Set sc_replication_dest_host/username/password to "" to signal no replication is configured.
6872
sc_replication_dest_host: https://10.5.11.60
6973
# We have same username on .50 and .60 node.
7074
sc_replication_dest_username: "{{ sc_username_50 }}"
@@ -78,13 +82,36 @@ sc_config:
7882
smtp:
7983
<<: *base_smtp
8084
from_address: PUB5@scalecomputing.com
85+
# Under features are described properties that affect expected integration test output.
86+
features:
87+
version_update:
88+
# Current SW (ICOS) version running on the host.
89+
current_version: "9.2.13.211102"
90+
# The next version available update for the host.
91+
next_version: ""
92+
# The latest version available update for the host.
93+
latest_version: ""
94+
# Can we update the host? VSNS hosts report update as available,
95+
# but if we try to update, the update fails (unsupported HW is reported back).
96+
can_be_applied: True
97+
virtual_disk:
98+
# Virtual disk feature is supported iff version ">=9.2.10"
99+
is_supported: True
100+
# expected virtual disk replucation factor
101+
replication_factor: 2
102+
cluster_name:
103+
# cluster name can be changed iff version ">=9.1.21 <9.2.0 || >=9.2.11"
104+
is_writable: True
81105

82106
https://10.5.11.200:
83107
<<: *base_cfg
84108
sc_username: admin
85109
sc_password: admin
110+
sc_replication_dest_host: ""
111+
sc_replication_dest_username: ""
112+
sc_replication_dest_password: ""
86113
cluster:
87-
name: VSNS200
114+
name: "HC3 System" # VSNS200
88115
support_tunnel:
89116
open: true
90117
code: "4423"
@@ -93,11 +120,25 @@ sc_config:
93120
from_address: VSNS200@scalecomputing.com
94121
syslog_server:
95122
host: 10.5.11.222
123+
features:
124+
version_update:
125+
current_version: "9.1.14.208456"
126+
next_version: "9.1.23.210897"
127+
latest_version: "9.1.23.210897"
128+
can_be_applied: False
129+
virtual_disk:
130+
is_supported: False
131+
# replication_factor:
132+
cluster_name:
133+
is_writable: False
96134

97135
https://10.5.11.201:
98136
<<: *base_cfg
99137
sc_username: admin
100138
sc_password: admin
139+
sc_replication_dest_host: ""
140+
sc_replication_dest_username: ""
141+
sc_replication_dest_password: ""
101142
cluster:
102143
name: VSNS201
103144
support_tunnel:
@@ -108,3 +149,14 @@ sc_config:
108149
from_address: VSNS201@scalecomputing.com
109150
syslog_server:
110151
host: 10.5.11.222
152+
features:
153+
version_update:
154+
current_version: "9.2.13.211102"
155+
next_version: ""
156+
latest_version: ""
157+
can_be_applied: False
158+
virtual_disk:
159+
is_supported: True
160+
replication_factor: 1
161+
cluster_name:
162+
is_writable: True
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
- name: Change cluster name
3+
block:
4+
- name: Retrieve cluster name
5+
scale_computing.hypercore.cluster_info:
6+
register: cluster_initial
7+
8+
- name: Update cluster name
9+
scale_computing.hypercore.cluster_name:
10+
name_new: name_updated
11+
register: cluster
12+
- ansible.builtin.assert:
13+
that:
14+
- cluster is changed
15+
- cluster.record.keys() | sort == ['icos_version', 'name', 'uuid']
16+
- cluster.record.name == "name_updated"
17+
- cluster.diff.before.name == cluster_initial.record.name
18+
- cluster.diff.after.name == "name_updated"
19+
register: cluster # to catch assertion msg for always
20+
21+
- name: Check if cluster name is updated
22+
scale_computing.hypercore.cluster_info:
23+
register: cluster
24+
- ansible.builtin.assert:
25+
that:
26+
- cluster.record.name == "name_updated"
27+
register: cluster # to catch assertion msg for always
28+
29+
- name: Update cluster name - idempotence
30+
scale_computing.hypercore.cluster_name:
31+
name_new: name_updated
32+
register: cluster
33+
- ansible.builtin.assert:
34+
that:
35+
- cluster is not changed
36+
- cluster.record.keys() | sort == ['icos_version', 'name', 'uuid']
37+
- cluster.record.name == "name_updated"
38+
- cluster.diff.before.name == "name_updated"
39+
- cluster.diff.after.name == "name_updated"
40+
register: cluster # to catch assertion msg for always
41+
42+
- name: Retrieve cluster name
43+
scale_computing.hypercore.cluster_info:
44+
register: cluster
45+
- ansible.builtin.assert:
46+
that:
47+
- cluster.record.name == "name_updated"
48+
register: cluster # to catch assertion msg for always
49+
50+
- name: Set back the initial cluster name
51+
scale_computing.hypercore.cluster_name:
52+
name_new: "{{ cluster_initial.record.name }}"
53+
register: cluster
54+
- ansible.builtin.assert:
55+
that:
56+
- cluster is changed
57+
- cluster.record.keys() | sort == ['icos_version', 'name', 'uuid']
58+
- cluster.record.name == cluster_initial.record.name
59+
- cluster.diff.before.name == "name_updated"
60+
- cluster.diff.after.name == cluster_initial.record.name
61+
register: cluster # to catch assertion msg for always
62+
63+
- name: Check if cluster name is updated
64+
scale_computing.hypercore.cluster_info:
65+
register: cluster
66+
- ansible.builtin.assert:
67+
that:
68+
- cluster.record.name == cluster_initial.record.name
69+
register: cluster # to catch assertion msg for always
70+
71+
always:
72+
- name: Set back the initial cluster_name
73+
scale_computing.hypercore.api:
74+
action: patch
75+
endpoint: /rest/v1/Cluster/{{ cluster_initial.record.uuid }}
76+
data:
77+
clusterName: "{{ cluster_config.name }}"
78+
when: "'does not match required version' not in cluster.msg"
79+
80+
- name: Get current cluster name
81+
scale_computing.hypercore.api:
82+
action: get
83+
endpoint: /rest/v1/Cluster
84+
register: cluster
85+
- name: Show cluster
86+
ansible.builtin.debug:
87+
var: cluster
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
- name: Retrieve cluster name
3+
scale_computing.hypercore.cluster_info:
4+
register: cluster_initial
5+
6+
- ansible.builtin.assert:
7+
that:
8+
- cluster_initial.record.name == cluster_config.name
9+
10+
- name: Update cluster name
11+
scale_computing.hypercore.cluster_name:
12+
name_new: cluster_config.cluster_name
13+
register: cluster
14+
ignore_errors: True
15+
16+
- ansible.builtin.assert:
17+
that:
18+
- cluster is not changed
19+
- cluster is failed
20+
- "{{ 'does not match required version' in cluster.msg }}"
21+
- "{{ 'record' not in cluster }}"

0 commit comments

Comments
 (0)