diff --git a/.ci/functional-tests.yml b/.ci/functional-tests.yml index 2e839574a..c004a6926 100644 --- a/.ci/functional-tests.yml +++ b/.ci/functional-tests.yml @@ -1,66 +1,27 @@ --- # SPDX-License-Identifier: AGPL-3.0-or-later -.app-server: - stage: functional-tests - dependencies: [] - except: - - $GITLAB_USER_LOGIN == "weblate" - script: - - BUILD_JOB_ID=$(curl -s "https://salsa.debian.org/api/v4/projects/$CI_PROJECT_ID/pipelines/$CI_PIPELINE_ID/jobs?scope[]=success" | jq -r '.[] | select(.name==env.BUILD_JOB_NAME) | .id') - - export AWS_DEFAULT_REGION=us-east-1 - - | - aws lambda invoke --function-name launch_app_server --payload '{"launch_template_name": "'"$LAUNCH_TEMPLATE_NAME"'", "instance_name": "'"$INSTANCE_NAME"'", "ci_project_id": "'"$CI_PROJECT_ID"'", "build_job_id": "'"$BUILD_JOB_ID"'"}' response.json - - echo "APP_SERVER_IP_1=$(jq -r '.app_server_ip' response.json)" >> app-servers.env - - echo "INSTANCE_ID_1=$(jq -r '.instance_id' response.json)" >> app-servers.env - - | - aws lambda invoke --function-name launch_app_server --payload '{"launch_template_name": "'"$LAUNCH_TEMPLATE_NAME"'", "instance_name": "'"$INSTANCE_NAME"'", "ci_project_id": "'"$CI_PROJECT_ID"'", "build_job_id": "'"$BUILD_JOB_ID"'"}' response.json - - echo "APP_SERVER_IP_2=$(jq -r '.app_server_ip' response.json)" >> app-servers.env - - echo "INSTANCE_ID_2=$(jq -r '.instance_id' response.json)" >> app-servers.env - tags: - - functional-tests - artifacts: - reports: - dotenv: app-servers.env - .run-functional-tests: stage: functional-tests - timeout: 3h + needs: [] + dependencies: [] + tags: + - functional-tests + timeout: 6h # Need to find another way of running the cleanup step even on failure allow_failure: true - when: delayed - # Wait for the app-server to come up. Saves time for the CI runners. - start_in: 3 minutes + except: + - $GITLAB_USER_LOGIN == "weblate" before_script: - apt-get update - - apt-get install -y sudo curl wget - - ./plinth/tests/functional/install.sh - - adduser tester --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password && echo "tester:password" | chpasswd + - sudo -u plinth ./run --develop > plinth.log 2>&1 & + - 'echo -e "Cmnd_Alias FREEDOMBOX_ACTION_DEV = /usr/share/plinth/actions/actions, `pwd`/actions/actions\nDefaults!FREEDOMBOX_ACTION_DEV closefrom_override\nplinth ALL=(ALL:ALL) NOPASSWD:SETENV : FREEDOMBOX_ACTION_DEV\n" > /etc/sudoers.d/01-freedombox-development' + - while ! grep -q "Setup thread finished" plinth.log; do sleep 1; echo -n .; done script: - - cp -r . /home/tester/freedombox && chown -R tester:tester /home/tester/freedombox - - | - sudo APP_SERVER_URL_1="https://$APP_SERVER_IP_1" APP_SERVER_URL_2="https://$APP_SERVER_IP_2" -u tester bash -c \ - 'cd /home/tester/freedombox && py.test-3 -v --durations=10 --include-functional --splinter-headless -n 2 --dist=loadscope --template=html1/index.html --report=functional-tests.html' - after_script: - - echo "INSTANCE_ID_1=$INSTANCE_ID_1" >> app-servers.env - - echo "INSTANCE_ID_2=$INSTANCE_ID_2" >> app-servers.env - - cp /home/tester/freedombox/functional-tests.html . - - cp -r /home/tester/freedombox/screenshots/ . + - FREDOMBOX_URL=https://localhost FREEDOMBOX_SSH_PORT=22 FREEDOMBOX_SAMBA_PORT=445 pytest -v --durations=10 --include-functional --splinter-headless --template=html1/index.html --report=functional-tests.html artifacts: when: always - reports: - dotenv: app-servers.env paths: - functional-tests.html - screenshots/ - -# Does not run if the previous job times out or is cancelled -.terminate-app-server: - stage: functional-tests - script: - - export AWS_DEFAULT_REGION=us-east-1 - - | - aws lambda invoke --function-name terminate_app_server --payload '{"instance_id": "'"$INSTANCE_ID_1"'"}' response.json - aws lambda invoke --function-name terminate_app_server --payload '{"instance_id": "'"$INSTANCE_ID_2"'"}' response.json - tags: - - functional-tests + - plinth.log diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 14380bdfa..ea70cd905 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,63 +47,9 @@ doc-tests: script: - make check-doc -.app-server-stable: - variables: - LAUNCH_TEMPLATE_NAME: functional-tests-stable - INSTANCE_NAME: app-server-stable - BUILD_JOB_NAME: build-backports - extends: .app-server - -.run-functional-tests-stable: - needs: - - job: app-server-stable - artifacts: true +run-functional-tests-stable: extends: .run-functional-tests -.terminate-app-server-stable: - needs: - - job: run-functional-tests-stable - artifacts: true - extends: .terminate-app-server - -.app-server-testing: - variables: - LAUNCH_TEMPLATE_NAME: functional-tests-testing - INSTANCE_NAME: app-server-testing - BUILD_JOB_NAME: build - extends: .app-server - -.run-functional-tests-testing: - needs: - - job: app-server-testing - artifacts: true - extends: .run-functional-tests - -.terminate-app-server-testing: - needs: - - job: run-functional-tests-testing - artifacts: true - extends: .terminate-app-server - -.app-server-unstable: - variables: - LAUNCH_TEMPLATE_NAME: functional-tests-unstable - INSTANCE_NAME: app-server-unstable - BUILD_JOB_NAME: build - extends: .app-server - -.run-functional-tests-unstable: - needs: - - job: app-server-unstable - artifacts: true - extends: .run-functional-tests - -.terminate-app-server-unstable: - needs: - - job: run-functional-tests-unstable - artifacts: true - extends: .terminate-app-server - extract-source: extends: .provisioning-extract-source