Exemplo n.º 1
0
def burnham(
    verbose: bool,
    test_run: str,
    test_name: str,
    enable_telemetry: bool,
    platform: str,
    spore_drive: str,
    missions: Tuple[Mission],
) -> None:
    """Travel through space and complete missions with the Discovery crew.

    If telemetry is enabled, measure, collect, and submit non-personal
    information to the specified data platform with Glean.
    """

    if verbose:
        logging.basicConfig(level=logging.DEBUG)
    else:
        logging.basicConfig(level=logging.INFO)

    Glean.initialize(
        application_id=__title__,
        application_version=__version__,
        upload_enabled=enable_telemetry is True,
        data_dir=Path(TemporaryDirectory().name),
        configuration=Configuration(server_endpoint=platform),
    )

    metrics.test.run.set(test_run)
    metrics.test.name.set(test_name)

    space_ship = Discovery(
        warp_drive=WarpDrive(),
        spore_drive=SporeDrive(branch=spore_drive,
                               active=spore_drive is not None),
    )
    pings.space_ship_ready.submit()

    try:
        for mission in missions:
            complete_mission(space_ship=space_ship, mission=mission)

            # When mission "MISSION H: DISABLE GLEAN UPLOAD" disables the Glean
            # SDK ping upload all pending events, metrics and pings are
            # cleared, except for first_run_date. We need to restore values for
            # test.run and test.name after re-enabling ping upload, so that we
            # can properly correlate new pings with the test scenario.
            if mission.identifier == "MISSION I: ENABLE GLEAN UPLOAD":
                metrics.test.run.set(test_run)
                metrics.test.name.set(test_name)

        secs = 5
        logger.info("All missions completed.")
        logger.info(f" Waiting {secs}s for telemetry to be sent.")
        time.sleep(secs)

    except BurnhamError as err:
        click.echo(f"Error: {err}", err=True)
        sys.exit(1)
Exemplo n.º 2
0
def fixture_space_ship():
    """Return a Discovery instance with spore_drive active."""
    return Discovery(
        warp_drive=WarpDrive(),
        spore_drive=SporeDrive(branch="tardigrade", active=True),
    )