diff options
author | Lars Wirzenius <lwirzenius@wikimedia.org> | 2020-03-06 18:10:04 +0200 |
---|---|---|
committer | Lars Wirzenius <lwirzenius@wikimedia.org> | 2020-03-06 18:10:04 +0200 |
commit | e234c9ede462ae26ec12c123fa0d775fdfa95dfc (patch) | |
tree | 45a119900d490256eb94ab3093e8646e9b727c35 | |
parent | 16f56d83e32da0d1db42aa51720c6513a7cdbdab (diff) | |
download | wmf-ssh-config-e234c9ede462ae26ec12c123fa0d775fdfa95dfc.tar.gz |
Add: test Gerrit access
-rw-r--r-- | ssh-config.md | 15 | ||||
-rw-r--r-- | ssh-config.py | 11 | ||||
-rw-r--r-- | 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<host>\S+) (?P<cmd>.+) function: run_ssh +- when: I run git clone (?P<repo>\S+) + function: run_git_clone + - then: the output matches /(?P<regex>.+)/ function: stdout_matches + +- then: the directory (?P<dirname>\S+) exists + function: dir_exists |