diff --git a/singlestoredb/tests/test_fusion.py b/singlestoredb/tests/test_fusion.py index 2013b0b25..fa206ae44 100644 --- a/singlestoredb/tests/test_fusion.py +++ b/singlestoredb/tests/test_fusion.py @@ -950,6 +950,33 @@ def message(params): assert 'workspace group' in msg, msg +def _longer_wait_on_active(test, klass, method_name, timeout=1200): + """ + Default ``wait_timeout`` on ``klass.method_name`` for the rest of ``test``. + + ``CREATE CLUSTER`` and ``CREATE WORKSPACE`` have no clause for the wait + timeout, so their handlers leave it at the 600s default. Provisioning + usually takes five or six minutes but sometimes runs past ten, failing the + test with "Exceeded waiting time for ... to become active". 1200s is what + resources/create_test_cluster.py allows for the same wait. + + Patched on the class because the handlers get their own manager or group. + Wrapping what is installed now keeps the deployment tracking from + utils.install_deployment_tracking. + """ + from unittest import mock + + method = getattr(klass, method_name) + + def with_longer_wait(receiver, *args, **kwargs): + kwargs.setdefault('wait_timeout', timeout) + return method(receiver, *args, **kwargs) + + patcher = mock.patch.object(klass, method_name, with_longer_wait) + patcher.start() + test.addCleanup(patcher.stop) + + @pytest.mark.management @pytest.mark.management_v1 class TestWorkspaceFusion(unittest.TestCase): @@ -1266,6 +1293,11 @@ def test_show_workspaces(self): assert names == ['show-ws-3', 'show-ws-2'] def test_create_drop_workspace(self): + # The group, not the manager: WorkspaceGroup.create_workspace passes + # its own 600s default down explicitly. + from singlestoredb.management.v1.workspace import WorkspaceGroup + _longer_wait_on_active(self, WorkspaceGroup, 'create_workspace') + mgr = s2.manage_workspaces(version='v1') wg = mgr.workspace_groups[f'A Fusion Testing {self.id}'] @@ -1728,6 +1760,9 @@ def _wait_cluster_gone(self, name, timeout=180, interval=5): time.sleep(interval) def test_create_drop_cluster(self): + from singlestoredb.management.v2.cluster import ClusterManager + _longer_wait_on_active(self, ClusterManager, 'create_cluster') + mgr = type(self).manager name = f'd-fusion-cluster-{self.id}' region = type(self).us_regions[0] diff --git a/singlestoredb/tests/test_management_v1.py b/singlestoredb/tests/test_management_v1.py index 7a6533d47..6d4e44b3c 100755 --- a/singlestoredb/tests/test_management_v1.py +++ b/singlestoredb/tests/test_management_v1.py @@ -87,6 +87,7 @@ def setUpClass(cls): cls.workspace = cls.workspace_group.create_workspace( f'ws-test-{name}-x', wait_on_active=True, + wait_timeout=1200, ) except Exception: # Guarded: an unguarded terminate here would replace the create @@ -996,6 +997,7 @@ def setUpClass(cls): cls.workspace = cls.workspace_group.create_workspace( f'ws-test-{name}-x', wait_on_active=True, + wait_timeout=1200, ) except Exception: # Guarded: an unguarded terminate here would replace the create diff --git a/singlestoredb/tests/test_management_v2.py b/singlestoredb/tests/test_management_v2.py index ce11fefa3..6618ccd60 100644 --- a/singlestoredb/tests/test_management_v2.py +++ b/singlestoredb/tests/test_management_v2.py @@ -1335,6 +1335,7 @@ def setUpClass(cls): expires_at=utils.DEPLOYMENT_EXPIRES_AT, project=_project_id(cls.manager), wait_on_active=True, + wait_timeout=1200, ) # v2 generates the admin password and reports it only in the create @@ -1442,6 +1443,7 @@ def test_update(self): # refresh() inside update() still reports the old ranges. self.cluster.update( firewall_ranges=['192.168.0.0/16'], wait_on_active=True, + wait_timeout=1200, ) cluster = self.cluster