Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
spicy-sauce committed Aug 5, 2024
1 parent 403e1a4 commit e317cab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion integration-tests/common/redis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def add_to_emp_stream(redis_client: Redis):
],
"__$$opcode": "u"
},
# gender length is too long, should be failed (except from Cassandra)
# gender length is too long, should fail (except from Cassandra)
{
"_id": 11,
"fname": "jane",
Expand Down
14 changes: 7 additions & 7 deletions integration-tests/test_redis_to_relational.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@
def test_redis_to_relational_db(db_type: str, schema_name: Optional[str]):
"""Reads data from a Redis stream and writes it to a relational database."""
try:
job_name = f"tests.redis_to_{db_type}"
redis_container = redis_utils.get_redis_oss_container(redis_utils.REDIS_PORT)
redis_container.start()

redis_utils.add_to_emp_stream(redis_utils.get_redis_client("localhost", redis_utils.REDIS_PORT))

# the job is supposed to fail due to the missing database connection
with pytest.raises(ConnectionError):
run_job(job_name)

if db_type == "db2":
db_container = db_utils.get_db2_container("hr", "my_user", "my_pass")
elif db_type == "mysql":
Expand All @@ -52,19 +57,14 @@ def test_redis_to_relational_db(db_type: str, schema_name: Optional[str]):
db_utils.insert_to_emp_table(engine, schema_name)
db_utils.insert_to_address_table(engine, schema_name)

db_container.stop()
with pytest.raises(ConnectionError):
run_job(f"tests.redis_to_{db_type}")

db_container.start()
run_job(f"tests.redis_to_{db_type}")
run_job(job_name)

check_results(engine, schema_name)
finally:
with suppress(Exception):
redis_container.stop()
with suppress(Exception):
database_container.stop()
db_container.stop()


def check_results(engine: Engine, schema_name: Optional[str]):
Expand Down

0 comments on commit e317cab

Please sign in to comment.