Exemplo n.º 1
0
def cleanup_app():
    if container_helper.get_apps(application=HELM_APP_NAME):
        LOG.fixture_step("Remove {} app if applied".format(HELM_APP_NAME))
        container_helper.remove_app(app_name=HELM_APP_NAME)

        LOG.fixture_step("Delete {} app".format(HELM_APP_NAME))
        container_helper.delete_app(app_name=HELM_APP_NAME)
Exemplo n.º 2
0
def cleanup_app(con_ssh=None, auth_info=Tenant.get('admin_platform')):
    """
    Remove application stx-monitor
    Delete application stx-monitor
    Remove stx-monitor images registries from all hosts
    Remove stx-monitor labels from all hosts
    """

    LOG.info("Remove application {}".format(STX_MONITOR_APP_NAME))
    container_helper.remove_app(app_name=STX_MONITOR_APP_NAME,
                                con_ssh=con_ssh,
                                auth_info=auth_info)

    LOG.info("Delete application {}".format(STX_MONITOR_APP_NAME))
    container_helper.delete_app(app_name=STX_MONITOR_APP_NAME,
                                con_ssh=con_ssh,
                                auth_info=auth_info)

    delete_images_from_host_registries(con_ssh=con_ssh, auth_info=auth_info)

    LOG.info("Delete labels for {}".format(STX_MONITOR_APP_NAME))
    delete_all_monitor_labels(con_ssh=con_ssh, auth_info=auth_info)

    LOG.info("Cleanup completed")
Exemplo n.º 3
0
def test_launch_app_via_sysinv(copy_test_apps, cleanup_app):
    """
    Test upload, apply, remove, delete custom app via system cmd
    Args:
        copy_test_apps (str): module fixture
        cleanup_app: fixture

    Setups:
        - Copy test files from test server to tis system (module)
        - Remove and delete test app if exists

    Test Steps:
        - system application-upload test app tar file and wait for it to be
            uploaded
        - system application-apply test app and wait for it to be applied
        - wget <oam_ip>:<app_targetPort> from remote host
        - Verify app contains expected content
        - system application-remove test app and wait for it to be uninstalled
        - system application-delete test app from system

    """
    app_dir = copy_test_apps
    app_name = HELM_APP_NAME

    LOG.tc_step("Upload {} helm charts".format(app_name))
    container_helper.upload_app(app_name=app_name,
                                app_version=HELM_APP_VERSION,
                                tar_file=os.path.join(app_dir, HELM_TAR))

    LOG.tc_step("Apply {}".format(app_name))
    container_helper.apply_app(app_name=app_name)

    LOG.tc_step("wget app via <oam_ip>:<targetPort>")
    json_path = '{.spec.ports[0].nodePort}'
    node_port = kube_helper.get_pod_value_jsonpath(
        type_name='service/{}'.format(HELM_POD_FULL_NAME), jsonpath=json_path)
    assert re.match(r'\d+', node_port), "Unable to get nodePort via " \
                                        "jsonpath '{}'".format(json_path)

    localhost = LocalHostClient(connect=True)
    prefix = 'http'
    oam_ip = ProjVar.get_var('LAB')['floating ip']
    if common.get_ip_version(oam_ip) == 6:
        oam_ip = '[{}]'.format(oam_ip)
    output_file = '{}/{}.html'.format(ProjVar.get_var('TEMP_DIR'),
                                      HELM_APP_NAME)
    localhost.exec_cmd('wget {}://{}:{} -O {}'.format(prefix, oam_ip,
                                                      node_port, output_file),
                       fail_ok=False)

    LOG.tc_step("Verify app contains expected content")
    app_content = localhost.exec_cmd('cat {}; echo'.format(output_file),
                                     get_exit_code=False)[1]
    assert app_content.startswith(HELM_MSG), \
        "App does not start with expected message."

    LOG.tc_step("Remove applied app")
    container_helper.remove_app(app_name=app_name)

    LOG.tc_step("Delete uninstalled app")
    container_helper.delete_app(app_name=app_name)

    LOG.tc_step("Wait for pod terminate")
    kube_helper.wait_for_resources_gone(resource_names=HELM_POD_FULL_NAME,
                                        check_interval=10,
                                        namespace='default')