summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/data/app-a/root/bin/app-a4
-rwxr-xr-xtest/it-install-remove.bats24
-rw-r--r--test/utils.bash28
3 files changed, 47 insertions, 9 deletions
diff --git a/test/data/app-a/root/bin/app-a b/test/data/app-a/root/bin/app-a
index 7d251a0..1386f31 100644
--- a/test/data/app-a/root/bin/app-a
+++ b/test/data/app-a/root/bin/app-a
@@ -2,8 +2,12 @@
me=`basename $0`
+echo "Starting" >> $me.log
+
for i in {1..10}
do
echo "#$i: `date`" >> $me.log
sleep 1
done
+
+echo "Exiting" >> $me.log
diff --git a/test/it-install-remove.bats b/test/it-install-remove.bats
index 98a79c9..3358118 100755
--- a/test/it-install-remove.bats
+++ b/test/it-install-remove.bats
@@ -5,18 +5,28 @@ load utils
@test "install remove roundtrip" {
mkzip "app-a"
- a="-n app-a -i prod"
+ name="app-a"
+ instance="prod"
+ a="-n $name -i $instance"
+
+ describe "Installing $name/$instance"
app instance install \
-r file \
-u $BATS_TEST_DIRNAME/data/app-a.zip \
- $a
+ -n $name -i $instance
+
+# set -x
+ can_not_read ".app/var/pid/$name-$instance.pid"
- [ ! -r .app/var/pid/$name-$instance.pid ]
- app $a operate start; echo_lines
- [ -r .app/var/pid/$name-$instance.pid ]
+ describe "Starting $name/$instance"
+ app -n $name -i $instance operate start
+ echo_lines
+ can_read .app/var/pid/$name-$instance.pid
- app $a operate stop; echo_lines
- [ ! -r .app/var/pid/$name-$instance.pid ]
+ describe "Stopping $name/$instance"
+ app -n $name -i $instance operate stop
+ echo_lines
+ can_not_read .app/var/pid/$name-$instance.pid
# app instance install \
# -r file \
diff --git a/test/utils.bash b/test/utils.bash
index 03871f8..653aae4 100644
--- a/test/utils.bash
+++ b/test/utils.bash
@@ -30,6 +30,30 @@ mkzip() {
}
app() {
- (set -x
- run ./app "$@")
+ echo ./app $@
+ run ./app $@
+}
+
+describe() {
+ echo "# " $@ >&3
+}
+
+can_read() {
+ if [ -r "$1" ]
+ then
+ return 0
+ else
+ echo "Can't read $1"
+ return 1
+ fi
+}
+
+can_not_read() {
+ if [ ! -r "$1" ]
+ then
+ return 0
+ else
+ echo "Can read $1"
+ return 1
+ fi
}