Example #1
0
def run_tests_in_emulator(package):
    """Spawn an emulator instance and run the system tests.

    :type package: str
    :param package: The package to run system tests against.
    """
    # Make sure this package has environment vars to replace.
    env_vars = PACKAGE_INFO[package]

    start_command = get_start_command(package)
    # Ignore stdin and stdout, don't pollute the user's output with them.
    proc_start = subprocess.Popen(start_command, stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)
    try:
        wait_ready(package, proc_start)
        env_init_command = get_env_init_command(package)
        proc_env = subprocess.Popen(env_init_command, stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE)
        env_status = proc_env.wait()
        if env_status != 0:
            raise RuntimeError(env_status, proc_env.stderr.read())
        env_lines = proc_env.stdout.read().strip().split('\n')
        # Set environment variables before running the system tests.
        for env_var in env_vars:
            line_prefix = 'export ' + env_var + '='
            value, = [line.split(line_prefix, 1)[1] for line in env_lines
                      if line.startswith(line_prefix)]
            os.environ[env_var] = value
        run_module_tests(package,
                         ignore_requirements=True)
    finally:
        cleanup(proc_start.pid)
Example #2
0
def main():
    """Spawn an emulator instance and run the datastore system tests."""
    # Ignore stdin and stdout, don't pollute the user's output with them.
    proc_start = subprocess.Popen(_START_CMD,
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)
    try:
        env_lines = subprocess.check_output(_ENV_INIT_CMD).strip().split('\n')
        dataset, = [
            line.split(_DATASET_PREFIX, 1)[1] for line in env_lines
            if line.startswith(_DATASET_PREFIX)
        ]
        host, = [
            line.split(_HOST_LINE_PREFIX, 1)[1] for line in env_lines
            if line.startswith(_HOST_LINE_PREFIX)
        ]
        # Set environment variables before running the system tests.
        os.environ[GCD_DATASET] = dataset
        os.environ[GCD_HOST] = host
        os.environ['GCLOUD_NO_PRINT'] = 'true'
        run_module_tests('datastore', ignore_requirements=True)
    finally:
        # NOTE: This is mostly defensive. Since ``proc_start`` will be spawned
        #       by this current process, it should be killed when this process
        #       exits whether or not we kill it.
        proc_start.kill()
def main():
    """Run all the system tests if necessary."""
    prepare_to_run()

    sys.path.append(ROOT_DIR)
    from system_tests.run_system_test import run_module_tests
    for module in MODULES:
        run_module_tests(module)
def main():
    """Spawn an emulator instance and run the datastore system tests."""
    # Ignore stdin and stdout, don't pollute the user's output with them.
    proc_start = subprocess.Popen(_START_CMD, stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE)
    try:
        env_lines = subprocess.check_output(
            _ENV_INIT_CMD).strip().split('\n')
        dataset, = [line.split(_DATASET_PREFIX, 1)[1] for line in env_lines
                    if line.startswith(_DATASET_PREFIX)]
        host, = [line.split(_HOST_LINE_PREFIX, 1)[1] for line in env_lines
                 if line.startswith(_HOST_LINE_PREFIX)]
        # Set environment variables before running the system tests.
        os.environ[GCD_DATASET] = dataset
        os.environ[GCD_HOST] = host
        os.environ['GCLOUD_NO_PRINT'] = 'true'
        run_module_tests('datastore',
                         ignore_requirements=True)
    finally:
        # NOTE: This is mostly defensive. Since ``proc_start`` will be spawned
        #       by this current process, it should be killed when this process
        #       exits whether or not we kill it.
        proc_start.kill()
def main():
    """Run all the system tests if necessary."""
    prepare_to_run()
    for module in MODULES:
        run_module_tests(module)