Exemplo n.º 1
0
    def test_thread(self):
        outfile = tempfile.NamedTemporaryFile()
        params = Params()
        params.concurrency = 2
        params.iterations = 10
        params.report = outfile.name
        params.tests = dummy_tests

        worker = Worker(params)
        worker.run_nose(params)
Exemplo n.º 2
0
 def test_loadgen(self):
     params = Params()
     params.iterations = 1
     params.concurrency = 1
     params.report = 'log.ldjson'
     params.tests = dummy_tests
     worker = Worker(params)
     worker.run_nose(params)
     action_handlers = thread.get_from_thread_store('action_handlers')
     plugin = action_handlers.pop(0)
     self.assertTrue(plugin.started)
     self.assertTrue(plugin.ended)
Exemplo n.º 3
0
    def test_ramp_up2(self):
        outfile = tempfile.NamedTemporaryFile()

        params1 = Params()
        params1.concurrency = 50
        params1.report = outfile.name
        params1.tests = dummy_tests
        params1.ramp_up = 60

        params1.worker_count = 1
        params1.worker_index = 0

        worker1 = Worker(params1)
        res1 = [x.delay for x in worker1._get_thread_params()]
        self.assertEquals(params1.concurrency, len(res1))
Exemplo n.º 4
0
    def test_empty_worker(self):
        outfile = tempfile.NamedTemporaryFile()
        print(outfile.name)
        params = Params()
        params.concurrency = 2
        params.iterations = 10
        params.report = outfile.name
        params.tests = []

        worker = Worker(params)
        worker.close = self.get_required_method(
            worker.close)  # check whether close has been called
        try:
            worker.start()
        except:  # assertRaises doesn't catch it
            pass
        self.assertTrue(self.required_method_called)
Exemplo n.º 5
0
    def test_empty_test_file(self):
        outfile = tempfile.NamedTemporaryFile()
        params = Params()
        params.concurrency = 1
        params.iterations = 1
        params.report = outfile.name
        params.tests = [os.path.join(RESOURCES_DIR, "test_invalid.py")]

        worker = Worker(params)
        self.assertRaises(RuntimeError, worker.start)
Exemplo n.º 6
0
    def test_empty_worker(self):
        outfile = tempfile.NamedTemporaryFile()
        params = Params()
        params.concurrency = 2
        params.iterations = 10
        params.report = outfile.name
        params.tests = []

        worker = Worker(params)
        self.assertRaises(RuntimeError, worker.start)
Exemplo n.º 7
0
    def test_ramp_up1(self):
        outfile = tempfile.NamedTemporaryFile()
        print(outfile.name)

        params1 = Params()
        params1.concurrency = 50
        params1.report = outfile.name
        params1.tests = dummy_tests
        params1.ramp_up = 60
        params1.steps = 5

        params1.worker_count = 2
        params1.worker_index = 0

        worker1 = Worker(params1)
        res1 = [x.delay for x in worker1._get_thread_params()]
        print(res1)
        self.assertEquals(params1.concurrency, len(res1))

        params2 = copy.deepcopy(params1)
        params2.worker_index = 1
        worker2 = Worker(params2)
        res2 = [x.delay for x in worker2._get_thread_params()]
        print(res2)
        self.assertEquals(params2.concurrency, len(res2))

        print(sorted(res1 + res2))
Exemplo n.º 8
0
    def test_setup_errors(self):
        error_tests = [os.path.join(RESOURCES_DIR, "test_setup_errors.py")]

        outfile = tempfile.NamedTemporaryFile()
        params = Params()
        params.concurrency = 1
        params.iterations = 1
        params.report = outfile.name
        params.tests = error_tests
        params.verbose = True

        worker = Worker(params)
        self.assertRaises(BaseException, worker.run_nose, params)
Exemplo n.º 9
0
    def test_setup_teardown_graceful(self):
        error_tests = [
            os.path.join(RESOURCES_DIR, "setup_teardown_graceful.py")
        ]

        outfile = tempfile.NamedTemporaryFile()
        params = Params()
        params.concurrency = 1
        params.iterations = 1
        params.report = outfile.name
        params.tests = error_tests
        params.verbose = True

        worker = Worker(params)
        worker.run_nose(params)

        # todo: fix result of "samples = self.apiritif_extractor.parse_recording(recording, sample)"
        test_result = apiritif.get_from_thread_store('test_result')
        sample = [
            '1. setup1', '2. setup2', '3. main1', '4. main2', '5. teardown1',
            '6. teardown2'
        ]
        self.assertEqual(sample, test_result)
Exemplo n.º 10
0
    def test_worker(self):
        outfile = tempfile.NamedTemporaryFile()
        params = Params()
        params.concurrency = 2
        params.iterations = 10
        params.report = outfile.name
        params.tests = dummy_tests

        worker = Worker(params)
        worker.start()
        worker.join()
Exemplo n.º 11
0
    def test_setup_errors(self):
        error_tests = [
            os.path.join(os.path.dirname(__file__), "resources",
                         "test_setup_errors.py")
        ]

        outfile = tempfile.NamedTemporaryFile()
        print(outfile.name)
        params = Params()
        params.concurrency = 1
        params.iterations = 1
        params.report = outfile.name
        params.tests = error_tests
        params.verbose = True

        worker = Worker(params)
        self.assertRaises(RuntimeError, worker.run_nose, params)

        with open(outfile.name, 'rt') as _file:
            _file.read()
Exemplo n.º 12
0
    def test_unicode_ldjson(self):
        outfile = tempfile.NamedTemporaryFile(suffix=".ldjson")
        print(outfile.name)
        params = Params()
        params.concurrency = 2
        params.iterations = 1
        params.report = outfile.name
        params.tests = dummy_tests

        worker = Worker(params)
        worker.start()
        worker.join()

        with open(outfile.name) as fds:
            print(fds.read())
Exemplo n.º 13
0
    def test_unicode_ldjson(self):
        outfile = tempfile.NamedTemporaryFile(suffix=".ldjson")
        params = Params()
        params.concurrency = 2
        params.iterations = 1
        params.report = outfile.name
        params.tests = dummy_tests

        worker = Worker(params)
        worker.start()
        worker.join()

        with open(outfile.name) as fds:
            result = fds.readlines()
        self.assertEqual(4, len(result))