[dak/master] add a first integration test
Just to see how it works out with Jenkins.
---
integration-tests/common | 8 ++++++++
integration-tests/run-tests | 29 +++++++++++++++++++++++++++++
integration-tests/setup | 34 ++++++++++++++++++++++++++++++++++
integration-tests/tests/0001-basic | 34 ++++++++++++++++++++++++++++++++++
4 files changed, 105 insertions(+)
create mode 100644 integration-tests/common
create mode 100755 integration-tests/run-tests
create mode 100644 integration-tests/setup
create mode 100755 integration-tests/tests/0001-basic
diff --git a/integration-tests/common b/integration-tests/common
new file mode 100644
index 0000000..512ac7f
--- /dev/null
+++ b/integration-tests/common
@@ -0,0 +1,8 @@
+# -*- mode: sh -*-
+
+assert-equal() {
+ if [[ "${2}" != "${3}" ]]; then
+ echo "E: ${1} returned '${2}' (expected: '${3}')" >&2
+ exit 1
+ fi
+}
diff --git a/integration-tests/run-tests b/integration-tests/run-tests
new file mode 100755
index 0000000..9338e71
--- /dev/null
+++ b/integration-tests/run-tests
@@ -0,0 +1,29 @@
+#! /bin/bash
+
+set -e
+set -u
+
+# find-postgresql-version: () -> str
+# locate postgresql version for which both server and debversion
+# extension are installed. exits with error if no version is found.
+# returns: version, e.g. "9.6"
+find-postgresql-version() {
+ local status
+ for v in 9.6 9.4; do
+ status=$(dpkg-query \
+ -f'${db:Status-Status} ' \
+ -W postgresql-${v} postgresql-${v}-debversion 2>/dev/null || :)
+ if [ "${status}" = "installed installed " ]; then
+ echo ${v}
+ exit 0
+ fi
+ done
+ echo "No PostgreSQL version with server and debversion extension found." >&2
+ exit 1
+}
+
+pgversion=$(find-postgresql-version)
+export DAK_INTEGRATION_TEST=1
+export DAK_ROOT="$(cd $(dirname "$0")/..; pwd)"
+
+pg_virtualenv -v "${pgversion}" -t "${DAK_ROOT}/integration-tests/tests/0001-basic"
diff --git a/integration-tests/setup b/integration-tests/setup
new file mode 100644
index 0000000..8b732c9
--- /dev/null
+++ b/integration-tests/setup
@@ -0,0 +1,34 @@
+# -*- mode: sh -*-
+
+if [[ ! -v DAK_INTEGRATION_TEST || ! -v DAK_ROOT ]]; then
+ exit 1
+fi
+
+dak-setup() {
+ local setupdir="${DAK_ROOT}/setup"
+
+ export DAKBASE=$(mktemp -d)
+
+ (cd ${setupdir}; ./init_db)
+ if [[ ${PGUSER:-} != dak ]]; then
+ psql -c "GRANT dak TO ${PGUSER}"
+ fi
+ psql -f ${setupdir}/current_schema.sql -d projectb >/dev/null
+ unset PGDATABASE
+ (cd ${setupdir}; ./init_core)
+
+ export DAK_CONFIG="${DAKBASE}/etc/dak.conf"
+ mkdir ${DAKBASE}/etc
+ (cd ${setupdir}; ./init_minimal_conf) > ${DAK_CONFIG}
+
+ dak update-db --yes
+}
+
+dak-cleanup() {
+ if [[ -v DAKBASE ]]; then
+ rm -rf -- "${DAKBASE}"
+ fi
+}
+
+trap dak-cleanup EXIT
+dak-setup
diff --git a/integration-tests/tests/0001-basic b/integration-tests/tests/0001-basic
new file mode 100755
index 0000000..c34adda
--- /dev/null
+++ b/integration-tests/tests/0001-basic
@@ -0,0 +1,34 @@
+#! /bin/bash
+
+set -e
+set -u
+
+. ${DAK_ROOT:?}/integration-tests/common
+. ${DAK_ROOT:?}/integration-tests/setup
+
+# add a unstable suite with amd64
+dak admin architecture add amd64 AMD64
+dak admin suite add unstable "" codename=sid
+dak admin suite-architecture add unstable all amd64
+dak admin suite-component add unstable main contrib non-free
+
+(
+ suites="$(dak admin suite list | sort | xargs)"
+ suites_e="byhand new unstable"
+ assert-equal "dak admin suite list" "${suites}" "${suites_e}"
+)
+
+(
+ unstable_archs="$(dak admin s-a list-arch unstable | sort | xargs)"
+ assert-equal "dak admin s-a list-arch unstable" "${unstable_archs}" "amd64"
+)
+
+(
+ cs_unstable="$(dak control-suite -l unstable)"
+ assert-equal "dak control-suite -l unstable" "${cs_unstable}" ""
+)
+
+(
+ co_unstable="$(dak control-override -l unstable)"
+ assert-equal "dak control-override -l unstable" "${co_unstable}" ""
+)
--
2.1.4
Reply to: