Exemplo n.º 1
0
    def test_gen_pipeline(self):
        with open('data/expected_buildkite_pipeline.yaml', 'r') as f:
            lines = f.readlines()
            expected_pipeline = ''.join(lines)

        gen_pipeline_env = 'BUILDKITE_PIPELINE_SLUG=SLUG BUILDKITE_BRANCH=BRANCH'
        gen_pipeline_cmd = '{env} ../.buildkite/gen-pipeline.sh'.format(
            env=gen_pipeline_env)
        actual_pipeline, exit_code = tiny_shell_exec.execute(gen_pipeline_cmd)

        self.assertEqual(0, exit_code)
        self.assertEqual(expected_pipeline, actual_pipeline)
Exemplo n.º 2
0
    def _execute(self, command):
        logging.debug('executing %s', command)
        res = tiny_shell_exec.execute(command)

        if res:
            if res[1]:
                logging.warning('command failed: {}'.format(res[0].strip()))
            else:
                logging.debug('command succeeded: {}'.format(res[0].strip()))
        else:
            logging.error('command failed: {}'.format(command))

        return res
Exemplo n.º 3
0
def _get_mpi_implementation(env=None):
    """
    Detects the available MPI implementation by invoking `mpirun --version`.
    This command is executed by the given execute function, which takes the
    command as the only argument and returns (output, exit code). Output
    represents the stdout and stderr as a string.

    Returns one of:
    - _OMPI_IMPL, _SMPI_IMPL or _MPICH_IMPL for known implementations
    - _UNKNOWN_IMPL for any unknown implementation
    - _MISSING_IMPL if `mpirun --version` could not be executed.

    :param env: environment variable to use to run mpirun
    :return: string representing identified implementation
    """
    command = 'mpirun --version'
    res = tiny_shell_exec.execute(command, env)
    if res is None:
        return _MISSING_IMPL
    (output, exit_code) = res

    if exit_code == 0:
        if 'Open MPI' in output or 'OpenRTE' in output:
            return _OMPI_IMPL
        elif 'IBM Spectrum MPI' in output:
            return _SMPI_IMPL
        elif 'MPICH' in output:
            return _MPICH_IMPL

        print(
            'Unknown MPI implementation given in output of mpirun --version:',
            file=sys.stderr)
        print(output, file=sys.stderr)
        return _UNKNOWN_IMPL
    else:
        print('Was unable to run {command}:'.format(command=command),
              file=sys.stderr)
        print(output, file=sys.stderr)
        return _MISSING_IMPL