-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UMB broker to docker-compose environment
Signed-off-by: Lukas Holecek <hluk@email.cz>
- Loading branch information
Showing
8 changed files
with
311 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
|
||
config = { | ||
# fedmsg boilerplate | ||
'endpoints': {}, | ||
'sign_messages': False, | ||
'validate_signatures': False, | ||
|
||
# STOMP settings | ||
'zmq_enabled': False, | ||
'stomp_uri': 'umb:61612', | ||
'stomp_heartbeat': 900000, | ||
'stomp_ack_mode': 'client-individual', | ||
|
||
# Hacks to make us publish to | ||
# /topic/VirtualTopic.eng.greenwave.decision.update | ||
'topic_prefix': '/topic/VirtualTopic', | ||
'environment': 'eng', | ||
'resultsdb_topic_suffix': 'resultsdb.result.new', | ||
'waiverdb_topic_suffix': 'waiverdb.waiver.new', | ||
|
||
# Workaround for moksha memory leak and mitigate message loss. | ||
# Memory leak is fixed in python-moksha-hub-1.5.7 (https://github.com/mokshaproject/moksha/pull/57). | ||
'moksha.blocking_mode': True, | ||
|
||
# moksha-monitor-exporter's point of contact | ||
'moksha.monitoring.socket': 'tcp://0.0.0.0:10030', | ||
} | ||
|
||
# Enable one consumer or the other in different deployments. | ||
if os.environ.get("RESULTSDB_HANDLER") and os.environ.get("WAIVERDB_HANDLER"): | ||
raise ValueError("Both RESULTSDB_HANDLER and WAIVERDB_HANDLER may not" | ||
"be specified. Only one.") | ||
|
||
if os.environ.get("RESULTSDB_HANDLER"): | ||
config.update({ | ||
'resultsdb_handler': True, | ||
'waiverdb_handler': False, | ||
'stomp_queue': '/queue/Consumer.client-greenwave.resultsdb.VirtualTopic.eng.resultsdb.result.new', | ||
}) | ||
elif os.environ.get("WAIVERDB_HANDLER"): | ||
config.update({ | ||
'resultsdb_handler': False, | ||
'waiverdb_handler': True, | ||
'stomp_queue': '/queue/Consumer.client-greenwave.waiverdb.VirtualTopic.eng.waiverdb.waiver.new', | ||
}) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
config = dict(logging={ | ||
"version": 1, | ||
"disable_existing_loggers": False, | ||
"formatters": { | ||
"bare": { | ||
"datefmt": "%Y-%m-%d %H:%M:%S", | ||
"format": "[%(asctime)s][%(name)10s %(levelname)7s] %(message)s" | ||
} | ||
}, | ||
"loggers": { | ||
"greenwave": { | ||
"handlers": ["console"], "propagate": True, "level": "DEBUG" | ||
}, | ||
"moksha": { | ||
"handlers": ["console"], "propagate": False, "level": "DEBUG" | ||
}, | ||
"requests": { | ||
"handlers": ["console"], "propagate": False, "level": "DEBUG" | ||
}, | ||
"resultsdb_handler": { | ||
"handlers": ["console"], "propagate": False, "level": "DEBUG" | ||
}, | ||
"waiverdb_handler": { | ||
"handlers": ["console"], "propagate": False, "level": "DEBUG" | ||
}, | ||
"dogpile": { | ||
"handlers": ["console"], "propagate": False, "level": "DEBUG" | ||
}, | ||
}, | ||
"handlers": { | ||
"console": { | ||
"formatter": "bare", | ||
"class": "logging.StreamHandler", | ||
"stream": "ext://sys.stdout", | ||
"level": "DEBUG" | ||
} | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
import os | ||
import itertools | ||
|
||
from pprint import pprint | ||
|
||
from rhmsg.activemq.consumer import AMQConsumer | ||
|
||
ADDRESS = "Consumer.mister.queue.VirtualTopic.eng.>" | ||
SUBSCRIPTION_NAME = "Greenwave" | ||
URLS = ["amqp://localhost:5671"] | ||
|
||
counter = itertools.count(1) | ||
|
||
|
||
class InsecureAMQConsumer(AMQConsumer): | ||
ssl_domain = None | ||
|
||
def __init__(self, urls): | ||
self.urls = urls | ||
|
||
|
||
def message_handler(message, data): | ||
num = next(counter) | ||
|
||
body = message.body | ||
if isinstance(body, str): | ||
body = body.encode("utf-8", "backslashreplace") | ||
if data["dump"]: | ||
print("------------- ({0}) {1} --------------".format(num, message.id)) | ||
print("address:", message.address) | ||
print("subject:", message.subject) | ||
print("properties:", message.properties) | ||
print("durable:", message.durable) | ||
print("content_type:", message.content_type) | ||
print("content_encoding:", message.content_encoding) | ||
print("delivery_count:", message.delivery_count) | ||
print("reply_to:", message.reply_to) | ||
print("priority:", message.priority) | ||
if data["pp"]: | ||
print("body:") | ||
pprint(json.loads(body)) | ||
else: | ||
print("body:", body) | ||
else: | ||
if data["pp"]: | ||
print("Got [%02d]:" % num) | ||
pprint(json.loads(body)) | ||
else: | ||
print("Got [%02d]:" % num, body) | ||
|
||
return data["one_message_only"], not data["manual_ack"] | ||
|
||
|
||
def main(): | ||
os.environ['PN_TRACE_FRM'] = '1' | ||
consumer = InsecureAMQConsumer(urls=URLS) | ||
consumer.consume( | ||
ADDRESS, | ||
selector=None, | ||
callback=message_handler, | ||
auto_accept=False, | ||
subscription_name=SUBSCRIPTION_NAME, | ||
data={ | ||
"dump": False, | ||
"pp": False, | ||
"one_message_only": False, | ||
"manual_ack": False, | ||
}, | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import json | ||
import proton | ||
import os | ||
import sys | ||
|
||
from rhmsg.activemq.producer import AMQProducer | ||
|
||
TOPIC = "VirtualTopic.eng.resultsdb.result.new" | ||
URLS = ["amqp://localhost:5671"] | ||
SUBJECT = f"test_message_{sys.argv[1]}" | ||
MESSAGE = { | ||
"submit_time": "2019-08-27T13:57:53.490376", | ||
"testcase": { | ||
"name": "example_test" | ||
}, | ||
"data": { | ||
"type": ["brew-build"], | ||
"item": ["example-container"] | ||
} | ||
} | ||
MESSAGE = { | ||
"data": { | ||
"category": ["validation"], | ||
"ci_email": ["exd-guild-gating@redhat.com"], | ||
"ci_irc": ["not available"], | ||
"ci_name": ["example-jenkins"], | ||
"ci_team": ["PnT DevOps"], | ||
"ci_url": ["https://jenkins.example.com"], | ||
"component": ["nethack-prod"], | ||
"item": ["nethack-prod-3.5.202110051331.w9756"], | ||
"log": ["https://jenkins.example.com/job/x/build/y/console"], | ||
"publisher_id": ["msg-greenwave-segment-test"], | ||
"type": ["koji_build"], | ||
"version": ["3.5.202110051331.w9756"] | ||
}, | ||
"groups": ["52c6b84b-b617-4b79-af47-8975d11bb635"], | ||
"href": "http://resultsdb/api/v2.0/results/123", | ||
"id": 123, | ||
"note": "", | ||
"outcome": "PASSED", | ||
"ref_url": "https://jenkins.example.com/job/x/build/y", | ||
"submit_time": "2021-10-05T13:35:29.721850", | ||
"testcase": { | ||
"href": "http://resultsdb/api/v2.0/testcases/dist.abicheck", | ||
"name": "dist.abicheck", | ||
"ref_url": "https://jenkins.example.com/job/x/build/y" | ||
} | ||
} | ||
|
||
|
||
def main(): | ||
os.environ['PN_TRACE_FRM'] = '1' | ||
|
||
with AMQProducer(urls=URLS) as producer: | ||
# Disable SSL | ||
del producer.conf["cert"] | ||
|
||
producer.through_topic(TOPIC) | ||
body = json.dumps(MESSAGE) | ||
message = proton.Message( | ||
subject=SUBJECT, | ||
body=body) | ||
producer.send(message) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
server: | ||
port: 8081 | ||
management: | ||
security.enabled: false | ||
endpoints: | ||
enabled-by-default: false | ||
web: | ||
base-path: / | ||
exposure: | ||
include: "*" | ||
health: | ||
jms.enabled: false | ||
amq.enabled: true | ||
ldap.enabled: false | ||
umb: | ||
ldap: | ||
embedded: | ||
enabled: false | ||
amq: | ||
broker: | ||
plugins: | ||
enableLdapBackedAuthentication: false | ||
enableLdapBackedAuthorization: false | ||
transportConnectors: | ||
- amqp://0.0.0.0:5671?transport.maximumConnections=2500&transport.needClientAuth=true&transport.transformer=jms&wireFormat.allowNonSaslConnections=true&transport.closeAsync=false&transport.daemon=true&wireFormat.maxInactivityDurationInitalDelay=60000&wireFormat.maxInactivityDuration=60000 | ||
- stomp://0.0.0.0:61612?transport.maximumConnections=2500&transport.needClientAuth=true&transport.closeAsync=false&transport.daemon=true&wireFormat.maxInactivityDurationInitalDelay=60000&wireFormat.maxInactivityDuration=60000 | ||
logging: | ||
pattern: | ||
dateformat: "yyyy-MM-dd'T'HH:mm:ss.SSSZ" | ||
path: /var/log/umb | ||
file.max-size: 10MB | ||
file.max-history: 50 | ||
server.asyncappender.queue.size: 20000 | ||
dlq.asyncappender.queue.size: 5000 |