summaryrefslogtreecommitdiff
path: root/yarns/900-implements.yarn
blob: 2ffee047cdbba0f65a1e7c007e3341f605937c3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# 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"

## 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 "$SERVER" hostname | grep -Fx "$SERVER"

## 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

## 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"