| 1 | import pytest |
| 2 | import subprocess |
| 3 | import platform |
| 4 | import shutil |
| 5 | import os |
| 6 | |
| 7 | import lttng_ivc.utils.ProjectFactory as ProjectFactory |
| 8 | import lttng_ivc.utils.utils as utils |
| 9 | import lttng_ivc.utils.runtime as Run |
| 10 | import lttng_ivc.settings as Settings |
| 11 | |
| 12 | """ |
| 13 | FC: Fully Compatible |
| 14 | I: Incompatible |
| 15 | |
| 16 | +------------------------------------------------------------------------------+ |
| 17 | | LTTng consumer daemon vs LTTng session daemon | |
| 18 | +--------------------------+------------+------------+------------+------------+ |
| 19 | | Consumerd/Sessiond | 2.7 | 2.8 | 2.9 | 2.10 | |
| 20 | +--------------------------+------------+------------+------------+------------+ |
| 21 | | 2.7 | FC | I | I | I | |
| 22 | | 2.8 | I | FC | I | I | |
| 23 | | 2.9 | I | I | FC | I | |
| 24 | | 2.10 | I | I | I | FC | |
| 25 | +--------------------------+------------+------------+------------+------------+ |
| 26 | |
| 27 | """ |
| 28 | |
| 29 | test_matrix_consumerd = [ |
| 30 | ("lttng-tools-2.7", "lttng-tools-2.7", True), |
| 31 | ("lttng-tools-2.7", "lttng-tools-2.8", False), |
| 32 | ("lttng-tools-2.7", "lttng-tools-2.9", False), |
| 33 | ("lttng-tools-2.7", "lttng-tools-2.10", False), |
| 34 | ("lttng-tools-2.8", "lttng-tools-2.7", False), |
| 35 | ("lttng-tools-2.8", "lttng-tools-2.8", True), |
| 36 | ("lttng-tools-2.8", "lttng-tools-2.9", True), |
| 37 | ("lttng-tools-2.8", "lttng-tools-2.10", False), |
| 38 | ("lttng-tools-2.9", "lttng-tools-2.7", False), |
| 39 | ("lttng-tools-2.9", "lttng-tools-2.8", True), |
| 40 | ("lttng-tools-2.9", "lttng-tools-2.9", True), |
| 41 | ("lttng-tools-2.9", "lttng-tools-2.10", False), |
| 42 | ("lttng-tools-2.10", "lttng-tools-2.7", False), |
| 43 | ("lttng-tools-2.10", "lttng-tools-2.8", False), |
| 44 | ("lttng-tools-2.10", "lttng-tools-2.9", False), |
| 45 | ("lttng-tools-2.10", "lttng-tools-2.10", True), |
| 46 | ] |
| 47 | |
| 48 | runtime_matrix_consumerd = [] |
| 49 | |
| 50 | if not Settings.test_only: |
| 51 | runtime_matrix_consumerd = test_matrix_consumerd |
| 52 | else: |
| 53 | for tup in test_matrix_consumerd: |
| 54 | if (tup[0] in Settings.test_only or tup[1] in |
| 55 | Settings.test_only): |
| 56 | runtime_matrix_consumerd.append(tup) |
| 57 | |
| 58 | |
| 59 | @pytest.mark.parametrize("consumerd_l,tools_l,should_work", runtime_matrix_consumerd) |
| 60 | def test_consumerd_vs_sessiond(tmpdir, consumerd_l, tools_l, should_work): |
| 61 | """ |
| 62 | Scenario: |
| 63 | Point a lttng-tools to a consumerd of another version and see what |
| 64 | happen. We do not expect anything good to come out of this since for |
| 65 | now lttng-tools(2.10) no versioning exist between sessiond and |
| 66 | consumerd. |
| 67 | """ |
| 68 | |
| 69 | nb_event = 100; |
| 70 | |
| 71 | consumerd = ProjectFactory.get_precook(consumerd_l) |
| 72 | tools = ProjectFactory.get_precook(tools_l) |
| 73 | babeltrace = ProjectFactory.get_precook(Settings.default_babeltrace) |
| 74 | |
| 75 | app_path = os.path.join(str(tmpdir), "app") |
| 76 | |
| 77 | replacement_consumerd = utils.find_file(consumerd.installation_path, "lttng-consumerd") |
| 78 | assert(replacement_consumerd) |
| 79 | |
| 80 | c_dict = {"32bit": "--consumerd32-path", "64bit": "--consumerd64-path"} |
| 81 | platform_type = platform.architecture()[0] |
| 82 | |
| 83 | sessiond_opt_args = "{}={}".format(c_dict[platform_type], replacement_consumerd) |
| 84 | |
| 85 | with Run.get_runtime(str(tmpdir)) as runtime: |
| 86 | runtime.add_project(tools) |
| 87 | runtime.add_project(babeltrace) |
| 88 | |
| 89 | shutil.copytree(Settings.apps_gen_events_folder, app_path) |
| 90 | runtime.run("make V=1", cwd=app_path) |
| 91 | |
| 92 | utils.sessiond_spawn(runtime, sessiond_opt_args) |
| 93 | |
| 94 | # Consumer is only called on channel creation |
| 95 | runtime.run("lttng create") |
| 96 | try: |
| 97 | runtime.run("lttng enable-event -u tp:tptest", timeout=5) |
| 98 | runtime.run("lttng start", timeout=5) |
| 99 | |
| 100 | # Run application |
| 101 | cmd = './app {}'.format(100) |
| 102 | runtime.run(cmd, cwd=app_path) |
| 103 | |
| 104 | runtime.run("lttng stop", timeout=5) |
| 105 | runtime.run("lttng destroy -a", timeout=5) |
| 106 | cp, cp_out, cp_err = runtime.run("babeltrace {}".format(runtime.lttng_home)) |
| 107 | assert(utils.line_count(cp_out) == nb_event) |
| 108 | except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as e: |
| 109 | if should_work: |
| 110 | raise e |
| 111 | else: |
| 112 | # Expecting some error |
| 113 | return |
| 114 | if not should_work: |
| 115 | raise Exception("Supposed to fail") |