Skip to content

Commit 0a92f3e

Browse files
committed
CFR: Fix software tests
1 parent 7496f6c commit 0a92f3e

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

tests/cfr/test_systable.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ def test_cfr_sys_export_success(cratedb, tmp_path, caplog):
3535
"""
3636

3737
# Invoke command.
38-
runner = CliRunner(env={"CRATEDB_CLUSTER_URL": cratedb.database.dburi, "CFR_TARGET": str(tmp_path)})
38+
runner = CliRunner(
39+
env={"CRATEDB_CLUSTER_URL": cratedb.database.dburi, "CFR_TARGET": str(tmp_path)}, mix_stderr=False
40+
)
3941
result = runner.invoke(
4042
cli,
4143
args="--debug sys-export",
@@ -47,8 +49,8 @@ def test_cfr_sys_export_success(cratedb, tmp_path, caplog):
4749
assert "Exporting system tables to" in caplog.text
4850
assert re.search(r"Successfully exported \d+ system tables", caplog.text), "Log message missing"
4951

50-
# Verify outcome.
51-
path = Path(json.loads(result.output)["path"])
52+
# Verify the outcome.
53+
path = Path(json.loads(result.stdout)["path"])
5254
assert filenames(path) == ["data", "schema"]
5355

5456
schema_files = filenames(path / "schema")
@@ -66,7 +68,9 @@ def test_cfr_sys_export_to_archive_file(cratedb, tmp_path, caplog):
6668
target = os.path.join(tmp_path, "cluster-data.tgz")
6769

6870
# Invoke command.
69-
runner = CliRunner(env={"CRATEDB_CLUSTER_URL": cratedb.database.dburi, "CFR_TARGET": str(tmp_path)})
71+
runner = CliRunner(
72+
env={"CRATEDB_CLUSTER_URL": cratedb.database.dburi, "CFR_TARGET": str(tmp_path)}, mix_stderr=False
73+
)
7074
result = runner.invoke(
7175
cli,
7276
args=f"--debug sys-export {target}",
@@ -78,8 +82,8 @@ def test_cfr_sys_export_to_archive_file(cratedb, tmp_path, caplog):
7882
assert "Exporting system tables to" in caplog.text
7983
assert re.search(r"Successfully exported \d+ system tables", caplog.text), "Log message missing"
8084

81-
# Verify outcome.
82-
path = Path(json.loads(result.output)["path"])
85+
# Verify the outcome.
86+
path = Path(json.loads(result.stdout)["path"])
8387
assert "cluster-data.tgz" in path.name
8488

8589
data_files = []
@@ -102,7 +106,7 @@ def test_cfr_sys_export_failure(cratedb, tmp_path, caplog):
102106
"""
103107

104108
# Invoke command.
105-
runner = CliRunner(env={"CRATEDB_CLUSTER_URL": "crate://foo.bar/", "CFR_TARGET": str(tmp_path)})
109+
runner = CliRunner(env={"CRATEDB_CLUSTER_URL": "crate://foo.bar/", "CFR_TARGET": str(tmp_path)}, mix_stderr=False)
106110
result = runner.invoke(
107111
cli,
108112
args="--debug sys-export",
@@ -116,15 +120,17 @@ def test_cfr_sys_export_failure(cratedb, tmp_path, caplog):
116120

117121

118122
def test_cfr_sys_export_ensure_table_name_is_quoted(cratedb, tmp_path, caplog):
119-
runner = CliRunner(env={"CRATEDB_CLUSTER_URL": cratedb.database.dburi, "CFR_TARGET": str(tmp_path)})
123+
runner = CliRunner(
124+
env={"CRATEDB_CLUSTER_URL": cratedb.database.dburi, "CFR_TARGET": str(tmp_path)}, mix_stderr=False
125+
)
120126
result = runner.invoke(
121127
cli,
122128
args="--debug sys-export",
123129
catch_exceptions=False,
124130
)
125131
assert result.exit_code == 0
126132

127-
path = Path(json.loads(result.output)["path"])
133+
path = Path(json.loads(result.stdout)["path"])
128134
sys_cluster_table_schema = path / "schema" / "sys-cluster.sql"
129135
with open(sys_cluster_table_schema, "r") as f:
130136
content = f.read()
@@ -172,7 +178,9 @@ def test_cfr_sys_import_success(cratedb, tmp_path, caplog):
172178
shutil.copy(sys_operations_data, data_path)
173179

174180
# Invoke command.
175-
runner = CliRunner(env={"CRATEDB_CLUSTER_URL": cratedb.database.dburi, "CFR_SOURCE": str(tmp_path)})
181+
runner = CliRunner(
182+
env={"CRATEDB_CLUSTER_URL": cratedb.database.dburi, "CFR_SOURCE": str(tmp_path)}, mix_stderr=False
183+
)
176184
result = runner.invoke(
177185
cli,
178186
args="--debug sys-import",
@@ -184,7 +192,7 @@ def test_cfr_sys_import_success(cratedb, tmp_path, caplog):
184192
assert "Importing system tables from" in caplog.text
185193
assert re.search(r"Successfully imported \d+ system tables", caplog.text), "Log message missing"
186194

187-
# Verify outcome.
195+
# Verify the outcome.
188196
results = cratedb.database.run_sql("SHOW TABLES", records=True)
189197
assert {"table_name": "sys-operations"} in results
190198

@@ -198,7 +206,7 @@ def test_cfr_sys_import_failure(cratedb, tmp_path, caplog):
198206
"""
199207

200208
# Invoke command.
201-
runner = CliRunner(env={"CRATEDB_CLUSTER_URL": "crate://foo.bar/", "CFR_SOURCE": str(tmp_path)})
209+
runner = CliRunner(env={"CRATEDB_CLUSTER_URL": "crate://foo.bar/", "CFR_SOURCE": str(tmp_path)}, mix_stderr=False)
202210
result = runner.invoke(
203211
cli,
204212
args="--debug sys-import",

0 commit comments

Comments
 (0)