예제 #1
0
파일: test_base.py 프로젝트: slashk/rally
    def test_run_scenario_once_internal_logic(self, mock_clients):
        mock_clients.Clients.return_value = "cl"

        context = base._get_scenario_context(fakes.FakeUserContext({}).context)
        scenario_cls = mock.MagicMock()
        args = (2, scenario_cls, "test", context, {})
        base._run_scenario_once(args)

        expected_calls = [
            mock.call(context=context, admin_clients="cl", clients="cl"),
            mock.call().test(),
            mock.call().idle_duration(),
            mock.call().idle_duration(),
            mock.call().atomic_actions()
        ]
        scenario_cls.assert_has_calls(expected_calls, any_order=True)
예제 #2
0
    def test_run_scenario_once_internal_logic(self, mock_clients):
        mock_clients.Clients.return_value = "cl"

        context = base._get_scenario_context(fakes.FakeUserContext({}).context)
        scenario_cls = mock.MagicMock()
        args = (2, scenario_cls, "test", context, {})
        base._run_scenario_once(args)

        expected_calls = [
            mock.call(context=context, admin_clients="cl", clients="cl"),
            mock.call().test(),
            mock.call().idle_duration(),
            mock.call().idle_duration(),
            mock.call().atomic_actions()
        ]
        scenario_cls.assert_has_calls(expected_calls, any_order=True)
예제 #3
0
파일: serial.py 프로젝트: varunarya10/rally
    def _run_scenario(self, cls, method_name, context, args):
        """Runs the specified benchmark scenario with given arguments.

        The scenario iterations are executed one-by-one in the same python
        interpreter process as Rally. This allows you to benchmark your
        scenario without introducing any concurrent operations as well as
        interactively debug the scenario from the same command that you use
        to start Rally.

        :param cls: The Scenario class where the scenario is implemented
        :param method_name: Name of the method that implements the scenario
        :param context: Benchmark context that contains users, admin & other
                        information, that was created before benchmark started.
        :param args: Arguments to call the scenario method with

        :returns: List of results fore each single scenario iteration,
                  where each result is a dictionary
        """
        times = self.config.get("times", 1)

        for i in range(times):
            if self.aborted.is_set():
                break
            run_args = (i, cls, method_name, base._get_scenario_context(context), args)
            result = base._run_scenario_once(run_args)
            self._send_result(result)
예제 #4
0
파일: serial.py 프로젝트: varunarya10/rally
    def _run_scenario(self, cls, method_name, context, args):
        """Runs the specified benchmark scenario with given arguments.

        The scenario iterations are executed one-by-one in the same python
        interpreter process as Rally. This allows you to benchmark your
        scenario without introducing any concurrent operations as well as
        interactively debug the scenario from the same command that you use
        to start Rally.

        :param cls: The Scenario class where the scenario is implemented
        :param method_name: Name of the method that implements the scenario
        :param context: Benchmark context that contains users, admin & other
                        information, that was created before benchmark started.
        :param args: Arguments to call the scenario method with

        :returns: List of results fore each single scenario iteration,
                  where each result is a dictionary
        """
        times = self.config.get("times", 1)

        for i in range(times):
            if self.aborted.is_set():
                break
            run_args = (i, cls, method_name,
                        base._get_scenario_context(context), args)
            result = base._run_scenario_once(run_args)
            self._send_result(result)
예제 #5
0
    def _run_scenario(self, cls, method_name, context, args):
        times = self.config.get('times', 1)

        for i in range(times):
            run_args = (i, cls, method_name,
                        base._get_scenario_context(context), args)
            result = base._run_scenario_once(run_args)
            self._send_result(result)
예제 #6
0
파일: serial.py 프로젝트: x-ion-de/rally
    def _run_scenario(self, cls, method_name, context, args):
        times = self.config.get("times", 1)

        for i in range(times):
            if self.aborted.is_set():
                break
            run_args = (i, cls, method_name,
                        base._get_scenario_context(context), args)
            result = base._run_scenario_once(run_args)
            self._send_result(result)
예제 #7
0
    def _run_scenario(self, cls, method_name, context, args):
        # runners settings are stored in self.config
        min_times = self.config.get("min_times", 1)
        max_times = self.config.get("max_times", 1)

        for i in range(random.randrange(min_times, max_times)):
            run_args = (i, cls, method_name,
                        base._get_scenario_context(context), args)
            result = base._run_scenario_once(run_args)
            # use self.send_result for result of each iteration
            self._send_result(result)
예제 #8
0
    def _run_scenario(self, cls, method_name, context, args):
        times = self.config.get('times', 1)

        results = []

        for i in range(times):
            run_args = (i, cls, method_name,
                        base._get_scenario_context(context), args)
            result = base._run_scenario_once(run_args)
            results.append(result)

        return base.ScenarioRunnerResult(results)
예제 #9
0
파일: serial.py 프로젝트: rsokolkov/rally
    def _run_scenario(self, cls, method_name, context, args, config):

        times = config.get('times', 1)

        results = []

        for i in range(times):
            run_args = (i, cls, method_name, context['admin'],
                        random.choice(context['users']), args)
            result = base._run_scenario_once(run_args)
            results.append(result)

        return base.ScenarioRunnerResult(results)
예제 #10
0
    def test_run_scenario_once_without_scenario_output(self, mock_clients, mock_rtimer):
        context = base._get_scenario_context(fakes.FakeUserContext({}).context)
        args = (1, fakes.FakeScenario, "do_it", context, {})
        result = base._run_scenario_once(args)

        expected_result = {
            "duration": fakes.FakeTimer().duration(),
            "timestamp": fakes.FakeTimer().timestamp(),
            "idle_duration": 0,
            "error": [],
            "scenario_output": {"errors": "", "data": {}},
            "atomic_actions": {},
        }
        self.assertEqual(expected_result, result)
예제 #11
0
 def test_run_scenario_once_exception(self, mock_clients, mock_rtimer):
     context = base._get_scenario_context(fakes.FakeUserContext({}).context)
     args = (1, fakes.FakeScenario, "something_went_wrong", context, {})
     result = base._run_scenario_once(args)
     expected_error = result.pop("error")
     expected_result = {
         "duration": fakes.FakeTimer().duration(),
         "timestamp": fakes.FakeTimer().timestamp(),
         "idle_duration": 0,
         "scenario_output": {"errors": "", "data": {}},
         "atomic_actions": {},
     }
     self.assertEqual(expected_result, result)
     self.assertEqual(expected_error[:2], ["Exception", "Something went wrong"])
예제 #12
0
    def test_run_scenario_once_without_scenario_output(self, mock_clients,
                                                       mock_rutils):
        mock_rutils.Timer = fakes.FakeTimer
        context = base._get_scenario_context(fakes.FakeUserContext({}).context)
        args = (1, fakes.FakeScenario, "do_it", context, {})
        result = base._run_scenario_once(args)

        expected_result = {
            "duration": fakes.FakeTimer().duration(),
            "idle_duration": 0,
            "error": [],
            "scenario_output": {"errors": "", "data": {}},
            "atomic_actions": []
        }
        self.assertEqual(expected_result, result)
예제 #13
0
 def test_run_scenario_once_exception(self, mock_clients, mock_rutils):
     mock_rutils.Timer = fakes.FakeTimer
     context = base._get_scenario_context(fakes.FakeUserContext({}).context)
     args = (1, fakes.FakeScenario, "something_went_wrong", context, {})
     result = base._run_scenario_once(args)
     expected_error = result.pop("error")
     expected_result = {
         "duration": fakes.FakeTimer().duration(),
         "idle_duration": 0,
         "scenario_output": {"errors": "", "data": {}},
         "atomic_actions": []
     }
     self.assertEqual(expected_result, result)
     self.assertEqual(expected_error[:2],
                      [str(Exception), "Something went wrong"])
예제 #14
0
 def test_run_scenario_once_exception(self, mock_clients, mock_rutils):
     mock_rutils.Timer = fakes.FakeTimer
     context = base._get_scenario_context(fakes.FakeUserContext({}).context)
     args = (1, fakes.FakeScenario, "something_went_wrong", context, {})
     result = base._run_scenario_once(args)
     expected_error = result.pop("error")
     expected_reuslt = {
         "duration": fakes.FakeTimer().duration(),
         "idle_duration": 0,
         "scenario_output": {},
         "atomic_actions": []
     }
     self.assertEqual(expected_reuslt, result)
     self.assertEqual(expected_error[:2],
                      [str(Exception), "Something went wrong"])
예제 #15
0
    def test_run_scenario_once_with_scenario_output(self, mock_clients,
                                                    mock_rtimer):
        context = base._get_scenario_context(fakes.FakeUserContext({}).context)
        args = (1, fakes.FakeScenario, "with_output", context, {})
        result = base._run_scenario_once(args)

        expected_result = {
            "duration": fakes.FakeTimer().duration(),
            "timestamp": fakes.FakeTimer().timestamp(),
            "idle_duration": 0,
            "error": [],
            "scenario_output": fakes.FakeScenario().with_output(),
            "atomic_actions": {}
        }
        self.assertEqual(expected_result, result)
예제 #16
0
파일: test_base.py 프로젝트: slashk/rally
    def test_run_scenario_once_with_scenario_output(self, mock_clients,
                                                    mock_rutils):
        mock_rutils.Timer = fakes.FakeTimer
        context = base._get_scenario_context(fakes.FakeUserContext({}).context)
        args = (1, fakes.FakeScenario, "with_output", context, {})
        result = base._run_scenario_once(args)

        expected_result = {
            "duration": fakes.FakeTimer().duration(),
            "idle_duration": 0,
            "error": [],
            "scenario_output": fakes.FakeScenario().with_output(),
            "atomic_actions": []
        }
        self.assertEqual(expected_result, result)
예제 #17
0
파일: rps.py 프로젝트: linhuacheng/rally
def _worker_thread(queue, args):
        queue.put(base._run_scenario_once(args))
예제 #18
0
파일: rps.py 프로젝트: sahanasj/rally
def _worker_thread(queue, args):
    queue.put(base._run_scenario_once(args))
예제 #19
0
파일: rps.py 프로젝트: congto/rally
 def _th_worker(self, args):
     result = base._run_scenario_once(args)
     self.queue.put(result)