From dd7813ca4ebcfe14429eca5a7e5530e0be349743 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Wed, 12 Sep 2012 12:29:07 +0000 Subject: Test the trove-* support. This adds a way to cause the processed configuration to be dumped out. We do this in the overridden process_args method so that the configuration dumped has had all the processing done on it which is necessary. The test then uses this functionality to ensure that the repo-alias setting has been correctly updated with the Trove-hosted prefixes. --- tests/trove-prefix.script | 99 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100755 tests/trove-prefix.script (limited to 'tests') diff --git a/tests/trove-prefix.script b/tests/trove-prefix.script new file mode 100755 index 00000000..612311f3 --- /dev/null +++ b/tests/trove-prefix.script @@ -0,0 +1,99 @@ +#!/bin/sh +# +# Verify that trove-prefix (and by corollary trove-host) work properly. +# +# Copyright (C) 2012 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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. + +set -eu + +RAWDUMP="$DATADIR/raw-configdump" +PROCESSEDDUMP="$DATADIR/processed-configdump" + +# Step 1, gather all the raw and processed repo-alias entries + +"$SRCDIR/scripts/test-morph" \ + --trove-host="TROVEHOST" \ + --trove-prefix="fudge" \ + --trove-prefix="github" \ + --dump-config > "$RAWDUMP" +env MORPH_DUMP_PROCESSED_CONFIG=1 "$SRCDIR/scripts/test-morph" \ + --trove-host="TROVEHOST" \ + --trove-prefix="fudge" \ + --trove-prefix="github" \ + > "$PROCESSEDDUMP" + +RAW_ALIAS=$(grep repo-alias "$RAWDUMP" | cut -d\ -f3-) +PROCESSED_ALIAS=$(grep repo-alias "$PROCESSEDDUMP" | cut -d\ -f3-) + +find_alias () { + ALIASES="$1" + WHICH="$2" + for alias in $ALIASES; do + alias=$(echo $alias | sed -e's/,$//') + prefix=$(echo $alias | cut -d= -f1) + if test "x$WHICH" = "x$prefix"; then + echo $alias + exit 0 + fi + done +} + +# Step 2, all raw aliases should be in processed aliases unchanged. As part of +# this, we're also validating that the 'github' prefix we pass in does not +# affect the alias output since it is overridden by repo-alias. + +for raw_alias in $RAW_ALIAS; do + raw_alias=$(echo $raw_alias | sed -e's/,$//') + raw_prefix=$(echo $raw_alias | cut -d= -f1) + processed_alias=$(find_alias "$PROCESSED_ALIAS" "$raw_prefix") + if test "x$raw_alias" != "x$processed_alias"; then + echo >&2 "Raw $raw_alias not in processed aliases" + fi +done + +# Step 3, all aliases in the processed aliases which do not come from the raw +# aliases should contain the trove host. + +for processed_alias in $PROCESSED_ALIAS; do + processed_alias=$(echo $processed_alias | sed -e's/,$//') + processed_prefix=$(echo $processed_alias | cut -d= -f1) + raw_alias=$(find_alias "$RAW_ALIAS" "$processed_prefix") + if test "x$raw_alias" = "x"; then + grep_out=$(echo "$processed_alias" | grep TROVEHOST) + if test "x$grep_out" = "x"; then + echo >&2 "Processed $processed_alias does not mention TROVEHOST" + fi + fi +done + +# Step 4, validate that the processed aliases do contain a baserock and an +# upstream alias since those are implicit in morph's behaviour. + +for prefix in baserock upstream; do + processed_alias=$(find_alias "$PROCESSED_ALIAS" "$prefix") + if test "x$processed_alias" = "x"; then + echo >&2 "Processed aliases lack $prefix prefix" + fi +done + +# Step 5, validate that the fudge prefix has been correctly expanded as though +# it were fudge=fudge#ssh#ssh + +fudge_alias=$(find_alias "$PROCESSED_ALIAS" "fudge") +desired_fudge="fudge=ssh://git@TROVEHOST/fudge/%s#ssh://git@TROVEHOST/fudge/%s" +if test "x$fudge_alias" != "x$desired_fudge"; then + echo >&2 "Fudge alias was '$fudge_alias' where we wanted '$desired_fudge'" +fi -- cgit v1.2.1