summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-02-14 14:52:02 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-02-14 14:52:02 +0000
commitff853d19a8a3c184eddee80acbe5c8d3db036470 (patch)
tree6550b0749f8616f3ff628cffbd69f830f285e631
parentf6b0ea89c7c1f6ab01709b6f7861ebf3bbc339e5 (diff)
downloadtbdiff-ff853d19a8a3c184eddee80acbe5c8d3db036470.tar.gz
Tests for baserock-system-config-sync
-rw-r--r--baserock-system-config-sync/files/basefile0
-rw-r--r--baserock-system-config-sync/files/new-basefile0
-rw-r--r--baserock-system-config-sync/files/userfile0
-rw-r--r--baserock-system-config-sync/test.yarn121
4 files changed, 121 insertions, 0 deletions
diff --git a/baserock-system-config-sync/files/basefile b/baserock-system-config-sync/files/basefile
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/baserock-system-config-sync/files/basefile
diff --git a/baserock-system-config-sync/files/new-basefile b/baserock-system-config-sync/files/new-basefile
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/baserock-system-config-sync/files/new-basefile
diff --git a/baserock-system-config-sync/files/userfile b/baserock-system-config-sync/files/userfile
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/baserock-system-config-sync/files/userfile
diff --git a/baserock-system-config-sync/test.yarn b/baserock-system-config-sync/test.yarn
new file mode 100644
index 0000000..09c20c3
--- /dev/null
+++ b/baserock-system-config-sync/test.yarn
@@ -0,0 +1,121 @@
+
+
+ # Reference table for merging a regular file
+ #
+ # V1 Vuser V2 action
+ # ------------------------------------------
+1 # none none none inconceivable!
+2 # exists none none use V1
+3 # none exists none use Vuser
+4 # none none exists use V2
+5 # exists none exists use V2
+6 # exists exists none use Vuser
+7 # none exists exists diff V2 Vuser applied to V2
+8 # exists exists exists diff V1 Vuser applied to V2
+
+
+
+1 No needed implementation
+
+2
+ SCENARIO The old version has a file and the new hasn't
+ GIVEN a version called foo
+ AND a version called new-foo
+ AND a basefile in the orignial version foo
+ AND the version foo is the default
+ THEN bscs merge the version new-foo
+ AND version new-foo has the file basefile
+
+3
+
+ SCENARIO The old version has a file created by the user
+ GIVEN a version called foo
+ AND a version called new-foo
+ AND a userfile in the running version foo
+ AND the version foo is the default
+ THEN bscs merge the version new-foo
+ AND version new-foo has the file userfile
+
+4
+
+ SCENARIO The new version adds a file
+ GIVEN a version called foo
+ AND a version called new-foo
+ AND a new-basefile in the running version foo-new
+ AND the version foo is the default
+ THEN bscs merge the version new-foo
+ AND version new-foo has the file new-basefile
+
+5
+
+ SCENARIO The new version changes a file which was removed by the user
+ GIVEN a version called foo
+ AND a version called new-foo
+ AND a basefile in the original version foo
+ AND a new-basefile in the running version new-foo
+ AND the version foo is the default
+ THEN bscs merge the version new-foo
+ AND version new-foo has the file new-basefile
+
+
+6
+
+ SCENARIO The old version has a file and the user has modified it
+ GIVEN a version called foo
+ AND a version called new-foo
+ AND a basefile in the original version foo
+ AND a userfile in the running version foo
+ AND the version foo is the default
+ THEN bscs merge the version new-foo
+ AND version new-foo has the file userfile
+
+
+7 patch applies
+7 patch doesn't applies
+
+8 patch applies
+8 patch doesn't applies
+$
+
+
+ IMPLEMENTS GIVEN a version called (\S+)
+ tmpdir=$(mktemp -d)
+ mount_disk="$(findmnt / -n -l -o SOURCE | cut -f 1 | cut -d [ -f 1)"
+ mount $mount_disk $tmpdir
+ rm -r $tmpdir/systems/$MATCH_1
+ mkdir $tmpdir/systems/$MATCH_1
+ mkdir -p $tmpdir/systems/$MATCH_1/orig/etc
+ mkdir -p $tmpdir/systems/$MATCH_1/run/etc
+ umount $tmpdir
+ rm -r $tmpdir
+
+ IMPLEMENTS GIVEN a (basefile|userfile|new-basefile) in the (original|running) version (\S+)
+ tmpdir=$(mktemp -d)
+ mount_disk="$(findmnt / -n -l -o SOURCE | cut -f 1 | cut -d [ -f 1)"
+ mount $mount_disk $tmpdir
+ case $MATCH_2 in
+ 'original') version="orig"
+ ;;
+ 'running') version="run"
+ ;;
+ esac
+ algo=`pwd`
+ cp files/$MATCH_1 $tmpdir/systems/$MATCH_3/$version/etc/config.conf
+ umount $tmpdir
+ rm -r $tmpdir
+
+ IMPLEMENTS GIVEN the version (\S+) is the default
+ snapshot-mgr set-default $MATCH_1
+
+ IMPLEMENTS THEN bscs merge the version (\S+)
+ baserock-system-config-sync merge $MATCH_1
+
+ IMPLEMENTS THEN version (\S+) has the file (\S+)
+ set -e
+ tmpdir=$(mktemp -d)
+ mount_disk="$(findmnt / -n -l -o SOURCE | cut -f 1 | cut -d [ -f 1)"
+ mount $mount_disk $tmpdir
+ diff files/$MATCH_2 $tmpdir/systems/$MATCH_1/run/etc/config.conf
+ umount $tmpdir
+ rm -r $tmpdir
+