[fedmsg] Patch tests to not be ridiculous.
Ralph Bean
ralph at fedoraproject.org
Thu Sep 5 19:34:37 UTC 2013
commit 52c1a272f952b0b092b1d9393f480249601ed8b4
Author: Ralph Bean <rbean at redhat.com>
Date: Thu Sep 5 15:34:19 2013 -0400
Patch tests to not be ridiculous.
fedmsg-consistent-gethostname.patch | 113 +++++++++++++++++++++++++++++++++++
fedmsg.spec | 7 ++-
2 files changed, 119 insertions(+), 1 deletions(-)
---
diff --git a/fedmsg-consistent-gethostname.patch b/fedmsg-consistent-gethostname.patch
new file mode 100644
index 0000000..86acee7
--- /dev/null
+++ b/fedmsg-consistent-gethostname.patch
@@ -0,0 +1,113 @@
+From 3adf17ef8c766db3b8c7064965abc3e467fa6ae6 Mon Sep 17 00:00:00 2001
+From: Ralph Bean <rbean at redhat.com>
+Date: Thu, 5 Sep 2013 15:27:52 -0400
+Subject: [PATCH] Make usage of socket.gethostname consistent throughout the
+ test suite (so that we succeed on a koji builder).
+
+---
+ fedmsg.d/endpoints.py | 2 +-
+ fedmsg.d/ssl.py | 1 -
+ fedmsg/tests/common.py | 2 +-
+ fedmsg/tests/fedmsg-test-config.py | 2 +-
+ fedmsg/tests/test_replay.py | 2 +-
+ fedmsg/tests/test_threads.py | 6 +++---
+ 6 files changed, 7 insertions(+), 8 deletions(-)
+
+diff --git a/fedmsg.d/endpoints.py b/fedmsg.d/endpoints.py
+index 9144a80..3599165 100644
+--- a/fedmsg.d/endpoints.py
++++ b/fedmsg.d/endpoints.py
+@@ -18,7 +18,7 @@
+ # Authors: Ralph Bean <rbean at redhat.com>
+ #
+ import socket
+-hostname = socket.gethostname()
++hostname = socket.gethostname().split('.', 1)[0]
+
+ config = dict(
+ # This is a dict of possible addresses from which fedmsg can send
+diff --git a/fedmsg.d/ssl.py b/fedmsg.d/ssl.py
+index 2aa4c71..fb5aa1e 100644
+--- a/fedmsg.d/ssl.py
++++ b/fedmsg.d/ssl.py
+@@ -22,7 +22,6 @@ import socket
+
+ SEP = os.path.sep
+ here = os.getcwd()
+-hostname = socket.gethostname()
+
+ config = dict(
+ sign_messages=False,
+diff --git a/fedmsg/tests/common.py b/fedmsg/tests/common.py
+index 57d9314..7643918 100644
+--- a/fedmsg/tests/common.py
++++ b/fedmsg/tests/common.py
+@@ -24,7 +24,7 @@ def load_config(name='fedmsg-test-config.py'):
+ config['zmq_subscribe_endpoints'] = ','.join(
+ ','.join(bunch) for bunch in config['endpoints'].values()
+ )
+- hub_name = "twisted.%s" % socket.gethostname()
++ hub_name = "twisted.%s" % socket.gethostname().split('.', 1)[0]
+ config['zmq_publish_endpoints'] = ','.join(
+ config['endpoints'][hub_name]
+ )
+diff --git a/fedmsg/tests/fedmsg-test-config.py b/fedmsg/tests/fedmsg-test-config.py
+index 971289f..571f1de 100644
+--- a/fedmsg/tests/fedmsg-test-config.py
++++ b/fedmsg/tests/fedmsg-test-config.py
+@@ -24,7 +24,7 @@ import random
+
+ SEP = os.path.sep
+ here = os.getcwd()
+-hostname = socket.gethostname()
++hostname = socket.gethostname().split('.', 1)[0]
+
+ ssl_enabled_for_tests = True
+ try:
+diff --git a/fedmsg/tests/test_replay.py b/fedmsg/tests/test_replay.py
+index b46e115..cff7abf 100644
+--- a/fedmsg/tests/test_replay.py
++++ b/fedmsg/tests/test_replay.py
+@@ -44,7 +44,7 @@ from fedmsg.replay.sqlstore import SqlStore, SqlMessage
+ from sqlalchemy.orm import sessionmaker
+ from sqlalchemy import create_engine
+
+-hostname = socket.gethostname()
++hostname = socket.gethostname().split('.', 1)[0]
+ local_name = 'unittest.{0}'.format(hostname)
+
+
+diff --git a/fedmsg/tests/test_threads.py b/fedmsg/tests/test_threads.py
+index 5ff8518..3cd0043 100644
+--- a/fedmsg/tests/test_threads.py
++++ b/fedmsg/tests/test_threads.py
+@@ -57,7 +57,7 @@ def load_config(name='fedmsg-test-config.py'):
+ config['zmq_subscribe_endpoints'] = ','.join(
+ ','.join(bunch) for bunch in config['endpoints'].values()
+ )
+- hub_name = "twisted.%s" % socket.gethostname()
++ hub_name = "twisted.%s" % socket.gethostname().split('.', 1)[0]
+ config['zmq_publish_endpoints'] = ','.join(
+ config['endpoints'][hub_name]
+ )
+@@ -90,7 +90,7 @@ class TestHub(unittest.TestCase):
+ self.hub.subscribe(topic=self.fq_topic, callback=callback)
+ sleep(sleep_duration)
+
+- test_name = "__main__.%s" % socket.gethostname()
++ test_name = "__main__.%s" % socket.gethostname().split('.', 1)[0]
+ self.config['name'] = test_name
+
+ class Publisher(threading.Thread):
+@@ -117,7 +117,7 @@ class TestHub(unittest.TestCase):
+ def test_reinitialize(self):
+ """ In a thread, try to destroy and re-init the API. """
+
+- test_name = "__main__.%s" % socket.gethostname()
++ test_name = "__main__.%s" % socket.gethostname().split('.', 1)[0]
+ self.config['name'] = test_name
+
+ self.test_reinit_success = False
+--
+1.8.3.1
+
diff --git a/fedmsg.spec b/fedmsg.spec
index 1cf7c91..b0c16e5 100644
--- a/fedmsg.spec
+++ b/fedmsg.spec
@@ -5,12 +5,13 @@
Name: fedmsg
Version: 0.7.0
-Release: 2%{?dist}
+Release: 3%{?dist}
Summary: Tools for Fedora Infrastructure real-time messaging
Group: Applications/Internet
License: LGPLv2+
URL: http://github.com/ralphbean/fedmsg
Source0: http://pypi.python.org/packages/source/f/%{modname}/%{modname}-%{version}.tar.gz
+Patch0: fedmsg-consistent-gethostname.patch
BuildArch: noarch
@@ -126,6 +127,7 @@ socket. Useful for repeating messages outside a firewal.
%prep
%setup -q -n %{modname}-%{version}
+%patch0 -p1
# This only got shipped with fedmsg-0.6.3
rm -f fedmsg.d/_tweet-real.py
@@ -308,6 +310,9 @@ fi
%config(noreplace) %{_sysconfdir}/fedmsg.d/gateway.py*
%changelog
+* Thu Sep 05 2013 Ralph Bean <rbean at redhat.com> - 0.7.0-3
+- Patch tests to use socket.gethostname consistently.
+
* Thu Sep 05 2013 Ralph Bean <rbean at redhat.com> - 0.7.0-2
- Knock out sqlalchemy test dep.
More information about the scm-commits
mailing list