def transfer_service_logs(services="sessiond session_proxy"): services = services.strip().split(' ') print("Transferring logs for " + str(services)) # We do NOT want to destroy this VM after we just set it up... vagrant_setup("cwag", False) with cd(CWAG_ROOT): for service in services: run("docker logs -t " + service + " 2> " + service + ".log")
def check_agw_cloud_connectivity(timeout=10): """ Check connectivity of AGW with the cloud using checkin_cli.py Args: timeout: amount of time the command will retry """ vagrant_setup("magma", destroy_vm=False, force_provision=False) with cd("/home/vagrant/build/python/bin/"): dev_utils.run_fab_command_with_repetition("./checkin_cli.py", timeout)
def package(vcs='hg', all_deps="False", cert_file=DEFAULT_CERT, proxy_config=DEFAULT_PROXY, destroy_vm='False', vm='magma'): """ Builds the magma package """ all_deps = False if all_deps == "False" else True destroy_vm = bool(strtobool(destroy_vm)) # If a host list isn't specified, default to the magma vagrant vm if not env.hosts: vagrant_setup(vm, destroy_vm=destroy_vm) if not hasattr(env, 'debug_mode'): print("Error: The Deploy target isn't specified. Specify one with\n\n" "\tfab [dev|test] package") exit(1) hash = pkg.get_commit_hash(vcs) with cd('~/magma/lte/gateway'): # Generate magma dependency packages run('mkdir -p ~/magma-deps') print("Generating lte/setup.py and orc8r/setup.py magma dependency packages") run('./release/pydep finddep --install-from-repo -b --build-output ~/magma-deps' + (' -l ./release/magma.lockfile') + ' python/setup.py' + (' %s/setup.py' % ORC8R_AGW_PYTHON_ROOT)) print("Building magma package, picking up commit %s..." % hash) run('make clean') build_type = "Debug" if env.debug_mode else "RelWithDebInfo" run('./release/build-magma.sh -h "%s" -t %s --cert %s --proxy %s' % (hash, build_type, cert_file, proxy_config)) run('rm -rf ~/magma-packages') run('mkdir -p ~/magma-packages') try: run('cp -f ~/magma-deps/*.deb ~/magma-packages') except Exception: # might be a problem if no deps found, but don't handle here pass run('mv *.deb ~/magma-packages') with cd('release'): mirrored_packages_file = 'mirrored_packages' if vm and vm.startswith('magma_'): mirrored_packages_file += vm[5:] run('cat {}'.format(mirrored_packages_file) + ' | xargs -I% sudo aptitude download -q2 %') run('cp *.deb ~/magma-packages') run('sudo rm -f *.deb') if all_deps: pkg.download_all_pkgs() run('cp /var/cache/apt/archives/*.deb ~/magma-packages')
def check_agw_feg_connectivity(timeout=10): """ Check connectivity of AGW with FEG feg_hello_cli.py Args: timeout: amount of time the command will retry """ vagrant_setup("magma", destroy_vm=False, force_provision=False) with cd("/home/vagrant/build/python/bin/"): dev_utils.run_remote_command_with_repetition("./feg_hello_cli.py m 0", timeout)
def federated_integ_test( build_all='False', clear_orc8r='False', provision_vm='False', destroy_vm='False', orc8r_on_vagrant='False', ): build_all = bool(strtobool(build_all)) clear_orc8r = bool(strtobool(clear_orc8r)) provision_vm = bool(strtobool(provision_vm)) destroy_vm = bool(strtobool(destroy_vm)) orc8r_on_vagrant = bool(strtobool(orc8r_on_vagrant)) if orc8r_on_vagrant: # Modify Vagrantfile to allow access to Orc8r running inside Vagrant execute(open_orc8r_port_in_vagrant) with lcd(FEG_INTEG_TEST_ROOT): if build_all: local( "fab build_all:clear_orc8r={},provision_vm={}," "orc8r_on_vagrant={}".format( clear_orc8r, provision_vm, orc8r_on_vagrant, ), ) if orc8r_on_vagrant: # modify dns entries to find Orc8r from inside Vagrant execute(redirect_feg_agw_to_vagrant_orc8r) local("fab start_all:orc8r_on_vagrant={}".format(orc8r_on_vagrant)) if orc8r_on_vagrant: print("Wait for orc8r to be available") sleep(60) local("fab configure_orc8r") sleep(20) local("fab test_connectivity:timeout=200") vagrant_setup( 'magma_trfserver', destroy_vm, force_provision=provision_vm, ) vagrant_setup( 'magma_test', destroy_vm, force_provision=provision_vm, ) execute(_make_integ_tests) sleep(20) execute(run_integ_tests, federated_mode=True)
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(_copy_config) 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: trf_host = vagrant_setup("magma_trfserver", destroy_vm) else: ansible_setup(trf_host, "trfserver", "../../lte/gateway/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") # Setup the trfserver: use the provided trfserver if given, else default to the # vagrant machine execute(_start_ue_simulator) execute(_run_integ_tests)
def build_feg(): """ build FEG on magma Vagrant vm using docker running in Vagrant """ print('#### Building FEG on Magma Vagrant VM ####') vagrant_setup('magma', destroy_vm=False) with cd(feg_docker_integ_test_path_vagrant): run('docker-compose down') run('docker-compose build') run('docker-compose up -d')
def start_orc8r(on_vagrant='False'): """ Start orc8r locally on Docker """ on_vagrant = bool(strtobool(on_vagrant)) command = './run.py' if not on_vagrant: subprocess.check_call(command, shell=True, cwd=orc8_docker_path) else: vagrant_setup('magma', destroy_vm=False) with cd(orc8r_vagrant_path): run(command)
def build_orc8r(on_vagrant='False'): """ Build orc8r locally on the host VM """ on_vagrant = bool(strtobool(on_vagrant)) command = './build.py -a' if not on_vagrant: subprocess.check_call(command, shell=True, cwd=orc8_docker_path) else: vagrant_setup('magma', destroy_vm=False) with cd(orc8r_vagrant_path): run(command)
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 build_test_vms(provision_vm='False', destroy_vm='False'): vagrant_setup( 'magma_trfserver', destroy_vm, force_provision=provision_vm, ) vagrant_setup( 'magma_test', destroy_vm, force_provision=provision_vm, ) execute(_make_integ_tests)
def redirect_feg_agw_to_vagrant_orc8r(): """ Modifies feg docker-compose.override.yml hosts and AGW /etc/hosts to point to localhost when Orc8r runs on inside Vagrant """ local( "sed -i '' 's/:10.0.2.2/:127.0.0.1/' {}/docker-compose.override.yml". format(FEG_INTEG_TEST_DOCKER_ROOT), ) vagrant_setup( 'magma', destroy_vm=False, force_provision=False, ) sudo("sed -i 's/10.0.2.2/127.0.0.1/' /etc/hosts")
def run_integ_tests(): """ Function is required to run tests only in pre-configured Jenkins env. """ test_host = vagrant_setup("magma_test", destroy_vm=False) gateway_ip = '192.168.60.142' execute(_run_integ_tests, gateway_ip)
def run_integ_tests(tests=None, federated_mode=False): """ Function is required to run tests only in pre-configured Jenkins env. In case of no tests specified with command executed like follows: $ fab run_integ_tests default tests set will be executed as a result of the execution of following command in test machine: $ make integ_test In case of selecting specific test like follows: $ fab run_integ_tests:tests=s1aptests/test_attach_detach.py $ fab run_integ_tests:tests=federated_tests/s1aptests/test_attach_detach.py,federated_mode=True The specific test will be executed as a result of the execution of following command in test machine: $ make integ_test TESTS=s1aptests/test_attach_detach.py $ make fed_integ_test TESTS=federated_tests/s1aptests/test_attach_detach.py """ test_host = vagrant_setup("magma_test", destroy_vm=False) gateway_ip = '192.168.60.142' if tests: tests = "TESTS=" + tests execute(_run_integ_tests, gateway_ip, tests, federated_mode)
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 configure_orc8r(on_vagrant='False'): """ Configure orc8r with a federated AGW and FEG """ on_vagrant = bool(strtobool(on_vagrant)) print('#### Configuring orc8r ####') command_agw = 'fab --fabfile=dev_tools.py register_federated_vm' command_feg = 'fab register_feg_gw' if not on_vagrant: subprocess.check_call(command_agw, shell=True, cwd=agw_path) subprocess.check_call(command_feg, shell=True, cwd=feg_path) else: vagrant_setup('magma', destroy_vm=False) with cd(agw_vagrant_path): run(command_agw) with cd(feg_vagrant_path): run(command_feg)
def transfer_artifacts(services="sessiond session_proxy", get_core_dump=False): """ Fetches service logs from Docker and optionally gets core dumps Args: services: A list of services for which services logs are requested get_core_dump: When set to True, it will fetch a tar of the core dumps """ services = services.strip().split(' ') print("Transferring logs for " + str(services)) # We do NOT want to destroy this VM after we just set it up... vagrant_setup("cwag", False) with cd(CWAG_ROOT): for service in services: run("docker logs -t " + service + " &> " + service + ".log") # For vagrant the files should already be in CWAG_ROOT if get_core_dump == "True": execute(_tar_coredump)
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 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 transfer_artifacts(gateway_vm="cwag", gateway_ansible_file="cwag_dev.yml", services="sessiond session_proxy", get_core_dump=False): """ Fetches service logs from Docker and optionally gets core dumps Args: services: A list of services for which services logs are requested get_core_dump: When set to True, it will fetch a tar of the core dumps """ services = services.strip().split(' ') print("Transferring logs for " + str(services)) # We do NOT want to destroy this VM after we just set it up... vagrant_setup(gateway_vm, False) with cd(CWAG_ROOT): for service in services: run("docker logs -t " + service + " &> " + service + ".log") # For vagrant the files should already be in CWAG_ROOT if get_core_dump == "True": execute(_tar_coredump, gateway_vm=gateway_vm, gateway_ansible_file=gateway_ansible_file) # get uesim logs # TODO: make sure exception is not triggered with settings(abort_exception=FabricException): result = None try: _switch_to_vm(None, "cwag_test", "cwag_test.yml", False) uesim_log = 'uesim.log' with cd(f'{CWAG_ROOT}'): result = run('tmux capture-pane -pt "$target-pane" >>' + uesim_log) except Exception: print("Error copying uesim.log %s" % str(result if result else ""))
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 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 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] # Transfer built images from local machine to CWAG host if gateway_host: execute(_transfer_docker_images) else: 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") execute(_set_cwag_test_configs) execute(_set_cwag_test_networking, cwag_br_mac) execute(_start_ue_simulator) execute(_run_integ_tests)
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 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)
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 openvswitch(destroy_vm='False', destdir='~/magma-packages/'): destroy_vm = bool(strtobool(destroy_vm)) # If a host list isn't specified, default to the magma vagrant vm if not env.hosts: vagrant_setup('magma', destroy_vm=destroy_vm) run('~/magma/third_party/gtp_ovs/ovs-gtp-patches/2.15/build.sh ' + destdir)