-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_source_and_sink_integration.py
46 lines (34 loc) · 1.27 KB
/
test_source_and_sink_integration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import asyncio
import pytest
from sink.db.dbops import connect
from source.run import main as source_main
from sink.run import main as sink_main
from common.checks_config import load_checks
from common.config import load_db_config, load_kafka_config
@pytest.fixture
def db_config(env: str = "TEST"):
return load_db_config(env)
@pytest.fixture
def kafka_config(env: str = "TEST"):
return load_kafka_config(env)
@pytest.fixture
def checks_config():
return load_checks()
@pytest.fixture
async def db(env: str = "TEST"):
config = load_db_config(env)
db = await connect(config['conn_string'])
await db.execute(f"DROP SCHEMA IF EXISTS {config['schema']} cascade")
return db
@pytest.mark.asyncio
@pytest.mark.skip
async def test_source_and_sink_integration(db, db_config, kafka_config, checks_config):
await db.execute(f"CREATE SCHEMA {db_config['schema']}")
source_coro = source_main(kafka_config, checks_config)
sink_coro = sink_main(db_config, kafka_config, buffer_limit=1)
try:
await asyncio.wait_for(asyncio.gather(source_coro, sink_coro), timeout=20)
except asyncio.TimeoutError:
print("timeout!!")
results = await db.fetch(f"SELECT * from {db_config['schema']}.{db_config['table']}")
assert len(results) > 1