예제 #1
0
 def test_task(self):
     cfg = {
         "Dummy.dummy_random_fail_in_atomic": [
             {
                 "runner": {
                     "type": "constant",
                     "times": 100,
                     "concurrency": 5
                 }
             }
         ]
     }
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
         config = utils.TaskConfig(cfg)
         output = self.rally(("task start --task %(task_file)s "
                              "--deployment %(deployment_id)s") %
                             {"task_file": config.filename,
                              "deployment_id": deployment_id})
         result = re.search(
             r"(?P<uuid>[0-9a-f\-]{36}): started", output)
         uuid = result.group("uuid")
         self.rally("use task --uuid %s" % uuid)
         current_task = envutils.get_global("RALLY_TASK")
         self.assertEqual(uuid, current_task)
예제 #2
0
 def test_use(self):
     rally = utils.Rally()
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
         config = utils.TaskConfig(self._get_sample_task_config())
         output = rally(("task start --task %(task_file)s "
                         "--deployment %(deployment_id)s") %
                        {"task_file": config.filename,
                         "deployment_id": deployment_id})
         result = re.search(
             r"(?P<uuid>[0-9a-f\-]{36}): started", output)
         uuid = result.group("uuid")
         rally("task use --task %s" % uuid)
         current_task = envutils.get_global("RALLY_TASK")
         self.assertEqual(uuid, current_task)
예제 #3
0
 def test_deployment(self):
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         output = self.rally(
             "deployment create --name t_create_env1 --fromenv")
         uuid = self._get_deployment_uuid(output)
         self.rally("deployment create --name t_create_env2 --fromenv")
         self.rally("use deployment --deployment %s" % uuid)
         current_deployment = envutils.get_global("RALLY_DEPLOYMENT")
         self.assertEqual(uuid, current_deployment)
예제 #4
0
 def test_deployment(self):
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         output = self.rally(
             "deployment create --name t_create_env1 --fromenv")
         uuid = self._get_deployment_uuid(output)
         self.rally("deployment create --name t_create_env2 --fromenv")
         self.rally("use deployment --deployment %s" % uuid)
         current_deployment = envutils.get_global("RALLY_DEPLOYMENT")
         self.assertEqual(uuid, current_deployment)
예제 #5
0
 def test_use(self):
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         output = self.rally(
             "deployment create --name t_create_env1 --fromenv")
         uuid = re.search(r"Using deployment: (?P<uuid>[0-9a-f\-]{36})",
                          output).group("uuid")
         self.rally("deployment create --name t_create_env2 --fromenv")
         self.rally("deployment use --deployment %s" % uuid)
         current_deployment = envutils.get_global("RALLY_DEPLOYMENT")
         self.assertEqual(uuid, current_deployment)
예제 #6
0
 def test_use(self):
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         output = self.rally(
             "deployment create --name t_create_env1 --fromenv")
         uuid = re.search(r"Using deployment: (?P<uuid>[0-9a-f\-]{36})",
                          output).group("uuid")
         self.rally("deployment create --name t_create_env2 --fromenv")
         self.rally("deployment use --deployment %s" % uuid)
         current_deployment = envutils.get_global("RALLY_DEPLOYMENT")
         self.assertEqual(uuid, current_deployment)
예제 #7
0
 def _test_start_abort_on_sla_failure(self, cfg, times):
     rally = utils.Rally()
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
         config = utils.TaskConfig(cfg)
         rally(("task start --task %(task_file)s "
                "--deployment %(deployment_id)s --abort-on-sla-failure") %
               {"task_file": config.filename,
                "deployment_id": deployment_id})
         results = json.loads(rally("task results"))
     iterations_completed = len(results[0]["result"])
     self.assertTrue(iterations_completed < times)
예제 #8
0
 def test_validate_is_invalid(self):
     rally = utils.Rally()
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
     cfg = {"invalid": "config"}
     config = utils.TaskConfig(cfg)
     self.assertRaises(utils.RallyCmdError,
                       rally,
                       ("task validate --task %(task_file)s "
                        "--deployment %(deployment_id)s") %
                       {"task_file": config.filename,
                        "deployment_id": deployment_id})
예제 #9
0
 def test_start(self):
     rally = utils.Rally()
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
         cfg = self._get_sample_task_config()
         config = utils.TaskConfig(cfg)
         output = rally(("task start --task %(task_file)s "
                         "--deployment %(deployment_id)s") %
                        {"task_file": config.filename,
                         "deployment_id": deployment_id})
     result = re.search(
         r"(?P<task_id>[0-9a-f\-]{36}): started", output)
     self.assertIsNotNone(result)
예제 #10
0
 def test_task(self):
     cfg = {
         "Dummy.dummy_random_fail_in_atomic": [{
             "runner": {
                 "type": "constant",
                 "times": 100,
                 "concurrency": 5
             }
         }]
     }
     with mock.patch.dict("os.environ", utils.TEST_ENV):
         deployment_id = envutils.get_global("RALLY_DEPLOYMENT")
         config = utils.TaskConfig(cfg)
         output = self.rally(("task start --task %(task_file)s "
                              "--deployment %(deployment_id)s") % {
                                  "task_file": config.filename,
                                  "deployment_id": deployment_id
                              })
         result = re.search(r"(?P<uuid>[0-9a-f\-]{36}): started", output)
         uuid = result.group("uuid")
         self.rally("use task --uuid %s" % uuid)
         current_task = envutils.get_global("RALLY_TASK")
         self.assertEqual(uuid, current_task)
예제 #11
0
    def list(self, deployment_list=None):
        """Print list of deployments."""
        headers = ['uuid', 'created_at', 'name', 'status', 'active']
        current_deploy_id = envutils.get_global('RALLY_DEPLOYMENT')
        deployment_list = deployment_list or db.deployment_list()

        table_rows = []
        if deployment_list:
            for t in deployment_list:
                r = [str(t[column]) for column in headers[:-1]]
                r.append("" if t["uuid"] != current_deploy_id else "*")
                table_rows.append(utils.Struct(**dict(zip(headers, r))))
            common_cliutils.print_list(table_rows, headers)
        else:
            print(_("There are no deployments. "
                    "To create a new deployment, use:"
                    "\nrally deployment create"))
예제 #12
0
파일: deployment.py 프로젝트: Ch00k/rally
    def list(self, deployment_list=None):
        """Print list of deployments."""
        headers = ['uuid', 'created_at', 'name', 'status', 'active']
        current_deploy_id = envutils.get_global('RALLY_DEPLOYMENT')
        deployment_list = deployment_list or db.deployment_list()
        if deployment_list:
            table = prettytable.PrettyTable(headers)

            for t in deployment_list:
                r = [str(t[column]) for column in headers[:-1]]
                r.append("" if t["uuid"] != current_deploy_id else "*")
                table.add_row(r)

            print(table)
        else:
            print(_("There are no deployments. "
                    "To create a new deployment, use:"
                    "\nrally deployment create"))
예제 #13
0
    def list(self, deployment_list=None):
        """Print list of deployments."""
        headers = ['uuid', 'created_at', 'name', 'status', 'active']
        current_deploy_id = envutils.get_global('RALLY_DEPLOYMENT')
        deployment_list = deployment_list or db.deployment_list()
        if deployment_list:
            table = prettytable.PrettyTable(headers)

            for t in deployment_list:
                r = [str(t[column]) for column in headers[:-1]]
                r.append("" if t["uuid"] != current_deploy_id else "*")
                table.add_row(r)

            print(table)
        else:
            print(_("There are no deployments. "
                    "To create a new deployment, use:"
                    "\nrally deployment create"))
예제 #14
0
    def list(self, deployment_list=None):
        """Print list of deployments."""
        headers = ['uuid', 'created_at', 'name', 'status', 'active']
        current_deploy_id = envutils.get_global('RALLY_DEPLOYMENT')
        deployment_list = deployment_list or db.deployment_list()

        table_rows = []
        if deployment_list:
            for t in deployment_list:
                r = [str(t[column]) for column in headers[:-1]]
                r.append("" if t["uuid"] != current_deploy_id else "*")
                table_rows.append(utils.Struct(**dict(zip(headers, r))))
            common_cliutils.print_list(table_rows, headers)
        else:
            print(
                _("There are no deployments. "
                  "To create a new deployment, use:"
                  "\nrally deployment create"))
예제 #15
0
    def list(self, deployment_list=None):
        """List existing deployments."""

        headers = ["uuid", "created_at", "name", "status", "active"]
        current_deployment = envutils.get_global("RALLY_DEPLOYMENT")
        deployment_list = deployment_list or db.deployment_list()

        table_rows = []
        if deployment_list:
            for t in deployment_list:
                r = [str(t[column]) for column in headers[:-1]]
                r.append("" if t["uuid"] != current_deployment else "*")
                table_rows.append(utils.Struct(**dict(zip(headers, r))))
            cliutils.print_list(table_rows, headers,
                                sortby_index=headers.index("created_at"))
        else:
            print(_("There are no deployments. "
                    "To create a new deployment, use:"
                    "\nrally deployment create"))
예제 #16
0
    def list(self, deployment_list=None):
        """List existing deployments."""

        headers = ["uuid", "created_at", "name", "status", "active"]
        current_deployment = envutils.get_global("RALLY_DEPLOYMENT")
        deployment_list = deployment_list or db.deployment_list()

        table_rows = []
        if deployment_list:
            for t in deployment_list:
                r = [str(t[column]) for column in headers[:-1]]
                r.append("" if t["uuid"] != current_deployment else "*")
                table_rows.append(utils.Struct(**dict(zip(headers, r))))
            cliutils.print_list(table_rows,
                                headers,
                                sortby_index=headers.index("created_at"))
        else:
            print(
                _("There are no deployments. "
                  "To create a new deployment, use:"
                  "\nrally deployment create"))
예제 #17
0
 def test_get_deployment_id_in_env(self):
     deployment_id = envutils.get_global(envutils.ENV_DEPLOYMENT)
     self.assertEqual("my_deployment_id", deployment_id)
예제 #18
0
 def test_get_task_id_in_env(self):
     self.assertEqual('my_task_id', envutils.get_global('RALLY_TASK'))
예제 #19
0
 def test_get_task_id_with_none(self, mock_file):
     self.assertIsNone(envutils.get_global("RALLY_TASK"))
     mock_file.assert_called_once_with(os.path.expanduser("~/.rally/globals"))
예제 #20
0
 def test_get_deployment_id_with_none(self, mock_file):
     self.assertIsNone(envutils.get_global(envutils.ENV_DEPLOYMENT))
     mock_file.assert_called_once_with(os.path.expanduser("~/.rally/globals"))
예제 #21
0
 def test_get_deployment_id_in_env(self):
     deploy_id = envutils.get_global('RALLY_DEPLOYMENT')
     self.assertEqual('my_deploy_id', deploy_id)
예제 #22
0
 def test_get_task_id_in_env(self):
     self.assertEqual('my_task_id', envutils.get_global(envutils.ENV_TASK))
예제 #23
0
 def test_get_task_id_with_none(self, mock_file):
     self.assertEqual(None, envutils.get_global('RALLY_TASK'))
     mock_file.assert_called_once_with(os.path.expanduser(
         '~/.rally/globals'))
예제 #24
0
 def test_get_deployment_id_with_none(self, mock_file):
     self.assertEqual(None, envutils.get_global('RALLY_DEPLOYMENT'))
     mock_file.assert_called_once_with(os.path.expanduser(
         '~/.rally/globals'))
예제 #25
0
 def test_get_task_id_with_none(self, mock_file):
     self.assertIsNone(envutils.get_global("RALLY_TASK"))
     mock_file.assert_called_once_with(
         os.path.expanduser("~/.rally/globals"))
예제 #26
0
 def test_get_task_id_in_env(self):
     self.assertEqual("my_task_id", envutils.get_global(envutils.ENV_TASK))
예제 #27
0
 def test_get_deployment_id_with_none(self, mock_file):
     self.assertIsNone(envutils.get_global(envutils.ENV_DEPLOYMENT))
     mock_file.assert_called_once_with(
         os.path.expanduser("~/.rally/globals"))
예제 #28
0
 def test_get_deployment_id_in_env(self):
     deployment_id = envutils.get_global(envutils.ENV_DEPLOYMENT)
     self.assertEqual("my_deployment_id", deployment_id)
예제 #29
0
 def test_get_task_id_with_none(self, mock_file):
     self.assertEqual(None, envutils.get_global('RALLY_TASK'))
     mock_file.assert_called_once_with(
         os.path.expanduser('~/.rally/globals'))