Skip to content

Commit

Permalink
Dev: behave: adjust functional tests for previous changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasyang2022 committed Oct 16, 2023
1 parent cb0ce73 commit fa4ddfd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/features/bootstrap_options.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# vim: sw=2 sts=2 noet
@bootstrap
Feature: crmsh bootstrap process - options

Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions test/features/steps/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 14 additions & 0 deletions test/features/steps/step_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fa4ddfd

Please sign in to comment.