Skip to content

Commit

Permalink
Dev: unittest: basic alice-bob init-join test
Browse files Browse the repository at this point in the history
This is just the first step to anchor the PR#1009.
There will follow other more advanced tests.
  • Loading branch information
Aleksei Burlakov committed Dec 20, 2022
1 parent 755834a commit 4d74918
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions data-manifest
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ test/defaults
test/descriptions
test/evaltest.sh
test/features/bootstrap_bugs.feature
test/features/bootstrap_init_join_remove_alice.feature
test/features/bootstrap_init_join_remove.feature
test/features/bootstrap_options.feature
test/features/bootstrap_sbd_delay.feature
Expand Down
17 changes: 17 additions & 0 deletions test/features/bootstrap_init_join_remove_alice.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@bootstrap
Feature: crmsh bootstrap process - init, join and remove

Test crmsh bootstrap init/join/remove process
Need nodes: hanode1 hanode2

Scenario: Setup a two nodes cluster as alice and bob
Given Nodes ["hanode1", "hanode2"] are cleaned up
And Cluster service is "stopped" on "hanode1"
And Cluster service is "stopped" on "hanode2"
When Run "su alice -c 'crm cluster init -y'" on "hanode1"
Then Cluster service is "started" on "hanode1"
And Show cluster status on "hanode1"
When Run "su bob -c 'crm cluster join -c alice@hanode1 -y'" on "hanode2"
Then Cluster service is "started" on "hanode2"
And Online nodes are "hanode1 hanode2"
And Show cluster status on "hanode1"
27 changes: 27 additions & 0 deletions test/run-functional-tests
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,31 @@ docker_exec() {
docker exec -t $name /bin/sh -c "$cmd"
}

create_custom_user() {
user_name=$1
user_id=$2
docker_exec $node_name "useradd -m -s /bin/bash -N -u ${user_id} -g 90 ${user_name} 2>/dev/null"
docker_exec $node_name "chmod u+w /etc/sudoers"
docker_exec $node_name "echo \"${user_name} ALL=(ALL) NOPASSWD: ALL\" >> /etc/sudoers"
docker_exec $node_name "chmod u-w /etc/sudoers"
docker_exec $node_name "echo 'export PATH=\$PATH:/usr/sbin/' >> ~${user_name}/.bashrc"
docker_exec $node_name "echo -e \"linux\\nlinux\" | passwd ${user_name} 2>/dev/null"
docker_exec $node_name "cp -r /root/.ssh ~${user_name}/ && chown ${user_name}:haclient -R ~${user_name}/.ssh"
}

create_alice_bob_carol() {
# Custom users are alice, bob and carol and they are as important as the root
# and eventually they should be already in the docker image
# However now, let's create them here
create_custom_user "alice" "1000"
create_custom_user "bob" "1001"
create_custom_user "carol" "1002"

# I think /var/log/crmsh used to be hacluster:haclient
# Let's make it here again anyway. (This is a workarout, please FIXME!)
docker_exec $node_name "chown hacluster:haclient -R /var/log/crmsh"
docker_exec $node_name "chmod g+w -R /var/log/crmsh"
}

deploy_ha_node() {
node_name=$1
Expand All @@ -201,6 +226,8 @@ deploy_ha_node() {
info "Building crmsh on \"$node_name\"..."
docker_exec $node_name "$make_cmd" 1> /dev/null || \
fatal "Building failed on $node_name!"

create_alice_bob_carol
}


Expand Down

0 comments on commit 4d74918

Please sign in to comment.