diff --git a/.lando.ini b/.lando.ini index f22e78c2dceb..5ab191b0ba71 100644 --- a/.lando.ini +++ b/.lando.ini @@ -3,33 +3,41 @@ enabled = True [lando-prod] +instance_id = lando-prod +api_domain = api.lando.services.mozilla.com + # Lando production Auth0 configuration. auth0_domain = auth.mozilla.auth0.com auth0_client_id = ccpmWbDAMz1pxHIWF4vqkdr0ScdgDyyM auth0_audience = https://api.lando.services.mozilla.com auth0_scope = openid email profile lando https://sso.mozilla.com/claim/groups -api_domain = api.lando.services.mozilla.com [lando-dev] +instance_id = lando-dev +api_domain = api.dev.lando.nonprod.cloudops.mozgcp.net + # Lando dev server Auth0 configuration. auth0_domain = auth.mozilla.auth0.com auth0_client_id = TAtuZwbJd4SRtWg0YznfS1YYCatOvvnX auth0_audience = https://api.lando.devsvcdev.mozaws.net auth0_scope = openid email profile lando https://sso.mozilla.com/claim/groups -api_domain = api.dev.lando.nonprod.cloudops.mozgcp.net [lando-prod-new] +instance_id = lando-prod-2025 +api_domain = lando.moz.tools + # Lando production Auth0 configuration. auth0_domain = auth.mozilla.auth0.com auth0_client_id = ccpmWbDAMz1pxHIWF4vqkdr0ScdgDyyM auth0_audience = https://lando.moz.tools auth0_scope = openid email profile lando https://sso.mozilla.com/claim/groups -api_domain = lando.moz.tools [lando-dev-new] +instance_id = lando-dev-2025 +api_domain = lando-dev.allizom.org + # Lando dev server Auth0 configuration. auth0_domain = auth.mozilla.auth0.com auth0_client_id = TAtuZwbJd4SRtWg0YznfS1YYCatOvvnX auth0_audience = https://lando-dev.allizom.org auth0_scope = openid email profile lando https://sso.mozilla.com/claim/groups -api_domain = lando-dev.allizom.org diff --git a/tools/tryselect/lando.py b/tools/tryselect/lando.py index dade3ba6fbd2..79c5da94d820 100644 --- a/tools/tryselect/lando.py +++ b/tools/tryselect/lando.py @@ -321,6 +321,7 @@ class LandoAPI: access_token: str api_url: str + instance_id: str verify_tls: bool = True @property @@ -366,6 +367,7 @@ class LandoAPI: return LandoAPI( api_url=parser.get(section, "api_domain"), access_token=token["access_token"], + instance_id=parser.get(section, "instance_id", fallback=section), verify_tls=parser.getboolean(section, "verify_tls", fallback=True), ) @@ -495,6 +497,6 @@ def push_to_lando_try( build.notify(success_msg) return { - "lando_instance": lando_config_section, + "lando_instance": lando_api.instance_id, "lando_job_id": job_id, } diff --git a/tools/tryselect/test/python.toml b/tools/tryselect/test/python.toml index 8904b4ca3738..de4e7f276f7f 100644 --- a/tools/tryselect/test/python.toml +++ b/tools/tryselect/test/python.toml @@ -11,6 +11,8 @@ subsuite = "try" ["test_mozharness_integration.py"] +["test_lando_api.py"] + ["test_perf.py"] ["test_perfcomparators.py"] diff --git a/tools/tryselect/test/test_lando_api.py b/tools/tryselect/test/test_lando_api.py new file mode 100644 index 000000000000..385651fc1e5a --- /dev/null +++ b/tools/tryselect/test/test_lando_api.py @@ -0,0 +1,55 @@ +from textwrap import dedent +from typing import Optional +from unittest import mock + +import mozunit +import pytest +from tryselect.lando import LandoAPI + + +@mock.patch("tryselect.lando.Auth0Config") +@pytest.mark.parametrize( + "section,expected_instance_id", + ( + ("no_id", "no_id"), + ("id", "id_present"), + ("missing", None), + ), +) +def test_lando_api_from_lando_config_file( + auth0_config: mock.Mock, section: str, expected_instance_id: Optional[str] +): + mock_config_path = mock.MagicMock() + mock_config_path.exists.return_value = True + mock_config_path.read_text.return_value = dedent(""" + [no_id] + api_domain = no_id.lando.example.net + # Lando production Auth0 configuration. + auth0_domain = auth.example.net + auth0_client_id = xXxX + auth0_audience = https://no_id.lando.example.net + auth0_scope = openid email profile lando https://sso.mozilla.com/claim/groups + [id] + instance_id = id_present + api_domain = id.lando.example.net + # Lando production Auth0 configuration. + auth0_domain = auth.example.net + auth0_client_id = XxXx + auth0_audience = https://id.lando.example.net + auth0_scope = openid email profile lando https://sso.mozilla.com/claim/groups + """) + + if expected_instance_id is None: + with pytest.raises( + ValueError, match=f"Lando config file does not have a {section} section." + ): + lando_api = LandoAPI.from_lando_config_file(mock_config_path, section) + else: + lando_api = LandoAPI.from_lando_config_file(mock_config_path, section) + assert lando_api.instance_id == expected_instance_id, ( + "Unexpected LandoApi instance_id" + ) + + +if __name__ == "__main__": + mozunit.main()