Skip to content

Commit 076d2c7

Browse files
committed
Merge branch 'bug1963745/spurious-message-reprocessing' into develop
2 parents fc24ded + ec78f80 commit 076d2c7

File tree

12 files changed

+95
-24
lines changed

12 files changed

+95
-24
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ variables:
137137
- PULSE_QUEUE
138138
- PULSE_ROUTING_KEY
139139
- PULSE_SSL (needs to be an empty string to be False, otherwise True)
140+
- PULSE_HEARTBEAT (needs to be an integer)
140141
- PULSE_USERID
141142

142143
### SSH key

config-development.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ password = "SET THIS IN PULSE_PASSWORD ENV VARIABLE"
99
exchange = "exchange/landodev/pushes"
1010
routing_key = "gitpushes"
1111
# The Consumer declares the queue and binds it to the exchange.
12+
heartbeat = 30
1213
queue = "queue/githgsyncdev/pushes"
1314

1415
[sentry]

config-docker.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ exchange = "exchange/git-hg-sync/test"
66
routing_key = "git-hg-sync"
77
queue = "queue/git-hg-sync/sync"
88
password = "guest"
9+
heartbeat = 30
910
ssl = false
1011

1112
[sentry]

config-production.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ password = "SET THIS IN PULSE_PASSWORD ENV VARIABLE"
99
exchange = "exchange/landoprod/pushes"
1010
routing_key = "gitpushes"
1111
# The Consumer declares the queue and binds it to the exchange.
12+
heartbeat = 30
1213
queue = "queue/githgsyncprod/pushes"
1314

1415
[sentry]

config-staging.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ password = "SET THIS IN PULSE_PASSWORD ENV VARIABLE"
99
exchange = "exchange/landostage/pushes"
1010
routing_key = "gitpushes"
1111
# The Consumer declares the queue and binds it to the exchange.
12+
heartbeat = 30
1213
queue = "queue/githgsyncstage/pushes"
1314

1415
[sentry]

config.toml.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ exchange = "exchange/<username>/test"
66
routing_key = ""
77
queue = "queue/<username>/test"
88
password = "<pulse-password>"
9+
heartbeat = 30
910
ssl = true
1011

1112
[sentry]

git_hg_sync/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def get_connection(config: PulseConfig) -> Connection:
3131
port=config.port,
3232
userid=config.userid,
3333
password=config.password,
34-
heartbeat=3,
34+
heartbeat=config.heartbeat,
3535
ssl=config.ssl,
3636
)
3737

git_hg_sync/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class PulseConfig(pydantic.BaseModel):
1919
routing_key: str
2020
queue: str
2121
password: str
22+
heartbeat: int
2223
ssl: bool
2324

2425

git_hg_sync/pulse_worker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ class EntityTypeError(Exception):
2121

2222

2323
class PulseWorker(ConsumerMixin):
24-
event_handler: EventHandler | None
2524
"""Function that will be called whenever an event is received"""
2625

26+
event_handler: EventHandler | None
27+
2728
def __init__(
2829
self,
2930
connection: kombu.Connection,

tests/conftest.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import sys
2+
from collections.abc import Callable
3+
from pathlib import Path
24

35
import mozlog
46
import mozlog.formatters
57
import mozlog.handlers
68
import pytest
79

8-
from git_hg_sync.config import PulseConfig
10+
from git_hg_sync.config import ClonesConfig, Config, PulseConfig, TrackedRepository
11+
from git_hg_sync.mapping import BranchMapping
912

1013

1114
@pytest.fixture(autouse=True, scope="session")
@@ -27,5 +30,42 @@ def pulse_config() -> PulseConfig:
2730
routing_key="#",
2831
queue="queue/guest/test",
2932
password="guest",
33+
heartbeat=30,
3034
ssl=False,
3135
)
36+
37+
@pytest.fixture
38+
def test_config(pulse_config: PulseConfig) -> Config:
39+
return Config(
40+
pulse=pulse_config,
41+
clones=ClonesConfig(directory=Path("clones")),
42+
tracked_repositories=[
43+
TrackedRepository(name="mozilla-central", url="https://github.com/mozilla-firefox/firefox.git"),
44+
],
45+
branch_mappings=[BranchMapping(
46+
branch_pattern = '.*',
47+
source_url = "https://github.com/mozilla-firefox/firefox.git",
48+
destination_url = 'destination_url',
49+
destination_branch = 'destination_branch',
50+
)],
51+
)
52+
53+
@pytest.fixture
54+
def get_payload() -> Callable:
55+
56+
def get_payload(**kwargs: dict) -> dict:
57+
"""Return a default payload, with override via kwargs."""
58+
payload = {
59+
"type": "push",
60+
"repo_url": "repo.git",
61+
"branches": { "main": 40 * "0"},
62+
"tags": {},
63+
"time": 0,
64+
"push_id": 0,
65+
"user": "user",
66+
"push_json_url": "push_json_url",
67+
}
68+
payload.update(kwargs)
69+
return payload
70+
71+
return get_payload

0 commit comments

Comments
 (0)