Skip to content

Commit c27c1d3

Browse files
authored
Merge pull request #362 from ScaleComputing/hc-v955
Easier local integration testing, SMB server
2 parents fde5fe4 + f7e4c95 commit c27c1d3

File tree

14 files changed

+237
-3
lines changed

14 files changed

+237
-3
lines changed

.ansible-lint

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ exclude_paths:
1010
- .github/workflows
1111
- changelogs
1212
- .tox
13+
- ci-infra/smb-server/compose.yml

DEVELOPMENT.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Create python venv and clone code.
44

5-
```
5+
```bash
66
mkdir -p ansible_collections/scale_computing/
77
cd ansible_collections/scale_computing/
88

@@ -109,6 +109,38 @@ Details:
109109
- IP 10.5.11.39 (see `tests/integration/integration_config.yml.j2`)
110110
- CI tests should use only `/cidata` and subdirectories
111111
112+
#### Local SMB server
113+
114+
Use `ci-infra/smb-server/compose.yml` to start a local SMB server.
115+
The HyperCore cluster needs to have access to the SMB server.
116+
Execute the commands on machine that is accessible to HyperCore cluster -
117+
e.g. VM on the HyperCore NUC.
118+
119+
Usage:
120+
121+
```bash
122+
cd ci-infra/smb-server/
123+
docker compose up
124+
125+
# test it works
126+
smbclient "//IP_ADDRESS/Home" -U "alice%alipass" -D "/" -c "ls"
127+
smbclient "//IP_ADDRESS/Home" -U "alice%alipass" -D "/" -c "put compose.yml"
128+
smbclient "//IP_ADDRESS/Home" -U "alice%alipass" -D "/" -c "ls"
129+
```
130+
131+
To use this SMB server in `ansible-test integration ...`,
132+
set in `tests/integration/integration_config.yml`:
133+
134+
```yaml
135+
smb_server: "IP_ADDRESS"
136+
smb_share: "/home"
137+
smb_username: "alice"
138+
smb_password: "alipass"
139+
```
140+
141+
Notice - windows SMB server username is `;administrator`, it starts with `;`.
142+
This Samba SMB server username does not start with `;`.
143+
112144
### CI NTP server
113145
114146
NTP server is running on VM with github runner.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This collection has been tested against following HyperCore cluster versions:
2626
- v9.2.13.211102
2727
- v9.3.5.212852
2828
- v9.4.17.215487
29+
- v9.5.5.219383
2930

3031
# Installation
3132

ci-infra/helpers/run-tests.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
3+
# Usage:
4+
# ./ci-infra/helpers/run-tests.sh outdir test-names.txt
5+
# Input:
6+
# - outdir will contain status/progress file, and log files of individual tests
7+
# - (optional) test-names.txt contains integration tests to be run, one per line.
8+
# Output:
9+
# - logs are one test per file, in outdir/log-timestamp/
10+
# - list of succeded/failed tests are in outdir/status.txt
11+
# If line starts with:
12+
# - PEND (or contains just test name), test will be run
13+
# - SKIP means skip this test
14+
# - OK or ERR are set after test is run
15+
16+
set -ue
17+
# set -v
18+
OUTD1="$1"
19+
TNFILE="${2:-}"
20+
21+
TIME=$(date +%Y%m%d-%H%M%S)
22+
TSTATUS="$OUTD1/status.txt"
23+
24+
[ ! -d "$OUTD1" ] && mkdir "$OUTD1"
25+
OUTD2="$OUTD1/log-$TIME"
26+
mkdir "$OUTD2"
27+
28+
if [ ! -f "$TSTATUS" ]
29+
then
30+
if [ -n "$TNFILE" ]
31+
then
32+
/bin/cp "$TNFILE" "$TSTATUS"
33+
else
34+
/bin/ls tests/integration/targets/ >"$TSTATUS"
35+
fi
36+
fi
37+
sed -i 's/^[a-z]/PEND\t&/' "$TSTATUS"
38+
if grep -q -v -E "^(OK|ERR|PEND|SKIP)" "$TSTATUS"
39+
then
40+
echo "ERROR file content $TSTATUS" 1>&2
41+
exit 1
42+
fi
43+
44+
TEST_NAMES=$(grep "^PEND" "$TSTATUS" | awk '{print $2}')
45+
# shellcheck disable=SC2086
46+
echo "Pending tests: "$TEST_NAMES
47+
# shellcheck disable=SC2086
48+
for TN in $TEST_NAMES
49+
do
50+
echo "Running test $TN"
51+
(
52+
echo ansible-test integration --local "$TN"
53+
echo "======================"
54+
set +e
55+
ansible-test integration --local "$TN"
56+
RET=$?
57+
set -e
58+
if [ "$RET" == "0" ]
59+
then
60+
status="OK"
61+
else
62+
status="ERR"
63+
fi
64+
sed -i "s/^PEND\t$TN\$/$status\t$TN/" "$TSTATUS"
65+
echo "======================"
66+
echo "RESULT $status"
67+
) >"$OUTD2/$TN.log" 2>&1
68+
res=$(grep $'\t'"$TN\$" "$TSTATUS" | awk '{print $1}')
69+
echo " result $res $TN"
70+
done

ci-infra/smb-server/compose.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
# docker-compose.yml example for https://github.com/ServerContainers/samba
3+
4+
services:
5+
samba:
6+
# build: .
7+
# image: ghcr.io/servercontainers/samba
8+
image: servercontainers/samba:smbd-only-a3.22.1-s4.21.4-r4
9+
restart: always
10+
# note that this network_mode makes it super easy (especially for zeroconf) but is not as safe as exposing ports directly
11+
# more about that here: https://book.hacktricks.wiki/en/linux-hardening/privilege-escalation/docker-security/docker-breakout-privilege-escalation/index.html#hostnetwork
12+
network_mode: host
13+
# uncomment to solve bug: https://github.com/ServerContainers/samba/issues/50 - wsdd2 only - not needed for samba
14+
#cap_add:
15+
# - CAP_NET_ADMIN
16+
environment:
17+
# uncomment to enable fail fast (currently only fails fast if there are conflicts/errors during user/group creation)
18+
#FAIL_FAST: 1
19+
20+
MODEL: 'TimeCapsule'
21+
AVAHI_NAME: StorageServer
22+
23+
SAMBA_CONF_LOG_LEVEL: 3
24+
25+
# uncomment to disable optional services
26+
WSDD2_DISABLE: 1
27+
AVAHI_DISABLE: 1
28+
NETBIOS_DISABLE: 1
29+
30+
GROUP_family: 1500
31+
32+
ACCOUNT_alice: alipass
33+
UID_alice: 1000
34+
GROUPS_alice: family
35+
36+
ACCOUNT_bob: bobpass
37+
UID_bob: 1001
38+
GROUPS_bob: family
39+
40+
# example for hashed password (user: foo | password: bar) - generated using create-hash.sh script.
41+
ACCOUNT_foo: "foo:1000:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:86C156FC198B358CCCF6278D8BD49B6A:[U ]:LCT-61B0859A:"
42+
# example for password hashes in the list format:
43+
# - "ACCOUNT_foo=foo:1000:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:8846F7EAEE8FB117AD06BDD830B7586C:[U ]:LCT-5FE1F7DF:"
44+
UID_foo: 1002
45+
GROUPS_foo: family
46+
47+
SAMBA_VOLUME_CONFIG_shared_home: "[Home]; path=/shares/homes/%U; valid users = alice, bob, foo; guest ok = no; read only = no; browseable = yes"
48+
49+
# SAMBA_VOLUME_CONFIG_aliceonly: "[Alice Share]; path=/shares/alice; valid users = alice; guest ok = no; read only = no; browseable = yes"
50+
# SAMBA_VOLUME_CONFIG_alicehidden: "[Alice Hidden Share]; path=/shares/alice-hidden; valid users = alice; guest ok = no; read only = no; browseable = no"
51+
52+
# SAMBA_VOLUME_CONFIG_bobonly: "[Bob Share]; path=/shares/bob; valid users = bob; guest ok = no; read only = no; browseable = yes"
53+
54+
# SAMBA_VOLUME_CONFIG_public: "[Public]; path=/shares/public; valid users = alice, bob, foo; guest ok = no; read only = no; browseable = yes; force group = family"
55+
# SAMBA_VOLUME_CONFIG_public_ro: "[Public ReadOnly]; path=/shares/public; guest ok = yes; read only = yes; browseable = yes; force group = family"
56+
57+
# SAMBA_VOLUME_CONFIG_timemachine: "[TimeMachine]; path=/shares/timemachine/%U; valid users = alice, bob, foo; guest ok = no; read only = no; browseable = yes; fruit:time machine = yes; fruit:time machine max size = 500G"
58+
59+
# SAMBA_VOLUME_CONFIG_guestmultilineexample: |
60+
# [Guest Share]
61+
# path = /shares/guest
62+
# guest ok = yes
63+
# browseable = yes
64+
65+
volumes:
66+
# - /etc/avahi/services/:/external/avahi
67+
68+
# avoid loops when mounting folders to /shares (I'd recommend explicit mapping for each share)
69+
# - ./shares/alice:/shares/alice
70+
# - ./shares/alice-hidden:/shares/alice-hidden
71+
# - ./shares/bob:/shares/bob
72+
# - ./shares/public:/shares/public
73+
# - ./shares/homes:/shares/homes
74+
# - ./shares/timemachine:/shares/timemachine
75+
- ./shares-homes:/shares/homes

docs/rst/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@ This collection has been tested against following HyperCore cluster versions:
5353
- v9.2.13.211102
5454
- v9.3.5.212852
5555
- v9.4.17.215487
56+
- v9.5.5.219383

tests/integration/integration_config.yml.j2

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,40 @@ sc_config:
270270
is_supported: True
271271
cluster_name:
272272
is_writable: True
273+
274+
https://10.5.11.206:
275+
<<: *base_cfg
276+
ci_system_name: vsns206
277+
sc_username: admin
278+
sc_password: admin
279+
sc_replication_dest_host: ""
280+
sc_replication_dest_cluster_name: ""
281+
sc_replication_dest_username: ""
282+
sc_replication_dest_password: ""
283+
cluster:
284+
name: VSNS206
285+
support_tunnel:
286+
open: true
287+
code: "4427"
288+
smtp:
289+
<<: *base_smtp
290+
from_address: [email protected]
291+
version_update:
292+
magic_allow_string: "oh-no-no"
293+
vm_shutdown_restart_allow_string: "allow-vm-shutdown-restart-test"
294+
syslog_server:
295+
host: 10.5.11.222
296+
features:
297+
version_update:
298+
current_version: "9.5.5.219383"
299+
next_version: ""
300+
latest_version: ""
301+
can_be_applied: False
302+
old_update_status_present: False
303+
virtual_disk:
304+
is_supported: True
305+
replication_factor: 1
306+
vtpm_disk:
307+
is_supported: True
308+
cluster_name:
309+
is_writable: True

tests/integration/targets/vm_snapshot/tasks/03_vm_snapshot_attach_disk.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
slot_b: 0 # vm_2, ide_disk
1414

1515
force_reboot: true # allow forced vm shutdown
16+
shutdown_timeout: 10
1617

1718
# disk size gets rounded by HC3:
1819
# 0.1 GB to 107374182 B
@@ -83,6 +84,7 @@
8384
source_disk_type: virtio_disk
8485
source_disk_slot: 1
8586
force_reboot: "{{ force_reboot }}"
87+
shutdown_timeout: "{{ shutdown_timeout }}"
8688
register: result
8789
- ansible.builtin.debug:
8890
var: result
@@ -128,6 +130,7 @@
128130
source_disk_type: virtio_disk
129131
source_disk_slot: 1
130132
force_reboot: "{{ force_reboot }}"
133+
shutdown_timeout: "{{ shutdown_timeout }}"
131134
register: result
132135
- ansible.builtin.debug:
133136
var: result
@@ -157,7 +160,7 @@
157160
source_disk_type: virtio_disk
158161
source_disk_slot: 1
159162
force_reboot: "{{ force_reboot }}"
160-
shutdown_timeout: 10 # For faster testing. VM has no OS, so it cannot react to ACPI shutdown.
163+
shutdown_timeout: "{{ shutdown_timeout }}" # For faster testing. VM has no OS, so it cannot react to ACPI shutdown.
161164
register: result
162165
- ansible.builtin.debug:
163166
var: result
@@ -201,6 +204,7 @@
201204
source_disk_type: virtio_disk
202205
source_disk_slot: 1
203206
force_reboot: "{{ force_reboot }}"
207+
shutdown_timeout: "{{ shutdown_timeout }}"
204208
register: result
205209
- ansible.builtin.debug:
206210
var: result
@@ -231,6 +235,7 @@
231235
source_disk_type: virtio_disk
232236
source_disk_slot: 1
233237
force_reboot: "{{ force_reboot }}"
238+
shutdown_timeout: "{{ shutdown_timeout }}"
234239
register: result
235240
- ansible.builtin.debug:
236241
var: result
@@ -270,6 +275,7 @@
270275
source_disk_type: virtio_disk
271276
source_disk_slot: 1
272277
force_reboot: "{{ force_reboot }}"
278+
shutdown_timeout: "{{ shutdown_timeout }}"
273279
register: result
274280
- ansible.builtin.debug:
275281
var: result

tests/integration/targets/vm_snapshot/tasks/main.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
# greater than 0, is a newer snapshot
1515

1616
block:
17+
- name: Delete VMs before test
18+
include_tasks: helper_api_vm_snapshot_delete_all.yml
19+
vars:
20+
vms_number: "{{ number_of_snapshot_testing_vms }}"
21+
1722
- name: Create VMs
1823
include_tasks: helper_api_vm_snapshot_create.yml
1924
vars:
@@ -31,6 +36,7 @@
3136
vars:
3237
test_vms_number: "{{ number_of_snapshot_testing_vms }}"
3338
always:
34-
- include_tasks: helper_api_vm_snapshot_delete_all.yml
39+
- name: Delete VMs after test
40+
include_tasks: helper_api_vm_snapshot_delete_all.yml
3541
vars:
3642
vms_number: "{{ number_of_snapshot_testing_vms }}"

tests/sanity/ignore-2.16.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ignore.txt

0 commit comments

Comments
 (0)