Skip to content

Commit 983c59f

Browse files
Include Koji build IDs in TF API response (#3002)
Include Koji build IDs in TF API response Related to packit/dashboard#512 Assisted-by: Cursor(Claude) Reviewed-by: gemini-code-assist[bot] Reviewed-by: Nikola Forró
2 parents 95ec989 + 9e06e45 commit 983c59f

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

packit_service/service/api/testing_farm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ def get(self, id):
163163
"commit_sha": test_run_model.commit_sha,
164164
"web_url": test_run_model.web_url,
165165
"copr_build_ids": [build.id for build in test_run_model.copr_builds],
166+
"koji_build_ids": [build.id for build in test_run_model.koji_builds],
166167
"run_ids": sorted(run.id for run in test_run_model.group_of_targets.runs),
167168
"submitted_time": optional_timestamp(test_run_model.submitted_time),
168169
}

tests_openshift/conftest.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
sa_session_transaction,
6060
sync_release_pr_association_table,
6161
tf_copr_association_table,
62+
tf_koji_association_table,
6263
)
6364

6465

@@ -212,6 +213,7 @@ def clean_db():
212213
session.query(ProjectEventModel).delete()
213214

214215
session.query(tf_copr_association_table).delete()
216+
session.query(tf_koji_association_table).delete()
215217
session.query(TFTTestRunTargetModel).delete()
216218
session.query(TFTTestRunGroupModel).delete()
217219
session.query(CoprBuildTargetModel).delete()
@@ -1173,6 +1175,32 @@ def a_new_test_run_pr(srpm_build_model_with_new_run_for_pr, a_copr_build_for_pr)
11731175
)
11741176

11751177

1178+
@pytest.fixture()
1179+
def a_new_test_run_with_koji_build(pr_project_event_model):
1180+
"""Test run with an associated Koji build (Fedora CI scenario)."""
1181+
_, run_model = SRPMBuildModel.create_with_new_run(
1182+
project_event_model=pr_project_event_model,
1183+
)
1184+
test_group = TFTTestRunGroupModel.create(run_model, ranch="public")
1185+
koji_group = KojiBuildGroupModel.create(run_model)
1186+
koji_build = KojiBuildTargetModel.create(
1187+
task_id=SampleValues.build_id,
1188+
web_url=SampleValues.koji_web_url,
1189+
target=SampleValues.target,
1190+
status=SampleValues.status_pending,
1191+
scratch=True,
1192+
koji_build_group=koji_group,
1193+
)
1194+
yield TFTTestRunTargetModel.create(
1195+
pipeline_id=SampleValues.different_pipeline_id,
1196+
web_url=SampleValues.testing_farm_url,
1197+
target=SampleValues.target,
1198+
status=TestingFarmResult.new,
1199+
test_run_group=test_group,
1200+
koji_build_targets=[koji_build],
1201+
)
1202+
1203+
11761204
@pytest.fixture()
11771205
def a_new_test_run_branch_push(
11781206
srpm_build_model_with_new_run_for_branch,

tests_openshift/service/test_api.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,33 @@ def test_get_testing_farm_result(client, clean_before_and_after, a_new_test_run_
362362
assert "release" in response_dict
363363

364364

365+
def test_get_testing_farm_result_with_koji_build(
366+
client,
367+
clean_before_and_after,
368+
a_new_test_run_with_koji_build,
369+
):
370+
"""Test that koji_build_ids are included in TF result API (Fedora CI scenario)."""
371+
response = client.get(
372+
url_for(
373+
"api.testing-farm_testing_farm_result",
374+
id=a_new_test_run_with_koji_build.id,
375+
),
376+
)
377+
response_dict = response.json
378+
379+
assert response_dict["pipeline_id"] == a_new_test_run_with_koji_build.pipeline_id
380+
assert response_dict["status"] == TestingFarmResult.new
381+
382+
# Verify koji_build_ids is present and contains the expected build
383+
assert "koji_build_ids" in response_dict
384+
assert len(response_dict["koji_build_ids"]) == 1
385+
assert response_dict["koji_build_ids"][0] == a_new_test_run_with_koji_build.koji_builds[0].id
386+
387+
# copr_build_ids should be empty for this test run
388+
assert "copr_build_ids" in response_dict
389+
assert response_dict["copr_build_ids"] == []
390+
391+
365392
def test_get_projects_list(client, clean_before_and_after, a_copr_build_for_pr):
366393
"""Test Get Projects"""
367394
response = client.get(url_for("api.projects_projects_list"))

0 commit comments

Comments
 (0)