Skip to content

Commit 60eb467

Browse files
committed
feat(ingest): Couchbase source additional test update
1 parent b5458fe commit 60eb467

File tree

2 files changed

+69
-18
lines changed

2 files changed

+69
-18
lines changed

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

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
from tests.test_helpers import mce_helpers
1919
from tests.test_helpers.docker_helpers import wait_for_port
2020

21+
retries = Retry(total=5, backoff_factor=2, status_forcelist=[404, 405, 500, 503])
22+
adapter = HTTPAdapter(max_retries=retries)
23+
session = requests.Session()
24+
session.mount("http://", adapter)
25+
session.mount("https://", adapter)
26+
2127

2228
class BasicAuth(AuthBase):
2329
def __init__(self, username, password):
@@ -35,6 +41,27 @@ def __call__(self, r):
3541
return r
3642

3743

44+
def http_test_get(url: str, auth: BasicAuth) -> int:
45+
response = session.get(
46+
url,
47+
verify=False,
48+
timeout=15,
49+
auth=auth,
50+
)
51+
return response.status_code
52+
53+
54+
def http_test_post(url: str, auth: BasicAuth, data: dict) -> int:
55+
response = session.post(
56+
url,
57+
verify=False,
58+
timeout=15,
59+
auth=auth,
60+
data=data,
61+
)
62+
return response.status_code
63+
64+
3865
@pytest.mark.integration_batch_2
3966
def test_couchbase_ingest(docker_compose_runner, pytestconfig, tmp_path, mock_time):
4067
test_resources_dir = pytestconfig.rootpath / "tests/integration/couchbase"
@@ -49,19 +76,18 @@ def test_couchbase_ingest(docker_compose_runner, pytestconfig, tmp_path, mock_ti
4976

5077
wait_for_port(docker_services, "testdb", 8093)
5178

52-
retries = Retry(total=5, backoff_factor=1, status_forcelist=[404])
53-
adapter = HTTPAdapter(max_retries=retries)
54-
session = requests.Session()
55-
session.mount("http://", adapter)
56-
session.mount("https://", adapter)
57-
response = session.get(
79+
result = http_test_get(
5880
"http://127.0.0.1:8091/pools/default/buckets/data",
59-
verify=False,
60-
timeout=15,
6181
auth=BasicAuth("Administrator", "password"),
6282
)
83+
assert result == 200
6384

64-
assert response.status_code == 200
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
6591

6692
time.sleep(2)
6793

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

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
from tests.test_helpers.docker_helpers import wait_for_port
1414

1515
logger = logging.getLogger(__name__)
16+
retries = Retry(total=5, backoff_factor=2, status_forcelist=[404, 405, 500, 503])
17+
adapter = HTTPAdapter(max_retries=retries)
18+
session = requests.Session()
19+
session.mount("http://", adapter)
20+
session.mount("https://", adapter)
1621

1722

1823
class BasicAuth(AuthBase):
@@ -31,6 +36,27 @@ def __call__(self, r):
3136
return r
3237

3338

39+
def http_test_get(url: str, auth: BasicAuth) -> int:
40+
response = session.get(
41+
url,
42+
verify=False,
43+
timeout=15,
44+
auth=auth,
45+
)
46+
return response.status_code
47+
48+
49+
def http_test_post(url: str, auth: BasicAuth, data: dict) -> int:
50+
response = session.post(
51+
url,
52+
verify=False,
53+
timeout=15,
54+
auth=auth,
55+
data=data,
56+
)
57+
return response.status_code
58+
59+
3460
@pytest.mark.slow
3561
@pytest.mark.asyncio
3662
async def test_couchbase_driver(
@@ -43,19 +69,18 @@ async def test_couchbase_driver(
4369
) as docker_services:
4470
wait_for_port(docker_services, "testdb", 8093)
4571

46-
retries = Retry(total=5, backoff_factor=1, status_forcelist=[404])
47-
adapter = HTTPAdapter(max_retries=retries)
48-
session = requests.Session()
49-
session.mount("http://", adapter)
50-
session.mount("https://", adapter)
51-
response = session.get(
72+
result = http_test_get(
5273
"http://127.0.0.1:8091/pools/default/buckets/data",
53-
verify=False,
54-
timeout=15,
5574
auth=BasicAuth("Administrator", "password"),
5675
)
76+
assert result == 200
5777

58-
assert response.status_code == 200
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
5984

6085
await asyncio.sleep(2)
6186

0 commit comments

Comments
 (0)