From f179ecf3257cf199855fc77123e1de6ee8ff66e0 Mon Sep 17 00:00:00 2001 From: Rohit T P Date: Thu, 2 May 2024 12:54:27 +0000 Subject: [PATCH] test: test for restart and upgrade --- .../setup-script/tests/configure/restart.bats | 27 +++++++++++++++++++ .../setup-script/tests/configure/upgrade.bats | 27 +++++++++++++++++++ .../tests/expects/configure/restart.sh | 18 +++++++++++++ .../tests/expects/configure/upgrade.sh | 18 +++++++++++++ 4 files changed, 90 insertions(+) create mode 100755 docker-compose/setup-script/tests/configure/restart.bats create mode 100755 docker-compose/setup-script/tests/configure/upgrade.bats create mode 100755 docker-compose/setup-script/tests/expects/configure/restart.sh create mode 100755 docker-compose/setup-script/tests/expects/configure/upgrade.sh diff --git a/docker-compose/setup-script/tests/configure/restart.bats b/docker-compose/setup-script/tests/configure/restart.bats new file mode 100755 index 0000000000..b2c2d53777 --- /dev/null +++ b/docker-compose/setup-script/tests/configure/restart.bats @@ -0,0 +1,27 @@ +#!/usr/bin/env bats + +NOCO_HOME="${HOME}/.nocodb" +export NOCO_HOME + +WORKING_DIR="$(pwd)" + +setup() { + cd "${WORKING_DIR}" || exit 1 + ./setup.sh "setup" +} + +teardown() { + cd "${WORKING_DIR}" || exit 1 + ./setup.sh +} + +@test "Check Redis, WatchTower and NocoDB are restarted" { + ../expects/configure/restart.sh + + cd "${NOCO_HOME}" || exit 1 + + # Verify container is running + docker compose ps | grep -q 'redis' + docker compose ps | grep -q 'watchtower' + docker compose ps | grep -q 'nocodb' +} diff --git a/docker-compose/setup-script/tests/configure/upgrade.bats b/docker-compose/setup-script/tests/configure/upgrade.bats new file mode 100755 index 0000000000..10b04b3dfb --- /dev/null +++ b/docker-compose/setup-script/tests/configure/upgrade.bats @@ -0,0 +1,27 @@ +#!/usr/bin/env bats + +NOCO_HOME="${HOME}/.nocodb" +export NOCO_HOME + +WORKING_DIR="$(pwd)" + +setup() { + cd "${WORKING_DIR}" || exit 1 + ./setup.sh "setup" +} + +teardown() { + cd "${WORKING_DIR}" || exit 1 + ./setup.sh +} + +@test "Check Redis, WatchTower and NocoDB are upgraded" { + ../expects/configure/upgrade.sh + + cd "${NOCO_HOME}" || exit 1 + + # Verify container is running + docker compose ps | grep -q 'redis' + docker compose ps | grep -q 'watchtower' + docker compose ps | grep -q 'nocodb' +} diff --git a/docker-compose/setup-script/tests/expects/configure/restart.sh b/docker-compose/setup-script/tests/expects/configure/restart.sh new file mode 100755 index 0000000000..22c358bc59 --- /dev/null +++ b/docker-compose/setup-script/tests/expects/configure/restart.sh @@ -0,0 +1,18 @@ +#!/usr/bin/expect -f + +# Configure timeout for each expect command +set timeout 10 + +# Start your main script +spawn bash ../../noco.sh + +expect "Do you want to reinstall NocoDB*" +send "N\r" + +expect "Enter your choice: " +send "4\r" + +expect "Enter your choice: " +send "0\r" + +expect EOF \ No newline at end of file diff --git a/docker-compose/setup-script/tests/expects/configure/upgrade.sh b/docker-compose/setup-script/tests/expects/configure/upgrade.sh new file mode 100755 index 0000000000..d45ccda9f1 --- /dev/null +++ b/docker-compose/setup-script/tests/expects/configure/upgrade.sh @@ -0,0 +1,18 @@ +#!/usr/bin/expect -f + +# Configure timeout for each expect command +set timeout 10 + +# Start your main script +spawn bash ../../noco.sh + +expect "Do you want to reinstall NocoDB*" +send "N\r" + +expect "Enter your choice: " +send "5\r" + +expect "Enter your choice: " +send "0\r" + +expect EOF \ No newline at end of file