|
10 | 10 | import sqlalchemy as sa |
11 | 11 |
|
12 | 12 | from ai.backend.common.identifier.deployment import DeploymentID |
| 13 | +from ai.backend.common.identifier.domain import DomainID |
| 14 | +from ai.backend.common.identifier.resource_group import ResourceGroupID |
13 | 15 | from ai.backend.common.types import ResourceSlot, VFolderHostPermissionMap |
14 | 16 | from ai.backend.manager.data.auth.hash import PasswordHashAlgorithm |
15 | 17 | from ai.backend.manager.data.group.types import ProjectType |
@@ -111,16 +113,22 @@ async def db_with_cleanup( |
111 | 113 | ): |
112 | 114 | yield database_connection |
113 | 115 |
|
| 116 | + @pytest.fixture |
| 117 | + def test_domain_id(self) -> DomainID: |
| 118 | + return DomainID(uuid.uuid4()) |
| 119 | + |
114 | 120 | @pytest.fixture |
115 | 121 | async def test_domain( |
116 | 122 | self, |
117 | 123 | db_with_cleanup: ExtendedAsyncSAEngine, |
| 124 | + test_domain_id: DomainID, |
118 | 125 | ) -> str: |
119 | 126 | """Create test domain""" |
120 | 127 | domain_name = f"test-domain-{uuid.uuid4().hex[:8]}" |
121 | 128 |
|
122 | 129 | async with db_with_cleanup.begin_session() as session: |
123 | 130 | domain = DomainRow( |
| 131 | + id=test_domain_id, |
124 | 132 | name=domain_name, |
125 | 133 | description="Test domain", |
126 | 134 | is_active=True, |
@@ -290,17 +298,20 @@ async def inactive_endpoint_with_session_and_routing( |
290 | 298 | self, |
291 | 299 | db_with_cleanup: ExtendedAsyncSAEngine, |
292 | 300 | test_domain: str, |
| 301 | + test_domain_id: DomainID, |
293 | 302 | test_user: uuid.UUID, |
294 | 303 | test_group: uuid.UUID, |
295 | 304 | ) -> EndpointWithSessionFixtureData: |
296 | 305 | """Create one inactive endpoint with a session and routing entry""" |
297 | 306 | endpoint_id = DeploymentID(uuid.uuid4()) |
298 | 307 | session_id = uuid.uuid4() |
| 308 | + sgroup_id = ResourceGroupID(uuid.uuid4()) |
299 | 309 | sgroup_name = f"default-{uuid.uuid4().hex[:8]}" |
300 | 310 |
|
301 | 311 | async with db_with_cleanup.begin_session() as session: |
302 | 312 | # Create scaling group |
303 | 313 | sgroup = ScalingGroupRow( |
| 314 | + id=sgroup_id, |
304 | 315 | name=sgroup_name, |
305 | 316 | description="Test scaling group", |
306 | 317 | is_active=True, |
@@ -332,8 +343,10 @@ async def inactive_endpoint_with_session_and_routing( |
332 | 343 | id=session_id, |
333 | 344 | creation_id=f"test-session-{uuid.uuid4().hex[:8]}", |
334 | 345 | domain_name=test_domain, |
| 346 | + domain_id=test_domain_id, |
335 | 347 | group_id=test_group, |
336 | 348 | scaling_group_name=sgroup_name, |
| 349 | + resource_group_id=sgroup_id, |
337 | 350 | user_uuid=test_user, |
338 | 351 | access_key="test-access-key", |
339 | 352 | cluster_mode="single-node", |
@@ -413,17 +426,20 @@ async def multiple_endpoints_with_sessions( |
413 | 426 | self, |
414 | 427 | db_with_cleanup: ExtendedAsyncSAEngine, |
415 | 428 | test_domain: str, |
| 429 | + test_domain_id: DomainID, |
416 | 430 | test_user: uuid.UUID, |
417 | 431 | test_group: uuid.UUID, |
418 | 432 | ) -> MultipleEndpointsWithSessionsFixtureData: |
419 | 433 | """Create 3 inactive endpoints, each with a session and routing entry""" |
420 | 434 | endpoint_ids = [] |
421 | 435 | session_ids = [] |
| 436 | + sgroup_id = ResourceGroupID(uuid.uuid4()) |
422 | 437 | sgroup_name = f"default-{uuid.uuid4().hex[:8]}" |
423 | 438 |
|
424 | 439 | async with db_with_cleanup.begin_session() as session: |
425 | 440 | # Create scaling group |
426 | 441 | sgroup = ScalingGroupRow( |
| 442 | + id=sgroup_id, |
427 | 443 | name=sgroup_name, |
428 | 444 | description="Test scaling group", |
429 | 445 | is_active=True, |
@@ -459,8 +475,10 @@ async def multiple_endpoints_with_sessions( |
459 | 475 | id=session_id, |
460 | 476 | creation_id=f"test-session-{i}-{uuid.uuid4().hex[:8]}", |
461 | 477 | domain_name=test_domain, |
| 478 | + domain_id=test_domain_id, |
462 | 479 | group_id=test_group, |
463 | 480 | scaling_group_name=sgroup_name, |
| 481 | + resource_group_id=sgroup_id, |
464 | 482 | user_uuid=test_user, |
465 | 483 | access_key=f"test-access-key-{i}", |
466 | 484 | cluster_mode="single-node", |
|
0 commit comments