CI: rework of test scripts

This commit is contained in:
checktheroads 2019-06-16 22:04:13 -07:00
parent 5c4b684ece
commit b90df6dc0b
3 changed files with 25 additions and 34 deletions

View file

@ -1,10 +1,10 @@
#!/usr/bin/env python3
"""
Starts hyperglass with the Flask development server
"""
import os
import sys
import glob
import shutil
import requests
import json
from logzero import logger
working_directory = os.path.dirname(os.path.abspath(__file__))
@ -24,9 +24,8 @@ def flask_dev_server(host, port):
try:
sys.path.insert(0, parent_directory)
from hyperglass import hyperglass
from hyperglass import configuration
from hyperglass import render
from hyperglass import hyperglass
render.css()
logger.info("Starting Flask development server")
@ -37,7 +36,4 @@ def flask_dev_server(host, port):
if __name__ == "__main__":
if ci_config():
flask_dev_server("localhost", 5000)
else:
raise
flask_dev_server("localhost", 5000)

View file

@ -1,10 +1,15 @@
#!/usr/bin/env python3
"""
Prepares the test environment prior to starting hyperglass.
"""
import os
import glob
import shutil
from logzero import logger
working_directory = os.path.dirname(os.path.abspath(__file__))
parent_directory = os.path.dirname(working_directory)
def ci_copy_config():
"""Copies test configuration files to usable config files"""
@ -16,19 +21,19 @@ def ci_copy_config():
logger.debug(working_directory)
logger.debug(parent_directory)
status = False
for f in config_files:
if os.path.exists(f):
logger.debug(f"{f} already exists")
os.remove(f)
logger.debug(f"Deleted {f}")
for f in test_files:
for file in config_files:
if os.path.exists(file):
logger.debug(f"{file} already exists")
os.remove(file)
logger.debug(f"Deleted {file}")
for file in test_files:
try:
shutil.copy(f, config_dir)
logger.debug(f"Copied {f}")
shutil.copy(file, config_dir)
logger.debug(f"Copied {file}")
logger.info("Successfully migrated test config files")
status = True
except:
logger.error(f"Failed to migrate {f}")
logger.error(f"Failed to migrate {file}")
raise
return status

View file

@ -1,12 +1,9 @@
#!/usr/bin/env python3
"""
Runs tests against test hyperglass instance
"""
import os
import sys
import glob
import json
import shutil
import inspect
import requests
from logzero import logger
working_directory = os.path.dirname(os.path.abspath(__file__))
@ -27,18 +24,13 @@ def ci_hyperglass_test(
target_ipv6,
requires_ipv6_cidr,
test_blacklist,
test_community,
test_aspath,
test_host,
test_port,
):
"""Fully tests hyperglass backend by making use of requests library to mimic the JS Ajax POST \
"""Tests hyperglass backend by making use of requests library to mimic the JS Ajax POST \
performed by the front end."""
test_target = None
invalid_ip = "this_ain't_an_ip!"
invalid_community = "192.0.2.1"
invalid_aspath = ".*"
ipv4_host = "1.1.1.1"
ipv4_cidr = "1.1.1.0/24"
ipv6_host = "2606:4700:4700::1111"
ipv6_cidr = "2606:4700:4700::/48"
@ -173,8 +165,6 @@ if __name__ == "__main__":
"2606:4700:4700::/48",
"pop1",
"100.64.0.1",
"65001:1",
"_65001$",
"localhost",
5000,
)