From fa4ddfd4cbf1c994bf1aa88f364321b34489f27b Mon Sep 17 00:00:00 2001 From: nicholasyang Date: Mon, 16 Oct 2023 15:19:32 +0800 Subject: [PATCH] Dev: behave: adjust functional tests for previous changes --- test/features/bootstrap_options.feature | 12 ++++++++++++ test/features/steps/const.py | 2 ++ test/features/steps/step_implementation.py | 14 ++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/test/features/bootstrap_options.feature b/test/features/bootstrap_options.feature index fd73472bcf..12bb2a5067 100644 --- a/test/features/bootstrap_options.feature +++ b/test/features/bootstrap_options.feature @@ -1,3 +1,4 @@ +# vim: sw=2 sts=2 noet @bootstrap Feature: crmsh bootstrap process - options @@ -157,3 +158,14 @@ Feature: crmsh bootstrap process - options When Run "crm cluster init csync2 -y" on "hanode1" Then Service "csync2.socket" is "started" on "hanode1" And Service "csync2.socket" is "started" on "hanode2" + + @clean + Scenario: Skip creating ssh key pairs with --use-ssh-agent + Given Directory "/root/.ssh" is renamed to "/root/ssh_disabled" on nodes ["hanode1", "hanode2"] + And ssh-agent is started at "/root/ssh-auth-sock" on nodes ["hanode1", "hanode2"] + When Run "SSH_AUTH_SOCK=/root/ssh-auth-sock ssh-add /root/ssh_disabled/id_rsa" on "hanode1,hanode2" + And Run "SSH_AUTH_SOCK=/root/ssh-auth-sock crm cluster init --use-ssh-agent -y" on "hanode1" + And Run "SSH_AUTH_SOCK=/root/ssh-auth-sock crm cluster join --use-ssh-agent -y -c hanode1" on "hanode2" + Then Cluster service is "started" on "hanode1" + And Run "test x1 == x$(awk 'END {print NR}' ~root/.ssh/authorized_keys)" OK + And Run "test x2 == x$(awk 'END {print NR}' ~hacluster/.ssh/authorized_keys)" OK diff --git a/test/features/steps/const.py b/test/features/steps/const.py index 8dde42b640..cd8645f3d0 100644 --- a/test/features/steps/const.py +++ b/test/features/steps/const.py @@ -82,6 +82,8 @@ --no-overwrite-sshkey Avoid "/root/.ssh/id_rsa" overwrite if "-y" option is used (False by default; Deprecated) + --use-ssh-agent Use an existing key from ssh-agent instead of creating + new key pairs Network configuration: Options for configuring the network and messaging layer. diff --git a/test/features/steps/step_implementation.py b/test/features/steps/step_implementation.py index c881e65cfa..3c4f4deb97 100644 --- a/test/features/steps/step_implementation.py +++ b/test/features/steps/step_implementation.py @@ -523,3 +523,17 @@ def step_impl(context, nodelist): assert bootstrap.is_nologin('hacluster') is False else: assert bootstrap.is_nologin('hacluster', node) is False + + +@given('Directory "{src}" is renamed to "{dst}" on nodes [{nodes:str+}]') +def step_impl(context, src, dst, nodes): + for node in nodes: + rc, _, _ = behave_agent.call(node, 1122, f"mv '{src}' '{dst}'", user='root') + assert 0 == rc + + +@given('ssh-agent is started at "{path}" on nodes [{nodes:str+}]') +def step_impl(context, path, nodes): + for node in nodes: + rc, _, _ = behave_agent.call(node, 1122, f"systemd-run -u ssh-agent /usr/bin/ssh-agent -D -a '{path}'", user='root') + assert 0 == rc