Add post-deploy tests as an Ansible role
Change-Id: Id033dbf8ef697091459c5ee424d765239e907c01
(cherry picked from commit a27effe0c79ac28da7750b375279557270297076)
diff --git a/roles/post-deploy-tests/tasks/main.yml b/roles/post-deploy-tests/tasks/main.yml
new file mode 100644
index 0000000..32b8b63
--- /dev/null
+++ b/roles/post-deploy-tests/tasks/main.yml
@@ -0,0 +1,49 @@
+---
+# post-deploy-tasks/tasks/main.yml
+#
+# Run tests to check that the single-node deployment has worked
+
+- name: Create a sample CORD subscriber
+ command: ansible xos-1 -u ubuntu -m shell \
+ -a "cd ~/service-profile/cord-pod; make cord-subscriber"
+
+- 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 vSG VM to come up
+ shell: bash -c "source ~/admin-openrc.sh; nova list --all-tenants|grep 'vsg.*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_vsg|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: Wait for Docker container inside VM to come up
+ shell: ssh -o ProxyCommand="ssh -W %h:%p ubuntu@nova-compute-1" ubuntu@{{ mgmt_ip.stdout }} "sudo docker ps|grep vcpe" > /dev/null
+ register: result
+ until: result | success
+ retries: 20
+ delay: 60
+
+- name: Run dhclient inside testclient to get IP address from vSG
+ command: ansible nova-compute-1 -u ubuntu -m shell \
+ -s -a "lxc-attach -n testclient -- dhclient eth0.222.111"
+
+- name: Test external connectivity in test client
+ command: ansible nova-compute-1 -u ubuntu -m shell \
+ -s -a "lxc-attach -n testclient -- ping -c 3 8.8.8.8"
+ register: pingtest
+
+- name: Output from ping test
+ debug: var=pingtest.stdout_lines
\ No newline at end of file
diff --git a/roles/test-client-install/files/test-client-playbook.yml b/roles/test-client-install/files/test-client-playbook.yml
index fa13250..263cbec 100644
--- a/roles/test-client-install/files/test-client-playbook.yml
+++ b/roles/test-client-install/files/test-client-playbook.yml
@@ -23,3 +23,16 @@
- name: Create testclient
become: yes
shell: lxc-ls | grep testclient || lxc-create -t ubuntu -n testclient
+
+ - name: Start testclient
+ become: yes
+ shell: lxc-info -n testclient -s | grep RUNNING || lxc-start -n testclient
+
+ - name: Set up networking inside the testclient for testing sample CORD subscriber
+ become: yes
+ shell: "{{ item }}"
+ with_items:
+ - "lxc-attach -n testclient -- bash -c 'ip link show eth0.222 || ip link add link eth0 name eth0.222 type vlan id 222'"
+ - "lxc-attach -n testclient -- bash -c 'ip link show eth0.222.111 || ip link add link eth0.222 name eth0.222.111 type vlan id 111'"
+ - "lxc-attach -n testclient -- ifconfig eth0.222 up"
+ - "lxc-attach -n testclient -- ifconfig eth0.222.111 up"