diff --git a/tests/integration/env/matrix-authentication-service-syn2mas.rc b/tests/integration/env/matrix-authentication-service-syn2mas.rc new file mode 100644 index 00000000..b29338b4 --- /dev/null +++ b/tests/integration/env/matrix-authentication-service-syn2mas.rc @@ -0,0 +1,5 @@ +# Copyright 2025 New Vector Ltd +# +# SPDX-License-Identifier: AGPL-3.0-only + +export TEST_VALUES_FILE=charts/matrix-stack/ci/pytest-matrix-authentication-service-syn2mas-values.yaml diff --git a/tests/integration/test_syn2mas.py b/tests/integration/test_syn2mas.py new file mode 100644 index 00000000..5bd46646 --- /dev/null +++ b/tests/integration/test_syn2mas.py @@ -0,0 +1,64 @@ +# Copyright 2024 New Vector Ltd +# +# SPDX-License-Identifier: AGPL-3.0-only + +import os + +import pyhelm3 +import pytest + +from .fixtures import ESSData +from .lib.utils import value_file_has +from .test_matrix_authentication_service import test_matrix_authentication_service_graphql_endpoint + + +@pytest.mark.skipif(value_file_has("synapse.enabled", False), reason="Synapse not deployed") +@pytest.mark.skipif(value_file_has("matrixAuthenticationService.syn2mas.enabled", False), reason="Syn2Mas not deployed") +@pytest.mark.asyncio_cooperative +async def test_run_syn2mas_upgrade( + helm_client: pyhelm3.Client, + ingress_ready, + ssl_context, + generated_data: ESSData, +): + await ingress_ready("synapse") + # After the base chart is setup, we enable MAS to run the syn2mas dry run job + + revision = await helm_client.get_current_revision( + generated_data.release_name, namespace=generated_data.ess_namespace + ) + values = await revision.values() + values["matrixAuthenticationService"]["enabled"] = True + chart = await helm_client.get_chart("charts/matrix-stack") + # Install or upgrade a release + revision = await helm_client.install_or_upgrade_release( + generated_data.release_name, + chart, + values, + namespace=generated_data.ess_namespace, + atomic="CI" not in os.environ, + wait=True, + ) + assert revision.status == pyhelm3.ReleaseRevisionStatus.DEPLOYED + # We should still be able to reach synapse ingress + await ingress_ready("synapse") + # We then run the final migration + revision = await helm_client.get_current_revision( + generated_data.release_name, namespace=generated_data.ess_namespace + ) + values = await revision.values() + values["matrixAuthenticationService"]["syn2mas"].setdefault("migrate")["dryRun"] = False + chart = await helm_client.get_chart("charts/matrix-stack") + # Install or upgrade a release + revision = await helm_client.install_or_upgrade_release( + generated_data.release_name, + chart, + values, + namespace=generated_data.ess_namespace, + atomic="CI" not in os.environ, + wait=True, + ) + assert revision.status == pyhelm3.ReleaseRevisionStatus.DEPLOYED + + # MAS should be available + await test_matrix_authentication_service_graphql_endpoint(ingress_ready, generated_data, ssl_context)