Skip to content

Commit

Permalink
Merge pull request #1029 from lbarcziova/testing-farm-results-ref
Browse files Browse the repository at this point in the history
Use commit_sha from DB when processing TF results

Fixes #1028

Reviewed-by: Jiri Popelka <None>
  • Loading branch information
softwarefactory-project-zuul[bot] authored Mar 24, 2021
2 parents 9bc0408 + f3790d4 commit 79727db
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
10 changes: 6 additions & 4 deletions packit_service/worker/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,11 +801,13 @@ def parse_testing_farm_results_event(

ref: str = nested_get(event, "test", "fmf", "ref")
project_url: str = nested_get(event, "test", "fmf", "url")

# ["test"]["fmf"]["ref"] contains ref to the TF test, i.e. "master",
# but we need the original commit_sha to be able to continue
if tft_test_run:
ref = tft_test_run.commit_sha

if project_url == TESTING_FARM_INSTALLABILITY_TEST_URL:
# ["test"]["fmf"]["ref"] in this case contains ref to the TF test, i.e. "master",
# but we need the original commit_sha to be able to continue
if tft_test_run:
ref = tft_test_run.commit_sha
# There are no artifacts in install-test results
copr_build_id = copr_chroot = ""
else:
Expand Down
11 changes: 7 additions & 4 deletions tests/unit/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ def test_parse_testing_farm_notification(
flexmock(
job_trigger=flexmock(),
data={"base_project_url": "https://github.com/packit/packit"},
commit_sha="12345",
)
.should_receive("get_trigger_object")
.and_return(flexmock(pr_id=10))
Expand All @@ -647,7 +648,7 @@ def test_parse_testing_farm_notification(
assert event_object.pipeline_id == request_id
assert event_object.result == TestingFarmResult.passed
assert event_object.project_url == "https://github.com/packit/packit"
assert event_object.commit_sha == "e7e3c8b688403048e7aefa64c19b79e89fe764df"
assert event_object.commit_sha == "12345"
assert not event_object.summary
assert event_object.compose == "Fedora-32"
assert event_object.copr_build_id == "1810530"
Expand All @@ -668,6 +669,7 @@ def test_parse_testing_farm_notification_error(
flexmock(
job_trigger=flexmock(),
data={"base_project_url": "https://github.com/packit/packit"},
commit_sha="12345",
)
.should_receive("get_trigger_object")
.and_return(flexmock(pr_id=10))
Expand All @@ -680,7 +682,7 @@ def test_parse_testing_farm_notification_error(
assert event_object.pipeline_id == request_id
assert event_object.result == TestingFarmResult.error
assert event_object.project_url == "https://github.com/packit/packit"
assert event_object.commit_sha == "e7e3c8b688403048e7aefa64c19b79e89fe764df"
assert event_object.commit_sha == "12345"
assert event_object.summary == "something went wrong"
assert event_object.compose == "Fedora-32"
assert event_object.copr_build_id == "1810530"
Expand Down Expand Up @@ -885,13 +887,14 @@ def test_get_project_testing_farm_notification(
).and_return(testing_farm_results)
flexmock(TFTTestRunModel).should_receive("get_by_pipeline_id").with_args(
request_id
).and_return(flexmock(data={"base_project_url": "abc"}))
).and_return(flexmock(data={"base_project_url": "abc"}, commit_sha="12345"))
event_object = Parser.parse_event(testing_farm_notification)

assert isinstance(event_object, TestingFarmResultsEvent)
assert isinstance(event_object.pipeline_id, str)
assert event_object.pipeline_id == request_id
assert event_object.project_url == "abc"
assert event_object.commit_sha == "12345"

def test_distgit_commit(self, distgit_commit):

Expand Down Expand Up @@ -932,7 +935,7 @@ def test_json_testing_farm_notification(
testing_farm_results
)
flexmock(TFTTestRunModel).should_receive("get_by_pipeline_id").and_return(
flexmock(data={"base_project_url": "abc"})
flexmock(data={"base_project_url": "abc"}, commit_sha="12345")
)
event_object = Parser.parse_event(testing_farm_notification)
assert json.dumps(event_object.pipeline_id)
Expand Down
4 changes: 2 additions & 2 deletions tests_requre/database/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def test_testing_farm_response_existing_pr(
event_object = Parser.parse_event(tf_notification)
assert isinstance(event_object, TestingFarmResultsEvent)

assert event_object.commit_sha == SampleValues.different_commit_sha
assert event_object.commit_sha == SampleValues.commit_sha

assert isinstance(event_object.db_trigger, PullRequestModel)
assert event_object.db_trigger == pr_model
Expand Down Expand Up @@ -340,7 +340,7 @@ def test_testing_farm_response_existing_branch_push(
event_object = Parser.parse_event(tf_notification)
assert isinstance(event_object, TestingFarmResultsEvent)

assert event_object.commit_sha == SampleValues.different_commit_sha
assert event_object.commit_sha == SampleValues.commit_sha

assert isinstance(event_object.db_trigger, GitBranchModel)
assert event_object.db_trigger == branch_model
Expand Down

0 comments on commit 79727db

Please sign in to comment.