Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rabbitMQ in docker-compose #8

Merged
merged 1 commit into from
Jul 26, 2024
Merged
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
clones
.tox
**/__pycache__/
config.ini
config.toml
.coverage
23 changes: 23 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -2,3 +2,26 @@ services:
sync:
build: .
command: ['pytest', 'tests', '-p', 'no:cacheprovider']
environment:
- RABBITMQ=true
depends_on:
pulse:
condition: service_healthy
networks:
- pulse_network

pulse:
image: rabbitmq:3-management-alpine
healthcheck:
test: rabbitmq-diagnostics -q ping
interval: 5s
timeout: 2s
retries: 1
ports:
- 15672:15672
networks:
- pulse_network

networks:
pulse_network:
driver: bridge
8 changes: 4 additions & 4 deletions tests/pulse_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from datetime import datetime
from pathlib import Path
import sys

import kombu

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


def send_pulse_message(pulse_config, payload):
def send_pulse_message(pulse_config, payload, ssl=True):
"""Send a pulse message
The routing key will be constructed from the repository URL.
The Pulse message will be constructed from the specified payload
@@ -30,7 +30,7 @@ def send_pulse_message(pulse_config, payload):
userid=userid,
password=password,
connect_timeout=100,
ssl=True,
ssl=ssl,
)
connection.connect()

@@ -56,7 +56,7 @@ def send_pulse_message(pulse_config, payload):
"exchange": exchange,
"routing_key": routing_key,
"serializer": "json",
"sent": datetime.utcnow().isoformat(),
"sent": datetime.now(),
},
}

38 changes: 38 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import os

import pulse_utils
import pytest

from git_hg_sync.config import PulseConfig

NO_RABBITMQ = not (os.getenv("RABBITMQ") == "true")


@pytest.fixture
def pulse_config():
return PulseConfig(
**{
"userid": "guest",
"host": "pulse",
"port": 5672,
"exchange": "exchange/guest/test",
"routing_key": "#",
"queue": "queue/guest/test",
"password": "guest",
}
)


@pytest.mark.skipif(NO_RABBITMQ, reason="Test doesn't work without rabbitMq")
def test_send(pulse_config):
payload = {
"type": "tag",
"repo_url": "repo.git",
"tag": "Tag",
"commit": "sha",
"time": 0,
"pushid": 0,
"user": "user",
"push_json_url": "push_json_url",
}
pulse_utils.send_pulse_message(pulse_config, payload, ssl=False)
2 changes: 1 addition & 1 deletion tests/test_repo_synchronizer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from git_hg_sync.config import PulseConfig, MappingConfig
from git_hg_sync.__main__ import get_connection, get_queue
from git_hg_sync.config import MappingConfig, PulseConfig
from git_hg_sync.repo_synchronizer import Push, RepoSynchronyzer