Skip to content

Commit 5893bc2

Browse files
authored
Merge pull request #40 from oracle/ci/adb-free
CI enhancements
2 parents e8ec2d0 + ec8e85a commit 5893bc2

14 files changed

Lines changed: 162 additions & 67 deletions

‎.github/workflows/test.yaml‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: select_ai_py_tests
22
on:
33
push:
4+
branches:
5+
- "**"
46
workflow_call:
57

68
permissions:
@@ -9,6 +11,20 @@ permissions:
911
jobs:
1012
test:
1113
runs-on: ${{ matrix.os }}
14+
services:
15+
adb:
16+
image: ghcr.io/oracle/adb-free:latest-26ai
17+
env:
18+
WORKLOAD_TYPE: ATP
19+
START_ORDS: "False"
20+
ENABLE_ARCHIVE_LOG: "False"
21+
ADMIN_PASSWORD: ${{ secrets.PYSAI_TEST_ADMIN_PASSWORD }}
22+
WALLET_PASSWORD: ${{ secrets.PYSAI_TEST_WALLET_PASSWORD }}
23+
ports:
24+
- 1521:1521
25+
options: >-
26+
--cap-add SYS_ADMIN
27+
--device /dev/fuse
1228
strategy:
1329
fail-fast: true
1430
matrix:
@@ -36,6 +52,17 @@ jobs:
3652
pip install pytest anyio
3753
pip install -e .
3854
55+
- name: Wait for ADB Free Container
56+
run: |
57+
for attempt in {1..60}; do
58+
if nc -z localhost 1521; then
59+
exit 0
60+
fi
61+
sleep 10
62+
done
63+
docker logs ${{ job.services.adb.id }}
64+
exit 1
65+
3966
- name: Run select_ai tests
4067
run: |
4168
python_version=${{matrix.python-version}}
@@ -44,9 +71,9 @@ jobs:
4471
env:
4572
PYSAI_TEST_USER: ${{ secrets.PYSAI_TEST_USER }}_${{env.PYTHON_VERSION_WITHOUT_DOT}}
4673
PYSAI_TEST_USER_PASSWORD: ${{ secrets.PYSAI_TEST_USER_PASSWORD }}
47-
PYSAI_TEST_ADMIN_USER: ${{ secrets.PYSAI_TEST_ADMIN_USER }}
74+
PYSAI_TEST_ADMIN_USER: ADMIN
4875
PYSAI_TEST_ADMIN_PASSWORD: ${{ secrets.PYSAI_TEST_ADMIN_PASSWORD }}
49-
PYSAI_TEST_CONNECT_STRING: ${{ secrets.PYSAI_TEST_CONNECT_STRING }}
76+
PYSAI_TEST_CONNECT_STRING: localhost:1521/myatp
5077
PYSAI_TEST_OCI_USER_OCID: ${{ secrets.PYSAI_TEST_OCI_USER_OCID }}
5178
PYSAI_TEST_OCI_TENANCY_OCID: ${{ secrets.PYSAI_TEST_OCI_TENANCY_OCID }}
5279
PYSAI_TEST_OCI_PRIVATE_KEY: ${{ secrets.PYSAI_TEST_OCI_PRIVATE_KEY }}

‎tests/agents/conftest.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010

1111

1212
@pytest.fixture(scope="module")
13-
def provider():
13+
def provider(oci_compartment_id):
1414
return select_ai.OCIGenAIProvider(
1515
region="us-chicago-1",
1616
oci_apiformat="GENERIC",
17+
oci_compartment_id=oci_compartment_id,
1718
model="meta.llama-4-maverick-17b-128e-instruct-fp8",
1819
)
1920

‎tests/profiles/conftest.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ def log_test_case(request, configure_module_logging):
5757

5858

5959
@pytest.fixture(scope="module")
60-
def provider():
60+
def provider(oci_compartment_id):
6161
return select_ai.OCIGenAIProvider(
62-
region="us-phoenix-1", oci_apiformat="GENERIC"
62+
region="us-phoenix-1",
63+
oci_apiformat="GENERIC",
64+
oci_compartment_id=oci_compartment_id,
6365
)
6466

6567

‎tests/profiles/test_1300_profile_async.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ async def test_1307():
277277
assert profile.attributes.provider.model == "meta.llama-3.1-70b-instruct"
278278

279279

280-
async def test_1308(oci_credential):
280+
async def test_1308(oci_credential, oci_compartment_id):
281281
"""Set multiple attributes for a Profile"""
282282
logger.info(
283283
"Setting multiple attributes for async profile %s",
@@ -290,6 +290,7 @@ async def test_1308(oci_credential):
290290
model="meta.llama-4-maverick-17b-128e-instruct-fp8",
291291
region="us-chicago-1",
292292
oci_apiformat="GENERIC",
293+
oci_compartment_id=oci_compartment_id,
293294
),
294295
object_list=[{"owner": "ADMIN", "name": "gymnasts"}],
295296
comments=True,

‎tests/vector_index/conftest.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,18 @@ def vcidx_object_store_credentials():
9898

9999
@pytest.fixture(scope="class")
100100
def vcidx_params(
101+
request,
101102
test_env,
102103
oci_credential,
103104
oci_compartment_id,
104105
embedding_location,
105106
vcidx_object_store_credentials,
106107
):
108+
# Test modules share a schema. Include the module name in every generated
109+
# resource so credentials, profiles, and indexes never overlap.
110+
module_suffix = (
111+
Path(request.module.__file__).stem.removeprefix("test_").upper()
112+
)
107113
py_suffix = os.environ.get("PYTHON_VERSION_WITHOUT_DOT")
108114
run_suffix = os.environ.get("GITHUB_RUN_ID")
109115
run_attempt = os.environ.get("GITHUB_RUN_ATTEMPT")
@@ -113,9 +119,9 @@ def vcidx_params(
113119
run_suffix = uuid.uuid4().hex[:12].upper()
114120

115121
if py_suffix:
116-
resource_suffix = f"PY{py_suffix}_{run_suffix}"
122+
resource_suffix = f"PY{py_suffix}_{run_suffix}_{module_suffix}"
117123
else:
118-
resource_suffix = f"PYSAI_{run_suffix}"
124+
resource_suffix = f"PYSAI_{run_suffix}_{module_suffix}"
119125

120126
return {
121127
"resource_suffix": resource_suffix,

‎tests/vector_index/test_5100_async_drop_index.py‎

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ async def vector_index_test_state(request):
7979

8080
@pytest.mark.usefixtures("delete_vec_params", "setup_and_teardown")
8181
class TestAsyncDeleteVectorIndex:
82+
def resource_name(self, name: str) -> str:
83+
return f"{name}_{self.delete_vec_params['resource_suffix']}"
84+
8285
@classmethod
8386
def get_native_cred_param(cls, cred_name=None) -> dict:
8487
logger.info("Preparing native credential params for: %s", cred_name)
@@ -420,14 +423,16 @@ async def test_5108(self):
420423
async def test_5109(self):
421424
"""Test delete of a nonexistent index (should not error)."""
422425
idx = select_ai.AsyncVectorIndex(
423-
index_name="nonexistent_index",
426+
index_name=self.resource_name("nonexistent_index"),
424427
attributes=self.vector_index_attributes,
425428
profile=self.profile,
426429
)
427430
logger.info("Attempting to delete nonexistent index")
428431
await idx.delete(force=True)
429432
await asyncio.sleep(1)
430-
await self.assert_index_count("^nonexistent_index", 0)
433+
await self.assert_index_count(
434+
f"^{self.resource_name('nonexistent_index')}$", 0
435+
)
431436
logger.info("Nonexistent delete verified (no error)")
432437

433438
async def test_5110(self):
@@ -458,7 +463,7 @@ async def test_5110(self):
458463
async def test_5111(self):
459464
"""Test case-sensitive name for create and delete."""
460465
idx = select_ai.AsyncVectorIndex(
461-
index_name="CaseSensitiveIndex",
466+
index_name=self.resource_name("CaseSensitiveIndex"),
462467
attributes=self.vector_index_attributes,
463468
profile=self.profile,
464469
)
@@ -467,12 +472,14 @@ async def test_5111(self):
467472
logger.info("Deleting case-sensitive index")
468473
await idx.delete(force=True)
469474
await asyncio.sleep(1)
470-
await self.assert_index_count("^CaseSensitiveIndex", 0)
475+
await self.assert_index_count(
476+
f"^{self.resource_name('CaseSensitiveIndex')}$", 0
477+
)
471478
logger.info("Case-sensitive index delete verified")
472479

473480
async def test_5112(self):
474481
"""Test creation and deletion with long index name."""
475-
long_name = "index_" + "x" * 40
482+
long_name = self.resource_name("index_" + "x" * 40)
476483
idx = select_ai.AsyncVectorIndex(
477484
index_name=long_name,
478485
attributes=self.vector_index_attributes,
@@ -488,7 +495,10 @@ async def test_5112(self):
488495

489496
async def test_5113(self):
490497
"""Test creation and bulk deletion of indexes."""
491-
names = [f"bulk_idx_{i}" for i in range(3)]
498+
names = [
499+
f"bulk_idx_{self.delete_vec_params['resource_suffix']}_{i}"
500+
for i in range(3)
501+
]
492502
logger.info("Creating bulk indexes")
493503
for name in names:
494504
await select_ai.AsyncVectorIndex(
@@ -506,7 +516,9 @@ async def test_5113(self):
506516
).delete(force=True)
507517
await asyncio.sleep(1)
508518
logger.info("Deleted %s", name)
509-
await self.assert_index_count("^bulk_idx_", 0)
519+
await self.assert_index_count(
520+
f"^bulk_idx_{self.delete_vec_params['resource_suffix']}_", 0
521+
)
510522
logger.info("Bulk delete verified")
511523

512524
async def test_5114(self):
@@ -545,24 +557,26 @@ async def test_5115(self):
545557
async def test_5116(self):
546558
"""Test delete of one out of multiple indexes."""
547559
idx1 = select_ai.AsyncVectorIndex(
548-
index_name="IDX_1",
560+
index_name=self.resource_name("IDX_1"),
549561
attributes=self.vector_index_attributes,
550562
profile=self.profile,
551563
)
552564
idx2 = select_ai.AsyncVectorIndex(
553-
index_name="IDX_2",
565+
index_name=self.resource_name("IDX_2"),
554566
attributes=self.vector_index_attributes,
555567
profile=self.profile,
556568
)
557-
logger.info("Creating two indexes IDX_1 and IDX_2")
569+
logger.info("Creating two isolated indexes")
558570
await idx1.create(replace=True)
559571
await idx2.create(replace=True)
560572
logger.info("Deleting IDX_1 only")
561-
await self.delete_and_wait(force=True, pattern="^IDX_1$")
573+
await self.delete_and_wait(
574+
force=True, pattern=f"^{self.resource_name('IDX_1')}$"
575+
)
562576
remaining_idx2 = [
563577
index
564578
async for index in self.async_vector_index.list(
565-
index_name_pattern="^IDX_2$"
579+
index_name_pattern=f"^{self.resource_name('IDX_2')}$"
566580
)
567581
]
568582
logger.info("IDX_2 entries after IDX_1 delete: %s", remaining_idx2)

‎tests/vector_index/test_5100_drop_index.py‎

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ def log_test_name(request):
6868

6969
@pytest.mark.usefixtures("delete_vec_params", "setup_and_teardown")
7070
class TestDeleteVectorIndex:
71+
def resource_name(self, name: str) -> str:
72+
return f"{name}_{self.delete_vec_params['resource_suffix']}"
73+
7174
@classmethod
7275
def get_native_cred_param(cls, cred_name=None) -> dict:
7376
logger.info(f"Preparing native credential params for: {cred_name}")
@@ -443,14 +446,16 @@ def test_5108(self):
443446
def test_5109(self):
444447
"""Test delete of a nonexistent index (should not error)."""
445448
idx = select_ai.VectorIndex(
446-
index_name="nonexistent_index",
449+
index_name=self.resource_name("nonexistent_index"),
447450
attributes=self.vector_index_attributes,
448451
profile=self.profile,
449452
)
450453
logger.info("Attempting to delete nonexistent index")
451454
idx.delete(force=True)
452455
time.sleep(1)
453-
self.assert_index_count("^nonexistent_index", 0)
456+
self.assert_index_count(
457+
f"^{self.resource_name('nonexistent_index')}$", 0
458+
)
454459
logger.info("Nonexistent delete verified (no error)")
455460

456461
def test_5110(self):
@@ -477,7 +482,7 @@ def test_5110(self):
477482
def test_5111(self):
478483
"""Test case-sensitive name for create and delete."""
479484
idx = select_ai.VectorIndex(
480-
index_name="CaseSensitiveIndex",
485+
index_name=self.resource_name("CaseSensitiveIndex"),
481486
attributes=self.vector_index_attributes,
482487
profile=self.profile,
483488
)
@@ -486,12 +491,14 @@ def test_5111(self):
486491
logger.info("Deleting case-sensitive index")
487492
idx.delete(force=True)
488493
time.sleep(1)
489-
self.assert_index_count("^CaseSensitiveIndex", 0)
494+
self.assert_index_count(
495+
f"^{self.resource_name('CaseSensitiveIndex')}$", 0
496+
)
490497
logger.info("Case-sensitive index delete verified")
491498

492499
def test_5112(self):
493500
"""Test creation and deletion with long index name."""
494-
long_name = "index_" + "x" * 40
501+
long_name = self.resource_name("index_" + "x" * 40)
495502
idx = select_ai.VectorIndex(
496503
index_name=long_name,
497504
attributes=self.vector_index_attributes,
@@ -507,7 +514,10 @@ def test_5112(self):
507514

508515
def test_5113(self):
509516
"""Test creation and bulk deletion of indexes."""
510-
names = [f"bulk_idx_{i}" for i in range(3)]
517+
names = [
518+
f"bulk_idx_{self.delete_vec_params['resource_suffix']}_{i}"
519+
for i in range(3)
520+
]
511521
logger.info("Creating bulk indexes")
512522
for n in names:
513523
select_ai.VectorIndex(
@@ -525,7 +535,9 @@ def test_5113(self):
525535
).delete(force=True)
526536
time.sleep(1)
527537
logger.info(f"Deleted {n}")
528-
self.assert_index_count("^bulk_idx_", 0)
538+
self.assert_index_count(
539+
f"^bulk_idx_{self.delete_vec_params['resource_suffix']}_", 0
540+
)
529541
logger.info("Bulk delete verified")
530542

531543
def test_5114(self):
@@ -556,22 +568,26 @@ def test_5115(self):
556568
def test_5116(self):
557569
"""Test delete of one out of multiple indexes."""
558570
idx1 = select_ai.VectorIndex(
559-
index_name="IDX_1",
571+
index_name=self.resource_name("IDX_1"),
560572
attributes=self.vector_index_attributes,
561573
profile=self.profile,
562574
)
563575
idx2 = select_ai.VectorIndex(
564-
index_name="IDX_2",
576+
index_name=self.resource_name("IDX_2"),
565577
attributes=self.vector_index_attributes,
566578
profile=self.profile,
567579
)
568-
logger.info("Creating two indexes IDX_1 and IDX_2")
580+
logger.info("Creating two isolated indexes")
569581
idx1.create(replace=True)
570582
idx2.create(replace=True)
571583
logger.info("Deleting IDX_1 only")
572-
self.delete_and_wait(force=True, pattern="^IDX_1$")
584+
self.delete_and_wait(
585+
force=True, pattern=f"^{self.resource_name('IDX_1')}$"
586+
)
573587
remaining_idx2 = list(
574-
self.vector_index.list(index_name_pattern="^IDX_2$")
588+
self.vector_index.list(
589+
index_name_pattern=f"^{self.resource_name('IDX_2')}$"
590+
)
575591
)
576592
logger.info(f"IDX_2 entries after IDX_1 delete: {remaining_idx2}")
577593
assert len(remaining_idx2) == 1

‎tests/vector_index/test_5200_async_setindex_attributes.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,9 @@ async def test_5228(self):
942942
async def test_5229(self):
943943
"""Update on nonexistent vector index."""
944944
logger.info("Testing update on nonexistent vector index...")
945-
temp_index = AsyncVectorIndex(index_name="does_not_exist")
945+
temp_index = AsyncVectorIndex(
946+
index_name=f"does_not_exist_{self.resource_suffix}"
947+
)
946948
with pytest.raises(AttributeError):
947949
await temp_index.set_attribute("chunk_size", 512)
948950
logger.info(

‎tests/vector_index/test_5200_setindex_attributes.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,9 @@ def test_5228(self):
911911
def test_5229(self):
912912
"""Update on nonexistent vector index."""
913913
logger.info("Testing update on nonexistent vector index...")
914-
temp_index = VectorIndex(index_name="does_not_exist")
914+
temp_index = VectorIndex(
915+
index_name=f"does_not_exist_{self.resource_suffix}"
916+
)
915917
with pytest.raises(AttributeError):
916918
temp_index.set_attribute("chunk_size", 512)
917919
logger.info(

0 commit comments

Comments
 (0)