Skip to content

Commit 952900f

Browse files
author
huangtianhua
authored
Merge pull request apache#399 from liu-sheng/openshift-public-clouds-support
Add jobs of openshift origin + public clouds
2 parents 87050ad + 1e4de40 commit 952900f

7 files changed

Lines changed: 261 additions & 0 deletions

File tree

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
- name: Deploy example applications for testing cluster functionalities
3+
hosts: masters
4+
become: yes
5+
tasks:
6+
- name: Create resources in openshift cluster
7+
shell:
8+
cmd: |
9+
set -xe
10+
git clone http://github.com/huaweicloud/openshift-ansible
11+
oc adm policy add-scc-to-group anyuid system:authenticated
12+
oc create -f openshift-ansible/applications/
13+
oc_get_running_pods() { oc get pods -o jsonpath='{range .items[*].status}{.phase}{"\n"}{end}'; }
14+
export -f oc_get_running_pods
15+
timeout 60 bash -c '
16+
while :
17+
do
18+
[[ $(oc_get_running_pods | uniq) == Running ]] && break
19+
sleep 2
20+
done
21+
'
22+
executable: /bin/bash
23+
24+
- name: Record pvc cinder volumes name
25+
shell: oc get pvc -o jsonpath='{range .items[*].spec}{.volumeName}{end}'
26+
register: vol_name
27+
28+
- name: Record loadbalancer name
29+
shell: oc get svc nginx-service -o jsonpath='{.metadata.uid}' | tr -d '-' | sed 's/^/a/' | cut -c -32
30+
register: lbaas_id
31+
32+
- name: Confirm the cloud resources has been created
33+
hosts: localhost
34+
become: yes
35+
vars:
36+
lbaas_name: '{{ hostvars[groups["masters"][0]]["lbaas_id"].stdout }}'
37+
pvc_vol_name: '{{ hostvars[groups["masters"][0]]["vol_name"].stdout }}'
38+
tasks:
39+
- name: confirm resources in cloud
40+
shell:
41+
cmd: |
42+
set -xe
43+
timeout 60 bash -c '
44+
while :
45+
do
46+
openstack volume show kubernetes-dynamic-{{ pvc_vol_name }} && \
47+
neutron lbaas-loadbalancer-show {{ lbaas_name }} && break
48+
sleep 2
49+
done
50+
'
51+
executable: /bin/bash
52+
53+
- name: Clean resources in openshift cluster
54+
hosts: masters
55+
become: yes
56+
tasks:
57+
- name: clean resources in openshift cluster
58+
shell:
59+
cmd: |
60+
set -xe
61+
oc delete -f openshift-ansible/applications/
62+
oc delete all --all
63+
executable: /bin/bash
64+
65+
- name: Confirm the cloud resources has been removed
66+
hosts: localhost
67+
become: yes
68+
vars:
69+
lbaas_name: '{{ hostvars[groups["masters"][0]]["lbaas_id"].stdout }}'
70+
pvc_vol_name: '{{ hostvars[groups["masters"][0]]["vol_name"].stdout }}'
71+
tasks:
72+
- name: confirm resources in cloud removed
73+
shell:
74+
cmd: |
75+
set -xe
76+
timeout 60 bash -c '
77+
while :
78+
do
79+
! openstack volume show kubernetes-dynamic-{{ pvc_vol_name }} && \
80+
! neutron lbaas-loadbalancer-show {{ lbaas_name }} && break
81+
sleep 2
82+
done
83+
'
84+
executable: /bin/bash
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
{% if openshift_image_name is defined %}
3+
openshift_openstack_default_image_name: "{{ openshift_image_name }}"
4+
{% endif %}
5+
openshift_openstack_clusterid: "openshift-{{ job_uid }}"
6+
openshift_openstack_public_dns_domain: "openlab.com"
7+
openshift_openstack_keypair_name: "openshift-{{ job_uid }}"
8+
openshift_openstack_num_infra: 0
9+
openshift_openstack_num_nodes: 1
10+
openshift_release: "{{ openshift_release | default('3.9') }}"
11+
openshift_hosted_infra_selector: "node-role.kubernetes.io/master=true"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
- hosts: all
2+
become: yes
3+
vars:
4+
job_uid: '{{ zuul.build[:10] }}'
5+
roles:
6+
- export-cloud-openrc
7+
tasks:
8+
- name: Clean up resources of openshift cluster on {{ cloud_name }}
9+
shell:
10+
cmd: |
11+
set -e
12+
set -x
13+
openstack stack delete --wait --yes "openshift-{{ job_uid }}.openlab.com" || true
14+
openstack keypair delete "openshift-{{ job_uid }}" || true
15+
openstack volume delete `openstack volume list --status available -f value -c Name |grep kubernetes-dynamic-pvc` || true
16+
executable: /bin/bash
17+
environment: '{{ global_env }}'
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
- hosts: all
2+
become: yes
3+
vars:
4+
job_uid: '{{ zuul.build[:10] }}'
5+
roles:
6+
- export-cloud-openrc
7+
tasks:
8+
- name: Copy cluster testing playbook under openshift-ansible
9+
become: yes
10+
copy:
11+
src: cluster-testing.yaml
12+
dest: '{{ ansible_user_dir }}/src/github.com/huaweicloud/openshift-ansible/cluster-testing.yaml'
13+
14+
- name: Generate cloud specific extra vars for openshift cluster deployment
15+
become: yes
16+
template:
17+
dest: "{{ ansible_user_dir }}/src/github.com/huaweicloud/openshift-ansible/extra_vars.yml"
18+
src: "extra_vars.yml.j2"
19+
20+
- name: Run Openshift Origin functional tests against {{ cloud_name }}
21+
shell:
22+
cmd: |
23+
set -xe
24+
pip install ansible
25+
pip install jinja2
26+
pip install shade
27+
pip install jmespath
28+
pip install dnspython
29+
pip install python-openstackclient
30+
pip install python-heatclient
31+
pip install python-neutronclient
32+
33+
openstack keypair create "openshift-{{ job_uid }}" > "openshift-{{ job_uid }}.pem"
34+
chmod 400 "openshift-{{ job_uid }}.pem"
35+
36+
export ANSIBLE_HOST_KEY_CHECKING=false
37+
export OPENSHIFT_CLUSTER="openshift-{{ job_uid }}.openlab.com"
38+
39+
# Check prerequisites
40+
ansible-playbook --user root \
41+
-i playbooks/openstack/inventory.py \
42+
-i "playbooks/openstack/{{ inventory_name }}-inventory" \
43+
--private-key "./openshift-{{ job_uid }}.pem" \
44+
playbooks/openstack/openshift-cluster/prerequisites.yml \
45+
-e @extra_vars.yml
46+
47+
# Provision
48+
ansible-playbook --user root \
49+
-i playbooks/openstack/inventory.py \
50+
-i "playbooks/openstack/{{ inventory_name }}-inventory" \
51+
--private-key "./openshift-{{ job_uid }}.pem" \
52+
playbooks/openstack/openshift-cluster/provision.yml \
53+
-e @extra_vars.yml
54+
55+
# Install openshift cluster
56+
ansible-playbook --user root \
57+
-i playbooks/openstack/inventory.py \
58+
-i "playbooks/openstack/{{ inventory_name }}-inventory" \
59+
--private-key "./openshift-{{ job_uid }}.pem" \
60+
playbooks/openstack/openshift-cluster/install.yml \
61+
-e @extra_vars.yml
62+
63+
# Testing openshift cluster functionalities
64+
ansible-playbook --user root \
65+
-i playbooks/openstack/inventory.py \
66+
-i "playbooks/openstack/{{ inventory_name }}-inventory" \
67+
--private-key "./openshift-{{ job_uid }}.pem" \
68+
cluster-testing.yaml \
69+
-e @extra_vars.yml
70+
executable: /bin/bash
71+
chdir: '{{ ansible_user_dir }}/src/github.com/huaweicloud/openshift-ansible'
72+
environment: '{{ global_env }}'

zuul.d/jobs.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,3 +1039,56 @@
10391039
timeout: 18000
10401040
secrets:
10411041
- fusioncloud_credentials
1042+
1043+
- job:
1044+
name: openshift-origin-functional-test-huaweicloud
1045+
parent: init-test
1046+
description: |
1047+
Run functional tests of openshift-origin repo of v3.9.0 release against huaweicloud
1048+
run: playbooks/openshift-origin-functional-test-public-clouds/run.yaml
1049+
post-run: playbooks/openshift-origin-functional-test-public-clouds/post.yaml
1050+
vars:
1051+
cloud_name: huaweicloud
1052+
inventory_name: huawei
1053+
openshift_image_name: "CentOS 7.5 64bit"
1054+
secrets:
1055+
- huaweicloud_credentials
1056+
1057+
- job:
1058+
name: openshift-origin-functional-test-opentelekomcloud
1059+
parent: init-test
1060+
description: |
1061+
Run functional tests of openshift-origin repo of v3.9.0 release against opentelekomcloud
1062+
run: playbooks/openshift-origin-functional-test-public-clouds/run.yaml
1063+
post-run: playbooks/openshift-origin-functional-test-public-clouds/post.yaml
1064+
vars:
1065+
cloud_name: opentelekomcloud
1066+
inventory_name: otc
1067+
secrets:
1068+
- opentelekomcloud_credentials
1069+
1070+
- job:
1071+
name: openshift-origin-functional-test-telefonica
1072+
parent: init-test
1073+
description: |
1074+
Run functional tests of openshift-origin repo of v3.9.0 release against telefonica cloud
1075+
run: playbooks/openshift-origin-functional-test-public-clouds/run.yaml
1076+
post-run: playbooks/openshift-origin-functional-test-public-clouds/post.yaml
1077+
vars:
1078+
cloud_name: telefonica
1079+
inventory_name: telefonica
1080+
secrets:
1081+
- telefonica_credentials
1082+
1083+
- job:
1084+
name: openshift-origin-functional-test-orange
1085+
parent: init-test
1086+
description: |
1087+
Run functional tests of openshift-origin repo of v3.9.0 release against orange cloud
1088+
run: playbooks/openshift-origin-functional-test-public-clouds/run.yaml
1089+
post-run: playbooks/openshift-origin-functional-test-public-clouds/post.yaml
1090+
vars:
1091+
cloud_name: orange
1092+
inventory_name: orange
1093+
secrets:
1094+
- orange_credentials

zuul.d/pipelines.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,19 @@
187187
failure:
188188
mysql:
189189

190+
- pipeline:
191+
name: periodic-utc-2
192+
description: Jobs in this queue are triggered on a timer. UTC-0 02:00
193+
manager: independent
194+
precedence: low
195+
trigger:
196+
timer:
197+
- time: '0 2 * * *'
198+
success:
199+
mysql:
200+
failure:
201+
mysql:
202+
190203
- pipeline:
191204
name: merge-check
192205
description: >

zuul.d/projects.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,14 @@
172172
jobs:
173173
- terraform-provider-huaweicloud-acceptance-test-fusioncloud:
174174
branches: master
175+
176+
177+
- project:
178+
name: huaweicloud/openshift-ansible
179+
periodic-utc-2:
180+
jobs:
181+
- openshift-origin-functional-test-huaweicloud
182+
- openshift-origin-functional-test-opentelekomcloud
183+
# NOTES: Telefonica account is disable
184+
# - openshift-origin-functional-test-telefonica
185+
- openshift-origin-functional-test-orange

0 commit comments

Comments
 (0)