Skip to content

Commit 75fc9bb

Browse files
committed
RHAIENG-3575 - Llama Stack and RAG Upgrade Testing.
Signed-off-by: Jiri Petrlik <jiripetrlik@gmail.com>
1 parent fda44af commit 75fc9bb

File tree

7 files changed

+666
-117
lines changed

7 files changed

+666
-117
lines changed

tests/conftest.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,13 +554,29 @@ def cluster_monitoring_config(
554554

555555
@pytest.fixture(scope="class")
556556
def unprivileged_model_namespace(
557-
request: FixtureRequest, admin_client: DynamicClient, unprivileged_client: DynamicClient
557+
request: FixtureRequest,
558+
pytestconfig: pytest.Config,
559+
admin_client: DynamicClient,
560+
unprivileged_client: DynamicClient,
561+
teardown_resources: bool,
558562
) -> Generator[Namespace, Any, Any]:
559563
if request.param.get("modelmesh-enabled"):
560564
request.getfixturevalue(argname="enabled_modelmesh_in_dsc")
561565

562-
with create_ns(admin_client=admin_client, unprivileged_client=unprivileged_client, pytest_request=request) as ns:
566+
ns = Namespace(client=unprivileged_client, name=request.param["name"])
567+
if pytestconfig.option.post_upgrade:
563568
yield ns
569+
ns.client = admin_client
570+
if teardown_resources:
571+
ns.clean_up()
572+
else:
573+
with create_ns(
574+
admin_client=admin_client,
575+
unprivileged_client=unprivileged_client,
576+
pytest_request=request,
577+
teardown=teardown_resources,
578+
) as ns:
579+
yield ns
564580

565581

566582
# MinIo

tests/fixtures/vector_io.py

Lines changed: 103 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,13 @@ def _factory(provider_name: str) -> list[dict[str, Any]]:
151151

152152
@pytest.fixture(scope="class")
153153
def vector_io_secret(
154+
pytestconfig: pytest.Config,
154155
unprivileged_client: DynamicClient,
155156
unprivileged_model_namespace: Namespace,
157+
teardown_resources: bool,
156158
) -> Generator[Secret, Any, Any]:
157159
"""Create a secret for the vector I/O providers"""
158-
with Secret(
160+
secret = Secret(
159161
client=unprivileged_client,
160162
namespace=unprivileged_model_namespace.name,
161163
name="vector-io-secret",
@@ -166,37 +168,55 @@ def vector_io_secret(
166168
"pgvector-password": PGVECTOR_PASSWORD,
167169
"milvus-token": MILVUS_TOKEN,
168170
},
169-
) as secret:
171+
ensure_exists=pytestconfig.option.post_upgrade,
172+
teardown=teardown_resources,
173+
)
174+
if pytestconfig.option.post_upgrade:
170175
yield secret
176+
secret.clean_up()
177+
else:
178+
with secret:
179+
yield secret
171180

172181

173182
@pytest.fixture(scope="class")
174183
def etcd_deployment(
184+
pytestconfig: pytest.Config,
175185
unprivileged_client: DynamicClient,
176186
unprivileged_model_namespace: Namespace,
187+
teardown_resources: bool,
177188
) -> Generator[Deployment, Any, Any]:
178189
"""Deploy an etcd instance for vector I/O provider testing."""
179-
with Deployment(
190+
deployment = Deployment(
180191
client=unprivileged_client,
181192
namespace=unprivileged_model_namespace.name,
182193
name="vector-io-etcd-deployment",
183194
replicas=1,
184195
selector={"matchLabels": {"app": "etcd"}},
185196
strategy={"type": "Recreate"},
186197
template=get_etcd_deployment_template(),
187-
teardown=True,
188-
) as deployment:
198+
teardown=teardown_resources,
199+
ensure_exists=pytestconfig.option.post_upgrade,
200+
)
201+
if pytestconfig.option.post_upgrade:
189202
deployment.wait_for_replicas(deployed=True, timeout=120)
190203
yield deployment
204+
deployment.clean_up()
205+
else:
206+
with deployment:
207+
deployment.wait_for_replicas(deployed=True, timeout=120)
208+
yield deployment
191209

192210

193211
@pytest.fixture(scope="class")
194212
def etcd_service(
213+
pytestconfig: pytest.Config,
195214
unprivileged_client: DynamicClient,
196215
unprivileged_model_namespace: Namespace,
216+
teardown_resources: bool,
197217
) -> Generator[Service, Any, Any]:
198218
"""Create a service for the etcd deployment."""
199-
with Service(
219+
service = Service(
200220
client=unprivileged_client,
201221
namespace=unprivileged_model_namespace.name,
202222
name="vector-io-etcd-service",
@@ -208,24 +228,33 @@ def etcd_service(
208228
],
209229
selector={"app": "etcd"},
210230
wait_for_resource=True,
211-
) as service:
231+
ensure_exists=pytestconfig.option.post_upgrade,
232+
teardown=teardown_resources,
233+
)
234+
if pytestconfig.option.post_upgrade:
212235
yield service
236+
service.clean_up()
237+
else:
238+
with service:
239+
yield service
213240

214241

215242
@pytest.fixture(scope="class")
216243
def remote_milvus_deployment(
244+
pytestconfig: pytest.Config,
217245
unprivileged_client: DynamicClient,
218246
unprivileged_model_namespace: Namespace,
219247
etcd_deployment: Deployment,
220248
etcd_service: Service,
221249
vector_io_secret: Secret,
250+
teardown_resources: bool,
222251
) -> Generator[Deployment, Any, Any]:
223252
"""Deploy a remote Milvus instance for vector I/O provider testing."""
224253
_ = etcd_deployment
225254
_ = etcd_service
226255
_ = vector_io_secret
227256

228-
with Deployment(
257+
deployment = Deployment(
229258
client=unprivileged_client,
230259
namespace=unprivileged_model_namespace.name,
231260
name="vector-io-milvus-deployment",
@@ -234,22 +263,31 @@ def remote_milvus_deployment(
234263
selector={"matchLabels": {"app": "milvus-standalone"}},
235264
strategy={"type": "Recreate"},
236265
template=get_milvus_deployment_template(),
237-
teardown=True,
238-
) as deployment:
266+
teardown=teardown_resources,
267+
ensure_exists=pytestconfig.option.post_upgrade,
268+
)
269+
if pytestconfig.option.post_upgrade:
239270
deployment.wait_for_replicas(deployed=True, timeout=240)
240271
yield deployment
272+
deployment.clean_up()
273+
else:
274+
with deployment:
275+
deployment.wait_for_replicas(deployed=True, timeout=240)
276+
yield deployment
241277

242278

243279
@pytest.fixture(scope="class")
244280
def milvus_service(
281+
pytestconfig: pytest.Config,
245282
unprivileged_client: DynamicClient,
246283
unprivileged_model_namespace: Namespace,
247284
remote_milvus_deployment: Deployment,
285+
teardown_resources: bool,
248286
) -> Generator[Service, Any, Any]:
249287
"""Create a service for the remote Milvus deployment."""
250288
_ = remote_milvus_deployment
251289

252-
with Service(
290+
service = Service(
253291
client=unprivileged_client,
254292
namespace=unprivileged_model_namespace.name,
255293
name="vector-io-milvus-service",
@@ -262,8 +300,15 @@ def milvus_service(
262300
],
263301
selector={"app": "milvus-standalone"},
264302
wait_for_resource=True,
265-
) as service:
303+
ensure_exists=pytestconfig.option.post_upgrade,
304+
teardown=teardown_resources,
305+
)
306+
if pytestconfig.option.post_upgrade:
266307
yield service
308+
service.clean_up()
309+
else:
310+
with service:
311+
yield service
267312

268313

269314
def get_milvus_deployment_template() -> dict[str, Any]:
@@ -343,14 +388,16 @@ def get_etcd_deployment_template() -> dict[str, Any]:
343388

344389
@pytest.fixture(scope="class")
345390
def pgvector_deployment(
391+
pytestconfig: pytest.Config,
346392
unprivileged_client: DynamicClient,
347393
unprivileged_model_namespace: Namespace,
348394
vector_io_secret: Secret,
395+
teardown_resources: bool,
349396
) -> Generator[Deployment, Any, Any]:
350397
"""Deploy a PGVector instance for vector I/O provider testing."""
351398
_ = vector_io_secret
352399

353-
with Deployment(
400+
deployment = Deployment(
354401
client=unprivileged_client,
355402
namespace=unprivileged_model_namespace.name,
356403
name="vector-io-pgvector-deployment",
@@ -359,22 +406,31 @@ def pgvector_deployment(
359406
selector={"matchLabels": {"app": "pgvector"}},
360407
strategy={"type": "Recreate"},
361408
template=get_pgvector_deployment_template(),
362-
teardown=True,
363-
) as deployment:
409+
teardown=teardown_resources,
410+
ensure_exists=pytestconfig.option.post_upgrade,
411+
)
412+
if pytestconfig.option.post_upgrade:
364413
deployment.wait_for_replicas(deployed=True, timeout=240)
365414
yield deployment
415+
deployment.clean_up()
416+
else:
417+
with deployment:
418+
deployment.wait_for_replicas(deployed=True, timeout=240)
419+
yield deployment
366420

367421

368422
@pytest.fixture(scope="class")
369423
def pgvector_service(
424+
pytestconfig: pytest.Config,
370425
unprivileged_client: DynamicClient,
371426
unprivileged_model_namespace: Namespace,
372427
pgvector_deployment: Deployment,
428+
teardown_resources: bool,
373429
) -> Generator[Service, Any, Any]:
374430
"""Create a service for the PGVector deployment."""
375431
_ = pgvector_deployment
376432

377-
with Service(
433+
service = Service(
378434
client=unprivileged_client,
379435
namespace=unprivileged_model_namespace.name,
380436
name="vector-io-pgvector-service",
@@ -387,8 +443,15 @@ def pgvector_service(
387443
],
388444
selector={"app": "pgvector"},
389445
wait_for_resource=True,
390-
) as service:
446+
ensure_exists=pytestconfig.option.post_upgrade,
447+
teardown=teardown_resources,
448+
)
449+
if pytestconfig.option.post_upgrade:
391450
yield service
451+
service.clean_up()
452+
else:
453+
with service:
454+
yield service
392455

393456

394457
def get_pgvector_deployment_template() -> dict[str, Any]:
@@ -438,14 +501,16 @@ def get_pgvector_deployment_template() -> dict[str, Any]:
438501

439502
@pytest.fixture(scope="class")
440503
def qdrant_deployment(
504+
pytestconfig: pytest.Config,
441505
unprivileged_client: DynamicClient,
442506
unprivileged_model_namespace: Namespace,
443507
vector_io_secret: Secret,
508+
teardown_resources: bool,
444509
) -> Generator[Deployment, Any, Any]:
445510
"""Deploy a Qdrant instance for vector I/O provider testing."""
446511
_ = vector_io_secret
447512

448-
with Deployment(
513+
deployment = Deployment(
449514
client=unprivileged_client,
450515
namespace=unprivileged_model_namespace.name,
451516
name="vector-io-qdrant-deployment",
@@ -454,22 +519,31 @@ def qdrant_deployment(
454519
selector={"matchLabels": {"app": "qdrant"}},
455520
strategy={"type": "Recreate"},
456521
template=get_qdrant_deployment_template(),
457-
teardown=True,
458-
) as deployment:
522+
teardown=teardown_resources,
523+
ensure_exists=pytestconfig.option.post_upgrade,
524+
)
525+
if pytestconfig.option.post_upgrade:
459526
deployment.wait_for_replicas(deployed=True, timeout=240)
460527
yield deployment
528+
deployment.clean_up()
529+
else:
530+
with deployment:
531+
deployment.wait_for_replicas(deployed=True, timeout=240)
532+
yield deployment
461533

462534

463535
@pytest.fixture(scope="class")
464536
def qdrant_service(
537+
pytestconfig: pytest.Config,
465538
unprivileged_client: DynamicClient,
466539
unprivileged_model_namespace: Namespace,
467540
qdrant_deployment: Deployment,
541+
teardown_resources: bool,
468542
) -> Generator[Service, Any, Any]:
469543
"""Create a service for the Qdrant deployment."""
470544
_ = qdrant_deployment
471545

472-
with Service(
546+
service = Service(
473547
client=unprivileged_client,
474548
namespace=unprivileged_model_namespace.name,
475549
name="vector-io-qdrant-service",
@@ -487,8 +561,15 @@ def qdrant_service(
487561
],
488562
selector={"app": "qdrant"},
489563
wait_for_resource=True,
490-
) as service:
564+
ensure_exists=pytestconfig.option.post_upgrade,
565+
teardown=teardown_resources,
566+
)
567+
if pytestconfig.option.post_upgrade:
491568
yield service
569+
service.clean_up()
570+
else:
571+
with service:
572+
yield service
492573

493574

494575
def get_qdrant_deployment_template() -> dict[str, Any]:

0 commit comments

Comments
 (0)