1 # Copyright (c) 2017 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to deal
5 # in the Software without restriction, including without limitation the rights
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 # copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
10 # The above copyright notice and this permission notice shall be included in all
11 # copies or substantial portions of the Software.
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 from flaky
import flaky
29 import lttng_ivc
.utils
.ProjectFactory
as ProjectFactory
30 import lttng_ivc
.utils
.utils
as utils
31 import lttng_ivc
.utils
.runtime
as Run
32 import lttng_ivc
.settings
as Settings
35 TODO: Add Command header section
39 First member: babeltrace label
40 Second member: tools label
43 pytest
.param("babeltrace-1.3", "lttng-tools-2.7", marks
=pytest
.mark
.xfail(reason
="Flaky test or Flaky babeltrace. Is under investigation")),
44 pytest
.param("babeltrace-1.3", "lttng-tools-2.8", marks
=pytest
.mark
.xfail(reason
="Flaky test or Flaky babeltrace. Is under investigation")),
45 pytest
.param("babeltrace-1.3", "lttng-tools-2.9", marks
=pytest
.mark
.xfail(reason
="Flaky test or Flaky babeltrace. Is under investigation")),
46 pytest
.param("babeltrace-1.3", "lttng-tools-2.10", marks
=pytest
.mark
.xfail(reason
="Flaky test or Flaky babeltrace. Is under investigation")),
47 ("babeltrace-1.4", "lttng-tools-2.7"),
48 ("babeltrace-1.4", "lttng-tools-2.8"),
49 ("babeltrace-1.4", "lttng-tools-2.9"),
50 ("babeltrace-1.4", "lttng-tools-2.10"),
51 ("babeltrace-1.5", "lttng-tools-2.7"),
52 ("babeltrace-1.5", "lttng-tools-2.8"),
53 ("babeltrace-1.5", "lttng-tools-2.9"),
54 ("babeltrace-1.5", "lttng-tools-2.10"),
57 runtime_matrix_live
= []
59 if not Settings
.test_only
:
60 runtime_matrix_live
= test_matrix_live
62 for tup
in test_matrix_live
:
63 if (tup
[0] in Settings
.test_only
or tup
[1] in
65 runtime_matrix_live
.append(tup
)
68 @flaky(max_runs
=10, min_passes
=3)
69 @pytest.mark
.parametrize("babeltrace_l,tools_l", runtime_matrix_live
)
70 def test_babeltrace_live(tmpdir
, babeltrace_l
, tools_l
):
73 nb_expected_events
= 100
75 babeltrace
= ProjectFactory
.get_precook(babeltrace_l
)
76 tools
= ProjectFactory
.get_precook(tools_l
)
78 runtime_path
= os
.path
.join(str(tmpdir
), "runtime")
79 app_path
= os
.path
.join(str(tmpdir
), "app")
80 session_name
= "trace"
82 with Run
.get_runtime(runtime_path
) as runtime
:
83 runtime
.add_project(tools
)
84 runtime
.add_project(babeltrace
)
86 shutil
.copytree(Settings
.apps_gen_events_folder
, app_path
)
87 runtime
.run("make V=1", cwd
=app_path
)
89 relayd
, ctrl_port
, data_port
, live_port
= utils
.relayd_spawn(runtime
)
90 sessiond
= utils
.sessiond_spawn(runtime
)
92 hostname
= socket
.gethostname()
93 url_babeltrace
= "net://localhost:{}/host/{}/{}".format(live_port
, hostname
, session_name
)
94 url
= "net://localhost:{}:{}".format(ctrl_port
, data_port
)
96 # Create session using mi to get path and session name
97 runtime
.run('lttng create --set-url={} {} --live'.format(url
, session_name
))
99 runtime
.run('lttng enable-event -u tp:tptest')
101 # From now on babeltrace should be able to hook itself up.
102 # Synchronization point is done via relayd log
103 p_babeltrace
= runtime
.spawn_subprocess("babeltrace -i lttng-live {}".format(url_babeltrace
))
105 # TODO: Move to settings
107 # TODO: Move to settings
108 # Make sure that babeltrace did hook itself or at least tried to.
109 synchro_text
= "Version check done using protocol"
111 for i
in range(timeout
):
112 log
= runtime
.get_subprocess_stderr_path(relayd
)
113 if utils
.file_contains(log
, synchro_text
):
119 raise Exception("Babeltrace live is not listening after timeout")
121 runtime
.run('lttng start')
124 cmd
= './app {}'.format(nb_loop
)
125 runtime
.run(cmd
, cwd
=app_path
)
128 runtime
.run('lttng stop')
129 runtime
.run('lttng destroy -a')
131 # Make sure babeltrace is done reading
132 runtime
.subprocess_wait(p_babeltrace
)
134 runtime
.subprocess_terminate(sessiond
)
135 runtime
.subprocess_terminate(relayd
)
137 # Check the output from babeltrace
138 cp_out
= runtime
.get_subprocess_stdout_path(p_babeltrace
)
139 assert(utils
.line_count(cp_out
) == nb_expected_events
)
This page took 0.038155 seconds and 5 git commands to generate.