Skip to content

Commit 8b3f3a1

Browse files
authored
Merge pull request #115 from manahl/xfang-httpd-drop-rhel5-support
pytest-server-fixtures: httpd: add rhel7 support
2 parents 71a102e + daafada commit 8b3f3a1

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
### 1.5.0 (Unreleased)
55
* pytest-server-fixtures: made postgres fixtures and its tests optional, like all other fixtures
66
* pytest-server-fixtures: reverted a fix for pymongo deprecation warning, as this will break compatibility with pymongo 3.6.0
7+
* pytest-server-fixtures: dropped RHEL5 support in httpd
78

89
### 1.4.1 (2019-01-18)
910
* pytest-server-fixtures: server fixture binary path specified in ENV now only affect server class 'thread'

pytest-server-fixtures/pytest_server_fixtures/httpd.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import functools
12
import os
3+
import platform
24
import socket
35
import string
46
import logging
@@ -17,11 +19,15 @@
1719
log = logging.getLogger(__name__)
1820

1921

22+
def is_rhel():
23+
""""Check if OS is RHEL/Centos"""
24+
return 'el' in platform.uname()[2]
25+
2026
@pytest.yield_fixture(scope='function')
2127
@yield_requires_config(CONFIG, ['httpd_executable', 'httpd_modules'])
2228
def httpd_server():
2329
""" Function-scoped httpd server in a local thread.
24-
30+
2531
Methods
2632
-------
2733
get() : Query url relative to the server root.
@@ -53,6 +59,10 @@ class HTTPDServer(HTTPTestServer):
5359
LoadModule authz_core_module $modules/mod_authz_core.so
5460
"""
5561

62+
cfg_rhel_template = """
63+
LoadModule unixd_module modules/mod_unixd.so
64+
"""
65+
5666
cfg_mpm_template = """
5767
LoadModule mpm_prefork_module $modules/mod_mpm_prefork.so
5868
StartServers 1
@@ -99,10 +109,18 @@ def __init__(self, proxy_rules=None, extra_cfg='', document_root=None, log_dir=N
99109
Server log directory, defaults to $(workspace)/logs
100110
"""
101111
self.proxy_rules = proxy_rules if proxy_rules is not None else {}
102-
self.cfg_template = string.Template(self.cfg_modules_template +
103-
self.cfg_mpm_template +
104-
self.cfg_template +
105-
extra_cfg)
112+
113+
if not is_rhel():
114+
self.cfg_template = string.Template(self.cfg_modules_template +
115+
self.cfg_mpm_template +
116+
self.cfg_template +
117+
extra_cfg)
118+
else:
119+
self.cfg_template = string.Template(self.cfg_modules_template +
120+
self.cfg_rhel_template +
121+
self.cfg_mpm_template +
122+
self.cfg_template +
123+
extra_cfg)
106124

107125
# Always print debug output for this process
108126
os.environ['DEBUG'] = '1'
@@ -111,7 +129,7 @@ def __init__(self, proxy_rules=None, extra_cfg='', document_root=None, log_dir=N
111129
kwargs['hostname'] = kwargs.get('hostname', socket.gethostbyname(os.uname()[1]))
112130

113131
super(HTTPDServer, self).__init__(**kwargs)
114-
132+
115133
self.document_root = document_root or self.workspace
116134
self.document_root = Path(self.document_root)
117135
self.log_dir = log_dir or self.workspace / 'logs'

0 commit comments

Comments
 (0)