9 import lttng_ivc
.utils
.ProjectFactory
as ProjectFactory
10 import lttng_ivc
.utils
.utils
as utils
11 import lttng_ivc
.utils
.runtime
as Run
12 import lttng_ivc
.settings
as Settings
15 TODO: Add Command header section
19 TODO: snapshot, file rotation, rotate
23 First member: relayd via lttng-tools
24 Second member: consumerd via lttng-tools
26 test_matrix_streaming_base
= [
27 ("lttng-tools-2.7", "lttng-tools-2.7", True),
28 ("lttng-tools-2.7", "lttng-tools-2.8", True),
29 ("lttng-tools-2.7", "lttng-tools-2.9", True),
30 ("lttng-tools-2.7", "lttng-tools-2.10", True),
31 ("lttng-tools-2.8", "lttng-tools-2.7", True),
32 ("lttng-tools-2.8", "lttng-tools-2.8", True),
33 ("lttng-tools-2.8", "lttng-tools-2.9", True),
34 ("lttng-tools-2.8", "lttng-tools-2.10", True),
35 ("lttng-tools-2.9", "lttng-tools-2.7", True),
36 ("lttng-tools-2.9", "lttng-tools-2.8", True),
37 ("lttng-tools-2.9", "lttng-tools-2.9", True),
38 ("lttng-tools-2.9", "lttng-tools-2.10", True),
39 ("lttng-tools-2.10", "lttng-tools-2.7", True),
40 ("lttng-tools-2.10", "lttng-tools-2.8", True),
41 ("lttng-tools-2.10", "lttng-tools-2.9", True),
42 ("lttng-tools-2.10", "lttng-tools-2.10", True),
45 test_matrix_streaming_regenerate_metadata
= [
46 ("lttng-tools-2.7", "lttng-tools-2.7", "metadata regenerate", "Unsupported by tools"),
47 ("lttng-tools-2.7", "lttng-tools-2.8", "metadata regenerate", "Unsupported by relayd"),
48 ("lttng-tools-2.7", "lttng-tools-2.9", "regenerate metadata", "Unsupported by relayd"),
49 ("lttng-tools-2.7", "lttng-tools-2.10", "regenerate metadata", "Unsupported by relayd"),
50 ("lttng-tools-2.8", "lttng-tools-2.7", "metadata regenerate", "Unsupported by tools"),
51 ("lttng-tools-2.8", "lttng-tools-2.8", "metadata regenerate", "Supported"),
52 ("lttng-tools-2.8", "lttng-tools-2.9", "regenerate metadata", "Supported"),
53 ("lttng-tools-2.8", "lttng-tools-2.10", "regenerate metadata", "Supported"),
54 ("lttng-tools-2.9", "lttng-tools-2.7", "metadata regenerate", "Unsupported by tools"),
55 ("lttng-tools-2.9", "lttng-tools-2.8", "metadata regenerate", "Supported"),
56 ("lttng-tools-2.9", "lttng-tools-2.9", "regenerate metadata", "Supported"),
57 ("lttng-tools-2.9", "lttng-tools-2.10", "regenerate metadata", "Supported"),
58 ("lttng-tools-2.10", "lttng-tools-2.7", "metadata regenerate", "Unsupported by tools"),
59 ("lttng-tools-2.10", "lttng-tools-2.8", "metadata regenerate", "Supported"),
60 ("lttng-tools-2.10", "lttng-tools-2.9", "regenerate metadata", "Supported"),
61 ("lttng-tools-2.10", "lttng-tools-2.10", "regenerate metadata", "Supported"),
64 test_matrix_live_base
= [
65 ("lttng-tools-2.7", "lttng-tools-2.7", True),
66 ("lttng-tools-2.7", "lttng-tools-2.8", True),
67 ("lttng-tools-2.7", "lttng-tools-2.9", True),
68 ("lttng-tools-2.7", "lttng-tools-2.10", True),
69 ("lttng-tools-2.8", "lttng-tools-2.7", True),
70 ("lttng-tools-2.8", "lttng-tools-2.8", True),
71 ("lttng-tools-2.8", "lttng-tools-2.9", True),
72 ("lttng-tools-2.8", "lttng-tools-2.10", True),
73 ("lttng-tools-2.9", "lttng-tools-2.7", True),
74 ("lttng-tools-2.9", "lttng-tools-2.8", True),
75 ("lttng-tools-2.9", "lttng-tools-2.9", True),
76 ("lttng-tools-2.9", "lttng-tools-2.10", True),
77 ("lttng-tools-2.10", "lttng-tools-2.7", True),
78 ("lttng-tools-2.10", "lttng-tools-2.8", True),
79 ("lttng-tools-2.10", "lttng-tools-2.9", True),
80 ("lttng-tools-2.10", "lttng-tools-2.10", True),
83 runtime_matrix_streaming_base
= []
84 runtime_matrix_streaming_regenerate_metadata
= []
85 runtime_matrix_live_base
= []
87 if not Settings
.test_only
:
88 runtime_matrix_streaming_base
= test_matrix_streaming_base
89 runtime_matrix_streaming_regenerate_metadata
= test_matrix_streaming_regenerate_metadata
90 runtime_matrix_live_base
= test_matrix_live_base
92 for tup
in test_matrix_streaming_base
:
93 if (tup
[0] in Settings
.test_only
or tup
[1] in
95 runtime_matrix_streaming_base
.append(tup
)
96 for tup
in test_matrix_streaming_regenerate_metadata
:
97 if (tup
[0] in Settings
.test_only
or tup
[1] in
99 runtime_matrix_streaming_regenerate_metadata
.append(tup
)
100 for tup
in test_matrix_live_base
:
101 if (tup
[0] in Settings
.test_only
or tup
[1] in
103 runtime_matrix_live_base
.append(tup
)
105 @pytest.mark
.parametrize("relayd_label,consumerd_label,scenario", runtime_matrix_streaming_base
)
106 def test_relayd_vs_consumerd_streaming_base(tmpdir
, relayd_label
, consumerd_label
, scenario
):
109 nb_expected_events
= 100
111 # Prepare environment
112 relayd
= ProjectFactory
.get_precook(relayd_label
)
113 consumerd
= ProjectFactory
.get_precook(consumerd_label
)
114 babeltrace
= ProjectFactory
.get_precook(Settings
.default_babeltrace
)
116 relayd_runtime_path
= os
.path
.join(str(tmpdir
), "relayd")
117 consumerd_runtime_path
= os
.path
.join(str(tmpdir
), "consumerd")
118 app_path
= os
.path
.join(str(tmpdir
), "app")
120 with Run
.get_runtime(relayd_runtime_path
) as runtime_relayd
, Run
.get_runtime(consumerd_runtime_path
) as runtime_consumerd
:
121 runtime_relayd
.add_project(relayd
)
122 runtime_relayd
.add_project(babeltrace
)
123 runtime_consumerd
.add_project(consumerd
)
125 # Make application using the ust runtime
126 shutil
.copytree(Settings
.apps_gen_events_folder
, app_path
)
127 runtime_consumerd
.run("make V=1", cwd
=app_path
)
129 # Start lttng-sessiond
130 relayd
= runtime_relayd
.spawn_subprocess('lttng-relayd -vvv')
131 # FIX: No way to know if good to go...
134 sessiond
= utils
.sessiond_spawn(runtime_consumerd
)
136 url
= "net://localhost"
138 # Create session using mi to get path and session name
139 runtime_consumerd
.run('lttng create --set-url={} trace '.format(url
))
141 runtime_consumerd
.run('lttng enable-event -u tp:tptest')
142 runtime_consumerd
.run('lttng start')
145 cmd
= './app {}'.format(nb_loop
)
146 runtime_consumerd
.run(cmd
, cwd
=app_path
)
149 runtime_consumerd
.run('lttng stop')
150 runtime_consumerd
.run('lttng destroy -a')
151 runtime_consumerd
.subprocess_terminate(sessiond
)
153 # TODO check for error.
154 runtime_relayd
.subprocess_terminate(relayd
)
157 # Read trace with babeltrace and check for event count via number of line
158 cmd
= 'babeltrace {}'.format(runtime_relayd
.lttng_home
)
159 cp_process
, cp_out
, cp_err
= runtime_relayd
.run(cmd
)
160 assert(utils
.line_count(cp_out
) == nb_expected_events
)
163 @pytest.mark
.parametrize("relayd_label,consumerd_label,command, scenario", runtime_matrix_streaming_regenerate_metadata
)
164 def test_relayd_vs_consumerd_streaming_regenerate_metadata(tmpdir
, relayd_label
, consumerd_label
, command
, scenario
):
167 nb_expected_events
= 100
169 # Prepare environment
170 relayd
= ProjectFactory
.get_precook(relayd_label
)
171 consumerd
= ProjectFactory
.get_precook(consumerd_label
)
172 babeltrace
= ProjectFactory
.get_precook(Settings
.default_babeltrace
)
174 relayd_runtime_path
= os
.path
.join(str(tmpdir
), "relayd")
175 consumerd_runtime_path
= os
.path
.join(str(tmpdir
), "consumerd")
176 app_path
= os
.path
.join(str(tmpdir
), "app")
179 with Run
.get_runtime(relayd_runtime_path
) as runtime_relayd
, Run
.get_runtime(consumerd_runtime_path
) as runtime_consumerd
:
180 runtime_relayd
.add_project(relayd
)
181 runtime_relayd
.add_project(babeltrace
)
182 runtime_consumerd
.add_project(consumerd
)
184 babeltrace_cmd
= 'babeltrace {}'.format(runtime_relayd
.lttng_home
)
186 # Make application using the ust runtime
187 shutil
.copytree(Settings
.apps_gen_events_folder
, app_path
)
188 runtime_consumerd
.run("make V=1", cwd
=app_path
)
190 # Start lttng-sessiond
191 relayd
= runtime_relayd
.spawn_subprocess('lttng-relayd -vvv')
192 # FIX: No way to know if good to go...
195 sessiond
= utils
.sessiond_spawn(runtime_consumerd
)
197 url
= "net://localhost"
199 # Create session using mi to get path and session name
200 runtime_consumerd
.run('lttng create --set-url={} trace '.format(url
))
202 runtime_consumerd
.run('lttng enable-event -u tp:tptest')
203 runtime_consumerd
.run('lttng start')
206 cmd
= './app {}'.format(nb_loop
)
207 runtime_consumerd
.run(cmd
, cwd
=app_path
)
210 runtime_consumerd
.run('lttng stop')
212 # Empty the metadata file
213 metadata
= utils
.find_file(runtime_relayd
.lttng_home
, "metadata")
214 open(metadata
, 'w').close()
216 # Babeltrace should never be able to parse the trace
217 with pytest
.raises(subprocess
.CalledProcessError
):
218 runtime_relayd
.run(babeltrace_cmd
)
220 runtime_consumerd
.run("lttng start")
222 # TODO: rework this a bit to differentiate each errors and rework how
223 # the condition are meet
224 if scenario
== "Unsupported by tools" or scenario
== "Unsupported by relayd":
225 with pytest
.raises(subprocess
.CalledProcessError
):
226 runtime_consumerd
.run("lttng {}".format(command
))
228 # Make sure everything looks good on this side
229 sessiond
= runtime_consumerd
.subprocess_terminate(sessiond
)
230 if sessiond
.returncode
!= 0:
231 pytest
.fail("Return value of sessiond is not zero")
232 relayd
= runtime_relayd
.subprocess_terminate(relayd
)
233 if relayd
.returncode
!= 0:
234 pytest
.fail("Return value of relayd is not zero")
237 runtime_consumerd
.run("lttng {}".format(command
))
239 runtime_consumerd
.run('lttng stop')
240 runtime_consumerd
.run('lttng destroy -a')
242 # Make sure everything looks good
243 sessiond
= runtime_consumerd
.subprocess_terminate(sessiond
)
244 if sessiond
.returncode
!= 0:
245 pytest
.fail("Return value of sessiond is not zero")
246 relayd
= runtime_relayd
.subprocess_terminate(relayd
)
247 if relayd
.returncode
!= 0:
248 pytest
.fail("Return value of relayd is not zero")
250 # Read trace with babeltrace and check for event count via number of line
251 cp_process
, cp_out
, cp_err
= runtime_relayd
.run(babeltrace_cmd
)
252 assert(utils
.line_count(cp_out
) == nb_expected_events
)
254 @pytest.mark
.parametrize("relayd_label,consumerd_label,scenario", runtime_matrix_streaming_base
)
255 def test_relayd_vs_consumerd_live_base(tmpdir
, relayd_label
, consumerd_label
, scenario
):
258 nb_expected_events
= 100
260 # Prepare environment
261 relayd
= ProjectFactory
.get_precook(relayd_label
)
262 consumerd
= ProjectFactory
.get_precook(consumerd_label
)
263 babeltrace
= ProjectFactory
.get_precook(Settings
.default_babeltrace
)
265 relayd_runtime_path
= os
.path
.join(str(tmpdir
), "relayd")
266 consumerd_runtime_path
= os
.path
.join(str(tmpdir
), "consumerd")
267 app_path
= os
.path
.join(str(tmpdir
), "app")
269 with Run
.get_runtime(relayd_runtime_path
) as runtime_relayd
, Run
.get_runtime(consumerd_runtime_path
) as runtime_consumerd
:
270 runtime_relayd
.add_project(relayd
)
271 runtime_relayd
.add_project(babeltrace
)
272 runtime_consumerd
.add_project(consumerd
)
274 # Make application using the ust runtime
275 shutil
.copytree(Settings
.apps_gen_events_folder
, app_path
)
276 runtime_consumerd
.run("make V=1", cwd
=app_path
)
278 # Start lttng-sessiond
279 relayd
= runtime_relayd
.spawn_subprocess('lttng-relayd -vvv')
280 # FIX: No way to know if good to go...
283 sessiond
= utils
.sessiond_spawn(runtime_consumerd
)
285 url
= "net://localhost"
287 # Create session using mi to get path and session name
288 runtime_consumerd
.run('lttng create --live --set-url={} trace '.format(url
))
290 runtime_consumerd
.run('lttng enable-event -u tp:tptest')
291 runtime_consumerd
.run('lttng start')
294 cmd
= './app {}'.format(nb_loop
)
295 runtime_consumerd
.run(cmd
, cwd
=app_path
)
298 runtime_consumerd
.run('lttng stop')
299 runtime_consumerd
.run('lttng destroy -a')
300 runtime_consumerd
.subprocess_terminate(sessiond
)
302 # TODO check for error.
303 runtime_relayd
.subprocess_terminate(relayd
)
306 # Read trace with babeltrace and check for event count via number of line
307 cmd
= 'babeltrace {}'.format(runtime_relayd
.lttng_home
)
308 cp_process
, cp_out
, cp_err
= runtime_relayd
.run(cmd
)
309 assert(utils
.line_count(cp_out
) == nb_expected_events
)