Skip to content
Snippets Groups Projects
Verified Commit ce79b934 authored by Nicolas KAROLAK's avatar Nicolas KAROLAK
Browse files

test output homogenization

parent 23e45a9b
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
"""
Criticality: Normal
Checks that the webserver is running.
'''
import os
"""
from pathlib import Path
import requests
import sys
sys.path.append(str(Path(__file__).parents[1].resolve()))
# pylint: disable=wrong-import-position
from envsetup import utils as u # noqa: E402
def main():
print("Checking nginx status:")
if not Path("/etc/nginx").exists():
u.info("nginx dir does not exists, skip test")
exit(2)
if not os.path.exists('/etc/nginx'):
print('Nginx dir does not exists, test skipped.')
sys.exit(2)
else:
print('Checking http://127.0.0.1:1080/nginx_status response.')
try:
req = requests.get('http://127.0.0.1:1080/nginx_status', proxies={'http': '', 'https': ''}, timeout=5)
req = requests.get(
"http://127.0.0.1:1080/nginx_status",
proxies={"http": "", "https": ""},
timeout=5,
)
if req.status_code != 200:
raise Exception('Request failed with status code %s.' % req.status_code)
if 'Active connections' not in req.text:
raise Exception('Invalid response from nginx status url.')
raise Exception("status code: {}".format(req.status_code))
if "Active connections" not in req.text:
raise Exception("invalid response from nginx status url")
except Exception as e:
print(str(e))
sys.exit(1)
u.error(str(e))
exit(1)
u.success("status code: {}".format(req.status_code))
exit(0)
if __name__ == "__main__":
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment