def load_test(gateway_host=None, destroy_vm=True): """ Run the load performance tests. This defaults to running on local vagrant machines, but can also be pointed to an arbitrary host (e.g. amazon) by passing "address:port" as arguments. Args: gateway_host: The ssh address string of the machine to run the gateway services on. Formatted as "host:port". If not specified, defaults to the `magma` vagrant box. destroy_vm: If the vagrant VM should be destroyed and setup before running load tests. """ # Setup the gateway: use the provided gateway if given, else default to the # vagrant machine if gateway_host: ansible_setup(gateway_host, 'dev', 'magma_dev.yml') gateway_ip = gateway_host.split('@')[1].split(':')[0] else: gateway_host = vagrant_setup('magma', destroy_vm) gateway_ip = '192.168.60.142' execute(_build_magma) execute(_start_gateway) # Sleep for 10 secs to let magma services finish starting sleep(10) execute(_run_load_tests, gateway_ip) if not gateway_host: execute(setup_env_vagrant) else: env.hosts = [gateway_host]
def start_magma(test_host=None, destroy_vm='False', provision_vm='False'): destroy_vm = bool(strtobool(destroy_vm)) provision_vm = bool(strtobool(provision_vm)) if not test_host: vagrant_setup('magma', destroy_vm, force_provision=provision_vm) else: ansible_setup(test_host, "test", "magma_test.yml") sudo('service magma@magmad start')
def make_integ_tests(test_host=None, destroy_vm='False', provision_vm='False'): destroy_vm = bool(strtobool(destroy_vm)) provision_vm = bool(strtobool(provision_vm)) if not test_host: vagrant_setup('magma_test', destroy_vm, force_provision=provision_vm) else: ansible_setup(test_host, "test", "magma_test.yml") execute(_make_integ_tests)
def build_and_start_magma_trf(test_host=None, destroy_vm='False', provision_vm='False'): destroy_vm = bool(strtobool(destroy_vm)) provision_vm = bool(strtobool(provision_vm)) if not test_host: vagrant_setup('magma_trfserver', destroy_vm, force_provision=provision_vm) else: ansible_setup(test_host, "test", "magma_test.yml") execute(_start_trfserver)
def bazel_integ_test_pre_build( gateway_host=None, test_host=None, trf_host=None, destroy_vm='True', provision_vm='True', ): """ Prepare to run the integration tests on the bazel build services. This defaults to running on local vagrant machines, but can also be pointed to an arbitrary host (e.g. amazon) by passing "address:port" as arguments gateway_host: The ssh address string of the machine to run the gateway services on. Formatted as "host:port". If not specified, defaults to the `magma` vagrant box. test_host: The ssh address string of the machine to run the tests on on. Formatted as "host:port". If not specified, defaults to the `magma_test` vagrant box. trf_host: The ssh address string of the machine to run the TrafficServer on. Formatted as "host:port". If not specified, defaults to the `magma_trfserver` vagrant box. """ destroy_vm = bool(strtobool(destroy_vm)) provision_vm = bool(strtobool(provision_vm)) # Setup the gateway: use the provided gateway if given, else default to the # vagrant machine gateway_ip = '192.168.60.142' if not gateway_host: gateway_host = vagrant_setup( 'magma', destroy_vm, force_provision=provision_vm, ) else: ansible_setup(gateway_host, "dev", "magma_dev.yml") gateway_ip = gateway_host.split('@')[1].split(':')[0] execute(_dist_upgrade) execute(_modify_for_bazel_services)
def build_and_start_magma(gateway_host=None, destroy_vm='False', provision_vm='False'): """ Build Magma AGW and starts magma Args: gateway_host: name of host in case is not Vagrant destroy_vm: if set to True it will destroy Magma Vagrant VM provision_vm: if set to true it will reprovision Magma VM Returns: """ provision_vm = bool(strtobool(provision_vm)) destroy_vm = bool(strtobool(destroy_vm)) if gateway_host: ansible_setup(gateway_host, 'dev', 'magma_dev.yml') else: vagrant_setup('magma', destroy_vm, provision_vm) sudo('service magma@* stop') execute(_build_magma) sudo('service magma@magmad start')
def integ_test(gateway_host=None, test_host=None, trf_host=None, destroy_vm="False"): """ Run the integration tests. This defaults to running on local vagrant machines, but can also be pointed to an arbitrary host (e.g. amazon) by passing "address:port" as arguments gateway_host: The ssh address string of the machine to run the gateway services on. Formatted as "host:port". If not specified, defaults to the `cwag` vagrant box. test_host: The ssh address string of the machine to run the tests on on. Formatted as "host:port". If not specified, defaults to the `cwag_test` vagrant box. trf_host: The ssh address string of the machine to run the tests on on. Formatted as "host:port". If not specified, defaults to the `magma_trfserver` vagrant box. """ destroy_vm = bool(strtobool(destroy_vm)) # Setup the gateway: use the provided gateway if given, else default to the # vagrant machine if not gateway_host: vagrant_setup("cwag", destroy_vm) else: ansible_setup(gateway_host, "cwag", "cwag_dev.yml") execute(_run_unit_tests) execute(_set_cwag_configs) cwag_host_to_mac = execute(_get_cwag_br_mac) host = env.hosts[0] cwag_br_mac = cwag_host_to_mac[host] execute(_start_gateway) # Setup the trfserver: use the provided trfserver if given, else default to the # vagrant machine with lcd(LTE_AGW_ROOT): if not trf_host: vagrant_setup("magma_trfserver", destroy_vm) else: ansible_setup(trf_host, "trfserver", "magma_trfserver.yml") execute(_start_trfserver) # Run the tests: use the provided test machine if given, else default to # the vagrant machine if not test_host: vagrant_setup("cwag_test", destroy_vm) else: ansible_setup(test_host, "cwag_test", "cwag_test.yml") execute(_set_cwag_test_configs) execute(_set_cwag_test_networking, cwag_br_mac) execute(_start_ue_simulator) execute(_run_integ_tests)
def integ_test(gateway_host=None, test_host=None, destroy_vm="True"): """ Run the integration tests. This defaults to running on local vagrant machines, but can also be pointed to an arbitrary host (e.g. amazon) by passing "address:port" as arguments gateway_host: The ssh address string of the machine to run the gateway services on. Formatted as "host:port". If not specified, defaults to the `cwag` vagrant box. test_host: The ssh address string of the machine to run the tests on on. Formatted as "host:port". If not specified, defaults to the `cwag_test` vagrant box. """ destroy_vm = bool(strtobool(destroy_vm)) # Setup the gateway: use the provided gateway if given, else default to the # vagrant machine if not gateway_host: vagrant_setup("cwag", destroy_vm) else: ansible_setup(gateway_host, "cwag", "cwag_dev.yml") execute(_copy_config) execute(_start_gateway) # Run the tests: use the provided test machine if given, else default to # the vagrant machine if not test_host: vagrant_setup("cwag_test", destroy_vm) else: ansible_setup(test_host, "cwag_test", "cwag_test.yml") execute(_start_ue_simulator) execute(_run_unit_tests) execute(_run_integ_tests)
def cloud_test(cloud=None, datastore=None, destroy_vm="True"): """ Run the cloud tests. This defaults to running on local vagrant machines, but can also be pointed to an arbitrary host (e.g. amazon) by passing "address:port" as arguments cloud: The ssh address string of the machine to run the cloud on. Formatted as "host:port". If not specified, defaults to the `cloud` vagrant box. datastore: The ssh address string of the machine to run the datastore on on. Formatted as "host:port". If not specified, defaults to the `datastore` vagrant box. """ destroy_vm = bool(strtobool(destroy_vm)) # Setup the datastore: use the provided test machine if given, else default # to the vagrant machine if not datastore: datastore = vagrant_setup("datastore", destroy_vm) else: ansible_setup(datastore, "datastore", "datastore.dev.yml") # Setup the cloud: use the provided address if given, else default to the # vagrant machine if not cloud: cloud = vagrant_setup("cloud", destroy_vm) else: ansible_setup(cloud, "magma-cloud-dev", "cloud.dev.yml") env.host_string = cloud (env.user, _, _) = split_hoststring(cloud) with cd('~/magma/orc8r/cloud'): # Retry golang dependency fetching 3 times to be resilient to network # flapping run('make download || make download || make download') run('make cover')
def integ_test(gateway_host=None, test_host=None, trf_host=None, destroy_vm="True"): """ Run the integration tests. This defaults to running on local vagrant machines, but can also be pointed to an arbitrary host (e.g. amazon) by passing "address:port" as arguments gateway_host: The ssh address string of the machine to run the gateway services on. Formatted as "host:port". If not specified, defaults to the `magma` vagrant box. test_host: The ssh address string of the machine to run the tests on on. Formatted as "host:port". If not specified, defaults to the `magma_test` vagrant box. trf_host: The ssh address string of the machine to run the TrafficServer on. Formatted as "host:port". If not specified, defaults to the `magma_trfserver` vagrant box. """ destroy_vm = bool(strtobool(destroy_vm)) # Setup the gateway: use the provided gateway if given, else default to the # vagrant machine gateway_ip = '192.168.60.142' if not gateway_host: gateway_host = vagrant_setup("magma", destroy_vm) else: ansible_setup(gateway_host, "dev", "magma_dev.yml") gateway_ip = gateway_host.split('@')[1].split(':')[0] execute(_dist_upgrade) execute(_build_magma) execute(_run_unit_tests) execute(_python_coverage) execute(_start_gateway) # Run suite of integ tests that are required to be run on the access gateway # instead of the test VM # TODO: fix the integration test T38069907 # execute(_run_local_integ_tests) # Setup the trfserver: use the provided trfserver if given, else default to the # vagrant machine if not trf_host: trf_host = vagrant_setup("magma_trfserver", destroy_vm) else: ansible_setup(trf_host, "trfserver", "magma_trfserver.yml") execute(_start_trfserver) # Run the tests: use the provided test machine if given, else default to # the vagrant machine if not test_host: test_host = vagrant_setup("magma_test", destroy_vm) else: ansible_setup(test_host, "test", "magma_test.yml") execute(_make_integ_tests) execute(_run_integ_tests, gateway_ip) if not gateway_host: setup_env_vagrant() else: env.hosts = [gateway_host] execute(_oai_coverage)
def _switch_to_vm(addr, host_name, ansible_file, destroy_vm): if not addr: vagrant_setup(host_name, destroy_vm) else: ansible_setup(addr, host_name, ansible_file)
def integ_test(gateway_host=None, test_host=None, trf_host=None, destroy_vm="False", no_build="False", tests_to_run="integ_test"): """ Run the integration tests. This defaults to running on local vagrant machines, but can also be pointed to an arbitrary host (e.g. amazon) by passing "address:port" as arguments gateway_host: The ssh address string of the machine to run the gateway services on. Formatted as "host:port". If not specified, defaults to the `cwag` vagrant box. test_host: The ssh address string of the machine to run the tests on on. Formatted as "host:port". If not specified, defaults to the `cwag_test` vagrant box. trf_host: The ssh address string of the machine to run the tests on on. Formatted as "host:port". If not specified, defaults to the `magma_trfserver` vagrant box. no_build: When set to true, this script will NOT rebuild all docker images. """ try: tests_to_run = SubTests(tests_to_run) except ValueError: print("{} is not a valid value. We support {}".format( tests_to_run, SubTests.list())) return destroy_vm = bool(strtobool(destroy_vm)) no_build = bool(strtobool(no_build)) # Setup the gateway: use the provided gateway if given, else default to the # vagrant machine if not gateway_host: vagrant_setup("cwag", destroy_vm) else: ansible_setup(gateway_host, "cwag", "cwag_dev.yml") execute(_run_unit_tests) execute(_set_cwag_configs) cwag_host_to_mac = execute(_get_br_mac, CWAG_BR_NAME) host = env.hosts[0] cwag_br_mac = cwag_host_to_mac[host] # Transfer built images from local machine to CWAG host if gateway_host: execute(_transfer_docker_images) else: execute(_stop_gateway) if not no_build: execute(_build_gateway) execute(_run_gateway) # Setup the trfserver: use the provided trfserver if given, else default to the # vagrant machine with lcd(LTE_AGW_ROOT): if not trf_host: vagrant_setup("magma_trfserver", destroy_vm) else: ansible_setup(trf_host, "trfserver", "magma_trfserver.yml") execute(_start_trfserver) # Run the tests: use the provided test machine if given, else default to # the vagrant machine if not test_host: vagrant_setup("cwag_test", destroy_vm) else: ansible_setup(test_host, "cwag_test", "cwag_test.yml") cwag_test_host_to_mac = execute(_get_br_mac, CWAG_TEST_BR_NAME) host = env.hosts[0] cwag_test_br_mac = cwag_test_host_to_mac[host] execute(_set_cwag_test_configs) # Get back to the gateway vm to setup static arp if not gateway_host: vagrant_setup("cwag", destroy_vm) else: ansible_setup(gateway_host, "cwag", "cwag_dev.yml") execute(_set_cwag_networking, cwag_test_br_mac) # Start tests if not test_host: vagrant_setup("cwag_test", destroy_vm) else: ansible_setup(test_host, "cwag_test", "cwag_test.yml") execute(_start_ue_simulator) execute(_set_cwag_test_networking, cwag_br_mac) execute(_run_integ_tests, test_host, trf_host, tests_to_run)
def _switch_to_vm_no_provision(addr, host_name, ansible_file): if not addr: vagrant_setup(host_name, destroy_vm=False, force_provision=False) else: ansible_setup(addr, host_name, ansible_file, full_provision='false')
def bazel_integ_test_post_build( gateway_host=None, test_host=None, trf_host=None, destroy_vm='True', provision_vm='True', ): """ Run the integration tests on the bazel build services. This defaults to running on local vagrant machines, but can also be pointed to an arbitrary host (e.g. amazon) by passing "address:port" as arguments gateway_host: The ssh address string of the machine to run the gateway services on. Formatted as "host:port". If not specified, defaults to the `magma` vagrant box. test_host: The ssh address string of the machine to run the tests on on. Formatted as "host:port". If not specified, defaults to the `magma_test` vagrant box. trf_host: The ssh address string of the machine to run the TrafficServer on. Formatted as "host:port". If not specified, defaults to the `magma_trfserver` vagrant box. """ destroy_vm = bool(strtobool(destroy_vm)) provision_vm = bool(strtobool(provision_vm)) gateway_ip = '192.168.60.142' if not gateway_host: gateway_host = vagrant_setup( 'magma', False, force_provision=False, ) else: ansible_setup(gateway_host, "dev", "magma_dev.yml") gateway_ip = gateway_host.split('@')[1].split(':')[0] execute(_run_sudo_python_unit_tests) execute(_restart_gateway) # Setup the trfserver: use the provided trfserver if given, else default to the # vagrant machine if not trf_host: trf_host = vagrant_setup( 'magma_trfserver', destroy_vm, force_provision=provision_vm, ) else: ansible_setup(trf_host, "trfserver", "magma_trfserver.yml") execute(_start_trfserver) # Run the tests: use the provided test machine if given, else default to # the vagrant machine if not test_host: test_host = vagrant_setup( 'magma_test', destroy_vm, force_provision=provision_vm, ) else: ansible_setup(test_host, "test", "magma_test.yml") execute(_make_integ_tests) execute(_run_integ_tests, gateway_ip) if not gateway_host: setup_env_vagrant() else: env.hosts = [gateway_host]
def integ_test(gateway_host=None, test_host=None, trf_host=None, transfer_images=False, destroy_vm=False, no_build=False, tests_to_run="all", skip_unit_tests=False, test_re=None): """ Run the integration tests. This defaults to running on local vagrant machines, but can also be pointed to an arbitrary host (e.g. amazon) by passing "address:port" as arguments gateway_host: The ssh address string of the machine to run the gateway services on. Formatted as "host:port". If not specified, defaults to the `cwag` vagrant box. test_host: The ssh address string of the machine to run the tests on on. Formatted as "host:port". If not specified, defaults to the `cwag_test` vagrant box. trf_host: The ssh address string of the machine to run the tests on on. Formatted as "host:port". If not specified, defaults to the `magma_trfserver` vagrant box. no_build: When set to true, this script will NOT rebuild all docker images. """ try: tests_to_run = SubTests(tests_to_run) except ValueError: print("{} is not a valid value. We support {}".format( tests_to_run, SubTests.list())) return # Setup the gateway: use the provided gateway if given, else default to the # vagrant machine if not gateway_host: vagrant_setup("cwag", destroy_vm) else: ansible_setup(gateway_host, "cwag", "cwag_dev.yml") if not skip_unit_tests: execute(_run_unit_tests) execute(_set_cwag_configs, "gateway.mconfig") cwag_host_to_mac = execute(_get_br_mac, CWAG_BR_NAME) host = env.hosts[0] cwag_br_mac = cwag_host_to_mac[host] # Transfer built images from local machine to CWAG host if gateway_host or transfer_images: execute(_transfer_docker_images) else: execute(_stop_gateway) if not no_build: execute(_build_gateway) execute(_run_gateway) # Stop not necessary services for this test case execute(_stop_docker_services, ["pcrf2", "ocs2"]) # Setup the trfserver: use the provided trfserver if given, else default to the # vagrant machine with lcd(LTE_AGW_ROOT): if not trf_host: vagrant_setup("magma_trfserver", destroy_vm) else: ansible_setup(trf_host, "trfserver", "magma_trfserver.yml") execute(_start_trfserver) # Run the tests: use the provided test machine if given, else default to # the vagrant machine if not test_host: vagrant_setup("cwag_test", destroy_vm) else: ansible_setup(test_host, "cwag_test", "cwag_test.yml") cwag_test_host_to_mac = execute(_get_br_mac, CWAG_TEST_BR_NAME) host = env.hosts[0] cwag_test_br_mac = cwag_test_host_to_mac[host] execute(_set_cwag_test_configs) # Get back to the gateway vm to setup static arp if not gateway_host: # We do NOT want to destroy this VM after we just set it up... vagrant_setup("cwag", False) else: ansible_setup(gateway_host, "cwag", "cwag_dev.yml") execute(_set_cwag_networking, cwag_test_br_mac) # Start main tests - except for multi session proxy if not test_host: # No, definitely do NOT destroy this VM vagrant_setup("cwag_test", False) else: ansible_setup(test_host, "cwag_test", "cwag_test.yml") execute(_start_ue_simulator) execute(_set_cwag_test_networking, cwag_br_mac) if tests_to_run.value != SubTests.MULTISESSIONPROXY.value: execute(_run_integ_tests, test_host, trf_host, tests_to_run, test_re) # Setup environment for multi service proxy if required if tests_to_run.value in (SubTests.ALL.value, SubTests.MULTISESSIONPROXY.value): # CWAG VM if not gateway_host: vagrant_setup("cwag", False) else: ansible_setup(gateway_host, "cwag", "cwag_dev.yml") # copy new config and restart the impacted services execute(_set_cwag_configs, "gateway.mconfig.multi_session_proxy") execute(_restart_docker_services, ["session_proxy", "pcrf", "ocs", "pcrf2", "ocs2"]) # CWAG_TEST VM if not test_host: vagrant_setup("cwag_test", False) else: ansible_setup(test_host, "cwag_test", "cwag_test.yml") execute(_run_integ_tests, test_host, trf_host, SubTests.MULTISESSIONPROXY, test_re) # If we got here means everything work well!! if not test_host and not trf_host: # Clean up only for now when running locally execute(_clean_up) print('Integration Test Passed for "{}"!'.format(tests_to_run.value)) sys.exit(0)