From: William Lallemand Date: Wed, 15 Nov 2017 18:17:23 +0000 (+0100) Subject: MINOR: tests: add a python wrapper to test inherited fd X-Git-Tag: v1.8-rc4~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=51606feaf2a303a4d9f20c0f4fc33cbd3834255e;p=thirdparty%2Fhaproxy.git MINOR: tests: add a python wrapper to test inherited fd --- diff --git a/tests/test-inherited-fd.py b/tests/test-inherited-fd.py new file mode 100644 index 0000000000..b4b076c4f3 --- /dev/null +++ b/tests/test-inherited-fd.py @@ -0,0 +1,23 @@ +#!/usr/bin/python +""" +Python wrapper example to test the fd@ function, +You have to bind on fd@${NEWFD} in your haproxy configuration + +The configuration parsing should still work upon a reload with the master-worker +mode. + +""" + +import socket, subprocess, fcntl + +s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) +flags = fcntl.fcntl(s.fileno(), fcntl.F_GETFD) +flags &= ~fcntl.FD_CLOEXEC +fcntl.fcntl(s.fileno(), fcntl.F_SETFD, flags) + +s.bind((socket.gethostname(), 5555)) +s.listen(1) +FD = s.fileno() + +subprocess.Popen('NEWFD={} ./haproxy -W -f haproxy.cfg'.format(FD), shell=True, close_fds=False)