forked from mirrors/thatmattlove-hyperglass
CI: rework of test scripts
This commit is contained in:
parent
5c4b684ece
commit
b90df6dc0b
3 changed files with 25 additions and 34 deletions
|
|
@ -1,10 +1,10 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Starts hyperglass with the Flask development server
|
||||||
|
"""
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import glob
|
import json
|
||||||
import shutil
|
|
||||||
import requests
|
|
||||||
from logzero import logger
|
from logzero import logger
|
||||||
|
|
||||||
working_directory = os.path.dirname(os.path.abspath(__file__))
|
working_directory = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
@ -24,9 +24,8 @@ def flask_dev_server(host, port):
|
||||||
try:
|
try:
|
||||||
sys.path.insert(0, parent_directory)
|
sys.path.insert(0, parent_directory)
|
||||||
|
|
||||||
from hyperglass import hyperglass
|
|
||||||
from hyperglass import configuration
|
|
||||||
from hyperglass import render
|
from hyperglass import render
|
||||||
|
from hyperglass import hyperglass
|
||||||
|
|
||||||
render.css()
|
render.css()
|
||||||
logger.info("Starting Flask development server")
|
logger.info("Starting Flask development server")
|
||||||
|
|
@ -37,7 +36,4 @@ def flask_dev_server(host, port):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if ci_config():
|
flask_dev_server("localhost", 5000)
|
||||||
flask_dev_server("localhost", 5000)
|
|
||||||
else:
|
|
||||||
raise
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,15 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Prepares the test environment prior to starting hyperglass.
|
||||||
|
"""
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
import shutil
|
import shutil
|
||||||
from logzero import logger
|
from logzero import logger
|
||||||
|
|
||||||
|
working_directory = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
parent_directory = os.path.dirname(working_directory)
|
||||||
|
|
||||||
|
|
||||||
def ci_copy_config():
|
def ci_copy_config():
|
||||||
"""Copies test configuration files to usable config files"""
|
"""Copies test configuration files to usable config files"""
|
||||||
|
|
@ -16,19 +21,19 @@ def ci_copy_config():
|
||||||
logger.debug(working_directory)
|
logger.debug(working_directory)
|
||||||
logger.debug(parent_directory)
|
logger.debug(parent_directory)
|
||||||
status = False
|
status = False
|
||||||
for f in config_files:
|
for file in config_files:
|
||||||
if os.path.exists(f):
|
if os.path.exists(file):
|
||||||
logger.debug(f"{f} already exists")
|
logger.debug(f"{file} already exists")
|
||||||
os.remove(f)
|
os.remove(file)
|
||||||
logger.debug(f"Deleted {f}")
|
logger.debug(f"Deleted {file}")
|
||||||
for f in test_files:
|
for file in test_files:
|
||||||
try:
|
try:
|
||||||
shutil.copy(f, config_dir)
|
shutil.copy(file, config_dir)
|
||||||
logger.debug(f"Copied {f}")
|
logger.debug(f"Copied {file}")
|
||||||
logger.info("Successfully migrated test config files")
|
logger.info("Successfully migrated test config files")
|
||||||
status = True
|
status = True
|
||||||
except:
|
except:
|
||||||
logger.error(f"Failed to migrate {f}")
|
logger.error(f"Failed to migrate {file}")
|
||||||
raise
|
raise
|
||||||
return status
|
return status
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Runs tests against test hyperglass instance
|
||||||
|
"""
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import glob
|
|
||||||
import json
|
import json
|
||||||
import shutil
|
|
||||||
import inspect
|
|
||||||
import requests
|
|
||||||
from logzero import logger
|
from logzero import logger
|
||||||
|
|
||||||
working_directory = os.path.dirname(os.path.abspath(__file__))
|
working_directory = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
@ -27,18 +24,13 @@ def ci_hyperglass_test(
|
||||||
target_ipv6,
|
target_ipv6,
|
||||||
requires_ipv6_cidr,
|
requires_ipv6_cidr,
|
||||||
test_blacklist,
|
test_blacklist,
|
||||||
test_community,
|
|
||||||
test_aspath,
|
|
||||||
test_host,
|
test_host,
|
||||||
test_port,
|
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."""
|
performed by the front end."""
|
||||||
test_target = None
|
|
||||||
invalid_ip = "this_ain't_an_ip!"
|
invalid_ip = "this_ain't_an_ip!"
|
||||||
invalid_community = "192.0.2.1"
|
|
||||||
invalid_aspath = ".*"
|
invalid_aspath = ".*"
|
||||||
ipv4_host = "1.1.1.1"
|
|
||||||
ipv4_cidr = "1.1.1.0/24"
|
ipv4_cidr = "1.1.1.0/24"
|
||||||
ipv6_host = "2606:4700:4700::1111"
|
ipv6_host = "2606:4700:4700::1111"
|
||||||
ipv6_cidr = "2606:4700:4700::/48"
|
ipv6_cidr = "2606:4700:4700::/48"
|
||||||
|
|
@ -173,8 +165,6 @@ if __name__ == "__main__":
|
||||||
"2606:4700:4700::/48",
|
"2606:4700:4700::/48",
|
||||||
"pop1",
|
"pop1",
|
||||||
"100.64.0.1",
|
"100.64.0.1",
|
||||||
"65001:1",
|
|
||||||
"_65001$",
|
|
||||||
"localhost",
|
"localhost",
|
||||||
5000,
|
5000,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue