Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions singlestoredb/tests/test_fusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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}']

Expand Down Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions singlestoredb/tests/test_management_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions singlestoredb/tests/test_management_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading