From b90df6dc0b360f2eb7c37300dc10d79e66358a42 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Sun, 16 Jun 2019 22:04:13 -0700 Subject: [PATCH] CI: rework of test scripts --- ci/ci_dev_server.py | 16 ++++++---------- ci/ci_prepare.py | 25 +++++++++++++++---------- ci/ci_test.py | 18 ++++-------------- 3 files changed, 25 insertions(+), 34 deletions(-) diff --git a/ci/ci_dev_server.py b/ci/ci_dev_server.py index e03af25..b60e979 100755 --- a/ci/ci_dev_server.py +++ b/ci/ci_dev_server.py @@ -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) diff --git a/ci/ci_prepare.py b/ci/ci_prepare.py index 8d8a962..3009867 100644 --- a/ci/ci_prepare.py +++ b/ci/ci_prepare.py @@ -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 diff --git a/ci/ci_test.py b/ci/ci_test.py index 866771c..05d64c3 100755 --- a/ci/ci_test.py +++ b/ci/ci_test.py @@ -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, )