From dd8a16f9d6dac30ccf379260aec4b4c1d2ba70d9 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Thu, 11 Apr 2024 21:10:59 +0200 Subject: [PATCH 1/2] improving end-to-end tests Signed-off-by: Matthieu Gallien --- .drone.yml | 32 +++++++++++++++++++++----------- admin/test/wait_for_server.sh | 25 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 11 deletions(-) create mode 100755 admin/test/wait_for_server.sh diff --git a/.drone.yml b/.drone.yml index 4a76132e95f59..1c5e4f57c78ce 100644 --- a/.drone.yml +++ b/.drone.yml @@ -28,19 +28,21 @@ steps: path: /drone/build commands: - cd /drone/build + - ../src/admin/test/wait_for_server.sh "server" - useradd -m -s /bin/bash test - chown -R test:test . - su -c 'ASAN_OPTIONS=detect_odr_violation=0,detect_leaks=0 xvfb-run ctest --output-on-failure' test services: - name: server - image: ghcr.io/nextcloud/continuous-integration-server:latest # also change in updateScreenshots.sh + image: ghcr.io/nextcloud/continuous-integration-shallow-server:latest # also change in updateScreenshots.sh environment: EVAL: true - SERVER_VERSION: 'stable24' + SERVER_VERSION: 'stable28' commands: - BRANCH="$SERVER_VERSION" /usr/local/bin/initnc.sh - echo 127.0.0.1 server >> /etc/hosts + - apt-get update && apt-get install -y composer - su www-data -c "OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1" - su www-data -c "OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2" - su www-data -c "OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3" @@ -48,12 +50,15 @@ services: - su www-data -c "php /var/www/html/occ group:add users" - su www-data -c "php /var/www/html/occ group:adduser users user1" - su www-data -c "php /var/www/html/occ group:adduser users user2" - - su www-data -c "git clone --depth=1 -b $SERVER_VERSION https://github.com/nextcloud/activity.git /var/www/html/apps/activity/" + - su www-data -c "git clone -b $SERVER_VERSION https://github.com/nextcloud/activity.git /var/www/html/apps/activity/" - su www-data -c "php /var/www/html/occ app:enable activity" - - su www-data -c "git clone --depth=1 -b $SERVER_VERSION https://github.com/nextcloud/text.git /var/www/html/apps/text/" + - su www-data -c "git clone -b $SERVER_VERSION https://github.com/nextcloud/text.git /var/www/html/apps/text/" - su www-data -c "php /var/www/html/occ app:enable text" - - su www-data -c "git clone --depth=1 -b $SERVER_VERSION https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption/" + - su www-data -c "git clone -b $SERVER_VERSION https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption/" - su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption" + - su www-data -c "git clone -b $SERVER_VERSION https://github.com/nextcloud/photos.git /var/www/html/apps/photos/" + - su www-data -c "cd /var/www/html/apps/photos; composer install" + - su www-data -c "php /var/www/html/occ app:enable -f photos" - /usr/local/bin/run.sh volumes: @@ -96,19 +101,21 @@ steps: path: /drone/build commands: - cd /drone/build + - ../src/admin/test/wait_for_server.sh "server" - useradd -m -s /bin/bash test - chown -R test:test . - su -c 'ASAN_OPTIONS=detect_odr_violation=0,detect_leaks=0 xvfb-run ctest --output-on-failure' test services: - name: server - image: ghcr.io/nextcloud/continuous-integration-server:latest # also change in updateScreenshots.sh + image: ghcr.io/nextcloud/continuous-integration-shallow-server:latest # also change in updateScreenshots.sh environment: EVAL: true - SERVER_VERSION: 'stable24' + SERVER_VERSION: 'stable28' commands: - BRANCH="$SERVER_VERSION" /usr/local/bin/initnc.sh - echo 127.0.0.1 server >> /etc/hosts + - apt-get update && apt-get install -y composer - su www-data -c "OC_PASS=user1 php /var/www/html/occ user:add --password-from-env --display-name='User One' user1" - su www-data -c "OC_PASS=user2 php /var/www/html/occ user:add --password-from-env --display-name='User Two' user2" - su www-data -c "OC_PASS=user3 php /var/www/html/occ user:add --password-from-env --display-name='User Three' user3" @@ -116,12 +123,15 @@ services: - su www-data -c "php /var/www/html/occ group:add users" - su www-data -c "php /var/www/html/occ group:adduser users user1" - su www-data -c "php /var/www/html/occ group:adduser users user2" - - su www-data -c "git clone --depth=1 -b $SERVER_VERSION https://github.com/nextcloud/activity.git /var/www/html/apps/activity/" + - su www-data -c "git clone -b $SERVER_VERSION https://github.com/nextcloud/activity.git /var/www/html/apps/activity/" - su www-data -c "php /var/www/html/occ app:enable activity" - - su www-data -c "git clone --depth=1 -b $SERVER_VERSION https://github.com/nextcloud/text.git /var/www/html/apps/text/" + - su www-data -c "git clone -b $SERVER_VERSION https://github.com/nextcloud/text.git /var/www/html/apps/text/" - su www-data -c "php /var/www/html/occ app:enable text" - - su www-data -c "git clone --depth=1 -b $SERVER_VERSION https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption/" + - su www-data -c "git clone -b $SERVER_VERSION https://github.com/nextcloud/end_to_end_encryption.git /var/www/html/apps/end_to_end_encryption/" - su www-data -c "php /var/www/html/occ app:enable end_to_end_encryption" + - su www-data -c "git clone -b $SERVER_VERSION https://github.com/nextcloud/photos.git /var/www/html/apps/photos/" + - su www-data -c "cd /var/www/html/apps/photos; composer install" + - su www-data -c "php /var/www/html/occ app:enable -f photos" - /usr/local/bin/run.sh volumes: @@ -196,6 +206,6 @@ trigger: - push --- kind: signature -hmac: a8fd97516ee53ca8c938ad413e030dc7df483f116c4b19b5811e359960b7b44d +hmac: 52e9470231175367dbb83f5aa33659332e977546cf1a9db3d942401778f53d68 ... diff --git a/admin/test/wait_for_server.sh b/admin/test/wait_for_server.sh new file mode 100755 index 0000000000000..78dfb9fe612b7 --- /dev/null +++ b/admin/test/wait_for_server.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors +# SPDX-FileCopyrightText: 2019-2020 Tobias Kaminsky +# SPDX-License-Identifier: AGPL-3.0-or-later + +counter=0 +status="" + +until [[ $status = "false" ]]; do + status=$(curl 2>/dev/null "http://$1/status.php" | jq .maintenance) + + echo "($counter) $status" + + if [[ "$status" =~ "false" || "$status" = "" ]]; then + let "counter += 1" + if [[ $counter -gt 50 ]]; then + echo "Failed to wait for server" + exit 1 + fi + fi + + sleep 10 +done + From cd924de9d30cecd887653d77380204b953e5aa8d Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Thu, 11 Apr 2024 21:10:59 +0200 Subject: [PATCH 2/2] improving end-to-end tests Signed-off-by: Matthieu Gallien --- admin/test/wait_for_server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/test/wait_for_server.sh b/admin/test/wait_for_server.sh index 78dfb9fe612b7..a252f9d63d54e 100755 --- a/admin/test/wait_for_server.sh +++ b/admin/test/wait_for_server.sh @@ -14,7 +14,7 @@ until [[ $status = "false" ]]; do if [[ "$status" =~ "false" || "$status" = "" ]]; then let "counter += 1" - if [[ $counter -gt 50 ]]; then + if [[ $counter -gt 90 ]]; then echo "Failed to wait for server" exit 1 fi