-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_experiment.yml
148 lines (126 loc) · 4.04 KB
/
run_experiment.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
---
- name: Restart Serverledge
hosts:
- sedge_Edge
- sedge_Cloud
tasks:
- include_tasks:
file: tasks/restart_serverledge.yml
- name: Install CPU monitoring script
ansible.builtin.copy:
src: monitorCPU.sh
dest: "{{ ansible_env.HOME }}"
mode: '0755'
- name: Install CPU monitoring service
ansible.builtin.template:
src: monitorCPU.service.j2
dest: /etc/systemd/system/monitorCPU.service
owner: root
group: root
become: yes
register: monitor_service
- name: Reload systemd
ansible.builtin.systemd:
daemon_reload: yes
become: yes
when: monitor_service.changed
- name: Start systemd service
ansible.builtin.systemd:
name: monitorCPU
state: restarted
become: yes
- name: Quick benchmark
hosts:
- sedge_Client
vars:
func_name: myFunction # must match with the testplan
func_mem: 128
func_cpu: 1.0
func_runtime: nodejs17ng
func_handler: sieve.js
func_src: sieve.js
testplan: jmeter/testplanClosed.jmx
users: 3
local_results_file: results.csv
local_responses_file: responses.tar.gz
tasks:
- name: Install JMeter
include_role:
role: jmeter
vars:
jmeter_home: "{{ ansible_env.HOME }}"
- name: Install serverledge-cli
include_role:
role: serverledge
vars:
deploy_cli_only: true
- ansible.builtin.copy:
src: files/sleep.py
dest: "{{ ansible_env.HOME }}/sleep.py"
- ansible.builtin.copy:
src: files/sieve.js
dest: "{{ ansible_env.HOME }}/sieve.js"
- ansible.builtin.shell: "./serverledge-cli delete -f {{ func_name }}"
ignore_errors: True
environment:
SERVERLEDGE_HOST: '{{ groups["sedge_Edge"][0] }}'
#- ansible.builtin.shell: "./serverledge-cli create -f myFunction --memory 128 --cpu 1.0 --src sieve.js --runtime nodejs17ng --handler sieve.js"
# environment:
# SERVERLEDGE_HOST: '{{ groups["sedge_Edge"][0] }}'
- ansible.builtin.shell: "./serverledge-cli create -f {{ func_name }} --memory {{ func_mem }} --cpu {{ func_cpu }} --src {{ func_src }} --runtime {{ func_runtime }} --handler {{ func_handler }}"
environment:
SERVERLEDGE_HOST: '{{ groups["sedge_Edge"][0] }}'
- name: Copy testplan
ansible.builtin.copy:
src: "{{ testplan }}"
dest: ./testplan.jmx
- name: Clean previous results
ansible.builtin.shell: "rm /tmp/jmeter*"
ignore_errors: True
- name: Clean previous responses
ansible.builtin.shell: "find . -name 'jmeterResponse_*' -delete"
ignore_errors: True
- name: Stop any running Jmeter instance
ansible.builtin.shell: "pgrep jmeter | xargs kill -TERM"
ignore_errors: True
- name: Start
ansible.builtin.shell: "{{ ansible_env.HOME }}/apache-jmeter-5.5/bin/jmeter -n -t ./testplan.jmx -l /tmp/jmeter_results -Jhost={{ groups['sedge_Edge'][0] }} -Jusers={{ users }}"
async: 900
poll: 20
register: jmeter_out
- name: Zip Response files
community.general.archive:
path:
- jmeterResponse_*
dest: /tmp/jmeter_responses.tar.gz
format: gz
remove: yes
- name: Copy results
ansible.builtin.fetch:
src: /tmp/jmeter_results
dest: "{{ local_results_file }}"
flat: yes
- name: Copy responses
ansible.builtin.fetch:
src: /tmp/jmeter_responses.tar.gz
dest: "{{ local_responses_file }}"
flat: yes
- debug:
var: jmeter_out.stdout_lines
- name: Get monitoring data
hosts:
- sedge_Edge
- sedge_Cloud
vars:
local_output_dir: "."
tasks:
- name: Stop systemd service
ansible.builtin.systemd:
name: monitorCPU
state: stopped
become: yes
- name: Copy monitoring data
ansible.builtin.fetch:
src: "{{ ansible_env.HOME }}/cpuUsage.txt"
dest: "{{ local_output_dir }}/cpuUsage-{{ ansible_hostname }}.txt"
flat: yes