Example #1
0
    def test_distributed_run(self):
        start_runner(get_runner_args(
            fqn='loads.examples.test_blog.TestWebSite.test_something',
            agents=2,
            project_name='test_distributed_run',
            output=['null'],
            observer=['loads.tests.test_functional.observer',
                      'loads.tests.test_functional.observer_fail'],
            users=1, hits=5))

        client = Pool()
        runs = client.list_runs()
        run_id = runs.keys()[0]
        client.stop_run(run_id)

        # checking the metadata
        metadata = client.get_metadata(run_id)
        self.assertEqual(metadata['project_name'], 'test_distributed_run')

        # checking the data
        data = client.get_data(run_id)
        self.assertTrue(len(data) > 25, len(data))
        self.assertEqual(client.get_urls(run_id),
                         {u'http://127.0.0.1:9000/': 10})
        counts = dict(client.get_counts(run_id))
        self.assertEquals(counts['socket_open'], 10)
        self.assertEquals(counts['socket_close'], 10)

        # making sure the observer was called
        with open(_RESULTS) as f:
            data = f.readlines()

        assert len(data) > 0, data
Example #2
0
def start_servers():
    procs = []

    procs.append(start_process('loads.transport.broker'))

    for x in range(3):
        procs.append(start_process('loads.transport.agent'))

    procs.append(start_process('loads.examples.echo_server'))

    # wait for the echo server to be started
    tries = 0
    while True:
        try:
            requests.get('http://0.0.0.0:9000')
            break
        except requests.ConnectionError:
            time.sleep(.2)
            tries += 1
            if tries > 20:
                raise

    # wait for the broker to be up with 3 slaves.
    client = Pool()
    while len(client.list()) != 3:
        time.sleep(.1)

    # control that the broker is responsive
    client.ping()
    for wid in client.list():
        status = client.status(wid)['status']
        assert status == {}, status

    client.close()
    return procs
Example #3
0
    def test_distributed_run(self):
        start_runner(get_runner_args(
            fqn='loads.examples.test_blog.TestWebSite.test_something',
            agents=2,
            output=['null'],
            users=1, hits=5))

        client = Pool()
        runs = client.list_runs()
        data = client.get_data(runs.keys()[0])
        self.assertTrue(len(data) > 25, len(data))
Example #4
0
    def test_distributed_run_external_runner(self):
        args = get_runner_args(
            fqn='loads.examples.test_blog.TestWebSite.test_something',
            agents=1,
            users=1,
            test_runner='%s -m loads.tests.runner {test}' % sys.executable)

        start_runner(args)
        client = Pool()
        runs = client.list_runs()
        data = client.get_metadata(runs.keys()[0])
        self.assertTrue(len(data) > 5, len(data))
Example #5
0
    def test_distributed_run_external_runner(self):
        args = get_runner_args(
            fqn='loads.examples.test_blog.TestWebSite.test_something',
            agents=1,
            users=1,
            test_runner='%s -m loads.tests.runner {test}' % sys.executable)

        start_runner(args)
        client = Pool()
        runs = client.list_runs()
        data = client.get_data(runs.keys()[0])
        self.assertTrue(len(data) > 5, len(data))
Example #6
0
    def test_distributed_run(self):
        start_runner(
            get_runner_args(
                fqn="loads.examples.test_blog.TestWebSite.test_something",
                agents=2,
                project_name="test_distributed_run",
                output=["null"],
                observer=["loads.tests.test_functional.observer", "loads.tests.test_functional.observer_fail"],
                users=1,
                hits=5,
            )
        )

        client = Pool()
        runs = client.list_runs()
        run_id = runs.keys()[0]
        client.stop_run(run_id)

        # checking the metadata
        metadata = client.get_metadata(run_id)
        self.assertEqual(metadata["project_name"], "test_distributed_run")

        # checking the data
        data = client.get_data(run_id)
        self.assertTrue(len(data) > 25, len(data))
        self.assertEqual(client.get_urls(run_id), {u"http://127.0.0.1:9000/": 10})
        counts = dict(client.get_counts(run_id))
        self.assertEquals(counts["socket_open"], 10)
        self.assertEquals(counts["socket_close"], 10)

        # making sure the observer was called
        with open(_RESULTS) as f:
            data = f.readlines()

        assert len(data) > 0, data
Example #7
0
def start_servers():
    procs = []

    procs.append(start_process('loads.transport.broker'))

    for x in range(3):
        procs.append(start_process('loads.transport.agent'))

    procs.append(start_process('loads.examples.echo_server'))

    # wait for the echo server to be started
    tries = 0
    while True:
        try:
            requests.get('http://0.0.0.0:9000')
            break
        except requests.ConnectionError:
            time.sleep(.2)
            tries += 1
            if tries > 20:
                raise

    # wait for the broker to be up with 3 slaves.
    client = Pool()
    while len(client.list()) != 3:
        time.sleep(.1)

    # control that the broker is responsive
    client.ping()
    for wid in client.list():
        status = client.status(wid)['status']
        assert status == {}, status

    client.close()
    return procs
Example #8
0
    def test_distributed_run_duration(self):
        args = get_runner_args(
            fqn="loads.examples.test_blog.TestWebSite.test_something", agents=1, output=["null"], users=1, duration=2
        )

        start_runner(args)

        client = Pool()

        for i in range(10):
            runs = client.list_runs()
            time.sleep(0.1)
            data = client.get_data(runs.keys()[0])
            if len(data) > 0:
                return

        raise AssertionError("No data back")
Example #9
0
    def test_distributed_run(self):
        start_runner(get_runner_args(
            fqn='loads.examples.test_blog.TestWebSite.test_something',
            agents=2,
            project_name='test_distributed_run',
            output=['null'],
            observer=['loads.tests.test_functional.Observer',
                      'loads.tests.test_functional.ObserverFail'],
            users=1, hits=5))

        client = Pool()
        runs = client.list_runs()
        run_id = runs.keys()[0]
        client.stop_run(run_id)

        # checking the metadata
        metadata = client.get_metadata(run_id)
        self.assertEqual(metadata['project_name'], 'test_distributed_run')

        # checking the data
        # the run is over so the detailed lines where pruned
        self.assertRaises(ValueError, client.get_data, run_id)
        self.assertEqual(client.get_urls(run_id),
                         {u'http://127.0.0.1:9000/': 10})
        counts = dict(client.get_counts(run_id))
        self.assertEquals(counts['socket_open'], 10)
        self.assertEquals(counts['socket_close'], 10)

        # making sure the observer was called
        with open(_RESULTS) as f:
            data = f.readlines()

        assert len(data) > 0, data
Example #10
0
    def test_distributed_run(self):
        start_runner(get_runner_args(
            fqn='loads.examples.test_blog.TestWebSite.test_something',
            agents=2,
            output=['null'],
            observer=['loads.tests.test_functional.observer',
                      'loads.tests.test_functional.observer_fail'],
            users=1, hits=5))

        client = Pool()
        runs = client.list_runs()
        run_id = runs.keys()[0]
        client.stop_run(run_id)

        # checking the data
        data = client.get_data(run_id)
        self.assertTrue(len(data) > 25, len(data))
        self.assertEqual(client.get_urls(run_id),
                         {u'http://127.0.0.1:9000/': 10})
        counts = dict(client.get_counts(run_id))
        self.assertEquals(counts['socket_open'], 10)
        #self.assertEquals(counts['socket_close'], 10)  XXX TO BE FIXED

        # making sure the observer was called
        with open(_RESULTS) as f:
            data = f.readlines()

        assert len(data) > 0, data
Example #11
0
    def test_distributed_run_duration(self):
        args = get_runner_args(
            fqn='loads.examples.test_blog.TestWebSite.test_something',
            agents=1,
            output=['null'],
            users=1,
            duration=2)

        start_runner(args)

        client = Pool()

        for i in range(10):
            runs = client.list_runs()
            time.sleep(.1)
            data = client.get_data(runs.keys()[0])
            if len(data) > 0:
                return

        raise AssertionError('No data back')
Example #12
0
def start_servers():
    if len(_PROCS) != 0:
        return _PROCS

    _PROCS.append(
        start_process('loads.transport.broker', '--db', 'python',
                      '--heartbeat', 'tcp://0.0.0.0:9876'))

    for x in range(10):
        _PROCS.append(start_process('loads.transport.agent'))

    _PROCS.append(start_process('loads.examples.echo_server'))

    # wait for the echo server to be started
    tries = 0
    while True:
        try:
            requests.get('http://0.0.0.0:9000')
            break
        except requests.ConnectionError:
            time.sleep(.2)
            tries += 1
            if tries > 20:
                raise

    # wait for the broker to be up with 3 slaves.
    client = Pool()
    while len(client.list()) != 10:
        time.sleep(.1)

    # control that the broker is responsive
    client.ping()
    for wid in client.list():
        status = client.status(wid)['status']
        assert status == {}, status

    client.close()

    if verify_broker() is None:
        raise ValueError('Broker seem down')

    return _PROCS
Example #13
0
def start_servers():
    if len(_PROCS) != 0:
        return _PROCS

    _PROCS.append(start_process('loads.transport.broker', '--db', 'python',
                                '--heartbeat', 'tcp://0.0.0.0:9876'))

    for x in range(10):
        _PROCS.append(start_process('loads.transport.agent'))

    _PROCS.append(start_process('loads.examples.echo_server'))

    # wait for the echo server to be started
    tries = 0
    while True:
        try:
            requests.get('http://0.0.0.0:9000')
            break
        except requests.ConnectionError:
            time.sleep(.2)
            tries += 1
            if tries > 20:
                raise

    # wait for the broker to be up with 3 slaves.
    client = Pool()
    while len(client.list()) != 10:
        time.sleep(.1)

    # control that the broker is responsive
    client.ping()
    for wid in client.list():
        status = client.status(wid)['status']
        assert status == {}, status

    client.close()

    if verify_broker() is None:
        raise ValueError('Broker seem down')

    return _PROCS
Example #14
0
 def _get_client(self):
     client = Pool()
     while len(client.list_runs()) > 0:
         time.sleep(.2)
     return client
Example #15
0
 def _get_client(self):
     client = Pool()
     while len(client.list_runs()) > 0:
         time.sleep(.2)
     return client