blob: 08e08a35f7dfac741200ae16d57c80e45451d1aa [file] [log] [blame]
Matteo Scandoloa86e0a12017-08-08 13:05:27 -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
Scott Baker171d35e2016-06-20 17:36:29 -070017---
18- hosts: {{ instance_name }}
19 #gather_facts: False
20 connection: ssh
21 user: ubuntu
Sapan Bhatia77a52f12017-02-07 11:32:57 -080022 become: yes
Scott Baker171d35e2016-06-20 17:36:29 -070023 vars:
24 container_name: {{ container_name }}
Scott Baker171d35e2016-06-20 17:36:29 -070025 scope: {{ scope }}
26 test: {{ test }}
27 argument: {{ argument }}
28 result_fn: {{ result_fn }}
29 resultcode_fn: {{ resultcode_fn }}
30
31
32 tasks:
33 - name: Remove any old result file
34 shell: rm -f /tmp/{{ result_fn }}
35
36 - name: Copy run_tcpdump.sh to VM
37 copy: src=/opt/xos/synchronizers/vtr/files/run_tcpdump.sh dest=/root/run_tcpdump.sh mode=0755
38 when: (test=="tcpdump")
39
40
41# -----------------
42# scope == VM
43# -----------------
44
45 - name: Send the pings from VM
46 shell: ping -c 10 {{ argument }} 2>&1 > /tmp/{{ result_fn }}
47 ignore_errors: yes
48 register: vm_ping_result
49 when: (scope=="vm") and (test=="ping")
50
51 - name: Store VM ping resultcode to file
52 shell: echo "{{ '{{' }} vm_ping_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
53 when: (scope=="vm") and (test=="ping")
54
55 - name: Install traceroute
56 apt: name=traceroute state=present
57 when: (scope=="vm") and (test=="traceroute")
58
59 - name: Send traceroute from VM
60 shell: traceroute {{ argument }} 2>&1 > /tmp/{{ result_fn }}
61 ignore_errors: yes
62 register: vm_traceroute_result
63 when: (scope=="vm") and (test=="traceroute")
64
65 - name: Store VM traceroute resultcode to file
66 shell: echo "{{ '{{' }} vm_traceroute_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
67 when: (scope=="vm") and (test=="traceroute")
68
Scott Baker4efbe562016-09-30 16:06:19 -070069 - name: Run tcpdump for 10 seconds on VM
Scott Baker171d35e2016-06-20 17:36:29 -070070 shell: /root/run_tcpdump.sh {{ argument }} 2>&1 > /tmp/{{ result_fn }}
71 ignore_errors: yes
72 register: vm_tcpdump_result
73 when: (scope=="vm") and (test=="tcpdump")
74
75 - name: Store VM tcpdump resultcode to file
76 shell: echo "{{ '{{' }} vm_tcpdump_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
77 when: (scope=="vm") and (test=="tcpdump")
78
79# ------------------
80# scope == container
81# ------------------
82
83 - name: Send the pings from Container
84 shell: docker exec {{ container_name }} ping -c 10 {{ argument }} 2>&1 > /tmp/{{ result_fn }}
85 ignore_errors: yes
86 register: ctr_ping_result
87 when: (scope=="container") and (test=="ping")
88
89 - name: Store ctr ping resultcode to file
90 shell: echo "{{ '{{' }} ctr_ping_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
91 when: (scope=="container") and (test=="ping")
92
Scott Baker3a5b8e12017-03-31 14:22:20 -070093 - name: Checking memory utilization
94 shell: docker exec {{ container_name }} free {{ '-m' if argument== 'mb' else '-h' }} 2>&1 > /tmp/{{ result_fn }}
95 ignore_errors: yes
96 register: ctr_memory_result
97 when: (scope=="container") and (test=="memory")
98
99 - name: Store container health resultcode to file
100 shell: echo "{{ '{{' }} ctr_memory_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
101 when: (scope=="container") and (test=="memory")
102
103 - name: Install iperf into Host vm
104 shell: apt-get -y install iperf
105 when: (scope=="container") and (test=="bandwidth")
106
107 - name: Install iperf into Container
108 shell: docker exec {{ container_name }} apt-get -y install iperf
109 when: (scope=="container") and (test=="bandwidth")
110
111 - name: Starting the iperf server in Host vm for uplink_upload
112 shell: iperf -s -u
113 async: 10
114 poll: 0
115 when: (scope=="container") and (test=="bandwidth") and (argument=="uplink_upload")
116
117 - name: Starting the iperf client in vsg container for uplink_upload
118 shell: docker exec {{ container_name }} iperf -c {{ wan_vm_ip }} -u -b 1000M 2>&1 > /tmp/{{ result_fn }}
119 ignore_errors: yes
120 register: ctr_bw_upload_result
121 when: (scope=="container") and (test=="bandwidth") and (argument=="uplink_upload")
122
123 - name: Starting the iperf server in vsg container for uplink_download
124 shell: docker exec {{ container_name }} iperf -s -u
125 async: 10
126 poll: 0
127 when: (scope=="container") and (test=="bandwidth") and (argument=="uplink_download")
128
129 - name: Starting the iperf client in the host vm for uplink_download
130 shell: iperf -c {{ wan_container_ip }} -u -b 1000M 2>&1 > /tmp/{{ result_fn }}
131 ignore_errors: yes
132 register: ctr_bw_download_result
133 when: (scope=="container") and (test=="bandwidth") and (argument=="uplink_download")
134
135 - name: Uninstall iperf from Container
136 shell: docker exec {{ container_name }} apt-get -y remove iperf
137 when: (scope=="container") and (test=="bandwidth")
138
139 - name: Store upload bandwidth resultcode to file
140 shell: echo "{{ '{{' }} ctr_bw_upload_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
141 when: (scope=="container") and (test=="bandwidth") and (argument=="uplink_upload")
142
143 - name: Store download bandwidth resultcode to file
144 shell: echo "{{ '{{' }} ctr_bw_download_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
145 when: (scope=="container") and (test=="bandwidth") and (argument=="uplink_download")
146
Scott Baker171d35e2016-06-20 17:36:29 -0700147 - name: Install traceroute into Container
148 shell: docker exec {{ container_name }} apt-get -y install traceroute
149 when: (scope=="container") and (test=="traceroute")
150
151 - name: Send traceroute from Container
152 shell: docker exec {{ container_name }} traceroute {{ argument }} 2>&1 > /tmp/{{ result_fn }}
153 ignore_errors: yes
154 register: ctr_traceroute_result
155 when: (scope=="container") and (test=="traceroute")
156
157 - name: Store ctr traceroute resultcode to file
158 shell: echo "{{ '{{' }} ctr_traceroute_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
159 when: (scope=="container") and (test=="traceroute")
160
161 - name: Copy run_tcpdump.sh to container
162 command: docker cp /root/run_tcpdump.sh {{ container_name }}:/root/run_tcpdump.sh
163 when: (scope=="container") and (test=="tcpdump")
164
Scott Baker4efbe562016-09-30 16:06:19 -0700165 - name: Run tcpdump for 10 seconds from Container
Scott Baker171d35e2016-06-20 17:36:29 -0700166 shell: docker exec {{ container_name }} /root/run_tcpdump.sh {{ argument }} 2>&1 > /tmp/{{ result_fn }}
167 ignore_errors: yes
Scott Baker4efbe562016-09-30 16:06:19 -0700168 register: ctr_tcpdump_result
Scott Baker171d35e2016-06-20 17:36:29 -0700169 when: (scope=="container") and (test=="tcpdump")
170
171 - name: Store ctr tcpdump resultcode to file
172 shell: echo "{{ '{{' }} ctr_tcpdump_result.rc {{ '}}' }}" > /tmp/{{ resultcode_fn }}
173 when: (scope=="container") and (test=="tcpdump")
174
175# ------------------
176# scope == *
177# ------------------
178 - name: Fetch the result
179 fetch: src=/tmp/{{ result_fn }} dest=/opt/xos/synchronizers/vtr/result/{{ result_fn }} flat=yes
180
181 - name: Fetch the resultcode
182 fetch: src=/tmp/{{ resultcode_fn }} dest=/opt/xos/synchronizers/vtr/result/{{ resultcode_fn }} flat=yes
183
184
185
186