summaryrefslogtreecommitdiff
path: root/yarns
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2015-03-19 09:34:58 +0000
committerMorph (on behalf of Adam Coldrick) <adam.coldrick@codethink.co.uk>2015-03-19 09:34:58 +0000
commit7db4ee53fb5398dd8f4ae8f56778735fe6531178 (patch)
tree01513d77326acd03b2da356ec2cd7f4761901b6b /yarns
parent211d6317d22bace089da58875d280ae5e54d5d54 (diff)
downloadmorph-7db4ee53fb5398dd8f4ae8f56778735fe6531178.tar.gz
Morph build 2ee8190abe87461992f5b7ed85fe2ee9
System branch: master
Diffstat (limited to 'yarns')
-rw-r--r--yarns/branches-workspaces.yarn18
-rw-r--r--yarns/building.yarn42
-rw-r--r--yarns/deployment.yarn46
-rw-r--r--yarns/implementations.yarn100
-rw-r--r--yarns/morph.shell-lib13
5 files changed, 159 insertions, 60 deletions
diff --git a/yarns/branches-workspaces.yarn b/yarns/branches-workspaces.yarn
index 34aa97e0..27bddff5 100644
--- a/yarns/branches-workspaces.yarn
+++ b/yarns/branches-workspaces.yarn
@@ -233,6 +233,7 @@ build branch is made to include that change.
WHEN the user makes changes to test-chunk in branch master
AND the user builds systems/test-system.morph of the master branch
THEN the changes to test-chunk in branch master are included in the temporary build branch
+ FINALLY the git server is shut down
### When branches are created ###
@@ -444,21 +445,8 @@ repositories referenced in the system branch.
THEN morph reports no outstanding changes in foo
FINALLY the git server is shut down
-`morph foreach`
---------------
-
-`morph foreach` runs a shell command in each of the git repos in a system
-branch checkout.
-
- SCENARIO morph foreach runs command in each git repo
- GIVEN a workspace
- AND a git server
- WHEN the user creates a system branch called foo
- AND the user edits the chunk test-chunk in branch foo
- AND running shell command in each repo in foo
- THEN morph ran command in test/morphs in foo
- AND morph ran command in test/test-chunk in foo
- FINALLY the git server is shut down
+Manifests
+---------
Generating a manifest works
diff --git a/yarns/building.yarn b/yarns/building.yarn
index 253b3b3c..b5e46b73 100644
--- a/yarns/building.yarn
+++ b/yarns/building.yarn
@@ -6,7 +6,35 @@ Morph Building Tests
AND a git server
WHEN the user checks out the system branch called master
AND the user creates an uncommitted system morphology called systems/base-system.morph for our architecture in system branch master
- THEN morph build the system systems/base-system.morph of the branch master
+ AND the user attempts to build the system systems/base-system.morph in branch master
+ THEN morph succeeded
+ FINALLY the git server is shut down
+
+ SCENARIO build system with relative path
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called master
+ AND the user creates an uncommitted system morphology called systems/base-system.morph for our architecture in system branch master
+ AND from the directory workspace/master/test/morphs/systems the user attempts to morph build the system base-system.morph
+ THEN morph succeeded
+ FINALLY the git server is shut down
+
+ SCENARIO build system with relative path (second variant)
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called master
+ AND the user creates an uncommitted system morphology called systems/base-system.morph for our architecture in system branch master
+ AND from the directory workspace/master/test/morphs/systems the user attempts to morph build the system ../systems/base-system.morph
+ THEN morph succeeded
+ FINALLY the git server is shut down
+
+ SCENARIO build system with absolute path
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called master
+ AND the user creates an uncommitted system morphology called systems/base-system.morph for our architecture in system branch master
+ AND from the directory workspace/master/test/morphs/systems the user attempts to morph build the system using the absolute path to base-system.morph
+ THEN morph succeeded
FINALLY the git server is shut down
System integrations
@@ -35,6 +63,7 @@ so when we deploy the system, we can check whether it exists.
WHEN the user attempts to deploy the cluster test-cluster.morph in branch master with options test-system.location="$DATADIR/test.tar"
THEN morph succeeded
AND tarball test.tar contains etc/passwd
+ FINALLY the git server is shut down
Distbuilding
------------
@@ -72,3 +101,14 @@ repos cached locally.
AND the distbuild worker is terminated
AND the communal cache server is terminated
AND the git server is shut down
+
+Empty strata don't build
+------------------------
+
+ SCENARIO empty-strata
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called empty-stratum
+ AND the user attempts to build the system systems/empty-stratum-system.morph in branch empty-stratum
+ THEN morph failed
+ FINALLY the git server is shut down
diff --git a/yarns/deployment.yarn b/yarns/deployment.yarn
index 0782c7c1..6ec8c0af 100644
--- a/yarns/deployment.yarn
+++ b/yarns/deployment.yarn
@@ -14,13 +14,35 @@ Morph Deployment Tests
GIVEN a workspace
AND a git server
WHEN the user checks out the system branch called master
- GIVEN a cluster called test-cluster.morph in system branch master
- AND a system in cluster test-cluster.morph in branch master called test-system
- AND system test-system in cluster test-cluster.morph in branch master builds systems/test-system.morph
- AND system test-system in cluster test-cluster.morph in branch master has deployment type: tar
- AND system test-system in cluster test-cluster.morph in branch master has deployment location: test.tar
- WHEN the user builds the system systems/test-system.morph in branch master
- AND the user attempts to deploy the cluster test-cluster.morph in branch master
+ AND the user builds the system systems/test-system.morph in branch master
+ AND the user attempts to deploy the cluster clusters/test-cluster.morph in branch master
+ THEN morph succeeded
+ FINALLY the git server is shut down
+
+ SCENARIO deploying a cluster using a relative path
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called master
+ AND the user builds the system systems/test-system.morph in branch master
+ AND from directory workspace/master/test/morphs/clusters the user attempts to deploy the cluster test-cluster.morph in branch master
+ THEN morph succeeded
+ FINALLY the git server is shut down
+
+ SCENARIO deploying a cluster using a relative path (second variant)
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called master
+ AND the user builds the system systems/test-system.morph in branch master
+ AND from directory workspace/master/test/morphs/clusters the user attempts to deploy the cluster ../clusters/test-cluster.morph in branch master
+ THEN morph succeeded
+ FINALLY the git server is shut down
+
+ SCENARIO deploying a cluster using an absolute path
+ GIVEN a workspace
+ AND a git server
+ WHEN the user checks out the system branch called master
+ AND the user builds the system systems/test-system.morph in branch master
+ AND from directory workspace/master/test/morphs/clusters the user attempts to deploy the cluster using the absolute path to test-cluster.morph in branch master
THEN morph succeeded
FINALLY the git server is shut down
@@ -31,13 +53,8 @@ this clear.
GIVEN a workspace
AND a git server
WHEN the user checks out the system branch called master
- GIVEN a cluster called test-cluster.morph in system branch master
- AND a system in cluster test-cluster.morph in branch master called test-system
- AND system test-system in cluster test-cluster.morph in branch master builds systems/test-system.morph
- AND system test-system in cluster test-cluster.morph in branch master has deployment type: tar
- AND system test-system in cluster test-cluster.morph in branch master has deployment location: test.tar
- WHEN the user builds the system systems/test-system.morph in branch master
- AND the user attempts to upgrade the cluster test-cluster.morph in branch master
+ AND the user builds the system systems/test-system.morph in branch master
+ AND the user attempts to upgrade the cluster clusters/test-cluster.morph in branch master
THEN morph failed
FINALLY the git server is shut down
@@ -328,3 +345,4 @@ Once it is rebuilt, it can be deployed.
WHEN the user attempts to deploy the cluster test-cluster.morph in branch mybranch
THEN morph succeeded
AND file workspace/mybranch/test/morphs/test-system.tar exists
+ FINALLY the git server is shut down
diff --git a/yarns/implementations.yarn b/yarns/implementations.yarn
index 6110148e..2bbb1f5c 100644
--- a/yarns/implementations.yarn
+++ b/yarns/implementations.yarn
@@ -34,7 +34,8 @@ we can test it later in a THEN step.
case $(cat "$DATADIR/morph-exit") in
0) echo "Morph succeeded!"
;;
- *) die "Morph should have succeeded, but didn't. Unexpected failure!"
+ *) cat "$DATADIR/result-latest" >&2
+ die "Morph should have succeeded, but didn't. Unexpected failure!"
;;
esac
@@ -246,6 +247,19 @@ another to hold a chunk.
morph: strata/core.morph
EOF
+ mkdir "$DATADIR/gits/morphs/clusters"
+ cd "$DATADIR/gits/morphs"
+ install -m644 -D /dev/stdin << EOF "clusters/test-cluster.morph"
+ name: test-cluster
+ kind: cluster
+ systems:
+ - morph: systems/test-system.morph
+ deploy:
+ test-system:
+ type: tar
+ location: test.tar
+ EOF
+
install -m644 -D /dev/stdin << EOF "strata/build-essential.morph"
name: build-essential
kind: stratum
@@ -322,6 +336,32 @@ another to hold a chunk.
git commit -m Initial.
git tag -a "test-tag" -m "Tagging test-tag"
+ # A new branch is created here as the presence of an empty stratum will
+ # break any morph commands which load all definitions in the repository.
+ git checkout -b empty-stratum
+
+ install -m644 -D /dev/stdin << EOF "systems/empty-stratum-system.morph"
+ name: empty-stratum-system
+ kind: system
+ arch: $arch
+ strata:
+ - name: build-essential
+ morph: strata/build-essential.morph
+ - name: core
+ morph: strata/core.morph
+ - name: empty
+ morph: strata/empty.morph
+ EOF
+
+ install -m644 -D /dev/stdin << EOF "strata/empty.morph"
+ name: empty
+ kind: stratum
+ EOF
+
+ git add .
+ git commit -m 'Add an empty stratum'
+ git checkout master
+
# Start a git daemon to serve our git repositories
port_file="$DATADIR/git-daemon-port"
pid_file="$DATADIR/git-daemon-pid"
@@ -584,16 +624,6 @@ Reporting status of checked out repositories:
cd "$DATADIR/workspace/$MATCH_2/$(slashify_colons "$MATCH_1")"
git commit -a -m test-commit
-Running shell command in each checked out repository:
-
- IMPLEMENTS WHEN running shell command in each repo in (\S+)
- cd "$DATADIR/workspace/$MATCH_1"
- run_morph foreach -- pwd > "$DATADIR/morph.stdout"
-
- IMPLEMENTS THEN morph ran command in (\S+) in (\S+)
- grep -Fx "$MATCH_1" "$DATADIR/morph.stdout"
- grep -Fx "$DATADIR/workspace/$MATCH_2/$MATCH_1" "$DATADIR/morph.stdout"
-
Generating a manifest.
IMPLEMENTS GIVEN a system artifact
@@ -702,7 +732,7 @@ Implementation sections for building
====================================
IMPLEMENTS WHEN the user (attempts to )?((dist)?build)s? the system (\S+) in branch (\S+)
- cd "$DATADIR/workspace/$MATCH_5"
+ cd "$DATADIR/workspace/$MATCH_5/test/morphs"
set "$MATCH_2" "$MATCH_4"
if [ "$MATCH_1" != "attempts to " ]; then run_morph "$@"
else attempt_morph "$@"; fi
@@ -711,7 +741,7 @@ Implementation sections for cross-bootstraping
==============================================
IMPLEMENTS THEN the user cross-bootstraps the system (\S+) in branch (\S+) of repo (\S+) to the arch (\S+)
- cd "$DATADIR/workspace/$MATCH_2"
+ cd "$DATADIR/workspace/$MATCH_2/test/morphs"
set -- cross-bootstrap "$MATCH_4" "$MATCH_3" "$MATCH_2" "$MATCH_1"
run_morph "$@"
@@ -722,32 +752,44 @@ Defaults are set in the cluster morphology, so we can deploy without
setting any extra parameters, but we also need to be able to override
them, so they can be added to the end of the implements section.
- IMPLEMENTS WHEN the user (attempts to deploy|deploys) the (system|cluster) (\S+) in branch (\S+)( with options (.*))?
- cd "$DATADIR/workspace/$MATCH_4"
- set -- deploy "$MATCH_3"
- if [ "$MATCH_5" != '' ]; then
+ IMPLEMENTS WHEN (from directory (\S+) )?the user (attempts to deploy|deploys) the (system|cluster) (using the absolute path to )?(\S+) in branch (\S+)( with options (.*))?
+ if [ "$MATCH_1" != "" ]
+ then
+ cd "$DATADIR/$MATCH_2"
+ else
+ cd "$DATADIR/workspace/$MATCH_7/test/morphs"
+ fi
+
+ if [ "$MATCH_5" != "" ]
+ then
+ set -- deploy "$(pwd)/$MATCH_6"
+ else
+ set -- deploy "$MATCH_6"
+ fi
+
+ if [ "$MATCH_8" != '' ]; then
# eval used so word splitting in the text is preserved
- eval set -- '"$@"' $MATCH_6
+ eval set -- '"$@"' $MATCH_9
fi
- if [ $MATCH_1 == "deploys" ]; then run_morph "$@"
+ if [ "$MATCH_3" = "deploys" ]; then run_morph "$@"
else attempt_morph "$@"; fi
IMPLEMENTS WHEN the user (attempts to deploy|deploys) (.*) from cluster (\S+) in branch (\S+)
- cd "$DATADIR/workspace/$MATCH_4"
+ cd "$DATADIR/workspace/$MATCH_4/test/morphs"
set -- deploy "$MATCH_3"
systems=$(echo "$MATCH_2" | sed -e 's/, /\n/g' -e 's/ and /\n/g')
set -- "$@" $systems
- if [ $MATCH_1 == "deploys" ]; then run_morph "$@"
+ 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"
+ cd "$DATADIR/workspace/$MATCH_4/test/morphs"
set -- upgrade "$MATCH_3"
if [ "$MATCH_5" != '' ]; then
# eval used so word splitting in the text is preserved
eval set -- '"$@"' $MATCH_6
fi
- if [ $MATCH_1 == "upgrades" ]; then run_morph "$@"
+ if [ "$MATCH_1" = "upgrades" ]; then run_morph "$@"
else attempt_morph "$@"; fi
Implementations sections for reading error messages
@@ -891,13 +933,21 @@ Implementations for building systems
------------------------------------
IMPLEMENTS THEN morph ((dist)?build) the system (\S+) of the (branch|tag) (\S+)
- cd "$DATADIR/workspace/$MATCH_5"
+ cd "$DATADIR/workspace/$MATCH_5/test/morphs"
run_morph "$MATCH_1" "$MATCH_3"
IMPLEMENTS WHEN the user builds (\S+) of the (\S+) (branch|tag)
- cd "$DATADIR/workspace/$MATCH_2"
+ cd "$DATADIR/workspace/$MATCH_2/test/morphs"
run_morph build "$MATCH_1"
+ IMPLEMENTS WHEN from the directory (\S+) the user attempts to morph build the system (\S+)
+ cd "$DATADIR/$MATCH_1"
+ attempt_morph build "$MATCH_2"
+
+ IMPLEMENTS WHEN from the directory (\S+) the user attempts to morph build the system using the absolute path to (\S+)
+ cd "$DATADIR/$MATCH_1"
+ attempt_morph build "$(pwd)/$MATCH_2"
+
Implementations for tarball inspection
--------------------------------------
diff --git a/yarns/morph.shell-lib b/yarns/morph.shell-lib
index 9c13e449..e7011091 100644
--- a/yarns/morph.shell-lib
+++ b/yarns/morph.shell-lib
@@ -3,7 +3,7 @@
# The shell functions in this library are meant to make writing IMPLEMENTS
# sections for yarn scenario tests easier.
-# Copyright (C) 2013-2014 Codethink Limited
+# Copyright (C) 2013-2015 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -15,8 +15,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# with this program. If not, see <http://www.gnu.org/licenses/>.
# Add $SRCDIR to PYTHONPATH.
@@ -39,9 +38,13 @@ run_morph()
set +e
"$SRCDIR"/morph --verbose \
--cachedir-min-space=0 --tempdir-min-space=0 \
- --no-default-config --config "$DATADIR/morph.conf" "$@" \
- 2> "$DATADIR/result-$1" > "$DATADIR/out-$1"
+ --no-default-config --config "$DATADIR/morph.conf" \
+ --log="$DATADIR/log-$1" \
+ "$@" 2> "$DATADIR/result-$1" > "$DATADIR/out-$1"
local exit_code="$?"
+ for o in log result out; do
+ ln -sf "$o-$1" "$DATADIR/$o-latest"
+ done
cat "$DATADIR/out-$1"
cat "$DATADIR/result-$1" >&2
return "$exit_code"