From 26b198764c5ccbcdcf1862e7a36741ce961dede6 Mon Sep 17 00:00:00 2001 From: Konboi Date: Tue, 18 Jul 2023 10:38:01 +0900 Subject: [PATCH 1/8] Add lineage option --- launchable/commands/record/session.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/launchable/commands/record/session.py b/launchable/commands/record/session.py index 8c7642649..6aec02cd6 100644 --- a/launchable/commands/record/session.py +++ b/launchable/commands/record/session.py @@ -82,6 +82,14 @@ def _validate_session_name(ctx, param, value): metavar='SESSION_NAME', callback=_validate_session_name, ) +@click.option( + '--lineage', + 'lineage', + help='Set lineage name', + required=False, + type=str, + metavar='LINEAGE', +) @click.pass_context def session( ctx: click.core.Context, @@ -93,6 +101,7 @@ def session( links: List[str] = [], is_no_build: bool = False, session_name: Optional[str] = None, + lineage: Optional[str] = None, ): """ print_session is for backward compatibility. @@ -132,6 +141,7 @@ def session( "flavors": flavor_dict, "isObservation": is_observation, "noBuild": is_no_build, + "lineage": lineage, } _links = capture_link(os.environ) From b22234ac9085ed7103ec5431f6f18858a71d11f3 Mon Sep 17 00:00:00 2001 From: Konboi Date: Tue, 18 Jul 2023 10:41:00 +0900 Subject: [PATCH 2/8] Add lineage option to pass record session command --- launchable/commands/helper.py | 3 +++ launchable/commands/record/tests.py | 14 ++++++++++++-- launchable/commands/subset.py | 10 ++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/launchable/commands/helper.py b/launchable/commands/helper.py index f485f7690..65f75128e 100644 --- a/launchable/commands/helper.py +++ b/launchable/commands/helper.py @@ -16,6 +16,7 @@ def find_or_create_session( is_observation: bool = False, links: List[str] = [], is_no_build: bool = False, + lineage: Optional[str] = None, ) -> Optional[str]: """Determine the test session ID to be used. @@ -45,6 +46,7 @@ def find_or_create_session( is_observation=is_observation, links=links, is_no_build=is_no_build, + lineage=lineage, ) saved_build_name = read_build() return read_session(str(saved_build_name)) @@ -83,6 +85,7 @@ def find_or_create_session( is_observation=is_observation, links=links, is_no_build=is_no_build, + lineage=lineage, ) return read_session(saved_build_name) diff --git a/launchable/commands/record/tests.py b/launchable/commands/record/tests.py index 2b7d37dcb..b0ce12432 100644 --- a/launchable/commands/record/tests.py +++ b/launchable/commands/record/tests.py @@ -143,6 +143,14 @@ def _validate_group(ctx, param, value): type=str, metavar='SESSION_NAME', ) +@click.option( + '--lineage', + 'lineage', + help='Set lineage name', + required=False, + type=str, + metavar='LINEAGE', +) @click.pass_context def tests( context: click.core.Context, @@ -158,7 +166,8 @@ def tests( is_allow_test_before_build: bool, links: List[str] = [], is_no_build: bool = False, - session_name: Optional[str] = None + session_name: Optional[str] = None, + lineage: Optional[str] = None, ): logger = Logger() @@ -200,7 +209,8 @@ def tests( session=session, build_name=build_name, flavor=flavor, - links=links)) + links=links, + lineage=lineage)) build_name = read_build() record_start_at = get_record_start_at(session_id, client) diff --git a/launchable/commands/subset.py b/launchable/commands/subset.py index 7a11200f0..6ebe0feb0 100644 --- a/launchable/commands/subset.py +++ b/launchable/commands/subset.py @@ -141,6 +141,14 @@ help="If you want to only send test reports, please use this option", is_flag=True, ) +@click.option( + '--lineage', + 'lineage', + help='Set lineage name', + required=False, + type=str, + metavar='LINEAGE', +) @click.pass_context def subset( context: click.core.Context, @@ -161,6 +169,7 @@ def subset( ignore_flaky_tests_above: Optional[float], links: List[str] = [], is_no_build: bool = False, + lineage: Optional[str] = None, ): if is_observation and is_get_tests_from_previous_sessions: @@ -180,6 +189,7 @@ def subset( is_observation=is_observation, links=links, is_no_build=is_no_build, + lineage=lineage ) file_path_normalizer = FilePathNormalizer(base_path, no_base_path_inference=no_base_path_inference) From c42fde46c5d09d7b36170ab8558e82cbd9f8f6dd Mon Sep 17 00:00:00 2001 From: Konboi Date: Tue, 18 Jul 2023 10:50:12 +0900 Subject: [PATCH 3/8] add a new filed to fix test --- launchable/commands/record/session.py | 2 +- tests/commands/record/test_session.py | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/launchable/commands/record/session.py b/launchable/commands/record/session.py index 6aec02cd6..fde0011ef 100644 --- a/launchable/commands/record/session.py +++ b/launchable/commands/record/session.py @@ -141,7 +141,7 @@ def session( "flavors": flavor_dict, "isObservation": is_observation, "noBuild": is_no_build, - "lineage": lineage, + "lineage": lineage if lineage else "", } _links = capture_link(os.environ) diff --git a/tests/commands/record/test_session.py b/tests/commands/record/test_session.py index e9ea9b05a..e186bc71c 100644 --- a/tests/commands/record/test_session.py +++ b/tests/commands/record/test_session.py @@ -27,7 +27,11 @@ def test_run_session_without_flavor(self): self.assertEqual(result.exit_code, 0) payload = json.loads(responses.calls[0].request.body.decode()) - self.assert_json_orderless_equal({"flavors": {}, "isObservation": False, "links": [], "noBuild": False}, payload) + self.assert_json_orderless_equal( + {"flavors": {}, + "isObservation": False, "links": [], + "noBuild": False, "lineage": ""}, + payload) @responses.activate @mock.patch.dict(os.environ, { @@ -49,6 +53,7 @@ def test_run_session_with_flavor(self): "isObservation": False, "links": [], "noBuild": False, + "lineage": "", }, payload) with self.assertRaises(ValueError): @@ -68,7 +73,11 @@ def test_run_session_with_observation(self): payload = json.loads(responses.calls[0].request.body.decode()) - self.assert_json_orderless_equal({"flavors": {}, "isObservation": True, "links": [], "noBuild": False}, payload) + self.assert_json_orderless_equal( + {"flavors": {}, + "isObservation": True, "links": [], + "noBuild": False, "lineage": ""}, + payload) @responses.activate @mock.patch.dict(os.environ, { @@ -99,4 +108,8 @@ def test_run_session_with_session_name(self): self.assertEqual(result.exit_code, 0) payload = json.loads(responses.calls[2].request.body.decode()) - self.assert_json_orderless_equal({"flavors": {}, "isObservation": False, "links": [], "noBuild": False}, payload) + self.assert_json_orderless_equal( + {"flavors": {}, + "isObservation": False, "links": [], + "noBuild": False, "lineage": ""}, + payload) From 572079a4139c6b3eb67854d73e478d033bcd470c Mon Sep 17 00:00:00 2001 From: Konboi Date: Tue, 18 Jul 2023 13:13:32 +0900 Subject: [PATCH 4/8] add lineage tests --- tests/commands/record/test_session.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/commands/record/test_session.py b/tests/commands/record/test_session.py index e186bc71c..3d3827985 100644 --- a/tests/commands/record/test_session.py +++ b/tests/commands/record/test_session.py @@ -113,3 +113,22 @@ def test_run_session_with_session_name(self): "isObservation": False, "links": [], "noBuild": False, "lineage": ""}, payload) + + @responses.activate + @mock.patch.dict(os.environ, { + "LAUNCHABLE_TOKEN": CliTestCase.launchable_token, + 'LANG': 'C.UTF-8', + }, clear=True) + def test_run_session_with_lineage(self): + result = self.cli("record", "session", "--build", self.build_name, + "--lineage", "example-lineage") + self.assertEqual(result.exit_code, 0) + + payload = json.loads(responses.calls[0].request.body.decode()) + self.assert_json_orderless_equal({ + "flavors": {}, + "isObservation": False, + "links": [], + "noBuild": False, + "lineage": "example-lineage", + }, payload) From 588c559414a82260def6461cf6ef12a83a65a99f Mon Sep 17 00:00:00 2001 From: Konboi Date: Tue, 18 Jul 2023 16:25:30 +0900 Subject: [PATCH 5/8] Add missing args comment --- launchable/commands/helper.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/launchable/commands/helper.py b/launchable/commands/helper.py index 65f75128e..d13108dd3 100644 --- a/launchable/commands/helper.py +++ b/launchable/commands/helper.py @@ -29,6 +29,11 @@ def find_or_create_session( Args: session: The --session option value build_name: The --build option value + flavor: The --flavor option values + is_observation: The --observation value + links: The --link option values + is_no_build: The --no-build option value + lineage: lineage option value """ from .record.session import session as session_command From 2353f914efd95ec8ea6f0d540751ef159b05db07 Mon Sep 17 00:00:00 2001 From: Konboi Date: Tue, 18 Jul 2023 16:28:29 +0900 Subject: [PATCH 6/8] Fix the empty value for lineage --- launchable/commands/record/session.py | 2 +- tests/commands/record/test_session.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/launchable/commands/record/session.py b/launchable/commands/record/session.py index fde0011ef..6aec02cd6 100644 --- a/launchable/commands/record/session.py +++ b/launchable/commands/record/session.py @@ -141,7 +141,7 @@ def session( "flavors": flavor_dict, "isObservation": is_observation, "noBuild": is_no_build, - "lineage": lineage if lineage else "", + "lineage": lineage, } _links = capture_link(os.environ) diff --git a/tests/commands/record/test_session.py b/tests/commands/record/test_session.py index 3d3827985..fe0029451 100644 --- a/tests/commands/record/test_session.py +++ b/tests/commands/record/test_session.py @@ -30,7 +30,7 @@ def test_run_session_without_flavor(self): self.assert_json_orderless_equal( {"flavors": {}, "isObservation": False, "links": [], - "noBuild": False, "lineage": ""}, + "noBuild": False, "lineage": None}, payload) @responses.activate @@ -53,7 +53,7 @@ def test_run_session_with_flavor(self): "isObservation": False, "links": [], "noBuild": False, - "lineage": "", + "lineage": None, }, payload) with self.assertRaises(ValueError): @@ -76,7 +76,7 @@ def test_run_session_with_observation(self): self.assert_json_orderless_equal( {"flavors": {}, "isObservation": True, "links": [], - "noBuild": False, "lineage": ""}, + "noBuild": False, "lineage": None}, payload) @responses.activate @@ -111,7 +111,7 @@ def test_run_session_with_session_name(self): self.assert_json_orderless_equal( {"flavors": {}, "isObservation": False, "links": [], - "noBuild": False, "lineage": ""}, + "noBuild": False, "lineage": None}, payload) @responses.activate From 31210206bd89cd6a48ce5bdac92e9b999be63d49 Mon Sep 17 00:00:00 2001 From: Konboi Date: Tue, 18 Jul 2023 16:35:13 +0900 Subject: [PATCH 7/8] fix help message --- launchable/commands/record/session.py | 2 +- launchable/commands/record/tests.py | 2 +- launchable/commands/subset.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/launchable/commands/record/session.py b/launchable/commands/record/session.py index 6aec02cd6..f0b23250e 100644 --- a/launchable/commands/record/session.py +++ b/launchable/commands/record/session.py @@ -85,7 +85,7 @@ def _validate_session_name(ctx, param, value): @click.option( '--lineage', 'lineage', - help='Set lineage name', + help='Set lineage name. A lineage is a set of test sessions grouped and this option value will be used for grouping.', required=False, type=str, metavar='LINEAGE', diff --git a/launchable/commands/record/tests.py b/launchable/commands/record/tests.py index b0ce12432..e8d8b4e88 100644 --- a/launchable/commands/record/tests.py +++ b/launchable/commands/record/tests.py @@ -146,7 +146,7 @@ def _validate_group(ctx, param, value): @click.option( '--lineage', 'lineage', - help='Set lineage name', + help='Set lineage name. This option value will be passed the record session command if a session isn\'t created yet.', required=False, type=str, metavar='LINEAGE', diff --git a/launchable/commands/subset.py b/launchable/commands/subset.py index 6ebe0feb0..eb303065e 100644 --- a/launchable/commands/subset.py +++ b/launchable/commands/subset.py @@ -144,7 +144,7 @@ @click.option( '--lineage', 'lineage', - help='Set lineage name', + help='Set lineage name. This option value will be passed the record session command if a session isn\'t created yet.', required=False, type=str, metavar='LINEAGE', From a1d26881073c15ee9a85725c53089b8dda296f51 Mon Sep 17 00:00:00 2001 From: Konboi Date: Tue, 18 Jul 2023 17:01:04 +0900 Subject: [PATCH 8/8] fix comment --- launchable/commands/record/session.py | 2 +- launchable/commands/record/tests.py | 2 +- launchable/commands/subset.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/launchable/commands/record/session.py b/launchable/commands/record/session.py index f0b23250e..06b86ec15 100644 --- a/launchable/commands/record/session.py +++ b/launchable/commands/record/session.py @@ -85,7 +85,7 @@ def _validate_session_name(ctx, param, value): @click.option( '--lineage', 'lineage', - help='Set lineage name. A lineage is a set of test sessions grouped and this option value will be used for grouping.', + help='Set lineage name. A lineage is a set of test sessions grouped and this option value will be used for a lineage name.', required=False, type=str, metavar='LINEAGE', diff --git a/launchable/commands/record/tests.py b/launchable/commands/record/tests.py index e8d8b4e88..502acd58f 100644 --- a/launchable/commands/record/tests.py +++ b/launchable/commands/record/tests.py @@ -146,7 +146,7 @@ def _validate_group(ctx, param, value): @click.option( '--lineage', 'lineage', - help='Set lineage name. This option value will be passed the record session command if a session isn\'t created yet.', + help='Set lineage name. This option value will be passed to the record session command if a session isn\'t created yet.', required=False, type=str, metavar='LINEAGE', diff --git a/launchable/commands/subset.py b/launchable/commands/subset.py index eb303065e..b77ef5159 100644 --- a/launchable/commands/subset.py +++ b/launchable/commands/subset.py @@ -144,7 +144,7 @@ @click.option( '--lineage', 'lineage', - help='Set lineage name. This option value will be passed the record session command if a session isn\'t created yet.', + help='Set lineage name. This option value will be passed to the record session command if a session isn\'t created yet.', required=False, type=str, metavar='LINEAGE',