def test_consumerd_vs_sessiond(tmpdir, consumerd_l, tools_l, should_work): """ Scenario: Point a lttng-tools to a consumerd of another version and see what happen. We do not expect anything good to come out of this since for now lttng-tools(2.10) no versionning exist between sessiond and consumerd. """ nb_event = 100 consumerd = ProjectFactory.get_precook(consumerd_l) tools = ProjectFactory.get_precook(tools_l) babeltrace = ProjectFactory.get_precook(Settings.default_babeltrace) app_path = os.path.join(str(tmpdir), "app") replacement_consumerd = utils.find_file(consumerd.installation_path, "lttng-consumerd") assert replacement_consumerd c_dict = {"32bit": "--consumerd32-path", "64bit": "--consumerd64-path"} platform_type = platform.architecture()[0] sessiond_opt_args = "{}={}".format(c_dict[platform_type], replacement_consumerd) with Run.get_runtime(str(tmpdir)) as runtime: runtime.add_project(tools) runtime.add_project(babeltrace) shutil.copytree(Settings.apps_gen_events_folder, app_path) runtime.run("make V=1", cwd=app_path) utils.sessiond_spawn(runtime, sessiond_opt_args) # Consumer is only called on channel creation runtime.run("lttng create") try: runtime.run("lttng enable-event -u tp:tptest", timeout=5) runtime.run("lttng start", timeout=5) # Run application cmd = "./app {}".format(100) runtime.run(cmd, cwd=app_path) runtime.run("lttng stop", timeout=5) runtime.run("lttng destroy -a", timeout=5) cp, cp_out, cp_err = runtime.run("babeltrace {}".format( runtime.lttng_home)) assert utils.line_count(cp_out) == nb_event except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as e: if should_work: raise e else: # Expecting some error return if not should_work: raise Exception("Supposed to fail")
def __init__(self, label, git_path, sha1, tmpdir): super(Lttng_tools, self).__init__(label=label, git_path=git_path, sha1=sha1, tmpdir=tmpdir) self.add_special_env_variable("LTTNG_SESSION_CONFIG_XSD_PATH", os.path.join(self.installation_path, "share/xml/lttng/")) # Find the mi xsd for xsd in Settings.mi_xsd_file_name: mi = find_file(self.source_path, xsd) if mi: break if not mi: raise Exception("MI xsd not found") self.mi_xsd = mi
def test_relayd_vs_consumerd_streaming_regenerate_metadata( tmpdir, relayd_label, consumerd_label, command, scenario): nb_loop = 100 nb_expected_events = 100 # Prepare environment relayd = ProjectFactory.get_precook(relayd_label) consumerd = ProjectFactory.get_precook(consumerd_label) babeltrace = ProjectFactory.get_precook(Settings.default_babeltrace) relayd_runtime_path = os.path.join(str(tmpdir), "relayd") consumerd_runtime_path = os.path.join(str(tmpdir), "consumerd") app_path = os.path.join(str(tmpdir), "app") with Run.get_runtime( relayd_runtime_path) as runtime_relayd, Run.get_runtime( consumerd_runtime_path) as runtime_consumerd: runtime_relayd.add_project(relayd) runtime_relayd.add_project(babeltrace) runtime_consumerd.add_project(consumerd) babeltrace_cmd = "babeltrace {}".format(runtime_relayd.lttng_home) # Make application using the ust runtime shutil.copytree(Settings.apps_gen_events_folder, app_path) runtime_consumerd.run("make V=1", cwd=app_path) # Start lttng-relayd relayd, ctrl_port, data_port, live_port = utils.relayd_spawn( runtime_relayd) sessiond = utils.sessiond_spawn(runtime_consumerd) url = "net://localhost:{}:{}".format(ctrl_port, data_port) # Create session using mi to get path and session name runtime_consumerd.run("lttng create --set-url={} trace ".format(url)) runtime_consumerd.run("lttng enable-event -u tp:tptest") runtime_consumerd.run("lttng start") # Run application cmd = "./app {}".format(nb_loop) runtime_consumerd.run(cmd, cwd=app_path) # Stop tracing runtime_consumerd.run("lttng stop") # Empty the metadata file metadata = utils.find_file(runtime_relayd.lttng_home, "metadata") open(metadata, "w").close() # Babeltrace should never be able to parse the trace with pytest.raises(subprocess.CalledProcessError): runtime_relayd.run(babeltrace_cmd) runtime_consumerd.run("lttng start") # TODO: rework this a bit to differentiate each errors and rework how # the condition are meet if scenario in ("Unsupported by tools", "Unsupported by relayd"): with pytest.raises(subprocess.CalledProcessError): runtime_consumerd.run("lttng {}".format(command)) # Make sure everything looks good on this side sessiond = runtime_consumerd.subprocess_terminate(sessiond) if sessiond.returncode != 0: pytest.fail("Return value of sessiond is not zero") relayd = runtime_relayd.subprocess_terminate(relayd) if relayd.returncode != 0: pytest.fail("Return value of relayd is not zero") return runtime_consumerd.run("lttng {}".format(command)) runtime_consumerd.run("lttng stop") runtime_consumerd.run("lttng destroy -a") # Make sure everything looks good sessiond = runtime_consumerd.subprocess_terminate(sessiond) if sessiond.returncode != 0: pytest.fail("Return value of sessiond is not zero") relayd = runtime_relayd.subprocess_terminate(relayd) if relayd.returncode != 0: pytest.fail("Return value of relayd is not zero") # Read trace with babeltrace and check for event count via number of line cp_process, cp_out, cp_err = runtime_relayd.run(babeltrace_cmd) assert utils.line_count(cp_out) == nb_expected_events