Exemplo n.º 1
0
def test_it (version, deploy=True, conf={}, rdkconf={}, tests=None, debug=False):
    """
    @brief Create, deploy and start a Kafka cluster using Kafka \p version
    Then run librdkafka's regression tests.
    """
    
    cluster = LibrdkafkaTestCluster(version, conf, debug=debug)

    # librdkafka's regression tests, as an App.
    rdkafka = LibrdkafkaTestApp(cluster, version, _rdkconf, tests=tests)
    rdkafka.do_cleanup = False
    rdkafka.local_tests = False

    if deploy:
        cluster.deploy()

    cluster.start(timeout=30)

    print('# Connect to cluster with bootstrap.servers %s' % cluster.bootstrap_servers())
    rdkafka.start()
    print('# librdkafka regression tests started, logs in %s' % rdkafka.root_path())
    try:
        rdkafka.wait_stopped(timeout=60*10)
        rdkafka.dbg('wait stopped: %s, runtime %ds' % (rdkafka.state, rdkafka.runtime()))
    except KeyboardInterrupt:
        print('# Aborted by user')

    report = rdkafka.report()
    report['root_path'] = rdkafka.root_path()

    cluster.stop(force=True)

    cluster.cleanup()
    return report
Exemplo n.º 2
0
def test_it (version, deploy=True, conf={}, rdkconf={}, tests=None, debug=False):
    """
    @brief Create, deploy and start a Kafka cluster using Kafka \p version
    Then run librdkafka's regression tests.
    """

    cluster = LibrdkafkaTestCluster(version, conf, debug=debug)

    # librdkafka's regression tests, as an App.
    rdkafka = LibrdkafkaTestApp(cluster, version, _rdkconf, tests=tests)
    rdkafka.do_cleanup = False
    rdkafka.local_tests = False

    if deploy:
        cluster.deploy()

    cluster.start(timeout=30)

    print('# Connect to cluster with bootstrap.servers %s' % cluster.bootstrap_servers())
    rdkafka.start()
    print('# librdkafka regression tests started, logs in %s' % rdkafka.root_path())
    try:
        rdkafka.wait_stopped(timeout=60*30)
        rdkafka.dbg('wait stopped: %s, runtime %ds' % (rdkafka.state, rdkafka.runtime()))
    except KeyboardInterrupt:
        print('# Aborted by user')

    report = rdkafka.report()
    if report is not None:
        report['root_path'] = rdkafka.root_path()

    cluster.stop(force=True)

    cluster.cleanup()
    return report
Exemplo n.º 3
0
def test_it(version,
            deploy=True,
            conf={},
            rdkconf={},
            tests=None,
            interact=False,
            debug=False):
    """
    @brief Create, deploy and start a Kafka cluster using Kafka \p version
    Then run librdkafka's regression tests.
    """

    cluster = LibrdkafkaTestCluster(version, conf, debug=debug)

    # librdkafka's regression tests, as an App.
    _rdkconf = conf.copy()  # Base rdkconf on cluster conf + rdkconf
    _rdkconf.update(rdkconf)
    rdkafka = LibrdkafkaTestApp(cluster, version, _rdkconf, tests=tests)
    rdkafka.do_cleanup = False

    if deploy:
        cluster.deploy()

    cluster.start(timeout=30)

    rdkafka.start()
    print('# librdkafka regression tests started, logs in %s' %
          rdkafka.root_path())
    rdkafka.wait_stopped(timeout=60 * 10)

    report = rdkafka.report()
    report['root_path'] = rdkafka.root_path()

    if report.get('tests_failed', 0) > 0 and interact:
        print('# Connect to cluster with bootstrap.servers %s' %
              cluster.bootstrap_servers())
        print('# Exiting the shell will bring down the cluster. Good luck.')
        subprocess.call(
            'bash --rcfile <(cat ~/.bashrc; echo \'PS1="[TRIVUP:%s@%s] \\u@\\h:\w$ "\')'
            % (cluster.name, version),
            shell=True,
            executable='/bin/bash')

    cluster.stop(force=True)

    cluster.cleanup()
    return report
Exemplo n.º 4
0
def test_it (version, deploy=True, conf={}, rdkconf={}, tests=None,
             interact=False, debug=False):
                  
    """
    @brief Create, deploy and start a Kafka cluster using Kafka \p version
    Then run librdkafka's regression tests.
    """
    
    cluster = LibrdkafkaTestCluster(version, conf,
                                    num_brokers=int(conf.get('broker_cnt', 3)),
                                    debug=debug)

    # librdkafka's regression tests, as an App.
    _rdkconf = conf.copy() # Base rdkconf on cluster conf + rdkconf
    _rdkconf.update(rdkconf)
    rdkafka = LibrdkafkaTestApp(cluster, version, _rdkconf, tests=tests)
    rdkafka.do_cleanup = False

    if deploy:
        cluster.deploy()

    cluster.start(timeout=30)

    if conf.get('test_mode', '') == 'bash':
        cmd_env = 'export KAFKA_PATH="%s" RDKAFKA_TEST_CONF="%s" ZK_ADDRESS="%s" BROKERS="%s" TEST_KAFKA_VERSION="%s" TRIVUP_ROOT="%s"; ' % \
                  (cluster.get_all('destdir', '', KafkaBrokerApp)[0], rdkafka.test_conf_file, cluster.get_all('address', '', ZookeeperApp)[0], cluster.bootstrap_servers(), version, cluster.instance_path())
        cmd = 'bash --rcfile <(cat ~/.bashrc; echo \'PS1="[TRIVUP:%s@%s] \\u@\\h:\w$ "\')' % (cluster.name, version)
        subprocess.call('%s %s' % (cmd_env, cmd), shell=True, executable='/bin/bash')
        report = None

    else:
        rdkafka.start()
        print('# librdkafka regression tests started, logs in %s' % rdkafka.root_path())
        rdkafka.wait_stopped(timeout=60*10)

        report = rdkafka.report()
        report['root_path'] = rdkafka.root_path()

        if report.get('tests_failed', 0) > 0 and interact:
            print('# Connect to cluster with bootstrap.servers %s' % cluster.bootstrap_servers())
            print('# Exiting the shell will bring down the cluster. Good luck.')
            subprocess.call('bash --rcfile <(cat ~/.bashrc; echo \'PS1="[TRIVUP:%s@%s] \\u@\\h:\w$ "\')' % (cluster.name, version), shell=True, executable='/bin/bash')

    cluster.stop(force=True)

    cluster.cleanup()
    return report
Exemplo n.º 5
0
def test_it (version, deploy=True, conf={}, rdkconf={}, tests=None,
             interact=False, debug=False):
                  
    """
    @brief Create, deploy and start a Kafka cluster using Kafka \p version
    Then run librdkafka's regression tests.
    """
    
    cluster = LibrdkafkaTestCluster(version, conf,
                                    num_brokers=int(conf.get('broker_cnt', 3)),
                                    debug=debug)

    # librdkafka's regression tests, as an App.
    _rdkconf = conf.copy() # Base rdkconf on cluster conf + rdkconf
    _rdkconf.update(rdkconf)
    rdkafka = LibrdkafkaTestApp(cluster, version, _rdkconf, tests=tests)
    rdkafka.do_cleanup = False

    if deploy:
        cluster.deploy()

    cluster.start(timeout=30)

    if conf.get('test_mode', '') == 'bash':
        cmd = 'bash --rcfile <(cat ~/.bashrc; echo \'PS1="[TRIVUP:%s@%s] \\u@\\h:\w$ "\')' % (cluster.name, version)
        subprocess.call(cmd, env=rdkafka.env, shell=True, executable='/bin/bash')
        report = None

    else:
        rdkafka.start()
        print('# librdkafka regression tests started, logs in %s' % rdkafka.root_path())
        rdkafka.wait_stopped(timeout=60*30)

        report = rdkafka.report()
        report['root_path'] = rdkafka.root_path()

        if report.get('tests_failed', 0) > 0 and interact:
            print('# Connect to cluster with bootstrap.servers %s' % cluster.bootstrap_servers())
            print('# Exiting the shell will bring down the cluster. Good luck.')
            subprocess.call('bash --rcfile <(cat ~/.bashrc; echo \'PS1="[TRIVUP:%s@%s] \\u@\\h:\w$ "\')' % (cluster.name, version), env=rdkafka.env, shell=True, executable='/bin/bash')

    cluster.stop(force=True)

    cluster.cleanup()
    return report
Exemplo n.º 6
0
def test_it(version,
            deploy=True,
            conf={},
            rdkconf={},
            tests=None,
            interact=False,
            debug=False):
    """
    @brief Create, deploy and start a Kafka cluster using Kafka \p version
    Then run librdkafka's regression tests.
    """

    cluster = LibrdkafkaTestCluster(version,
                                    conf,
                                    num_brokers=int(conf.get('broker_cnt', 3)),
                                    debug=debug)

    # librdkafka's regression tests, as an App.
    _rdkconf = conf.copy()  # Base rdkconf on cluster conf + rdkconf
    _rdkconf.update(rdkconf)
    rdkafka = LibrdkafkaTestApp(cluster, version, _rdkconf, tests=tests)
    rdkafka.do_cleanup = False

    if deploy:
        cluster.deploy()

    cluster.start(timeout=30)

    if conf.get('test_mode', '') == 'bash':
        cmd_env = 'export KAFKA_PATH="%s" RDKAFKA_TEST_CONF="%s" ZK_ADDRESS="%s" BROKERS="%s" TEST_KAFKA_VERSION="%s" TRIVUP_ROOT="%s"; ' % \
                  (cluster.get_all('destdir', '', KafkaBrokerApp)[0], rdkafka.test_conf_file, cluster.get_all('address', '', ZookeeperApp)[0], cluster.bootstrap_servers(), version, cluster.instance_path())
        cmd = 'bash --rcfile <(cat ~/.bashrc; echo \'PS1="[TRIVUP:%s@%s] \\u@\\h:\w$ "\')' % (
            cluster.name, version)
        subprocess.call('%s %s' % (cmd_env, cmd),
                        shell=True,
                        executable='/bin/bash')
        report = None

    else:
        rdkafka.start()
        print('# librdkafka regression tests started, logs in %s' %
              rdkafka.root_path())
        rdkafka.wait_stopped(timeout=60 * 10)

        report = rdkafka.report()
        report['root_path'] = rdkafka.root_path()

        if report.get('tests_failed', 0) > 0 and interact:
            print('# Connect to cluster with bootstrap.servers %s' %
                  cluster.bootstrap_servers())
            print(
                '# Exiting the shell will bring down the cluster. Good luck.')
            subprocess.call(
                'bash --rcfile <(cat ~/.bashrc; echo \'PS1="[TRIVUP:%s@%s] \\u@\\h:\w$ "\')'
                % (cluster.name, version),
                shell=True,
                executable='/bin/bash')

    cluster.stop(force=True)

    cluster.cleanup()
    return report