Skip to content

Commit 2815075

Browse files
authoredJul 26, 2024
Merge pull request #8 from mozilla-conduit/docker-rabbit
add rabbitMQ in docker-compose
2 parents 7bfd31e + b112e93 commit 2815075

5 files changed

+67
-6
lines changed
 

‎.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
clones
22
.tox
33
**/__pycache__/
4-
config.ini
4+
config.toml
55
.coverage

‎docker-compose.yaml

+23
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,26 @@ services:
22
sync:
33
build: .
44
command: ['pytest', 'tests', '-p', 'no:cacheprovider']
5+
environment:
6+
- RABBITMQ=true
7+
depends_on:
8+
pulse:
9+
condition: service_healthy
10+
networks:
11+
- pulse_network
12+
13+
pulse:
14+
image: rabbitmq:3-management-alpine
15+
healthcheck:
16+
test: rabbitmq-diagnostics -q ping
17+
interval: 5s
18+
timeout: 2s
19+
retries: 1
20+
ports:
21+
- 15672:15672
22+
networks:
23+
- pulse_network
24+
25+
networks:
26+
pulse_network:
27+
driver: bridge

‎tests/pulse_utils.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import sys
12
from datetime import datetime
23
from pathlib import Path
3-
import sys
44

55
import kombu
66

@@ -9,7 +9,7 @@
99
HERE = Path(__file__).parent
1010

1111

12-
def send_pulse_message(pulse_config, payload):
12+
def send_pulse_message(pulse_config, payload, ssl=True):
1313
"""Send a pulse message
1414
The routing key will be constructed from the repository URL.
1515
The Pulse message will be constructed from the specified payload
@@ -30,7 +30,7 @@ def send_pulse_message(pulse_config, payload):
3030
userid=userid,
3131
password=password,
3232
connect_timeout=100,
33-
ssl=True,
33+
ssl=ssl,
3434
)
3535
connection.connect()
3636

@@ -56,7 +56,7 @@ def send_pulse_message(pulse_config, payload):
5656
"exchange": exchange,
5757
"routing_key": routing_key,
5858
"serializer": "json",
59-
"sent": datetime.utcnow().isoformat(),
59+
"sent": datetime.now(),
6060
},
6161
}
6262

‎tests/test_integration.py

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import os
2+
3+
import pulse_utils
4+
import pytest
5+
6+
from git_hg_sync.config import PulseConfig
7+
8+
NO_RABBITMQ = not (os.getenv("RABBITMQ") == "true")
9+
10+
11+
@pytest.fixture
12+
def pulse_config():
13+
return PulseConfig(
14+
**{
15+
"userid": "guest",
16+
"host": "pulse",
17+
"port": 5672,
18+
"exchange": "exchange/guest/test",
19+
"routing_key": "#",
20+
"queue": "queue/guest/test",
21+
"password": "guest",
22+
}
23+
)
24+
25+
26+
@pytest.mark.skipif(NO_RABBITMQ, reason="Test doesn't work without rabbitMq")
27+
def test_send(pulse_config):
28+
payload = {
29+
"type": "tag",
30+
"repo_url": "repo.git",
31+
"tag": "Tag",
32+
"commit": "sha",
33+
"time": 0,
34+
"pushid": 0,
35+
"user": "user",
36+
"push_json_url": "push_json_url",
37+
}
38+
pulse_utils.send_pulse_message(pulse_config, payload, ssl=False)

‎tests/test_repo_synchronizer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22

3-
from git_hg_sync.config import PulseConfig, MappingConfig
43
from git_hg_sync.__main__ import get_connection, get_queue
4+
from git_hg_sync.config import MappingConfig, PulseConfig
55
from git_hg_sync.repo_synchronizer import Push, RepoSynchronyzer
66

77

0 commit comments

Comments
 (0)
Failed to load comments.