Skip to content

Commit

Permalink
PTFE-1834 check for active connections on prestop
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarmet committed Jun 26, 2024
1 parent d10aa51 commit 33a4d78
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/artifacts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,4 @@ deployment:
## Affinity for pod assignment
##
affinity: {}
terminationGracePeriodSeconds: 300
terminationGracePeriodSeconds: 600
10 changes: 10 additions & 0 deletions stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
echo "Stopping nginx..."
# Wait a bit before signaling the process to stop
sleep 5

# retrieve nginx status and check if there's any active connection
ACTIVE_CONNECTION=""

while [ ${ACTIVE_CONNECTION} != "1" ]; do
ACTIVE_CONNECTION=$(curl -s http://localhost/nginx_status | grep 'Active connections' | awk '{print $3}')
echo "Active connections: ${ACTIVE_CONNECTION}"
sleep 1
done

PID=$(cat /run/nginx.pid)
nginx -s quit

Expand Down
13 changes: 13 additions & 0 deletions tests/end2end/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,19 @@ def test_simple_redirections(self):
), headers={'Script-Name': '/foo'})
assert 'Location' not in req.headers

def test_nginx_status(self):
# assert "Active connections: 1" in req.text
# retry as much as needed in case there is more active connections from other
# tests running
for _ in range(10):
req = self.session.get(f"{self.artifacts_url}/nginx_status")
if "Active connections: 1" in req.text:
break
if _ == 9:
assert False, "Active connections: 1 not found in nginx_status"
time.sleep(1)



@pytest.mark.usefixtures("s3_client", "container", "artifacts_url", "buckets")
class TestExternalBasicAuthentication(unittest.TestCase):
Expand Down

0 comments on commit 33a4d78

Please sign in to comment.