Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 22 additions & 51 deletions schemas/pulse-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,57 +38,28 @@ properties:
maxLength: 25

origin:
oneOf:
- type: 'object'
description: |
PREFERRED: An HG job that only has a revision. This is for all
jobs going forward.
additionalProperties: false
title: 'HG Push'
properties:
kind:
type: 'string'
enum: ['hg.mozilla.org']
project:
type: 'string'
pattern: "^[\\w-]+$"
minLength: 1
maxLength: 50
revision:
type: 'string'
pattern: '^[0-9a-f]+$'
minLength: 40
maxLength: 40
pushLogID:
type: 'integer'
required: [kind, project, revision]

- type: 'object'
title: 'Github push or pull request'
additionalProperties: false
properties:
kind:
type: 'string'
enum: ['github.com']
owner:
description: Unused
type: 'string'
pattern: "^[\\w-]+$"
minLength: 1
maxLength: 50
project:
description: 'The repository name as known to Treeherder'
type: 'string'
pattern: "^[\\w-]+$"
minLength: 1
maxLength: 50
revision:
type: 'string'
minLength: 40
maxLength: 40
pullRequestID:
type: 'integer'
required: [kind, project, revision]
type: 'object'
description: Describes a Mercurial or Git event.
additionalProperties: false
title: 'Origin event metadata'
properties:
project:
description: 'The repository name as known to Treeherder'
type: 'string'
pattern: "^[\\w-]+$"
minLength: 1
maxLength: 50
revision:
type: 'string'
pattern: '^[0-9a-f]+$'
minLength: 40
maxLength: 40
id:
description: |
For Mercurial refers to the `pushLogID`. For Git it refers to the
`pullRequestID`.
type: 'integer'
required: [project, revision]

display:
type: 'object'
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ def test_repository_2(test_repository):
dvcs_type=test_repository.dvcs_type,
url=test_repository.url + "_2",
codebase=test_repository.codebase,
tc_root_url=test_repository.tc_root_url,
)


Expand Down
42 changes: 41 additions & 1 deletion tests/etl/test_job_loader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import copy
import uuid
from datetime import datetime

import pytest
import responses
Expand All @@ -8,7 +9,7 @@

from treeherder.etl.job_loader import JobLoader
from treeherder.etl.taskcluster_pulse.handler import handle_message
from treeherder.model.models import Job, JobLog, TaskclusterMetadata
from treeherder.model.models import Job, JobLog, Push, TaskclusterMetadata


@pytest.fixture
Expand Down Expand Up @@ -389,6 +390,45 @@ def test_transition_running_unscheduled_stays_running(
change_state_result(first_job, jl, "unscheduled", "unknown", "running", "unknown")


@responses.activate
def test_github_repo_origin(
pulse_jobs, push_stored, failure_classifications, mock_log_parser, test_repository_2
):
test_repository_2.url = "https://github.com/mozilla-mobile/fenix"
test_repository_2.save()

jl = JobLoader()
job = pulse_jobs[0]

responses.add(
responses.GET,
"https://firefox-ci-tc.services.mozilla.com/api/queue/v1/task/AI3Nrr3gSDSpZ9E9aBA3rg",
json={"extra": {"treeherder": {}}},
status=200,
)

revision = push_stored[0]["revision"]
Push.objects.create(
repository=test_repository_2,
revision=revision,
author=push_stored[0]["author"],
time=datetime.fromtimestamp(push_stored[0]["push_timestamp"]),
)

job["origin"]["revision"] = revision
job["origin"]["project"] = test_repository_2.name
job["origin"]["id"] = 42

jl.process_job(job, "https://firefox-ci-tc.services.mozilla.com")

jobs = Job.objects.all()
assert len(jobs) == 1

# Verify the job was processed successfully with the correct repository
job_obj = jobs[0]
assert job_obj.repository_id == test_repository_2.id


def change_state_result(test_job, job_loader, new_state, new_result, exp_state, exp_result):
# make a copy so we can modify it and not affect other tests
job = copy.deepcopy(test_job)
Expand Down
30 changes: 0 additions & 30 deletions tests/sample_data/pulse_consumer/job_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{
"taskId": "008dcdae-bde0-4834-a967-d13d681037ae/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -55,7 +54,6 @@
{
"taskId": "0401bb89-f4b5-41b1-820f-088e3fb36495/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -108,7 +106,6 @@
{
"taskId": "6e58db2d-115d-4f82-8609-6276fc2e91b1/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -161,7 +158,6 @@
{
"taskId": "6ff402cc-c8d5-4262-8fc8-ee4897425e77/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -214,7 +210,6 @@
{
"taskId": "73677162-e702-48c5-8f95-391bef4afcf6/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -267,7 +262,6 @@
{
"taskId": "09a2ba36-57c1-49fe-85f8-d015aeb2890d/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -320,7 +314,6 @@
{
"taskId": "0a29590a-79a2-4ca9-9a80-97bf87a1eae4/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -373,7 +366,6 @@
{
"taskId": "70f7bccb-4ef5-4a96-add3-d765033086ba/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -426,7 +418,6 @@
{
"taskId": "719ee073-d258-41ad-943c-40bf108c48ba/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -479,7 +470,6 @@
{
"taskId": "741f11e4-05ce-4597-82a4-37d0958525a3/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -532,7 +522,6 @@
{
"taskId": "7b560f96-5cfa-4cc6-b021-2a6e824471d6/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -585,7 +574,6 @@
{
"taskId": "79dce0cc-2a61-4c04-be40-dfd30277fb78/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -638,7 +626,6 @@
{
"taskId": "789f4f1b-8d6d-49a5-b335-4d6e63bfae49/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -691,7 +678,6 @@
{
"taskId": "7a441a78-2ff2-4742-bc8c-f2b1dbc13b10/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -744,7 +730,6 @@
{
"taskId": "15c6c852-855b-4b8b-adc4-5112f38c2b3f/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -797,7 +782,6 @@
{
"taskId": "15c943ea-003e-4d31-a0be-afebf7e2d20e/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -850,7 +834,6 @@
{
"taskId": "14d4f704-b890-4473-b5e0-d360a278d042/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -903,7 +886,6 @@
{
"taskId": "7ed5ec47-23b0-4607-a289-81f22135d438/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -956,7 +938,6 @@
{
"taskId": "19cbc73f-a1cb-49e3-bfac-a603376cbf4e/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -1009,7 +990,6 @@
{
"taskId": "18f2e4ef-c9ba-4b3e-934c-b24555c6b85f/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -1062,7 +1042,6 @@
{
"taskId": "23663e4c-135c-40f4-89ce-c2a507de6b7d/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -1115,7 +1094,6 @@
{
"taskId": "23e1e0ed-b338-4d43-aae0-9aa75f4a6dd2/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -1168,7 +1146,6 @@
{
"taskId": "3351028c-f241-4e59-b027-166ae695b2be/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -1221,7 +1198,6 @@
{
"taskId": "30aabc98-c33e-4483-b1ce-d5cee6783efc/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -1269,7 +1245,6 @@
{
"taskId": "32badb89-fcc1-4097-9f51-b4b6ca6e106a/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -1322,7 +1297,6 @@
{
"taskId": "39161834-c844-4f4c-b118-cbde97826e8e/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -1375,7 +1349,6 @@
{
"taskId": "4ea5830c-6a16-49b0-87f7-74534f13c05a/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -1428,7 +1401,6 @@
{
"taskId": "57caed20-3ae8-455f-86f5-bce3260952d0/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -1470,7 +1442,6 @@
{
"taskId": "5556b66a-6ccc-4bed-9c48-36e283d447b3/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down Expand Up @@ -1523,7 +1494,6 @@
{
"taskId": "60838ae3-4d72-4761-afca-020571f3d506/0",
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": "9c6e4c31ad26efdad0b9af47a2b530bc414ce2c3"
},
Expand Down
1 change: 0 additions & 1 deletion tests/sample_data/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ def generate_pulse_job_data(tasks, revision, output_file):
blob = {
"taskId": task["job_guid"],
"origin": {
"kind": "hg.mozilla.org",
"project": "set by test",
"revision": revision,
},
Expand Down
Loading