Skip to content

Commit 3dbae74

Browse files
liushengkiwik
authored andcommitted
Add bosh acceptance test job (apache#226)
* Add bosh acceptance test job * replace zuul home path with ansible var * Add resource cleanup and improve for bosh acc test job Close theopenlab/openlab#4
1 parent 08fa131 commit 3dbae74

File tree

4 files changed

+216
-0
lines changed

4 files changed

+216
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
- hosts: all
2+
become: yes
3+
roles:
4+
- role: export-cloud-openrc
5+
vars:
6+
cloud_name: 'opentelekomcloud'
7+
tasks:
8+
- name: Clean up resources for bosh acceptance tests
9+
shell:
10+
cmd: |
11+
set -e
12+
set -x
13+
# Cloud provider specific variables
14+
NET_ID="134ca339-24dc-44f5-ae6a-cf0404216ed2"
15+
SUBNET_ID="3d6e9157-655f-42ec-9778-94d455730e5c"
16+
BUILD_ID="{{ zuul.build }}"
17+
18+
cd bosh-1
19+
export BOSH_CLIENT=admin
20+
export BOSH_CLIENT_SECRET=`bosh int ./creds.yml --path /admin_password`
21+
bosh_ip=$(bosh environments --column=URL)
22+
bosh alias-env bosh-1 -e ${bosh_ip} --ca-cert <(bosh int ./creds.yml --path /director_ssl/ca)
23+
bosh -e bosh-1 env
24+
for vm_id in $(bosh -e bosh-1 vms --column="VM CID"); do
25+
bosh -e bosh-1 -d bat --non-interactive delete-vm ${vm_id}
26+
done
27+
for vol_id in $(bosh -e bosh-1 disks --orphaned); do
28+
bosh -e bosh-1 --non-interactive delete-disk ${vol_id}
29+
done
30+
for dep_name in $(bosh -e bosh-1 deployments --column="Name"); do
31+
bosh -e bosh-1 --non-interactive delete-deployment -d ${dep_name}
32+
done
33+
for img_id in $(bosh -e bosh-1 ss --column=CID); do
34+
img_name=$(openstack image show $img_id -f value -c name)
35+
bosh -e bosh-1 --non-interactive delete-stemcell $img_name
36+
done
37+
38+
set +x
39+
bosh delete-env bosh-deployment/bosh.yml \
40+
--state=state.json \
41+
--vars-store=creds.yml \
42+
-o bosh-deployment/openstack/cpi.yml \
43+
-v director_name=bosh-1 \
44+
-v internal_cidr=$(openstack subnet show ${SUBNET_ID} -f value -c cidr) \
45+
-v internal_gw=$(openstack subnet show ${SUBNET_ID} -f value -c gateway_ip) \
46+
-v internal_ip=${bosh_ip} \
47+
-v auth_url=${OS_AUTH_URL} \
48+
-v az=${OS_AVAILABILITY_ZONE} \
49+
-v default_key_name=microbosh-${BUILD_ID} \
50+
-v default_security_groups=[bosh-${BUILD_ID}] \
51+
-v net_id=${NET_ID} \
52+
-v openstack_password=${OS_PASSWORD} \
53+
-v openstack_username=${OS_USERNAME} \
54+
-v openstack_domain=${OS_DOMAIN_NAME} \
55+
-v openstack_project=${OS_TENANT_NAME} \
56+
-v private_key="{{ ansible_user_dir }}/bosh-1/microbosh.pem" \
57+
-v region=${OS_REGION_NAME}
58+
set -x
59+
openstack security group delete bosh-${BUILD_ID} || true
60+
openstack keypair delete microbosh-${BUILD_ID} || true
61+
executable: /bin/bash
62+
environment: '{{ golang_env }}'
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
- hosts: all
2+
become: yes
3+
roles:
4+
- role: export-cloud-openrc
5+
vars:
6+
cloud_name: 'opentelekomcloud'
7+
tasks:
8+
- name: Install bosh and run bosh acceptance tests
9+
shell:
10+
cmd: |
11+
set -x
12+
set -e
13+
set -o pipefail
14+
15+
# Cloud provider specific variables
16+
NET_ID="134ca339-24dc-44f5-ae6a-cf0404216ed2"
17+
SUBNET_ID="3d6e9157-655f-42ec-9778-94d455730e5c"
18+
SMALL_FLAVOR="s2.medium.1" #1U1G
19+
MEDIUM_FLAVOR="s2.large.1" #2U2G
20+
LARGE_FLAVOR="s2.2xlarge.1" #8U8G
21+
BUILD_ID="{{ zuul.build }}"
22+
23+
pip install python-openstackclient
24+
curl -Lo ./bosh https://s3.amazonaws.com/bosh-cli-artifacts/bosh-cli-3.0.1-linux-amd64
25+
chmod +x ./bosh
26+
cp ./bosh /usr/local/bin/bosh
27+
bosh -v
28+
apt-get install -y build-essential zlibc zlib1g-dev ruby ruby-dev openssl libxslt-dev libxml2-dev libssl-dev libreadline6 libreadline6-dev libyaml-dev libsqlite3-dev sqlite3
29+
30+
mkdir bosh-1 && cd bosh-1
31+
git clone https://github.com/cloudfoundry/bosh-deployment.git
32+
openstack keypair create microbosh-${BUILD_ID} > microbosh.pem
33+
openstack security group create bosh-${BUILD_ID} --description 'BOSH Security Group'
34+
openstack security group rule create --protocol tcp --ingress bosh-${BUILD_ID}
35+
openstack security group rule create --protocol icmp --ingress bosh-${BUILD_ID}
36+
37+
wget --content-disposition https://bosh.io/d/stemcells/bosh-openstack-kvm-ubuntu-trusty-go_agent -O bosh-openstack-kvm-ubuntu-trusty-go_agent.tgz
38+
sed -i 's|https://bosh.io/d/stemcells/.*$|file://{{ ansible_user_dir }}/bosh-1/bosh-openstack-kvm-ubuntu-trusty-go_agent.tgz|' bosh-deployment/openstack/cpi.yml
39+
sed -i "s/m1.small/${SMALL_FLAVOR}/g" `grep m1.small -rl bosh-deployment/openstack`
40+
sed -i "s/m1.xlarge/${LARGE_FLAVOR}/g" `grep m1.xlarge -rl bosh-deployment/openstack`
41+
sed -i '/^.*human_readable_vm_names.*$/ a\ \ \ \ state_timeout: 300000' bosh-deployment/openstack/cpi.yml
42+
43+
# NOTE: We need an available ip for bosh deployment, so following port creation and deletion actions are just
44+
# used to reserve an available ip address for bosh deployment
45+
_port_id=$(openstack port create --network ${NET_ID} bosh-port -f value -c id)
46+
bosh_ip=$(openstack port show ${_port_id} -f value -c fixed_ips | grep -Eo '([0-9]+\.){3}[0-9]+')
47+
openstack port delete ${_port_id}
48+
49+
set +x
50+
bosh create-env bosh-deployment/bosh.yml \
51+
--state=state.json \
52+
--vars-store=creds.yml \
53+
-o bosh-deployment/openstack/cpi.yml \
54+
-v director_name=bosh-1 \
55+
-v internal_cidr=$(openstack subnet show ${SUBNET_ID} -f value -c cidr) \
56+
-v internal_gw=$(openstack subnet show ${SUBNET_ID} -f value -c gateway_ip) \
57+
-v internal_ip=${bosh_ip} \
58+
-v auth_url=${OS_AUTH_URL} \
59+
-v az=${OS_AVAILABILITY_ZONE} \
60+
-v default_key_name=microbosh-${BUILD_ID} \
61+
-v default_security_groups=[bosh-${BUILD_ID}] \
62+
-v net_id=${NET_ID} \
63+
-v openstack_password=${OS_PASSWORD} \
64+
-v openstack_username=${OS_USERNAME} \
65+
-v openstack_domain=${OS_DOMAIN_NAME} \
66+
-v openstack_project=${OS_TENANT_NAME} \
67+
-v private_key="{{ ansible_user_dir }}/bosh-1/microbosh.pem" \
68+
-v region=${OS_REGION_NAME}
69+
set -x
70+
71+
bosh alias-env bosh-1 -e ${bosh_ip} --ca-cert <(bosh int ./creds.yml --path /director_ssl/ca)
72+
export BOSH_CLIENT=admin
73+
export BOSH_CLIENT_SECRET=`bosh int ./creds.yml --path /admin_password`
74+
bosh -e bosh-1 env
75+
76+
# path to the stemcell you want to use for testing
77+
export BAT_STEMCELL="{{ ansible_user_dir }}/bosh-1/bosh-openstack-kvm-ubuntu-trusty-go_agent.tgz"
78+
79+
# path to the bat yaml file which is used to generate the deployment manifest (see below `bat.yml`)
80+
export BAT_DEPLOYMENT_SPEC="{{ ansible_user_dir }}/bosh-1/bat.yml"
81+
82+
# BOSH CLI executable path
83+
export BAT_BOSH_CLI=bosh
84+
85+
# DNS host or IP where BOSH-controlled PowerDNS server is running, which is required for the DNS tests. For example, if BAT is being run against a MicroBOSH then this value will be the same as BAT_DIRECTOR
86+
export BAT_DNS_HOST=8.8.8.8
87+
88+
# the name of infrastructure that is used by bosh deployment. Examples: aws, vsphere, openstack, warden, oci.
89+
export BAT_INFRASTRUCTURE=openstack
90+
91+
# the type of networking being used: `dynamic` or `manual`.
92+
export BAT_NETWORKING=dynamic
93+
94+
# the path to ssh key, used by OS specs to ssh into BOSH VMs
95+
export BAT_PRIVATE_KEY="{{ ansible_user_dir }}/bosh-1/microbosh.pem"
96+
97+
# Run tests with --fail-fast and skip cleanup in case of failure (optional)
98+
export BAT_DEBUG_MODE=true
99+
100+
export BOSH_OS_BATS=true
101+
102+
export BOSH_ENVIRONMENT=bosh-1
103+
# export BOSH_CLIENT=<director username>
104+
# export BOSH_CLIENT_SECRET=<director password>
105+
# export BOSH_CA_CERT=<director ca cert content or path>
106+
cat << EOF >> bat.yml
107+
---
108+
cpi: openstack
109+
properties:
110+
stemcell:
111+
name: bosh-openstack-kvm-ubuntu-trusty-go_agent
112+
version: latest
113+
pool_size: 1
114+
instances: 1
115+
instance_type: ${SMALL_FLAVOR}
116+
availability_zone: ${OS_AVAILABILITY_ZONE}
117+
flavor_with_no_ephemeral_disk: ${MEDIUM_FLAVOR}
118+
vip: 0.0.0.43 # Virtual (public/floating) IP assigned to the bat-release job vm, for ssh testing
119+
networks:
120+
- name: default
121+
type: dynamic
122+
cloud_properties:
123+
net_id: ${NET_ID} # Network ID
124+
security_groups: [bosh-${BUILD_ID}] # security groups assigned to deployed VMs
125+
key_name: microbosh-${BUILD_ID} # (optional) SSH keypair name
126+
EOF
127+
128+
pushd '{{ ansible_user_dir }}/{{ zuul.project.src_dir }}'
129+
gem install bundler
130+
bundle install
131+
cp '{{ ansible_user_dir }}/bosh' /usr/local/bin/bosh
132+
bundle exec rspec spec --tag ~raw_ephemeral_storage
133+
popd
134+
135+
executable: /bin/bash
136+
chdir: '{{ ansible_user_dir }}'
137+
environment: '{{ golang_env }}'

zuul.d/jobs.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,14 @@
332332
run: playbooks/cf-openstack-validator-acceptance-test/run.yaml
333333
vars:
334334
os_branch: 'stable/newton'
335+
336+
- job:
337+
name: bosh-acceptance-test
338+
parent: golang-test
339+
description: |
340+
Run acceptance tests of bosh-acceptance-tests
341+
run: playbooks/bosh-acceptance-test/run.yaml
342+
post-run: playbooks/bosh-acceptance-test/post.yaml
343+
nodeset: ubuntu-xenial-otc
344+
secrets:
345+
- opentelekomcloud_credentials

zuul.d/nodesets.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,9 @@
2929
nodes:
3030
- name: ubuntu-bionic-vxh-arm64
3131
label: ubuntu-bionic-vxh-arm64
32+
33+
- nodeset:
34+
name: ubuntu-xenial-otc
35+
nodes:
36+
- name: ubuntu-xenial-otc
37+
label: ubuntu-xenial-otc

0 commit comments

Comments
 (0)