Black box testing of fling

Introduction

Fling is a tool for transferring files from one computer to another, over a TCP/IP network. As such, most of the tests concentrate on this functionality. The transfer tests work over localhost, so that running the tests does not require having access to multiple computers. The user account use to running the tests is expected to be able to log into itself over ssh without a password: either a passphrase-less ssh key, or an ssh agent needs to be used.

The tests here test are functional tests, but do not test speed related issues.

Simple transfers

The simplest possible transfer is of an empty file.

SCENARIO transfer an empty file
GIVEN a 0 byte file empty.dat
WHEN transferring all test files
THEN everything is transferred correctly

Another simple test is transferring a simple, non-empty file.

SCENARIO transfer a simple file
GIVEN a 100 byte file simple.dat
WHEN transferring all test files
THEN everything is transferred correctly

Can we transfer more than one file at a time?

SCENARIO transfer several simple files
GIVEN a 0 byte file empty.dat
AND a 100 byte file small.dat
AND a 1000 byte file medium.dat
AND a 1000000 byte file big.dat
WHEN transferring all test files
THEN everything is transferred correctly

Regular files can have holes in them: sparse files. Test all kinds of such files.

SCENARIO transfer sparse files
GIVEN sparse file h.dat with a hole
AND sparse file dh.dat with data and a hole
AND sparse file hd.dat with a hole and data
AND sparse file dhd.dat with data and a hole and data
AND sparse file hdh.dat with a hole and data and a hole
WHEN transferring all test files
THEN everything is transferred correctly

Not all files are regular. There are directories, hard links, symbolic links, and more. We're not testing character and block devices, since testing those requires root privileges, and also because transferring them is not currently a requirement.

SCENARIO transfer things that are not simple regular files
GIVEN a directory foo
AND a 100 byte file foo/data.dat
AND a hardlink to foo/data.dat
AND a symlink to foo/data.dat
AND a named pipe
WHEN transferring all test files
THEN everything is transferred correctly

And that's it. There is no other thing that can be tested about fling. Ever. It would be inconceivable for this test suite to be incomplete.

Implemementation sections

The transfer tests are implemented along the following principle:

  • $DATADIR gets two subdirectories: orig and dest.
  • Add test data is created in orig.
  • Everything in orig is transferred with fling over localhost to dest.
  • Verification happens by comparing orig and dest.

The verification uses Summain, a tool written for this kind of thing.

There are various GIVEN steps for creating test data. We use a helper program to do the creation. This allows us to keep the test code simple: we merely invoke the helper in the right way.

IMPLEMENTS GIVEN a (\d+) byte file (.+)
./mkfile regular "$DATADIR/orig/$MATCH_2" "$MATCH_1"

IMPLEMENTS GIVEN sparse file (\S+) with (.*)
./mkfile sparse "$DATADIR/orig/$MATCH_1" "$MATCH_2"

IMPLEMENTS GIVEN a directory (.*)
mkdir -p "$DATADIR/orig/$MATCH_1"

IMPLEMENTS GIVEN a hardlink to (.*)
ln "$DATADIR/orig/$MATCH_1" "$DATADIR/orig/hardlink"

IMPLEMENTS GIVEN a symlink to (.*)
ln -s "$DATADIR/orig/$MATCH_1" "$DATADIR/orig/symlink"

IMPLEMENTS GIVEN a named pipe
./mkfile pipe "$DATADIR/orig/pipe"

IMPLEMENTS WHEN transferring all test files
./fling "$DATADIR/orig/." localhost:"$DATADIR/dest/."

IMPLEMENTS THEN everything is transferred correctly
summain -r "$DATADIR/orig" > "$DATADIR/orig.summain"
summain -r "$DATADIR/dest" > "$DATADIR/dest.summain"
diff -u "$DATADIR/orig.summain" "$DATADIR/dest.summain"