forked from theopenlab/spark
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request apache#66 from animationzl/55
UT: dims/openstack-cloud-controller-manager + devstack [in vm]
- Loading branch information
Showing
4 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
93 changes: 93 additions & 0 deletions
93
playbooks/openstack-cloud-controller-manager-unittest/run.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
- hosts: all | ||
become: yes | ||
roles: | ||
- clone-devstack-gate-to-workspace | ||
- create-devstack-local-conf | ||
- install-devstack | ||
tasks: | ||
- shell: | ||
cmd: | | ||
set -e | ||
set -x | ||
# Prepare env on executing node | ||
source /opt/stack/new/devstack/openrc admin admin | ||
go get github.com/Masterminds/glide | ||
make depend | ||
is_instance_active() { | ||
local instance_id=$1 | ||
for i in {1..50} | ||
do | ||
[[ $(openstack server show $instance_id -f value -c status) == ACTIVE ]] && return | ||
echo "Waiting instance(id=$instance_id) for ACTIVE... $i" | ||
sleep 1 | ||
done | ||
return 1 | ||
} | ||
is_instance_ssh_accessible() { | ||
local user=$1 | ||
local host=$2 | ||
local private_key=$3 | ||
for i in {1..50} | ||
do | ||
ssh -i $private_key -o ConnectTimeout=5 -o StrictHostKeyChecking=no $user@$host : && return | ||
echo "Waiting host($host) for ssh accessible... $i" | ||
sleep 10 | ||
done | ||
return 1 | ||
} | ||
# Update subnet dns to allow access to internet | ||
SUBNET_ID=$(openstack subnet list --network private --ip-version 4 -f value -c ID) | ||
openstack subnet set --dns-nameserver 8.8.8.8 $SUBNET_ID | ||
IMAGE_SOURCE='http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img' | ||
IMAGE_NAME=${IMAGE_SOURCE##*/} | ||
wget -q -t 2 -c "$IMAGE_SOURCE" -O "$IMAGE_NAME" | ||
IMAGE_ID=$(openstack image create --file "$IMAGE_NAME" --min-disk 1 --container-format bare --disk-format qcow2 "$IMAGE_NAME" -f value -c id) | ||
rm "$IMAGE_NAME" | ||
openstack flavor create --vcpus 8 --ram 16384 --disk 10 flavor_1 | ||
openstack keypair create keypair_1 > privatekey_1 | ||
chmod 600 privatekey_1 | ||
# Create install and wait for ACTIVE | ||
INSTANCE_ID=$(openstack server create --image $IMAGE_ID --flavor flavor_1 --network private --key-name keypair_1 instance_1 -f value -c id) | ||
if ! is_instance_active $INSTANCE_ID; then | ||
echo "Instance(id=$INSTANCE_ID) is still not ACTIVE, exit" | ||
exit 1 | ||
fi | ||
PORT_ID=$(openstack port list --device-id $INSTANCE_ID -f value -c id) | ||
SECURITY_GROUP_ID=$(openstack port show $PORT_ID -f value -c security_group_ids) | ||
openstack security group rule create --ingress --protocol tcp --dst-port 22 $SECURITY_GROUP_ID | ||
FLOATING_IP=$(openstack floating ip create public -f value -c floating_ip_address) | ||
openstack server add floating ip $INSTANCE_ID $FLOATING_IP | ||
if ! is_instance_ssh_accessible ubuntu $FLOATING_IP privatekey_1; then | ||
echo "Instance(id=$INSTANCE_ID) is still not ssh accessible, exit" | ||
exit 1 | ||
fi | ||
# Remove env contains 'short_source' which is a function defined by devstack for formating PS4 | ||
export -p | grep -v short_source > exported-envs | ||
for rsync_dir in /home/zuul/src /home/zuul/bin /home/zuul/pkg /usr/local/go | ||
do | ||
rsync -az -e 'ssh -i privatekey_1' --rsync-path "sudo mkdir -p $rsync_dir && sudo rsync" $rsync_dir/ ubuntu@$FLOATING_IP:$rsync_dir | ||
done | ||
# Run test inside devstack instance | ||
ssh -i privatekey_1 ubuntu@$FLOATING_IP " | ||
set -x | ||
cd $PWD | ||
source exported-envs | ||
sudo apt install make -y | ||
TESTARGS='-v' make test 2>&1 | ||
" | tee $TEST_RESULTS_TXT | ||
executable: /bin/bash | ||
chdir: '{{ zuul.project.src_dir }}' | ||
environment: '{{ golang_env }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters