mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
tests: functional: Simplify GitLabCI configuration
- The GitLab CI Runner no longer directly runs AWS CLI commands - The Runner calls two AWS Lambda functions for running or terminating the app servers - The Lambda functions invoke AWS APIs using the Python boto3 library Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
35b50a2c71
commit
77f9037219
@ -9,14 +9,10 @@
|
||||
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
|
||||
- LAUNCH_TEMPLATE_ID=$(aws ec2 describe-launch-templates --launch-template-names $LAUNCH_TEMPLATE_NAME | jq -r ".LaunchTemplates[0].LaunchTemplateId")
|
||||
- |
|
||||
INSTANCE_ID=$(aws ec2 run-instances --launch-template LaunchTemplateId="$LAUNCH_TEMPLATE_ID" --associate-public-ip-address \
|
||||
--tag-specifications "ResourceType=instance, Tags=[{Key=salsa:project-id,Value=$CI_PROJECT_ID},{Key=salsa:build-job-id,Value=$BUILD_JOB_ID},{Key=Name,Value=$INSTANCE_NAME}]" | \
|
||||
jq -r ".Instances[0].InstanceId")
|
||||
- APP_SERVER_IP=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID | jq -r ".Reservations[0].Instances[0].PublicIpAddress")
|
||||
- echo "APP_SERVER_IP=$APP_SERVER_IP" >> app-servers.env
|
||||
- echo "INSTANCE_ID=$INSTANCE_ID" >> 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=$(jq -r '.app_server_ip' response.json)" >> app-servers.env
|
||||
- echo "INSTANCE_ID=$(jq -r '.instance_id' response.json)" >> app-servers.env
|
||||
tags:
|
||||
- functional-tests
|
||||
artifacts:
|
||||
@ -58,6 +54,8 @@
|
||||
.terminate-app-server:
|
||||
stage: functional-tests
|
||||
script:
|
||||
- aws ec2 --region us-east-1 terminate-instances --instance-ids $INSTANCE_ID > /dev/null
|
||||
- export AWS_DEFAULT_REGION=us-east-1
|
||||
- |
|
||||
aws lambda invoke --function-name terminate_app_server --payload '{"instance_id": "'"$INSTANCE_ID"'"}' response.json
|
||||
tags:
|
||||
- functional-tests
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user