summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2014-05-23 16:28:21 +0000
committerAdam Coldrick <adam.coldrick@codethink.co.uk>2014-06-11 12:49:25 +0000
commita927ab8a22c5bf9c7365868cccba6737540bc522 (patch)
tree77dbc93e26068a29c8fdfa19ff52aead9a675614
parent126d9ab69c12edec9509cb25bcc5e4b7c2e98f1f (diff)
downloadmorph-a927ab8a22c5bf9c7365868cccba6737540bc522.tar.gz
Add yarn tests for new deployment functionalitybaserock/adamcoldrick/deploy-specific-systems-v4
-rwxr-xr-xscripts/edit-morph2
-rw-r--r--yarns/deployment.yarn188
-rw-r--r--yarns/implementations.yarn13
3 files changed, 202 insertions, 1 deletions
diff --git a/scripts/edit-morph b/scripts/edit-morph
index 465a3ea3..2b81747c 100755
--- a/scripts/edit-morph
+++ b/scripts/edit-morph
@@ -209,7 +209,7 @@ class EditMorph(cliapp.Application):
d = yaml.load(f)
yield d
with open(path, 'w') as f:
- yaml.dump(d, f)
+ yaml.dump(d, f, default_flow_style=False)
def cmd_set_system_artifact_depends(self, args):
'''Change the artifacts used by a System.
diff --git a/yarns/deployment.yarn b/yarns/deployment.yarn
index 67aecce2..695dcf7e 100644
--- a/yarns/deployment.yarn
+++ b/yarns/deployment.yarn
@@ -185,3 +185,191 @@ will mention the initramfs, and the UUID of the disk.
AND file mnt/extlinux.conf matches initramfs
AND file mnt/extlinux.conf matches root=UUID=
FINALLY mnt is unmounted
+
+Partial deployments
+===================
+
+Deploy part of a cluster
+------------------------
+
+We may not always want to deploy every system in a cluster, for example
+if we only want to deploy a distbuild controller but we have a cluster
+for a full network.
+
+ SCENARIO partially deploying a cluster morphology
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called master
+ GIVEN a cluster called test-cluster in system branch master
+ AND a system in cluster test-cluster in branch master called test-system
+ AND system test-system in cluster test-cluster in branch master builds test-system
+ AND system test-system in cluster test-cluster in branch master has deployment type: tar
+ AND system test-system in cluster test-cluster in branch master has deployment location: test-system.tar
+
+We now want to add a second system to the cluster, so we can choose
+which one to deploy.
+
+ GIVEN a system in cluster test-cluster in branch master called second-system
+ AND system second-system in cluster test-cluster in branch master builds test-system
+ AND system second-system in cluster test-cluster in branch master has deployment type: tar
+ AND system second-system in cluster test-cluster in branch master has deployment location: second-system.tar
+
+ WHEN the user builds the system test-system in branch master
+ AND the user attempts to deploy the following systems from cluster test-cluster in branch master: test-system
+ THEN morph succeeded
+
+Morph succeeding alone does not satisfy the requirements of this test.
+It may have deployed both systems, or the wrong system, so we need to
+make sure only the correct tarball exists.
+
+ THEN file workspace/master/test/morphs/test-system.tar exists
+ AND file workspace/master/test/morphs/second-system.tar does not exist
+
+Deploy all of a multi-system cluster
+------------------------------------
+
+We should also test that not specifying a system deploys both systems.
+
+ SCENARIO deploying a cluster morphology that contains multiple systems
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called master
+ GIVEN a cluster called test-cluster in system branch master
+ AND a system in cluster test-cluster in branch master called test-system
+ AND system test-system in cluster test-cluster in branch master builds test-system
+ AND system test-system in cluster test-cluster in branch master has deployment type: tar
+ AND system test-system in cluster test-cluster in branch master has deployment location: test-system.tar
+
+We now want to add a second system deployment to the cluster, so we can
+check that deployment of clusters with multiple systems actually deploys
+multiple systems.
+
+ GIVEN a system in cluster test-cluster in branch master called second-system
+ AND system second-system in cluster test-cluster in branch master builds test-system
+ AND system second-system in cluster test-cluster in branch master has deployment type: tar
+ AND system second-system in cluster test-cluster in branch master has deployment location: second-system.tar
+
+ WHEN the user builds the system test-system in branch master
+ AND the user attempts to deploy the cluster test-cluster in branch master
+ THEN morph succeeded
+
+We should also check that both systems were deployed as expected.
+
+ THEN file workspace/master/test/morphs/test-system.tar exists
+ AND file workspace/master/test/morphs/second-system.tar exists
+
+Deploy part of a cluster that contains a nested deployment
+----------------------------------------------------------
+
+Cluster morphs can contain "nested systems", i.e. systems which have
+subsystems to deploy as part of them. We should test that partial
+deployment works as expected here.
+
+ SCENARIO partially deploying a cluster morphology containing a nested deployment
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called master
+ GIVEN a cluster called test-cluster in system branch master
+ AND a system in cluster test-cluster in branch master called test-system
+ AND system test-system in cluster test-cluster in branch master builds test-system
+ AND system test-system in cluster test-cluster in branch master has deployment type: tar
+ AND system test-system in cluster test-cluster in branch master has deployment location: test-system.tar
+
+After the usual setup, we also add a subsystem to the cluster.
+
+ GIVEN a subsystem in cluster test-cluster in branch master called test-system.sysroot
+ AND subsystem test-system.sysroot in cluster test-cluster in branch master builds test-system
+ AND subsystem test-system.sysroot in cluster test-cluster in branch master has deployment type: sysroot
+
+We specify the location as a file path, this is relative to the parent
+system's extracted rootfs, before it is configured.
+
+ AND subsystem test-system.sysroot in cluster test-cluster in branch master has deployment location: var/lib/sysroots/test-system
+
+We now want to add a second system to the cluster, so we can choose
+which one to deploy.
+
+ GIVEN a system in cluster test-cluster in branch master called second-system
+ AND system second-system in cluster test-cluster in branch master builds test-system
+ AND system second-system in cluster test-cluster in branch master has deployment type: tar
+ AND system second-system in cluster test-cluster in branch master has deployment location: second-system.tar
+
+ WHEN the user builds the system test-system in branch master
+ AND the user attempts to deploy the following systems from cluster test-cluster in branch master: test-system
+ THEN morph succeeded
+
+Morph succeeding alone does not satisfy the requirements of this test.
+It may have deployed both systems, or the wrong system, so we need to
+make sure only the correct tarball exists.
+
+ THEN file workspace/master/test/morphs/test-system.tar exists
+ AND file workspace/master/test/morphs/second-system.tar does not exist
+
+Fail if attempting to deploy a system which does not exist in the cluster
+-------------------------------------------------------------------------
+
+If the user asks to deploy a non-existent deployment, then morph should
+fail. We should test that morph fails in this case, rather than treating
+the bad name as if it were a deployment option.
+
+ SCENARIO fail to deploy a non-existent system
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called master
+ GIVEN a cluster called test-cluster in system branch master
+ AND a system in cluster test-cluster in branch master called test-system
+ AND system test-system in cluster test-cluster in branch master builds test-system
+ AND system test-system in cluster test-cluster in branch master has deployment type: tar
+ AND system test-system in cluster test-cluster in branch master has deployment location: test-system.tar
+
+We now want to add a second system to the cluster, so we can choose
+which one to deploy.
+
+ GIVEN a system in cluster test-cluster in branch master called second-system
+ AND system second-system in cluster test-cluster in branch master builds test-system
+ AND system second-system in cluster test-cluster in branch master has deployment type: tar
+ AND system second-system in cluster test-cluster in branch master has deployment location: second-system.tar
+
+ WHEN the user builds the system test-system in branch master
+ AND the user attempts to deploy the following systems from cluster test-cluster in branch master: not-a-system
+ THEN morph failed
+
+Fail to deploy a subsystem
+--------------------------
+
+Cluster morphs can contain "nested systems", i.e. systems which have
+subsystems to deploy as part of them. We should test that attempting
+to deploy a subsystem results in failure.
+
+ SCENARIO fail to deploy a subsystem
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called master
+ GIVEN a cluster called test-cluster in system branch master
+ AND a system in cluster test-cluster in branch master called test-system
+ AND system test-system in cluster test-cluster in branch master builds test-system
+ AND system test-system in cluster test-cluster in branch master has deployment type: tar
+ AND system test-system in cluster test-cluster in branch master has deployment location: test-system.tar
+
+After the usual setup, we also add a subsystem to the cluster.
+
+ GIVEN a subsystem in cluster test-cluster in branch master called test-system.sysroot
+ AND subsystem test-system.sysroot in cluster test-cluster in branch master builds test-system
+ AND subsystem test-system.sysroot in cluster test-cluster in branch master has deployment type: sysroot
+
+We specify the location as a file path, this is relative to the parent
+system's extracted rootfs, before it is configured.
+
+ AND subsystem test-system.sysroot in cluster test-cluster in branch master has deployment location: var/lib/sysroots/test-system
+
+We now want to add a second system to the cluster, so we can choose
+which one to deploy.
+
+ GIVEN a system in cluster test-cluster in branch master called second-system
+ AND system second-system in cluster test-cluster in branch master builds test-system
+ AND system second-system in cluster test-cluster in branch master has deployment type: tar
+ AND system second-system in cluster test-cluster in branch master has deployment location: second-system.tar
+
+ WHEN the user builds the system test-system in branch master
+ AND the user attempts to deploy the following systems from cluster test-cluster in branch master: test-system.sysroot
+ THEN morph failed
diff --git a/yarns/implementations.yarn b/yarns/implementations.yarn
index 66d47bfd..651c0748 100644
--- a/yarns/implementations.yarn
+++ b/yarns/implementations.yarn
@@ -657,6 +657,16 @@ them, so they can be added to the end of the implements section.
if [ $MATCH_1 == "deploys" ]; then run_morph "$@"
else attempt_morph "$@"; fi
+ IMPLEMENTS WHEN the user (attempts to deploy|deploys) the following systems from cluster (\S+) in branch (\S+): (.*)
+ cd "$DATADIR/workspace/$MATCH_3"
+ set -- deploy "$MATCH_2"
+ if [ "$MATCH_4" != '' ]; then
+ # eval used so word splitting in the text is preserved
+ eval set -- '"$@"' $MATCH_4
+ fi
+ if [ $MATCH_1 == "deploys" ]; then run_morph "$@"
+ else attempt_morph "$@"; fi
+
IMPLEMENTS WHEN the user (attempts to upgrade|upgrades) the (system|cluster) (\S+) in branch (\S+)( with options (.*))?
cd "$DATADIR/workspace/$MATCH_4"
set -- deploy --upgrade "$MATCH_3"
@@ -712,6 +722,9 @@ Check attributes of a file on the filesystem
IMPLEMENTS THEN file (\S+) exists
test -e "$DATADIR/$MATCH_1"
+ IMPLEMENTS THEN file (\S+) does not exist
+ test ! -e "$DATADIR/$MATCH_1"
+
IMPLEMENTS THEN file (\S+) has permissions (\S+)
stat -c %A "$DATADIR/$MATCH_1" | grep -Fx -e "$MATCH_2"