mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-04 17:55:06 -04:00
Add admin API to reset connection timeouts for remote server (#11639)
* Fix get federation status of destination if no error occured
This commit is contained in:
parent
15c2a6a106
commit
0d6cfea9b8
10 changed files with 183 additions and 33 deletions
|
@ -43,11 +43,15 @@ class FederationTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
@parameterized.expand(
|
||||
[
|
||||
("/_synapse/admin/v1/federation/destinations",),
|
||||
("/_synapse/admin/v1/federation/destinations/dummy",),
|
||||
("GET", "/_synapse/admin/v1/federation/destinations"),
|
||||
("GET", "/_synapse/admin/v1/federation/destinations/dummy"),
|
||||
(
|
||||
"POST",
|
||||
"/_synapse/admin/v1/federation/destinations/dummy/reset_connection",
|
||||
),
|
||||
]
|
||||
)
|
||||
def test_requester_is_no_admin(self, url: str) -> None:
|
||||
def test_requester_is_no_admin(self, method: str, url: str) -> None:
|
||||
"""
|
||||
If the user is not a server admin, an error 403 is returned.
|
||||
"""
|
||||
|
@ -56,7 +60,7 @@ class FederationTestCase(unittest.HomeserverTestCase):
|
|||
other_user_tok = self.login("user", "pass")
|
||||
|
||||
channel = self.make_request(
|
||||
"GET",
|
||||
method,
|
||||
url,
|
||||
content={},
|
||||
access_token=other_user_tok,
|
||||
|
@ -120,6 +124,16 @@ class FederationTestCase(unittest.HomeserverTestCase):
|
|||
self.assertEqual(HTTPStatus.NOT_FOUND, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.NOT_FOUND, channel.json_body["errcode"])
|
||||
|
||||
# invalid destination
|
||||
channel = self.make_request(
|
||||
"POST",
|
||||
self.url + "/dummy/reset_connection",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.NOT_FOUND, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(Codes.NOT_FOUND, channel.json_body["errcode"])
|
||||
|
||||
def test_limit(self) -> None:
|
||||
"""
|
||||
Testing list of destinations with limit
|
||||
|
@ -444,6 +458,39 @@ class FederationTestCase(unittest.HomeserverTestCase):
|
|||
self.assertIsNone(channel.json_body["failure_ts"])
|
||||
self.assertIsNone(channel.json_body["last_successful_stream_ordering"])
|
||||
|
||||
def test_destination_reset_connection(self) -> None:
|
||||
"""Reset timeouts and wake up destination."""
|
||||
self._create_destination("sub0.example.com", 100, 100, 100)
|
||||
|
||||
channel = self.make_request(
|
||||
"POST",
|
||||
self.url + "/sub0.example.com/reset_connection",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.OK, channel.code, msg=channel.json_body)
|
||||
|
||||
retry_timings = self.get_success(
|
||||
self.store.get_destination_retry_timings("sub0.example.com")
|
||||
)
|
||||
self.assertIsNone(retry_timings)
|
||||
|
||||
def test_destination_reset_connection_not_required(self) -> None:
|
||||
"""Try to reset timeouts of a destination with no timeouts and get an error."""
|
||||
self._create_destination("sub0.example.com", None, 0, 0)
|
||||
|
||||
channel = self.make_request(
|
||||
"POST",
|
||||
self.url + "/sub0.example.com/reset_connection",
|
||||
access_token=self.admin_user_tok,
|
||||
)
|
||||
|
||||
self.assertEqual(HTTPStatus.BAD_REQUEST, channel.code, msg=channel.json_body)
|
||||
self.assertEqual(
|
||||
"The retry timing does not need to be reset for this destination.",
|
||||
channel.json_body["error"],
|
||||
)
|
||||
|
||||
def _create_destination(
|
||||
self,
|
||||
destination: str,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue