Skip to content

Commit 6a68e02

Browse files
committed
add a testcase
1 parent e92007b commit 6a68e02

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from scripts import run_and_publish_benchmark
16+
17+
18+
def test_collect_benchmark_result(tmp_path):
19+
# Create dummy log files
20+
(tmp_path / "benchmark1.bytesprocessed").write_text("100")
21+
(tmp_path / "benchmark1.slotmillis").write_text("1000")
22+
(tmp_path / "benchmark1.bq_exec_time_seconds").write_text("1.0")
23+
(tmp_path / "benchmark1.local_exec_time_seconds").write_text("2.0")
24+
(tmp_path / "benchmark1.query_char_count").write_text("50")
25+
(tmp_path / "benchmark1.totalrows").write_text("10")
26+
27+
# Collect the benchmark results
28+
df, error_message = run_and_publish_benchmark.collect_benchmark_result(
29+
str(tmp_path), 1
30+
)
31+
32+
# Assert that the DataFrame is correct
33+
assert error_message is None
34+
assert len(df) == 1
35+
assert df["Benchmark_Name"][0] == "benchmark1"
36+
assert df["Bytes_Processed"][0] == 100
37+
assert df["Slot_Millis"][0] == 1000
38+
assert df["BigQuery_Execution_Time_Sec"][0] == 1.0
39+
assert df["Local_Execution_Time_Sec"][0] == 2.0
40+
assert df["Query_Char_Count"][0] == 50
41+
assert df["Total_Rows"][0] == 10

0 commit comments

Comments
 (0)