From 4d74918835ed201384f704bb4a83d22bf2252577 Mon Sep 17 00:00:00 2001 From: Aleksei Burlakov Date: Sun, 18 Dec 2022 14:01:45 +0100 Subject: [PATCH] Dev: unittest: basic alice-bob init-join test This is just the first step to anchor the PR#1009. There will follow other more advanced tests. --- data-manifest | 1 + .../bootstrap_init_join_remove_alice.feature | 17 ++++++++++++ test/run-functional-tests | 27 +++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 test/features/bootstrap_init_join_remove_alice.feature diff --git a/data-manifest b/data-manifest index e0e226b68f..a39b74331f 100644 --- a/data-manifest +++ b/data-manifest @@ -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 diff --git a/test/features/bootstrap_init_join_remove_alice.feature b/test/features/bootstrap_init_join_remove_alice.feature new file mode 100644 index 0000000000..97a342317d --- /dev/null +++ b/test/features/bootstrap_init_join_remove_alice.feature @@ -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" diff --git a/test/run-functional-tests b/test/run-functional-tests index 9de8eeee90..9f3e6a9c05 100755 --- a/test/run-functional-tests +++ b/test/run-functional-tests @@ -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 @@ -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 }