Skip to content
This repository was archived by the owner on Jan 14, 2021. It is now read-only.
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
15 changes: 8 additions & 7 deletions .travis-Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,23 @@ RUN yum -y update && \
gcc-c++ \
krb5-devel \
libffi-devel \
libyaml-devel \
# libyaml-devel \
openssl-devel \
python27 \
python-devel \
python-pip \
python3 \
python3-devel \
python3-pip \
redhat-rpm-config \
swig \
zeromq-devel \
rpm-devel \
python2-koji \
python3-koji \
libmodulemd && \
yum clean all

COPY . .

RUN pip install --upgrade pip setuptools && \
python setup.py develop && pip install -r test-requirements.txt
RUN pip3 install --upgrade pip setuptools && \
python3 setup.py develop && \
pip3 install -r test-requirements.txt

CMD ["pytest", "-v", "pdcupdater/tests/"]
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ Try running the test suite::

$ dnf install libyaml-devel
$ pip install -r test-requirements.txt
$ nosetests
$ pytest

Check test suite coverage::

$ pip install coverage
$ nosetests --with-coverage --cover-package=pdcupdater
$ pytest --with-coverage --cov=pdcupdater

If the test suite is failing, one thing to try is to remove the VCR cassette
data before re-running the tests::

$ rm -rf pdcupdater/tests/vcr-request-data/
$ nosetests
$ pytest

Getting an authentication token
-------------------------------
Expand Down
26 changes: 13 additions & 13 deletions fedmsg.d/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,38 @@
#
# Authors: Ralph Bean <rbean@redhat.com>
#
config = dict(
config = {
# Set this to dev if you're hacking on fedmsg or an app.
# Set to stg or prod if running in the Fedora Infrastructure
environment="dev",
'environment': "dev",

# Default is 0
high_water_mark=0,
io_threads=1,
'high_water_mark': 0,
'io_threads': 1,

## For the fedmsg-hub and fedmsg-relay. ##

# We almost always want the fedmsg-hub to be sending messages with zmq as
# opposed to amqp or stomp.
zmq_enabled=True,
'zmq_enabled': True,

# When subscribing to messages, we want to allow splats ('*') so we tell
# the hub to not be strict when comparing messages topics to subscription
# topics.
zmq_strict=False,
'zmq_strict': False,

# Number of seconds to sleep after initializing waiting for sockets to sync
post_init_sleep=0.5,
'post_init_sleep': 0.5,

# Wait a whole second to kill all the last io threads for messages to
# exit our outgoing queue (if we have any). This is in milliseconds.
zmq_linger=1000,
'zmq_linger': 1000,

# See the following
# - http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html
# - http://api.zeromq.org/3-2:zmq-setsockopt
zmq_tcp_keepalive=1,
zmq_tcp_keepalive_cnt=3,
zmq_tcp_keepalive_idle=60,
zmq_tcp_keepalive_intvl=5,
)
'zmq_tcp_keepalive': 1,
'zmq_tcp_keepalive_cnt': 3,
'zmq_tcp_keepalive_idle': 60,
'zmq_tcp_keepalive_intvl': 5,
}
36 changes: 18 additions & 18 deletions fedmsg.d/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,49 @@
# See the following for constraints on this format http://bit.ly/Xn1WDn
bare_format = "[%(asctime)s][%(name)10s %(levelname)7s] %(message)s"

config = dict(
logging=dict(
version=1,
formatters=dict(
bare={
config = {
'logging': {
'version': 1,
'formatters': {
'bare': {
"datefmt": "%Y-%m-%d %H:%M:%S",
"format": bare_format
},
),
handlers=dict(
console={
},
'handlers': {
'console': {
"class": "logging.StreamHandler",
"formatter": "bare",
"level": "DEBUG",
"stream": "ext://sys.stdout",
}
),
loggers=dict(
fedmsg={
},
'loggers': {
'fedmsg': {
"level": "DEBUG",
"propagate": False,
"handlers": ["console"],
},
moksha={
'moksha': {
"level": "DEBUG",
"propagate": False,
"handlers": ["console"],
},
pkgdb2client={
'pkgdb2client': {
"level": "INFO",
"propagate": False,
"handlers": ["console"],
},
modules={
'modules': {
"level": "DEBUG",
"propagate": False,
"handlers": ["console"],
},
pdcupdater={
'pdcupdater': {
"level": "DEBUG",
"propagate": False,
"handlers": ["console"],
},
),
),
)
},
},
}
10 changes: 5 additions & 5 deletions fedmsg.d/pdcupdater-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@
'pdcupdater.ContainerRPMInclusionDepChainHandler.container_build_user': 'containerbuild',

# Augment the base fedmsg logging config to also handle pdcupdater loggers.
'logging': dict(
loggers=dict(
pdcupdater={
'logging': {
'loggers': {
'pdcupdater': {
"level": "DEBUG",
"propagate": False,
"handlers": ["console"],
},
)
)
},
},
}
33 changes: 16 additions & 17 deletions fedmsg.d/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,28 @@
# Authors: Ralph Bean <rbean@redhat.com>
#
import os
import socket

SEP = os.path.sep
here = os.getcwd()

config = dict(
sign_messages=False,
validate_signatures=False,
config = {
'sign_messages': False,
'validate_signatures': False,

# Use these implementations to sign and validate messages
crypto_backend='x509',
crypto_validate_backends=['x509'],
'crypto_backend': 'x509',
'crypto_validate_backends': ['x509'],

ssldir="/etc/pki/fedmsg",
crl_location="https://fedoraproject.org/fedmsg/crl.pem",
crl_cache="/var/run/fedmsg/crl.pem",
crl_cache_expiry=10,
'ssldir': "/etc/pki/fedmsg",
'crl_location': "https://fedoraproject.org/fedmsg/crl.pem",
'crl_cache': "/var/run/fedmsg/crl.pem",
'crl_cache_expiry': 10,

ca_cert_location="https://fedoraproject.org/fedmsg/ca.crt",
ca_cert_cache="/var/run/fedmsg/ca.crt",
ca_cert_cache_expiry=0, # Never expires
'ca_cert_location': "https://fedoraproject.org/fedmsg/ca.crt",
'ca_cert_cache': "/var/run/fedmsg/ca.crt",
'ca_cert_cache_expiry': 0, # Never expires

certnames={
'certnames': {
# In prod/stg, map hostname to the name of the cert in ssldir.
# Unfortunately, we can't use socket.getfqdn()
#"app01.stg": "app01.stg.phx2.fedoraproject.org",
Expand All @@ -49,7 +48,7 @@
# A mapping of fully qualified topics to a list of cert names for which
# a valid signature is to be considered authorized. Messages on topics not
# listed here are considered automatically authorized.
routing_policy={
'routing_policy': {
# Only allow announcements from production if they're signed by a
# certain certificate.
"org.fedoraproject.prod.announce.announcement": [
Expand All @@ -62,5 +61,5 @@
# When this is False, only messages that have a topic in the routing_policy
# but whose cert names aren't in the associated list are dropped; messages
# whose topics do not appear in the routing_policy are not dropped.
routing_nitpicky=False,
)
'routing_nitpicky': False,
}
78 changes: 39 additions & 39 deletions pdcupdater/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ def retry():

def _initialize_basics(pdc):
""" Gotta have these before we can really do anything... """
arches = [dict(name=name) for name in ["armhfp", "i386", "x86_64"]]
arches = [{'name': name} for name in ["armhfp", "i386", "x86_64"]]
pdc_arches = list(pdc.get_paged(pdc['arches']._))
for arch in arches:
if arch not in pdc_arches:
log.info("Creating arch %r." % arch['name'])
log.info("Creating arch %r.", arch['name'])
pdc['arches']._(arch)


Expand All @@ -50,8 +50,8 @@ def initialize():
_initialize_basics(pdc)
handlers = pdcupdater.handlers.load_handlers(config)
for handler in handlers:
log.info("Calling .initialize() on %r" % handler)
pdc.set_comment("Initialized via %r" % handler)
log.info("Calling .initialize() on %r", handler)
pdc.set_comment(f"Initialized via {handler!r}")
try:
handler.initialize(pdc)
except beanbag.bbexcept.BeanBagException as e:
Expand All @@ -68,7 +68,7 @@ def audit():
results = {}
for handler in handlers:
name = type(handler).__name__
log.info('Performing audit for %s' % name)
log.info('Performing audit for %s', name)
results[name] = handler.audit(pdc)

verbose = False
Expand All @@ -82,75 +82,75 @@ def _print_audit_report(results, verbose):
fail = fail or present or absent

if not fail:
print "Everything seems to be OK."
print("Everything seems to be OK.")
else:
print "WARNING - audit script detected something is wrong."
print("WARNING - audit script detected something is wrong.")

print
print "Summary"
print "======="
print
print()
print("Summary")
print("=======")
print()

for key, values in results.items():
present, absent = values
if not present and not absent:
print "- [x]", key
print(f"- [x] {key}")
else:
print "- [!]", key
print " ", len(present), "extra entries in PDC unaccounted for"
print " ", len(absent), "entries absent from PDC"
print(f"- [!] {key}")
print(f" {len(present)} extra entries in PDC unaccounted for")
print(f" {len(absent)} entries absent from PDC")

print
print "Details"
print "======="
print()
print("Details")
print("=======")

limit = 100
for key, values in results.items():
present, absent = values
if not present and not absent:
continue

print
print key
print "-" * len(key)
print
print()
print(key)
print("-" * len(key))
print()

if not present:
print "No extra entries in PDC that do not appear in the source."
print("No extra entries in PDC that do not appear in the source.")
else:
print "Values present in PDC but missing from the source:"
print
print("Values present in PDC but missing from the source:")
print()
if verbose or len(present) < limit:
for value in present:
print "-", value
print(f"- {value}")
if isinstance(present, dict):
print " ", present[value]
print(f" {present[value]}")
else:
present = list(present)
for value in present[:limit]:
print "-", value
print(f"- {value}")
if isinstance(present, dict):
print " ", present[value]
print "- (plus %i more... truncated.)" % (len(present) - limit)
print
print(f" {present[value]}")
print(f"- (plus {len(present) - limit} more... truncated.)")
print()

if not absent:
print "No entries found in the source to be absent from from PDC."
print("No entries found in the source to be absent from from PDC.")
else:
print "Values absent from PDC but present in the source:"
print
print("Values absent from PDC but present in the source:")
print()
if verbose or len(absent) < limit:
for value in absent:
print "-", value
print(f"- {value}")
if isinstance(absent, dict):
print " ", absent[value]
print(f" {absent[value]}")
else:
absent = list(absent)
for value in absent[:limit]:
print "-", value
print(f"- {value}")
if isinstance(absent, dict):
print " ", absent[value]
print "- (plus %i more... truncated.)" % (len(absent) - limit)
print(f" {absent[value]}")
print(f"- (plus {len(absent) - limit} more... truncated.)")

if not fail:
return 0
Expand Down
Loading