Some fixes and documentation
- Introduced ACME HTTP-01 challenge documentation. - Added Docker Compose example for HTTP-01 setup. - Updated `get_haproxy_command` logic with improved PID validation using `psutil`. - Enhanced logging with a new `SingleLineNonEmptyFilter`. - Expanded tests for daemonize functionalities. - Updated dependencies to include `psutil`.
This commit is contained in:
parent
b4b02916af
commit
ea9e4ee7c8
8 changed files with 125 additions and 24 deletions
|
|
@ -1,5 +1,7 @@
|
|||
import os
|
||||
|
||||
import psutil
|
||||
|
||||
from functions import DaemonizeHAProxy, Functions
|
||||
|
||||
|
||||
|
|
@ -17,10 +19,31 @@ def test_daemonize_haproxy_get_haproxy_command_start():
|
|||
command = daemon.get_haproxy_command(DaemonizeHAProxy.HAPROXY_START)
|
||||
assert command == "/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /var/run/haproxy.sock"
|
||||
|
||||
def test_daemonize_haproxy_get_haproxy_command_reload():
|
||||
def test_daemonize_haproxy_get_haproxy_command_reload_nopid():
|
||||
daemon = DaemonizeHAProxy()
|
||||
command = daemon.get_haproxy_command(DaemonizeHAProxy.HAPROXY_RELOAD)
|
||||
assert command == "/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -x /var/run/haproxy.sock -sf "
|
||||
assert command == "/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /var/run/haproxy.sock"
|
||||
|
||||
def test_daemonize_haproxy_get_haproxy_command_reload_pidinvalid():
|
||||
daemon = DaemonizeHAProxy()
|
||||
try:
|
||||
with open("/tmp/temp.pid", 'w') as file:
|
||||
file.write("-1001")
|
||||
command = daemon.get_haproxy_command(DaemonizeHAProxy.HAPROXY_RELOAD, "/tmp/temp.pid")
|
||||
assert command == "/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /tmp/temp.pid -S /var/run/haproxy.sock"
|
||||
finally:
|
||||
assert not os.path.exists("/tmp/temp.pid")
|
||||
|
||||
def test_daemonize_haproxy_get_haproxy_command_reload_existing_pin():
|
||||
daemon = DaemonizeHAProxy()
|
||||
try:
|
||||
with open("/tmp/temp.pid", 'w') as file:
|
||||
file.write("1")
|
||||
command = daemon.get_haproxy_command(DaemonizeHAProxy.HAPROXY_RELOAD, "/tmp/temp.pid")
|
||||
assert command == "/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /tmp/temp.pid -x /var/run/haproxy.sock -sf 1"
|
||||
finally:
|
||||
assert os.path.exists("/tmp/temp.pid")
|
||||
os.unlink("/tmp/temp.pid")
|
||||
|
||||
def test_daemonize_haproxy2_check_config():
|
||||
daemon = DaemonizeHAProxy(os.path.abspath(os.path.dirname(__file__)) + '/fixtures')
|
||||
|
|
@ -34,15 +57,3 @@ def test_daemonize_haproxy2_get_haproxy_command_start():
|
|||
daemon = DaemonizeHAProxy(os.path.abspath(os.path.dirname(__file__)) + '/fixtures')
|
||||
command = daemon.get_haproxy_command(DaemonizeHAProxy.HAPROXY_START)
|
||||
assert command == "/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -f %s -p /run/haproxy.pid -S /var/run/haproxy.sock" % (os.path.dirname(__file__) + "/fixtures")
|
||||
|
||||
|
||||
def test_daemonize_haproxy2_get_haproxy_command_reload():
|
||||
tmp_pid_file = "/tmp/tmp_pid.txt"
|
||||
Functions.save(tmp_pid_file, "10")
|
||||
|
||||
try:
|
||||
daemon = DaemonizeHAProxy(os.path.abspath(os.path.dirname(__file__)) + '/fixtures')
|
||||
command = daemon.get_haproxy_command(DaemonizeHAProxy.HAPROXY_RELOAD, tmp_pid_file)
|
||||
assert command == "/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -f %s -p %s -x /var/run/haproxy.sock -sf %s" % (os.path.dirname(__file__) + "/fixtures", tmp_pid_file, 10)
|
||||
finally:
|
||||
os.remove(tmp_pid_file)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue