blob: 865631c0e97fb9857397598bcedbcd34b3e2aa69 [file] [log] [blame]
Matteo Scandolo3896c472017-08-01 13:31:42 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
Andy Bavier8a7b8b62016-07-26 18:35:06 -040017---
18# test-examplservice/tasks/main.yml
Andy Bavier8a7b8b62016-07-26 18:35:06 -040019# Run tests to check that the single-node deployment has worked
20
Zack Williamsa2763112017-01-03 11:38:38 -070021- name: Load TOSCA to apply test config for ExampleService, over REST
22 xostosca:
23 url: "http://xos.{{ site_suffix }}:{{ xos_ui_port }}/api/utility/tosca/run/"
24 user: "{{ xos_admin_user }}"
25 password: "{{ xos_admin_pass }}"
Zack Williamsc989f262017-05-11 13:02:59 -070026 recipe: "{{ lookup('file', head_cord_profile_dir + '/test-exampleservice.yaml' ) }}"
Andy Bavier8a7b8b62016-07-26 18:35:06 -040027
Andy Bavier8a7b8b62016-07-26 18:35:06 -040028- name: Wait for ExampleService VM to come up
Zack Williamsc989f262017-05-11 13:02:59 -070029 shell: bash -c "source /opt/cord_profile/admin-openrc.sh; nova list --all-tenants|grep 'exampleservice.*ACTIVE' > /dev/null"
Andy Bavier8a7b8b62016-07-26 18:35:06 -040030 register: result
31 until: result | success
32 retries: 10
33 delay: 60
Zack Williams35624562016-08-28 17:12:26 -070034 tags:
35 - skip_ansible_lint # running a sub job
Andy Bavier8a7b8b62016-07-26 18:35:06 -040036
37- name: Get ID of VM
Zack Williamsc989f262017-05-11 13:02:59 -070038 shell: bash -c "source /opt/cord_profile/admin-openrc.sh; nova list --all-tenants|grep mysite_exampleservice|cut -d '|' -f 2"
Andy Bavier8a7b8b62016-07-26 18:35:06 -040039 register: nova_id
Zack Williams35624562016-08-28 17:12:26 -070040 tags:
41 - skip_ansible_lint # running a sub job
Andy Bavier8a7b8b62016-07-26 18:35:06 -040042
43- name: Get mgmt IP of VM
Zack Williamsc989f262017-05-11 13:02:59 -070044 shell: bash -c "source /opt/cord_profile/admin-openrc.sh; nova interface-list {{ nova_id.stdout }}|grep -o -m 1 '172\.27\.[[:digit:]]*\.[[:digit:]]*'"
Andy Bavier8a7b8b62016-07-26 18:35:06 -040045 register: mgmt_ip
Zack Williams35624562016-08-28 17:12:26 -070046 tags:
47 - skip_ansible_lint # running a sub job
Andy Bavier8a7b8b62016-07-26 18:35:06 -040048
49- name: Get public IP of VM
Andy Bavierd6c09af2017-08-23 17:57:51 -070050 shell: bash -c "source /opt/cord_profile/admin-openrc.sh; nova interface-list {{ nova_id.stdout }}|grep -o -m 1 '10\.8\.[[:digit:]]*\.[[:digit:]]*'"
Andy Bavier8a7b8b62016-07-26 18:35:06 -040051 register: public_ip
Zack Williams35624562016-08-28 17:12:26 -070052 tags:
53 - skip_ansible_lint # running a sub job
Andy Bavier8a7b8b62016-07-26 18:35:06 -040054
Andy Bavier30d27c92016-09-15 15:59:17 -040055- name: Get name of compute node
Moshe Levi8f2867c2017-07-17 03:52:42 +030056 shell: bash -c "source /opt/cord_profile/admin-openrc.sh; nova show {{ nova_id.stdout }}|grep hypervisor_hostname|cut -d '|' -f 3"
Andy Bavier30d27c92016-09-15 15:59:17 -040057 register: node_name
58 tags:
59 - skip_ansible_lint # running a sub job
60
Andy Bavier8a7b8b62016-07-26 18:35:06 -040061- name: Wait for Apache to come up inside VM
Andy Bavier30d27c92016-09-15 15:59:17 -040062 shell: ssh -o ProxyCommand="ssh -W %h:%p -l ubuntu {{ node_name.stdout }}" ubuntu@{{ mgmt_ip.stdout }} "ls /var/run/apache2/apache2.pid" > /dev/null
Andy Bavier8a7b8b62016-07-26 18:35:06 -040063 register: result
64 until: result | success
65 retries: 20
66 delay: 60
Zack Williams35624562016-08-28 17:12:26 -070067 tags:
68 - skip_ansible_lint # running a sub job
Andy Bavier8a7b8b62016-07-26 18:35:06 -040069
Andy Bavierbef56282016-11-14 08:22:43 -080070- name: start container
Andy Bavierb83beac2016-10-20 15:54:08 -040071 become: yes
Andy Bavierbef56282016-11-14 08:22:43 -080072 lxd_container:
Andy Bavierb83beac2016-10-20 15:54:08 -040073 name: testclient
Andy Bavierbef56282016-11-14 08:22:43 -080074 state: started
75
76- name: Make sure testclient has default route to vSG
77 become: yes
78 shell: lxc exec testclient -- route | grep default | grep "eth0.222.111"
79 register: result
80 until: result | success
Zack Williams904e87f2017-03-02 14:35:28 -070081 retries: 20
82 delay: 30
Andy Bavierbef56282016-11-14 08:22:43 -080083 tags:
84 - skip_ansible_lint # running a sub job
85
86- name: Download the curl package through the vSG
87 become: yes
88 command: lxc exec testclient -- apt-get install -y curl
Zack Williams35624562016-08-28 17:12:26 -070089 tags:
90 - skip_ansible_lint # running a sub job
Andy Bavier8a7b8b62016-07-26 18:35:06 -040091
Andy Bavierb83beac2016-10-20 15:54:08 -040092# Don't use lxc_container in order to get output
Andy Bavier8a7b8b62016-07-26 18:35:06 -040093- name: Test connectivity to ExampleService from test client
Andy Bavierb83beac2016-10-20 15:54:08 -040094 become: yes
Andy Bavierbef56282016-11-14 08:22:43 -080095 command: lxc exec testclient -- curl -s http://{{ public_ip.stdout }}
Andy Bavier8a7b8b62016-07-26 18:35:06 -040096 register: curltest
Zack Williams35624562016-08-28 17:12:26 -070097 tags:
98 - skip_ansible_lint # running a sub job
Andy Bavier8a7b8b62016-07-26 18:35:06 -040099
100- name: Output from curl test
101 debug: var=curltest.stdout_lines
Zack Williamsa2763112017-01-03 11:38:38 -0700102