diff options
Diffstat (limited to 'yarns/900-implements.yarn')
-rw-r--r-- | yarns/900-implements.yarn | 121 |
1 files changed, 0 insertions, 121 deletions
diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn deleted file mode 100644 index 26a05a7..0000000 --- a/yarns/900-implements.yarn +++ /dev/null @@ -1,121 +0,0 @@ -# Appendix: Scenario step implementations - -## Configuration - -Save the name of the server to be tested, so it doesn't need to be -repeated for every step. - - IMPLEMENTS GIVEN server name is (.+) - echo "SERVER=$MATCH_1" >> "$DATADIR/config.sh" - -Set account name to use on server. - - IMPLEMENTS GIVEN server has account (.+) - echo "ACCOUNT=$MATCH_1" >> "$DATADIR/config.sh" - -## Ping - -Does the server respond to a ping? - - IMPLEMENTS THEN server responds to ping - . "$DATADIR/config.sh" - ping -c1 "$SERVER" - -## Check server hostname - -Does the server's hostname match its domain name? - - IMPLEMENTS THEN server hostname is as expected - . "$DATADIR/config.sh" - ssh "$ACCOUNT@$SERVER" hostname | grep -Fx "$SERVER" - -## Ansible account - -Does the server have an account `ansible` that has passwordless sudo -access to root? - - IMPLEMENTS THEN server account has sudo - . "$DATADIR/config.sh" - ssh "$ACCOUNT@$SERVER" sudo -n id -u > "$DATADIR/id.out" - grep -F 0 "$DATADIR/id.out" - -## Python 2 installed? - -Does the server have Python 2 installed, by invoking `python`? - - IMPLEMENTS THEN server has python version 2 installed - . "$DATADIR/config.sh" - ssh "$ACCOUNT@$SERVER" python --version 2> "$DATADIR/python.out" - grep "^Python 2\." "$DATADIR/python.out" - -## Running command over ssh - -Run a command on the server over ssh, capturing stdout and stderr and -exit code for later inspection. - - IMPLEMENTS WHEN running ssh (.*) - if ssh $MATCH_1 > "$DATADIR/stdout" 2> "$DATADIR/stderr" - then - echo 0 > "$DATADIR/exit" - else - echo $? > "$DATADIR/exit" - fi - -## Access server over SFTP - -Put and get a file over SFTP. - - IMPLEMENTS THEN server allows SFTP - . "$DATADIR/config.sh" - echo test.file > "$DATADIR/sftp.file" - cat > "$DATADIR/sftp.commands" << EOF - put $DATADIR/sftp.file sftp.file - get sftp.file $DATADIR/sftp.file.copy - rm sftp.file - EOF - sftp -b "$DATADIR/sftp.commands" "$ACCOUNT@$SERVER" - cmp "$DATADIR/sftp.file" "$DATADIR/sftp.file.copy" - -## Inspect results of running a command - -The stdout, stderr, and exit code have been saved. Inspect them. - - IMPLEMENTS THEN output matches (.+) - cat "$DATADIR/stdout" - grep "$MATCH_1" "$DATADIR/stdout" - -## Manage a remote temporary directory - -Whenever we need to do anything that takes more than one step, we'll -need a temporary directory in which to work. This is similar to the -`DATADIR` that yarn provides us on the local machine. - - IMPLEMENTS GIVEN a remote temporary directory to use - . "$DATADIR/config.sh" - name="$(ssh "$ACCOUNT@$SERVER" mktemp -d)" - echo "REMOTETMP=$name" >> "$DATADIR/config.sh" - - IMPLEMENTS FINALLY remove remote temporary directory - # FIXME: The following will fail if REMOTETMP contains shell's - # magic characters or whitespace. Ugh. - . "$DATADIR/config.sh" - ssh "$ACCOUNT@$SERVER" rm -rf "$REMOTETMP" - -## Create remote directory - - IMPLEMENTS GIVEN a directory (\S+) on the server - . "$DATADIR/config.sh" - run_remotely "$ACCOUNT@$SERVER" "$REMOTETMP" "mkdir $MATCH_1" - -## Check for files on the remote end - - IMPLEMENTS THEN remote files (\S+) exist - . "$DATADIR/config.sh" - run_remotely "$ACCOUNT@$SERVER" "$REMOTETMP" "ls -d $MATCH_1" | - grep . - -## Run a command on the server - - IMPLEMENTS WHEN server runs (.+) - . "$DATADIR/config.sh" - run_remotely "$ACCOUNT@$SERVER" "$REMOTETMP" "$MATCH_1" |