Bug 2014036 - add instance_id attribute to lando.ini sections r=ahal,sparky
This allows us to decouple the name of the lando instance from the section in the configuration file. The instance_id is useful for tools such as TreeHerder and PerfCompare to talk to the appropriate Lando instance. Differential Revision: https://phabricator.services.mozilla.com/D289149
This commit is contained in:
committed by
omehani@mozilla.com
parent
2cb7e08e46
commit
1269c64056
+12
-4
@@ -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
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ subsuite = "try"
|
||||
|
||||
["test_mozharness_integration.py"]
|
||||
|
||||
["test_lando_api.py"]
|
||||
|
||||
["test_perf.py"]
|
||||
|
||||
["test_perfcomparators.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()
|
||||
Reference in New Issue
Block a user