Skip to content

Commit 38d9896

Browse files
Dev: behave: add functional tests for pre-migration checks (jsc#PED-8252)
1 parent 0ed12a9 commit 38d9896

File tree

6 files changed

+130
-6
lines changed

6 files changed

+130
-6
lines changed

.github/workflows/crmsh-ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,21 @@ jobs:
415415
token: ${{ secrets.CODECOV_TOKEN }}
416416
flags: integration
417417

418+
functional_test_migration:
419+
runs-on: ubuntu-24.04
420+
timeout-minutes: 40
421+
steps:
422+
- uses: actions/checkout@v4
423+
- name: functional test for migration
424+
run: |
425+
echo '{ "exec-opts": ["native.cgroupdriver=systemd"] }' | sudo tee /etc/docker/daemon.json
426+
sudo systemctl restart docker.service
427+
$CONTAINER_SCRIPT `$GET_INDEX_OF migration` && $CONTAINER_SCRIPT -d && $CONTAINER_SCRIPT -u `$GET_INDEX_OF migration`
428+
- uses: codecov/codecov-action@v4
429+
with:
430+
token: ${{ secrets.CODECOV_TOKEN }}
431+
flags: integration
432+
418433
original_regression_test:
419434
runs-on: ubuntu-24.04
420435
timeout-minutes: 40

codecov.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ coverage:
88
threshold: 0.35%
99
codecov:
1010
notify:
11-
after_n_builds: 28
11+
after_n_builds: 29
1212
comment:
13-
after_n_builds: 28
13+
after_n_builds: 29
1414
layout: "condensed_header, flags, files, condensed_footer"

data-manifest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ test/features/environment.py
8383
test/features/geo_setup.feature
8484
test/features/gfs2.feature
8585
test/features/healthcheck.feature
86+
test/features/migration.feature
8687
test/features/ocfs2.feature
8788
test/features/qdevice_options.feature
8889
test/features/qdevice_setup_remove.feature

test/features/migration.feature

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# vim: sw=2 sts=2
2+
Feature: migration
3+
4+
Test migration and pre-migration checks
5+
Need nodes: hanode1 hanode2
6+
7+
Scenario: Run pre-migration checks when cluster services are running.
8+
Given Cluster service is "stopped" on "hanode1"
9+
And Cluster service is "stopped" on "hanode2"
10+
And Run "crm cluster init -y -N hanode2" OK on "hanode1"
11+
When Try "crm cluster health sles16" on "hanode1"
12+
Then Expected return code is "1"
13+
And Expected "[FAIL] Cluster services are running" in stdout
14+
15+
Scenario: Run pre-migration checks with cluster services stopped.
16+
When Run "crm cluster stop --all" on "hanode1"
17+
And Run "crm cluster stop --all" on "hanode2"
18+
And Try "crm cluster health sles16" on "hanode1"
19+
Then Expected return code is "0"
20+
21+
Scenario: Should run fixes.
22+
When Try "crm cluster health sles16 --fix" on "hanode1"
23+
Then Expected return code is "0"
24+
25+
Scenario: run pre-migration checks against corosync.conf generated in crmsh-4.6
26+
When Run "rm -f /etc/corosync/corosync.conf" on "hanode1"
27+
And Write multi lines to file "/etc/corosync/corosync.conf" on "hanode1"
28+
"""
29+
# Please read the corosync.conf.5 manual page
30+
totem {
31+
version: 2
32+
cluster_name: hacluster
33+
clear_node_high_bit: yes
34+
interface {
35+
ringnumber: 0
36+
mcastport: 5405
37+
ttl: 1
38+
}
39+
40+
transport: udpu
41+
crypto_hash: sha1
42+
crypto_cipher: aes256
43+
token: 5000
44+
join: 60
45+
max_messages: 20
46+
token_retransmits_before_loss_const: 10
47+
}
48+
49+
logging {
50+
fileline: off
51+
to_stderr: no
52+
to_logfile: yes
53+
logfile: /var/log/cluster/corosync.log
54+
to_syslog: yes
55+
debug: off
56+
timestamp: on
57+
logger_subsys {
58+
subsys: QUORUM
59+
debug: off
60+
}
61+
62+
}
63+
64+
quorum {
65+
66+
# Enable and configure quorum subsystem (default: off)
67+
# see also corosync.conf.5 and votequorum.5
68+
provider: corosync_votequorum
69+
expected_votes: 2
70+
two_node: 1
71+
}
72+
73+
nodelist {
74+
node {
75+
ring0_addr: @hanode1.ip.0
76+
name: hanode1
77+
nodeid: 1
78+
}
79+
80+
node {
81+
ring0_addr: @hanode2.ip.0
82+
name: hanode2
83+
nodeid: 2
84+
}
85+
86+
}
87+
"""
88+
And Run "crm cluster copy /etc/corosync/corosync.conf" on "hanode1"
89+
And Try "crm cluster health sles16" on "hanode1"
90+
Then Expected return code is "0"
91+
And Expect stdout contains snippets ["[PASS] This cluster is good to migrate to SLES 16.", "[INFO] Please run \"crm cluster health sles16 --fix\" on on any one of above nodes.", "[WARN] Corosync transport \"udpu\" will be deprecated in corosync 3. Please use knet.", "----- localhost -----", "----- hanode2 -----"].
92+
93+
Scenario: Run fixes against corosync.conf generated in crmsh-4.6
94+
When Try "crm cluster health sles16 --fix" on "hanode1"
95+
Then Expected return code is "0"
96+
97+
Scenario: Run pre-migration checks when some of the nodes are offline.
98+
When Run "systemctl stop sshd" on "hanode2"
99+
And Try "crm cluster health sles16" on "hanode1"
100+
Then Expected return code is "1"
101+
And Expect stdout contains snippets ["Cannot create SSH connection to", "----- localhost -----", "----- hanode2 -----"].
102+

test/features/steps/step_implementation.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import ast
12
import re
23
import time
34
import os
@@ -18,8 +19,8 @@
1819

1920

2021
def _parse_str(text):
21-
return text[1:-1].encode('utf-8').decode('unicode_escape')
22-
_parse_str.pattern='".*"'
22+
return ast.literal_eval(text)
23+
_parse_str.pattern='"([^"]|\\")*?"'
2324

2425

2526
behave.use_step_matcher("cfparse")
@@ -170,6 +171,13 @@ def step_impl(context, msg):
170171
context.stderr = None
171172

172173

174+
@then('Expect stdout contains snippets [{snippets:str+}].')
175+
def step_impl(context, snippets):
176+
for snippet in snippets:
177+
assert_in(snippet, context.stdout)
178+
context.stdout = None
179+
180+
173181
@then('Expected regex "{reg_str}" in stdout')
174182
def step_impl(context, reg_str):
175183
res = re.search(reg_str, context.stdout)

test/run-functional-tests

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,6 @@ deploy_ha_node() {
228228

229229

230230
create_node() {
231-
info "Loading container image $CONTAINER_IMAGE..."
232-
233231
echo 16777216 > /proc/sys/net/core/rmem_max
234232
echo 16777216 > /proc/sys/net/core/wmem_max
235233
info "Create ha specific container networks..."

0 commit comments

Comments
 (0)