diff --git a/docker-compose/setup-script/tests/expects/redis.sh b/docker-compose/setup-script/tests/expects/install/redis.sh similarity index 96% rename from docker-compose/setup-script/tests/expects/redis.sh rename to docker-compose/setup-script/tests/expects/install/redis.sh index 652f990068..5f87ce533a 100755 --- a/docker-compose/setup-script/tests/expects/redis.sh +++ b/docker-compose/setup-script/tests/expects/install/redis.sh @@ -4,7 +4,7 @@ set timeout 10 # Start your main script -spawn bash ../noco.sh +spawn bash ../../noco.sh # Respond to script prompts expect "Enter the IP address or domain name for the NocoDB instance (default: localhost):" diff --git a/docker-compose/setup-script/tests/expects/install/scale.sh b/docker-compose/setup-script/tests/expects/install/scale.sh new file mode 100755 index 0000000000..3d75a3b350 --- /dev/null +++ b/docker-compose/setup-script/tests/expects/install/scale.sh @@ -0,0 +1,31 @@ +#!/usr/bin/expect -f + +# Configure timeout for each expect command +set timeout 10 + +# Start your main script +spawn bash ../../noco.sh + +# Respond to script prompts +expect "Enter the IP address or domain name for the NocoDB instance (default: localhost):" +send "\r" + +expect "Show Advanced Options*" +send "Y\r" + +expect "Choose Community or Enterprise Edition*" +send "\r" + +expect "Do you want to enabled Redis for caching*" +send "Y\r" + +expect "Do you want to enabled Watchtower for automatic updates*" +send "\r" + +expect "How many instances of NocoDB do you want to run*" +send "2\r" + +expect "Do you want to start the management menu*" +send "N\r" + +expect eof diff --git a/docker-compose/setup-script/tests/expects/install/watchtower.sh b/docker-compose/setup-script/tests/expects/install/watchtower.sh new file mode 100755 index 0000000000..8fc835b93e --- /dev/null +++ b/docker-compose/setup-script/tests/expects/install/watchtower.sh @@ -0,0 +1,31 @@ +#!/usr/bin/expect -f + +# Configure timeout for each expect command +set timeout 10 + +# Start your main script +spawn bash ../../noco.sh + +# Respond to script prompts +expect "Enter the IP address or domain name for the NocoDB instance (default: localhost):" +send "\r" + +expect "Show Advanced Options*" +send "Y\r" + +expect "Choose Community or Enterprise Edition*" +send "\r" + +expect "Do you want to enabled Redis for caching*" +send "\r" + +expect "Do you want to enabled Watchtower for automatic updates*" +send "Y\r" + +expect "How many instances of NocoDB do you want to run*" +send "\r" + +expect "Do you want to start the management menu*" +send "N\r" + +expect eof diff --git a/docker-compose/setup-script/tests/redis.bats b/docker-compose/setup-script/tests/install/redis.bats similarity index 87% rename from docker-compose/setup-script/tests/redis.bats rename to docker-compose/setup-script/tests/install/redis.bats index c6a723803c..f81c81549b 100644 --- a/docker-compose/setup-script/tests/redis.bats +++ b/docker-compose/setup-script/tests/install/redis.bats @@ -7,16 +7,16 @@ WORKING_DIR="$(pwd)" setup() { cd "${WORKING_DIR}" || exit 1 - ./setup.sh + ../setup.sh } teardown() { cd "${WORKING_DIR}" || exit 1 - ./setup.sh + ../setup.sh } @test "Check Redis is enabled when specified" { - ./expects/redis.sh + ../expects/install/redis.sh cd "${NOCO_HOME}" diff --git a/docker-compose/setup-script/tests/install/scale.bats b/docker-compose/setup-script/tests/install/scale.bats new file mode 100644 index 0000000000..a4f1daea2d --- /dev/null +++ b/docker-compose/setup-script/tests/install/scale.bats @@ -0,0 +1,31 @@ +#!/usr/bin/env bats + +NOCO_HOME="${HOME}/.nocodb" +export NOCO_HOME + +WORKING_DIR="$(pwd)" + +setup() { + cd "${WORKING_DIR}" || exit 1 + ../setup.sh +} + +teardown() { + cd "${WORKING_DIR}" || exit 1 + ../setup.sh +} + +@test "Check if two instances of NoCoDB can be run" { + # Mock nproc to return 4 + nproc() { + echo 4 + } + + ../expects/install/scale.sh + + cd "${NOCO_HOME}" + + # Get scale from docker compose ps + scale=$(docker compose ps | grep nocodb | awk '{print $1}') + [ "$scale" -eq 2 ] +} diff --git a/docker-compose/setup-script/tests/install/watchtower.bats b/docker-compose/setup-script/tests/install/watchtower.bats new file mode 100644 index 0000000000..7449237b7e --- /dev/null +++ b/docker-compose/setup-script/tests/install/watchtower.bats @@ -0,0 +1,28 @@ +#!/usr/bin/env bats + +NOCO_HOME="${HOME}/.nocodb" +export NOCO_HOME + +WORKING_DIR="$(pwd)" + +setup() { + cd "${WORKING_DIR}" || exit 1 + ../setup.sh +} + +teardown() { + cd "${WORKING_DIR}" || exit 1 + ../setup.sh +} + +@test "Check WatchTower is enabled when specified" { + ../expects/install/watchtower.sh + + cd "${NOCO_HOME}" + + # Check Docker Compose file to verify WatchTower configuration + grep -q 'watchtower' docker-compose.yml + + # Verify WatchTower container is running + docker compose ps | grep -q 'watchtower' +}