Skip to content

Commit

Permalink
Fix: behave: adapt to podman network config (#1572)
Browse files Browse the repository at this point in the history
The default bridged network interfere the tests. Specify a --network on
`podman run` to get rid of it.
  • Loading branch information
nicholasyang2022 committed Oct 17, 2024
1 parent ce84504 commit b74cd9f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 21 deletions.
12 changes: 6 additions & 6 deletions test/features/bootstrap_options.feature
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ Feature: crmsh bootstrap process - options
@clean
Scenario: Using multiple network interface using "-i" option
Given Cluster service is "stopped" on "hanode1"
And IP "@hanode1.ip.default" is belong to "eth0"
And IP "@hanode1.ip.0" is belong to "eth0"
And IP "@hanode1.ip.0" is belong to "eth1"
When Run "crm cluster init -i eth0 -i eth1 -y" on "hanode1"
Then Cluster service is "started" on "hanode1"
And IP "@hanode1.ip.default" is used by corosync on "hanode1"
And IP "@hanode1.ip.0" is used by corosync on "hanode1"
And IP "@hanode1.ip.0" is used by corosync on "hanode1"
And Show corosync ring status

Expand All @@ -97,11 +97,11 @@ Feature: crmsh bootstrap process - options
Given Cluster service is "stopped" on "hanode2"
When Run "crm cluster init -i eth0 -i @hanode1.ip.0 -y" on "hanode1"
Then Cluster service is "started" on "hanode1"
And IP "@hanode1.ip.default" is used by corosync on "hanode1"
And IP "@hanode1.ip.0" is used by corosync on "hanode1"
And IP "@hanode1.ip.0" is used by corosync on "hanode1"
When Run "crm cluster join -c hanode1 -i eth0 -i @hanode2.ip.0 -y" on "hanode2"
Then Cluster service is "started" on "hanode2"
And IP "@hanode2.ip.default" is used by corosync on "hanode2"
And IP "@hanode2.ip.0" is used by corosync on "hanode2"
And IP "@hanode2.ip.0" is used by corosync on "hanode2"

When Try "crm cluster join cluster -c hanode1 -y" on "hanode2"
Expand Down Expand Up @@ -147,10 +147,10 @@ Feature: crmsh bootstrap process - options
Given Cluster service is "stopped" on "hanode2"
When Run "crm cluster init -I -i eth1 -y" on "hanode1"
Then Cluster service is "started" on "hanode1"
And IP "@hanode1.ip6.default" is used by corosync on "hanode1"
And IP "@hanode1.ip6.0" is used by corosync on "hanode1"
When Run "crm cluster join -c hanode1 -i eth1 -y" on "hanode2"
Then Cluster service is "started" on "hanode2"
And IP "@hanode2.ip6.default" is used by corosync on "hanode2"
And IP "@hanode2.ip6.0" is used by corosync on "hanode2"

@clean
Scenario: Init cluster with -N option (bsc#1175863)
Expand Down
4 changes: 2 additions & 2 deletions test/features/cluster_blocking_ssh.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ Feature: cluster testing with ssh blocked
nodelist {
node {
ring0_addr: @hanode1.ip.default
ring0_addr: @hanode1.ip.0
name: hanode1
nodeid: 1
}
node {
ring0_addr: @hanode2.ip.default
ring0_addr: @hanode2.ip.0
name: hanode2
nodeid: 2
}
Expand Down
4 changes: 2 additions & 2 deletions test/features/qdevice_usercase.feature
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ Feature: Verify usercase master survive when split-brain
When Run "corosync-quorumtool -s" on "hanode1"
Then Expected "Quorate: Yes" in stdout
# Use iptables command to simulate split-brain
When Run "iptables -I INPUT -s @hanode2.ip.default -j DROP; sudo iptables -I OUTPUT -d @hanode2.ip.default -j DROP" on "hanode1"
And Run "iptables -I INPUT -s @hanode1.ip.default -j DROP; sudo iptables -I OUTPUT -d @hanode1.ip.default -j DROP" on "hanode2"
When Run "iptables -I INPUT -s @hanode2.ip.0 -j DROP; sudo iptables -I OUTPUT -d @hanode2.ip.0 -j DROP" on "hanode1"
And Run "iptables -I INPUT -s @hanode1.ip.0 -j DROP; sudo iptables -I OUTPUT -d @hanode1.ip.0 -j DROP" on "hanode2"
# Check whether hanode1 has quorum, while hanode2 doesn't
And Run "sleep 20" on "hanode1"
When Run "crm corosync status quorum" on "hanode1"
Expand Down
16 changes: 5 additions & 11 deletions test/run-functional-tests
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,16 @@ create_alice_bob_carol() {

deploy_ha_node() {
node_name=$1
podman_options="--name $node_name -h $node_name --systemd always --shm-size 1g"
podman_options="--name $node_name -h $node_name --network ha_network_first --systemd always --shm-size 1g"
# CAP_SYS_NICE for corosync to set realtime priority
# CAP_AUDIT_CONTROL for sshd
# CAP_NET_ADMIN for firewall and virtual ip
podman_capabilties="--cap-add CAP_SYS_NICE --cap-add CAP_AUDIT_CONTROL --cap-add CAP_NET_ADMIN"
make_cmd="cd $PROJECT_INSIDE;./autogen.sh && ./configure --prefix /usr && make install && make install-crmconfDATA prefix= && cp /usr/bin/crm /usr/sbin"

info "Deploying \"$node_name\"..."
podman run --rm -d $podman_options $podman_capabilties $CONTAINER_IMAGE &> /dev/null
for network in ${HA_NETWORK_ARRAY[@]};do
podman network connect $network $node_name
done
podman run --rm -d $podman_options $podman_capabilties $CONTAINER_IMAGE
podman network connect ha_network_second $node_name

if [ "$node_name" != "qnetd-node" ];then
rm_qnetd_cmd="rpm -q corosync-qnetd && rpm -e corosync-qnetd"
Expand Down Expand Up @@ -328,7 +326,7 @@ cleanup_cluster() {

adjust_test_case() {
node_name=$1
replace_arry=(`podman_exec $node_name "grep -o -E '@(hanode[0-9]+|qnetd-node)\.ip[6]?\.(default|[0-9])' $2|sort -u|dos2unix"`)
replace_arry=(`podman_exec $node_name "grep -o -E '@(hanode[0-9]+|qnetd-node)\.ip6?\.[0-9]' $2|sort -u"`)
for item in ${replace_arry[@]};do
item_str=${item##@}
node=`echo $item_str|cut -d "." -f 1`
Expand All @@ -338,11 +336,7 @@ adjust_test_case() {
ip_search_str="GlobalIPv6Address"
fi
index=`echo $item_str|cut -d "." -f 3|tr -d "\r"`
if [ "$index" == "default" ];then
ip=`podman container inspect $node -f "{{range .NetworkSettings.Networks}}{{printf \"%s \" .$ip_search_str}}{{end}}"|awk '{print $1}'|tr -d "\r"`
else
ip=`podman container inspect $node -f "{{.NetworkSettings.Networks.${HA_NETWORK_ARRAY[$index]}.$ip_search_str}}"|tr -d "\r"`
fi
ip=`podman container inspect $node -f "{{.NetworkSettings.Networks.${HA_NETWORK_ARRAY[$index]}.$ip_search_str}}"|tr -d "\r"`
item=`echo $item|tr -d "\r"`
podman_exec $node_name "sed -i s/$item/$ip/g $2"
done
Expand Down

0 comments on commit b74cd9f

Please sign in to comment.