Skip to content
Snippets Groups Projects
Commit 81b69515 authored by Bo-Chun Chen's avatar Bo-Chun Chen
Browse files

Add test stage to test the newly built image

parent 1abcc2b7
No related branches found
No related tags found
1 merge request!10Add gitlab ci into project
......@@ -15,6 +15,7 @@ variables:
stages:
- build
- test
- deploy
build_image:
......@@ -61,16 +62,16 @@ build_image:
reports:
dotenv: image.env
deploy_knightly:
test:
image: $CI_REGISTRY_IMAGE:latest
stage: deploy
stage: test
environment:
name: knightly
tags:
- build
script:
- OLD_INSTANCE_ID=$(openstack server list --name ood-knightly -c ID -f value)
- if [ ! -z $OLD_INSTANCE_ID ]; then openstack server delete $OLD_INSTANCE_ID; fi
- export OLD_INSTANCE_ID=$(openstack server list --name ood-knightly -c ID -f value)
- echo OLD_INSTANCE_ID=$OLD_INSTANCE_ID | tee -a instance.env
- |
cat > user_data.txt << OEOF
#!/bin/bash
......@@ -82,7 +83,7 @@ deploy_knightly:
ip route add 172.20.0.0/16 via 10.250.0.1 dev eth0
OEOF
- >
NEW_INSTANCE_ID=$(openstack server create
export NEW_INSTANCE_ID=$(openstack server create
-c id -f value --image $BUILT_OOD_IMAGE_ID
--network openstack-cheaha-internal
--security-group ood-https-ports
......@@ -90,6 +91,23 @@ deploy_knightly:
--user-data user_data.txt
--flavor m1.medium
ood-knightly)
- echo NEW_INSTANCE_ID=$NEW_INSTANCE_ID | tee -a instance.env
- openstack server add floating ip $NEW_INSTANCE_ID $TEST_IP
- ssh $TEST_IP systemctl is-active shibd.service
- openstack server remove floating ip $NEW_INSTANCE_ID $TEST_IP
artifacts:
reports:
dotenv: instance.env
deploy_knightly:
image: $CI_REGISTRY_IMAGE:latest
stage: deploy
environment:
name: knightly
tags:
- build
script:
- if [ ! -z $OLD_INSTANCE_ID ]; then openstack server delete $OLD_INSTANCE_ID; fi
- |
if [ ! -z $NEW_INSTANCE_ID ]; then
openstack server add floating ip $NEW_INSTANCE_ID $CAMPUS_IP
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment