Add ExampleService by default to single-node POD
Change-Id: Ic2397aca2e732cc513e8c2165549c2225f2f27cd
(cherry picked from commit 8a7b8b62323eb72aadb1da816d0df29fce55ed8d)
diff --git a/roles/test-exampleservice/tasks/main.yml b/roles/test-exampleservice/tasks/main.yml
new file mode 100644
index 0000000..2ae3813
--- /dev/null
+++ b/roles/test-exampleservice/tasks/main.yml
@@ -0,0 +1,53 @@
+---
+# test-examplservice/tasks/main.yml
+#
+# Run tests to check that the single-node deployment has worked
+
+- name: Onboard ExampleService and instantiate a VM
+ command: ansible xos-1 -u ubuntu -m shell \
+ -a "cd ~/service-profile/cord-pod; make exampleservice"
+
+- name: Pause 60 seconds (work around bug in synchronizer)
+ pause: seconds=60
+
+- name: Re-run 'make vtn' (work around bug in synchronizer)
+ command: ansible xos-1 -u ubuntu -m shell \
+ -a "cd ~/service-profile/cord-pod; make vtn"
+
+- name: Wait for ExampleService VM to come up
+ shell: bash -c "source ~/admin-openrc.sh; nova list --all-tenants|grep 'exampleservice.*ACTIVE' > /dev/null"
+ register: result
+ until: result | success
+ retries: 10
+ delay: 60
+
+- name: Get ID of VM
+ shell: bash -c "source ~/admin-openrc.sh; nova list --all-tenants|grep mysite_exampleservice|cut -d '|' -f 2"
+ register: nova_id
+
+- name: Get mgmt IP of VM
+ shell: bash -c "source ~/admin-openrc.sh; nova interface-list {{ nova_id.stdout }}|grep -o -m 1 172.27.[[:digit:]]*.[[:digit:]]*"
+ register: mgmt_ip
+
+- name: Get public IP of VM
+ shell: bash -c "source ~/admin-openrc.sh; nova interface-list {{ nova_id.stdout }}|grep -o -m 1 10.168.[[:digit:]]*.[[:digit:]]*"
+ register: public_ip
+
+- name: Wait for Apache to come up inside VM
+ shell: ssh -o ProxyCommand="ssh -W %h:%p ubuntu@nova-compute-1" ubuntu@{{ mgmt_ip.stdout }} "ls /var/run/apache2/apache2.pid" > /dev/null
+ register: result
+ until: result | success
+ retries: 20
+ delay: 60
+
+- name: Install curl in testclient
+ command: ansible nova-compute-1 -u ubuntu -m shell \
+ -s -a "lxc-attach -n testclient -- apt-get -y install curl"
+
+- name: Test connectivity to ExampleService from test client
+ command: ansible nova-compute-1 -u ubuntu -m shell \
+ -s -a "lxc-attach -n testclient -- curl -s http://{{ public_ip.stdout }}"
+ register: curltest
+
+- name: Output from curl test
+ debug: var=curltest.stdout_lines