Skip to content

Commit

Permalink
Merge pull request apache#66 from animationzl/55
Browse files Browse the repository at this point in the history
UT: dims/openstack-cloud-controller-manager + devstack [in vm]
  • Loading branch information
kiwik authored Feb 22, 2018
2 parents db25236 + 1d83b44 commit 65a7fb9
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 0 deletions.
Empty file.
93 changes: 93 additions & 0 deletions playbooks/openstack-cloud-controller-manager-unittest/run.yaml
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 }}'
9 changes: 9 additions & 0 deletions zuul.d/jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,12 @@
run: playbooks/terraform-provider-opentelekomcloud-acceptance-test-opentelekomcloud/run.yaml
secrets:
- opentelekomcloud_credentials

# Kubernetes jobs
- job:
name: openstack-cloud-controller-manager-unittest
parent: golang-test
description: |
Run Kubernetes openstack-cloud-controller-manager unit test in devstack instance
run: playbooks/openstack-cloud-controller-manager-unittest/run.yaml
nodeset: ubuntu-xenial-large
6 changes: 6 additions & 0 deletions zuul.d/nodesets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@
nodes:
- name: ubuntu-xenial-ut
label: ubuntu-xenial-ut

- nodeset:
name: ubuntu-xenial-large
nodes:
- name: ubuntu-xenial-large
label: ubuntu-xenial-large

0 comments on commit 65a7fb9

Please sign in to comment.