Skip to content

Commit 1d81b09

Browse files
adapt tests to new ordered insertMany failures for tables, data api PR #2193 (#387)
* adapt tests to the change in ordered insertMany failures for tables, data api PR #2193 * bump hcd IT data api version, remove useless imgpull step * set prod-Astra int.tests to use legacy insertMany failuremodes --------- Co-authored-by: Stefano Lottini <236640031+sl-at-ibm@users.noreply.github.com>
1 parent 5295a4e commit 1d81b09

File tree

7 files changed

+34
-15
lines changed

7 files changed

+34
-15
lines changed

.github/workflows/local.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ env:
1818
AWS_ECR_ROLE_NAME: ${{ secrets.AWS_ECR_ROLE_NAME }}
1919
AWS_ECR_REPOSITORY: ${{ secrets.AWS_ECR_REPOSITORY }}
2020
AWS_ECR_REGISTRY: ${{ secrets.AWS_ECR_REGISTRY }}
21-
AWS_ECR_HCD_IMAGE_TAG: "1.2.1-early-preview"
2221

2322
jobs:
2423
test:
@@ -54,10 +53,6 @@ jobs:
5453
- name: Login to Amazon ECR
5554
uses: aws-actions/amazon-ecr-login@v2
5655

57-
- name: Pull the image
58-
run: |
59-
docker pull $AWS_ECR_REGISTRY/$AWS_ECR_REPOSITORY:$AWS_ECR_HCD_IMAGE_TAG
60-
6156
- name: Run pytest
6257
run: |
6358
uv run pytest tests/base/integration

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
ASTRA_DB_APPLICATION_TOKEN: ${{ secrets.ASTRA_DB_APPLICATION_TOKEN }}
1616
ASTRA_DB_API_ENDPOINT: ${{ secrets.ASTRA_DB_API_ENDPOINT }}
1717
HEADER_EMBEDDING_API_KEY_OPENAI: ${{ secrets.HEADER_EMBEDDING_API_KEY_OPENAI }}
18+
LEGACY_INSERTMANY_BEHAVIOUR_PRE2193: "yes"
1819
runs-on: ubuntu-latest
1920

2021
steps:

CHANGES

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ Event Observer API, to listen to events:
99
- events are: warnings, payloads/responses, ...
1010
- useful for customized logging, observability and instrumentation;
1111
- see `astrapy.event_observers` module and docstring of classes therein for more.
12-
mainteinance: enabled text-index integration tests on Astra
12+
maintenance: introduce `LEGACY_INSERTMANY_BEHAVIOUR_PRE2193` flag to control related tests
13+
maintenance: enabled text-index integration tests on Astra
1314
maintenance: introduced the publish-and-release workflow machinery
1415
maintenance: split development/maintenance from user README
1516
maintenance. Improvement in testing machinery:

DEVELOPING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ certain environment variables, otherwise the associated tests are excluded from
170170
Prepend tests with a `ASTRAPY_TEST_LATEST_MAIN=y` for features found on `main` that are not released anywhere.
171171
_(Tip: run a code search first to see what is currently marked as such. Chances are nothing is.)_
172172

173+
### Legacy ordered-insert-many behaviour
174+
175+
Generally, [PR 2193](https://github.com/stargate/data-api/pull/2193) is included in modern Data API versions. In case tests are run to Data API 1.0.32 or lower, run the tests with the following additional environment variable to adjust the test expectations: `LEGACY_INSERTMANY_BEHAVIOUR_PRE2193="yes"`.
176+
173177
## Publish-and-release
174178

175179
Releasing a new version happens through the Github `release` workflow, which includes all necessary testing

tests/base/integration/tables/test_table_dml_async.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from __future__ import annotations
1616

17+
import os
1718
from typing import Any, Iterable, Sequence, cast
1819

1920
import pytest
@@ -399,7 +400,10 @@ def _assert_tim_exceptions(exps: Sequence[Exception], count: int) -> None:
399400
await async_table_simple.insert_many(
400401
SIMPLE_SEVEN_ROWS_F2, ordered=True, chunk_size=2
401402
)
402-
await _assert_consistency([], exc.value)
403+
if "LEGACY_INSERTMANY_BEHAVIOUR_PRE2193" not in os.environ:
404+
await _assert_consistency(["p1"], exc.value)
405+
else:
406+
await _assert_consistency([], exc.value)
403407
_assert_tim_exceptions(exc.value.exceptions, count=1)
404408

405409
# ordered, failing later batch
@@ -408,7 +412,10 @@ def _assert_tim_exceptions(exps: Sequence[Exception], count: int) -> None:
408412
await async_table_simple.insert_many(
409413
SIMPLE_SEVEN_ROWS_F4, ordered=True, chunk_size=2
410414
)
411-
await _assert_consistency(["p1", "p2"], exc.value)
415+
if "LEGACY_INSERTMANY_BEHAVIOUR_PRE2193" not in os.environ:
416+
await _assert_consistency(["p1", "p2", "p3"], exc.value)
417+
else:
418+
await _assert_consistency(["p1", "p2"], exc.value)
412419
_assert_tim_exceptions(exc.value.exceptions, count=1)
413420

414421
# unordered/concurrency=1, good rows
@@ -537,7 +544,6 @@ async def test_table_insert_many_failures_async(
537544
assert err3.inserted_id_tuples == []
538545

539546
# ordered insertion [good, bad, good_skipped]
540-
# Tables do not insert anything in this case! (as opposed to Collections)
541547
err4: TableInsertManyException | None = None
542548
try:
543549
await async_table_simple.insert_many(
@@ -550,7 +556,10 @@ async def test_table_insert_many_failures_async(
550556
assert len(err4.exceptions) == 1
551557
assert isinstance(err4.exceptions[0], DataAPIResponseException)
552558
assert len(err4.exceptions[0].error_descriptors) == 1
553-
assert err4.inserted_id_tuples == []
559+
if "LEGACY_INSERTMANY_BEHAVIOUR_PRE2193" not in os.environ:
560+
assert err4.inserted_id_tuples == [("n0",)]
561+
else:
562+
assert err4.inserted_id_tuples == []
554563

555564
@pytest.mark.describe("test of table update_one, async")
556565
async def test_table_update_one_async(

tests/base/integration/tables/test_table_dml_sync.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from __future__ import annotations
1616

17+
import os
1718
from typing import Any, Iterable, Sequence, cast
1819

1920
import pytest
@@ -381,7 +382,10 @@ def _assert_tim_exceptions(exps: Sequence[Exception], count: int) -> None:
381382
sync_table_simple.insert_many(
382383
SIMPLE_SEVEN_ROWS_F2, ordered=True, chunk_size=2
383384
)
384-
_assert_consistency([], exc.value)
385+
if "LEGACY_INSERTMANY_BEHAVIOUR_PRE2193" not in os.environ:
386+
_assert_consistency(["p1"], exc.value)
387+
else:
388+
_assert_consistency([], exc.value)
385389
_assert_tim_exceptions(exc.value.exceptions, count=1)
386390

387391
# ordered, failing later batch
@@ -390,7 +394,10 @@ def _assert_tim_exceptions(exps: Sequence[Exception], count: int) -> None:
390394
sync_table_simple.insert_many(
391395
SIMPLE_SEVEN_ROWS_F4, ordered=True, chunk_size=2
392396
)
393-
_assert_consistency(["p1", "p2"], exc.value)
397+
if "LEGACY_INSERTMANY_BEHAVIOUR_PRE2193" not in os.environ:
398+
_assert_consistency(["p1", "p2", "p3"], exc.value)
399+
else:
400+
_assert_consistency(["p1", "p2"], exc.value)
394401
_assert_tim_exceptions(exc.value.exceptions, count=1)
395402

396403
# unordered/concurrency=1, good rows
@@ -517,7 +524,6 @@ def test_table_insert_many_failures_sync(
517524
assert err3.inserted_id_tuples == []
518525

519526
# ordered insertion [good, bad, good_skipped]
520-
# Tables do not insert anything in this case! (as opposed to Collections)
521527
err4: TableInsertManyException | None = None
522528
try:
523529
sync_table_simple.insert_many(
@@ -530,7 +536,10 @@ def test_table_insert_many_failures_sync(
530536
assert len(err4.exceptions) == 1
531537
assert isinstance(err4.exceptions[0], DataAPIResponseException)
532538
assert len(err4.exceptions[0].error_descriptors) == 1
533-
assert err4.inserted_id_tuples == []
539+
if "LEGACY_INSERTMANY_BEHAVIOUR_PRE2193" not in os.environ:
540+
assert err4.inserted_id_tuples == [("n0",)]
541+
else:
542+
assert err4.inserted_id_tuples == []
534543

535544
@pytest.mark.describe("test of table update_one, sync")
536545
def test_table_update_one_sync(

tests/hcd_compose/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ services:
2121
retries: 20
2222

2323
data-api:
24-
image: stargateio/data-api:v1.0.32
24+
image: stargateio/data-api:v1.0.34
2525
depends_on:
2626
hcd:
2727
condition: service_healthy

0 commit comments

Comments
 (0)