Skip to content

Commit 34308d2

Browse files
authored
Merge pull request #367 from ScaleComputing/dev-docs
Development scripts and docs improvements
2 parents c27c1d3 + 0364c7d commit 34308d2

12 files changed

Lines changed: 126 additions & 9 deletions

File tree

DEVELOPMENT.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,42 @@ Sample ansible.cfg is there to ensure collection does not need to be installed.
213213
ansible-playbook -i localhost, examples/iso_info.yml -v
214214
```
215215
216+
## Running integration tests
217+
218+
Some test objects (ISO image, VirtualDisk, VM) needs to be created before we run integration tests.
219+
Use command:
220+
221+
```bash
222+
ansible-playbook -i localhost, tests/integration/prepare/prepare_vm.yml -v
223+
ansible-playbook -i localhost, tests/integration/prepare/prepare_iso.yml -v
224+
ansible-playbook -i localhost, tests/integration/prepare/prepare_examples.yml -v
225+
```
226+
227+
The `ansible-test integration` will try to run all integration test, and will fail on first problematic test.
228+
It does allow you to continue from the failed test.
229+
230+
You might want to automatically continue running remaining tests.
231+
A few failed tests can be reviewed and retried later.
232+
The `./ci-infra/helpers/run-tests.sh` was made for this.
233+
If N tests fail in first pass, the `run-tests.sh` will retry only those N test in second pass.
234+
The script is used like:
235+
236+
```bash
237+
source ci-infra/local-dev/env-host-4.sh
238+
./ci-infra/helpers/run-tests.sh outdir <tests.txt>
239+
```
240+
241+
File `tests.txt` is optional input.
242+
It contains one test name per line.
243+
If ommited, all tests from `tests/integration` are run.
244+
245+
After run, the scripts create in `outd` directory:
246+
247+
- directory `log-${timestamp}` directory containing a log file for each run test
248+
- file `status.txt` contains OK/ERR/PEND/SKIP status for each run test
249+
250+
On next run, only tests that have PEND/ERR status are retried.
251+
216252
## Creating a release
217253
218254
Releases are automatically created when a tag is created with a name matching
@@ -231,7 +267,7 @@ ScaleComputing does setup new VSNS, with suitable HyperCore version installed.
231267
232268
Steps:
233269
- Request / reserve static IP address from Alex
234-
- either replacing existing static IP or using next in series 105.11.20x
270+
- either replacing existing static IP or using next in series 10.5.11.20x
235271
- create empty VM with 1 virtio disk, type other, tag hc3nested, 16GB ram, 4 cores.
236272
- image new vSNS node using test iso image (vs. release - this may change in upcoming releases)
237273
- (optional) Save it as template VM, example name `vsns9213-unconfigured`
@@ -240,6 +276,7 @@ Steps:
240276
- `sudo singleNodeCluster=1 scclusterinit`
241277
- Save it as template VM, example name `vsns9213-template`
242278
- Create a final vSNS from template VM, example name `vsns9213-ci`
279+
- keep same MAC address?
243280
- Add vSNS login URL to Azure OIDC redirectUris
244281
- ensure ip address is added to entraAD (azure) app registration for OIDC integration (ask Dave if needed)
245282
- "app_display_name": "Scale Computing HC3",

ci-infra/helpers/run-tests.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55
# Input:
66
# - outdir will contain status/progress file, and log files of individual tests
77
# - (optional) test-names.txt contains integration tests to be run, one per line.
8+
# If not given, all tests in tests/integration/targets/ are run.
89
# Output:
910
# - logs are one test per file, in outdir/log-timestamp/
1011
# - list of succeded/failed tests are in outdir/status.txt
1112
# If line starts with:
1213
# - PEND (or contains just test name), test will be run
1314
# - SKIP means skip this test
1415
# - OK or ERR are set after test is run
16+
# On second run, only PEND tests are run.
17+
# If there are no PEND tests, the ERR tests are retried.
1518

1619
set -ue
1720
# set -v
@@ -40,14 +43,29 @@ then
4043
echo "ERROR file content $TSTATUS" 1>&2
4144
exit 1
4245
fi
46+
/bin/cp "$TSTATUS" "$OUTD2/status.txt"
4347

4448
TEST_NAMES=$(grep "^PEND" "$TSTATUS" | awk '{print $2}')
49+
if [ -z "$TEST_NAMES" ]
50+
then
51+
echo "No PEND tests, retrying ERR tests"
52+
sed -i 's/^ERR/PEND/' "$TSTATUS"
53+
fi
54+
TEST_NAMES=$(grep "^PEND" "$TSTATUS" | awk '{print $2}')
55+
if [ -z "$TEST_NAMES" ]
56+
then
57+
echo "No tests to run, exiting."
58+
exit 0
59+
fi
4560
# shellcheck disable=SC2086
4661
echo "Pending tests: "$TEST_NAMES
4762
# shellcheck disable=SC2086
63+
TEST_COUNT=$(echo $TEST_NAMES | wc -w)
64+
65+
ii=0
4866
for TN in $TEST_NAMES
4967
do
50-
echo "Running test $TN"
68+
echo "Running test $TN ($ii/$TEST_COUNT)"
5169
(
5270
echo ansible-test integration --local "$TN"
5371
echo "======================"
@@ -67,4 +85,5 @@ do
6785
) >"$OUTD2/$TN.log" 2>&1
6886
res=$(grep $'\t'"$TN\$" "$TSTATUS" | awk '{print $1}')
6987
echo " result $res $TN"
88+
ii=$((ii+1))
7089
done

tests/integration/integration_config.yml.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ sc_config:
3535
# pool.ntp.org servers frequently return KOD.
3636
# time.google.com does not complain.
3737
source: time.google.com
38+
# We need 2 NTP servers.
39+
# Set them up per ci-infra/ntp-chrony/Readme.md.
40+
time_server_a: 10.5.11.5
41+
time_server_b: 10.5.11.75
3842
time_zone:
3943
zone: US/Eastern
4044
dns_config:

tests/integration/targets/i_vm_params/tasks/02_machine_type.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@
210210
- not output.records[0].snapshot_schedule
211211

212212
# ===================================================================
213+
# Reset a running VM
214+
- name: Check initial VM power_state
215+
ansible.builtin.assert:
216+
that:
217+
- output.records[0].power_state == "started"
218+
213219
- name: Set VMs power_state - reset
214220
scale_computing.hypercore.vm_params:
215221
vm_name: "{{ vm_name }}"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
- name: Set OIDC configuration
3+
hosts: localhost
4+
gather_facts: False
5+
vars:
6+
oidc_config: "{{ sc_config[sc_host].oidc }}"
7+
8+
tasks:
9+
- name: Import tasks setup_oidc_config.yml
10+
import_tasks: tasks/setup_oidc_config.yml

tests/integration/targets/inventory/runme.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ ansible-playbook -i localhost, -i hypercore_inventory_ansible_both_false.yml run
5555

5656
# test with OIDC user
5757
# We can do this only if OIDC login is configured.
58+
echo "Ensure OIDC login is setup on tested HyperCore."
59+
ansible-playbook -e @"$vars_file" oidc_config.yml
5860
echo "Testing inventory plugin with OIDC user."
5961
eval "$(cat <<EOF | python
6062
import yaml
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
- name: Set OIDC configuration
3+
scale_computing.hypercore.oidc_config:
4+
client_id: "{{ oidc_config.client_id_default }}"
5+
shared_secret: "{{ oidc_config.shared_secret_default }}"
6+
config_url: "{{ oidc_config.config_url_default }}"
7+
scopes: "openid+profile"
8+
9+
- name: Get OIDC configuration
10+
scale_computing.hypercore.api:
11+
action: get
12+
endpoint: /rest/v1/OIDCConfig
13+
register: oidc_config_response
14+
15+
- name: Assert OIDC is configured
16+
ansible.builtin.assert:
17+
that:
18+
- oidc_config_response.record | length == 1
19+
- oidc_config_response.record.0.clientID == oidc_config.client_id_default
20+
fail_msg: "OIDC is not configured on the Scale Computing cluster."

tests/integration/targets/role_template2vm/templates/meta-data.ubuntu-20.04.yml.j2

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
dsmode: local
22
local-hostname: "{{ vm_name }}"
3+
{#
4+
Comment out network configuration to use cloud-init default
5+
which is to enable DHCP on the first detected interface.
6+
In generated /var/lib/cloud/instance/network-config.json is string "_orig_eni_name".
7+
This is invalid cloud-init config.
8+
39
network-interfaces: |
410
auto lo
511
iface lo inet loopback
@@ -13,6 +19,8 @@ network-interfaces: |
1319
# - CI VSNS v9.3.5 (https://10.5.11.203/)
1420
# - CI VSNS v9.4.17 (https://10.5.11.205/)
1521
iface ens1 inet dhcp
22+
# Device enp1s1 on VSNS 4.7.0.221603 prerelease
23+
iface enp1 inet dhcp
1624
{% endif %}
1725
{% if vm_network_mode == "static" %}
1826
iface {{ vm_network_iface }} inet static
@@ -21,3 +29,4 @@ network-interfaces: |
2129
gateway {{ vm_network_gateway }}
2230
dns-nameservers {{ vm_network_dns_nameservers }}
2331
{% endif %}
32+
#}

tests/integration/targets/time_server/tasks/01_time_server_info.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66

77
vars:
88
actual_uuid: "timesource_guid"
9-
# We need 2 NTP servers.
10-
# Set them up per ci-infra/ntp-chrony/Readme.md.
11-
actual_host: "10.5.11.5"
9+
actual_host: "{{ sc_config[sc_host].time_server.time_server_a }}"
1210

1311
block:
1412
# -------------------------------------------------------

tests/integration/targets/time_server/tasks/02_time_server.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
SC_PASSWORD: "{{ sc_config[sc_host].sc_password }}"
66
SC_TIMEOUT: "{{ sc_timeout * 10 }}"
77
vars:
8-
# We need 2 NTP servers.
9-
# Set them up per ci-infra/ntp-chrony/Readme.md.
10-
time_server_a: 10.5.11.5
11-
time_server_b: 10.5.11.75
8+
time_server_a: "{{ sc_config[sc_host].time_server.time_server_a }}"
9+
time_server_b: "{{ sc_config[sc_host].time_server.time_server_b }}"
1210
actual_uuid: timesource_guid
1311

1412
block:

0 commit comments

Comments
 (0)