1+ import functools
12import os
3+ import platform
24import socket
35import string
46import logging
1719log = 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' ])
2228def 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