From e234c9ede462ae26ec12c123fa0d775fdfa95dfc Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 6 Mar 2020 18:10:04 +0200 Subject: Add: test Gerrit access --- ssh-config.md | 15 ++++++++++++++- ssh-config.py | 11 ++++++++++- ssh-config.yaml | 6 ++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/ssh-config.md b/ssh-config.md index 96dc320..a041359 100644 --- a/ssh-config.md +++ b/ssh-config.md @@ -33,7 +33,7 @@ Host *.wmnet IdentitiesOnly yes ~~~ -# Acceptance criteria +# Acceptance criteria for WMF For my work I need to access production servers. Most of them don't allow direct SSH access and I need to go through a bastion server. @@ -59,3 +59,16 @@ train. when I run ssh deploy1001.eqiad.wmnet hostname then the output matches /^deploy\d+$/ ~~~ + +## Gerrit access + +For Gerrit, we need more than just a simple ssh command. We need git. + +~~~scenario +when I run git clone ssh://gerrit.wikimedia.org/sandbox +then the directory sandbox exists +~~~ + +# Acceptance criteria for personal use + +## diff --git a/ssh-config.py b/ssh-config.py index bea1453..66f260d 100644 --- a/ssh-config.py +++ b/ssh-config.py @@ -8,10 +8,19 @@ def run_ssh(ctx, host=None, cmd=None): print('context:', ctx.as_dict()) assert_eq(ctx.get('exit'), 0) -def stdout_matches(ctx, regex): +def run_git_clone(ctx, repo=None): + _runcmd(ctx, ['git', 'clone', repo]) + if ctx.get('exit') != 0: + print('context:', ctx.as_dict()) + assert_eq(ctx.get('exit'), 0) + +def stdout_matches(ctx, regex=None): stdout = ctx.get('stdout', '') assert_ne(re.search(regex, stdout), None) +def dir_exists(ctx, dirname=None): + assert_eq(os.path.isdir(dirname), True) + def _runcmd(ctx, argv): p = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = p.communicate("") diff --git a/ssh-config.yaml b/ssh-config.yaml index 376fe44..9863c86 100644 --- a/ssh-config.yaml +++ b/ssh-config.yaml @@ -1,5 +1,11 @@ - when: I run ssh (?P\S+) (?P.+) function: run_ssh +- when: I run git clone (?P\S+) + function: run_git_clone + - then: the output matches /(?P.+)/ function: stdout_matches + +- then: the directory (?P\S+) exists + function: dir_exists -- cgit v1.2.1