Skip to content

Commit 8591db8

Browse files
committed
feat(ingest): Couchbase source additional test updates
1 parent 60eb467 commit 8591db8

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

metadata-ingestion/tests/integration/couchbase/test_couchbase.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import base64
2+
import json
23
import logging
34
import os
45
import shutil
@@ -15,6 +16,7 @@
1516
from datahub.ingestion.glossary.classifier import DynamicTypedClassifierConfig
1617
from datahub.ingestion.glossary.datahub_classifier import DataHubClassifierConfig
1718
from datahub.ingestion.run.pipeline import Pipeline
19+
from datahub.ingestion.source.couchbase.retry import retry
1820
from tests.test_helpers import mce_helpers
1921
from tests.test_helpers.docker_helpers import wait_for_port
2022

@@ -51,15 +53,16 @@ def http_test_get(url: str, auth: BasicAuth) -> int:
5153
return response.status_code
5254

5355

54-
def http_test_post(url: str, auth: BasicAuth, data: dict) -> int:
56+
def http_test_post(url: str, auth: BasicAuth, data: dict) -> dict:
5557
response = session.post(
5658
url,
5759
verify=False,
5860
timeout=15,
5961
auth=auth,
6062
data=data,
6163
)
62-
return response.status_code
64+
assert response.status_code == 200
65+
return json.loads(response.text)
6366

6467

6568
@pytest.mark.integration_batch_2
@@ -82,12 +85,17 @@ def test_couchbase_ingest(docker_compose_runner, pytestconfig, tmp_path, mock_ti
8285
)
8386
assert result == 200
8487

85-
result = http_test_post(
86-
"http://127.0.0.1:8093/query/service",
87-
auth=BasicAuth("Administrator", "password"),
88-
data={"statement": "SELECT count(*) as count FROM data.data.customers"},
89-
)
90-
assert result == 200
88+
@retry(factor=1)
89+
def collection_wait():
90+
response = http_test_post(
91+
"http://127.0.0.1:8093/query/service",
92+
auth=BasicAuth("Administrator", "password"),
93+
data={"statement": "SELECT count(*) as count FROM data.data.customers"},
94+
)
95+
results = response.get("results", [{}])
96+
assert results[0].get("count", 0) == 1000
97+
98+
collection_wait()
9199

92100
time.sleep(2)
93101

metadata-ingestion/tests/unit/couchbase/test_couchbase_source.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import base64
3+
import json
34
import logging
45

56
import pytest
@@ -10,6 +11,7 @@
1011

1112
from datahub.ingestion.source.couchbase.couchbase_aggregate import CouchbaseAggregate
1213
from datahub.ingestion.source.couchbase.couchbase_connect import CouchbaseConnect
14+
from datahub.ingestion.source.couchbase.retry import retry
1315
from tests.test_helpers.docker_helpers import wait_for_port
1416

1517
logger = logging.getLogger(__name__)
@@ -46,15 +48,16 @@ def http_test_get(url: str, auth: BasicAuth) -> int:
4648
return response.status_code
4749

4850

49-
def http_test_post(url: str, auth: BasicAuth, data: dict) -> int:
51+
def http_test_post(url: str, auth: BasicAuth, data: dict) -> dict:
5052
response = session.post(
5153
url,
5254
verify=False,
5355
timeout=15,
5456
auth=auth,
5557
data=data,
5658
)
57-
return response.status_code
59+
assert response.status_code == 200
60+
return json.loads(response.text)
5861

5962

6063
@pytest.mark.slow
@@ -75,12 +78,17 @@ async def test_couchbase_driver(
7578
)
7679
assert result == 200
7780

78-
result = http_test_post(
79-
"http://127.0.0.1:8093/query/service",
80-
auth=BasicAuth("Administrator", "password"),
81-
data={"statement": "SELECT count(*) as count FROM data.data.customers"},
82-
)
83-
assert result == 200
81+
@retry(factor=1)
82+
def collection_wait():
83+
response = http_test_post(
84+
"http://127.0.0.1:8093/query/service",
85+
auth=BasicAuth("Administrator", "password"),
86+
data={"statement": "SELECT count(*) as count FROM data.data.customers"},
87+
)
88+
results = response.get("results", [{}])
89+
assert results[0].get("count", 0) == 1000
90+
91+
collection_wait()
8492

8593
await asyncio.sleep(2)
8694

0 commit comments

Comments
 (0)