예제 #1
0
    def test_task_samples_is_valid(self):
        rally = utils.Rally(force_new_db=True)
        # In TestTaskSamples, Rally API will be called directly (not via
        # subprocess), so we need to change database options to temp database.
        db.db_options.set_defaults(
            db.CONF, connection="sqlite:///%s/db" % rally.tmp_dir)

        # let's use pre-created users to make TestTaskSamples quicker
        deployment = api.Deployment.get("MAIN")
        admin_cred = objects.Credential(**deployment["admin"])

        ctx = {"admin": {"credential": admin_cred},
               "task": {"uuid": self.__class__.__name__}}
        user_ctx = users.UserGenerator(ctx)
        user_ctx.setup()
        self.addCleanup(user_ctx.cleanup)

        config = deployment["config"]
        config["users"] = [{
            "username": ctx["users"][0]["credential"].username,
            "password": ctx["users"][0]["credential"].password,
            "tenant_name": ctx["users"][0]["credential"].tenant_name}]

        rally("deployment destroy MAIN", write_report=False)
        deployment_cfg = os.path.join(rally.tmp_dir, "new_deployment.json")
        with open(deployment_cfg, "w") as f:
            f.write(json.dumps(config))
        rally("deployment create --name MAIN --filename %s" % deployment_cfg,
              write_report=False)

        plugins.load()
        samples_path = os.path.join(
            os.path.dirname(__file__), os.pardir, os.pardir,
            "samples", "tasks")
        matcher = re.compile("\.json$")

        for dirname, dirnames, filenames in os.walk(samples_path):
            # NOTE(rvasilets): Skip by suggest of boris-42 because in
            # future we don't what to maintain this dir
            if dirname.find("tempest-do-not-run-against-production") != -1:
                continue
            for filename in filenames:
                full_path = os.path.join(dirname, filename)

                # NOTE(hughsaunders): Skip non config files
                # (bug https://bugs.launchpad.net/rally/+bug/1314369)
                if not matcher.search(filename):
                    continue
                with open(full_path) as task_file:
                    try:
                        input_task = task_file.read()
                        rendered_task = api.Task.render_template(input_task)
                        task_config = json.loads(rendered_task)
                        api.Task.validate("MAIN", task_config)
                    except Exception as e:
                        if not self._skip(six.text_type(e)):
                            print(traceback.format_exc())
                            print("Failed on task config %s with error." %
                                  full_path)
                            raise
예제 #2
0
파일: rallyd.py 프로젝트: dkalashnik/rallyd
def main():
    logging.basicConfig(level=logging.DEBUG,
                        format='%(asctime)s - %(levelname)s - %(name)s '
                               '- %(threadName)s - %(message)s',
                        filename='/var/log/rallyd.log',
                        filemode='w')

    console = logging.StreamHandler()
    console.setLevel(logging.INFO)
    formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(name)s '
                                  '- %(threadName)s - %(message)s')
    console.setFormatter(formatter)
    logging.getLogger('').addHandler(console)

    plugins.load()
    app.run("0.0.0.0", 8000, debug=True, use_reloader=False)
def _process_contexts(w_context):
    """Put the contexts setup and cleanup methods in the order of execution."""
    try:
        plugins.load()
        ctxs = []
        for ctx_name in w_context:
            ctx_cls = context.Context.get(ctx_name)
            ctxs.append((ctx_cls.get_order(), ctx_cls.get_fullname()))
        ctxs.sort()
        ctxs = ["%s.setup" % ctx_name for _i, ctx_name in ctxs]
        ctxs.extend(
            [ctx.replace(".setup", ".cleanup") for ctx in reversed(ctxs)])
        return ctxs
    except Exception:
        # the proper of context can be missed while applying the migration, it
        # should not stop us from migrating the database
        return None
def _process_contexts(w_context):
    """Put the contexts setup and cleanup methods in the order of execution."""
    try:
        plugins.load()
        ctxs = []
        for ctx_name in w_context:
            ctx_cls = context.Context.get(ctx_name)
            ctxs.append((ctx_cls.get_order(), ctx_cls.get_fullname()))
        ctxs.sort()
        ctxs = ["%s.setup" % ctx_name for _i, ctx_name in ctxs]
        ctxs.extend([ctx.replace(".setup", ".cleanup")
                     for ctx in reversed(ctxs)])
        return ctxs
    except Exception:
        # the proper of context can be missed while applying the migration, it
        # should not stop us from migrating the database
        return None
예제 #5
0
    def test_task_samples_is_valid(self):
        plugins.load()
        rally = utils.Rally(force_new_db=True)
        db.db_options.set_defaults(db.CONF,
                                   connection="sqlite:///%s/db" %
                                   rally.tmp_dir,
                                   sqlite_db="rally.sqlite")
        samples_path = os.path.join(os.path.dirname(__file__), os.pardir,
                                    os.pardir, "samples", "tasks")
        matcher = re.compile("\.json$")

        if not os.path.exists(utils.DEPLOYMENT_FILE):
            subprocess.call("rally deployment config > %s" %
                            utils.DEPLOYMENT_FILE,
                            shell=True)

        for dirname, dirnames, filenames in os.walk(samples_path):
            # NOTE(rvasilets): Skip by suggest of boris-42 because in
            # future we don't what to maintain this dir
            if dirname.find("tempest-do-not-run-against-production") != -1:
                continue
            for filename in filenames:
                full_path = os.path.join(dirname, filename)

                # NOTE(hughsaunders): Skip non config files
                # (bug https://bugs.launchpad.net/rally/+bug/1314369)
                if not matcher.search(filename):
                    continue
                with open(full_path) as task_file:
                    try:
                        input_task = task_file.read()
                        rendered_task = api.Task.render_template(input_task)
                        task_config = json.loads(rendered_task)
                        api.Task.validate("MAIN", task_config)
                    except Exception as e:
                        if not self._skip(six.text_type(e)):
                            print(traceback.format_exc())
                            print("Failed on task config %s with error." %
                                  full_path)
                            raise
예제 #6
0
    def test_task_samples_is_valid(self):
        plugins.load()
        rally = utils.Rally(force_new_db=True)
        db.db_options.set_defaults(
            db.CONF, connection="sqlite:///%s/db" % rally.tmp_dir,
            sqlite_db="rally.sqlite")
        samples_path = os.path.join(
            os.path.dirname(__file__), os.pardir, os.pardir,
            "samples", "tasks")
        matcher = re.compile("\.json$")

        if not os.path.exists(utils.DEPLOYMENT_FILE):
            subprocess.call(["rally", "deployment", "config"],
                            stdout=open(utils.DEPLOYMENT_FILE, "w"))

        for dirname, dirnames, filenames in os.walk(samples_path):
            # NOTE(rvasilets): Skip by suggest of boris-42 because in
            # future we don't what to maintain this dir
            if dirname.find("tempest-do-not-run-against-production") != -1:
                continue
            for filename in filenames:
                full_path = os.path.join(dirname, filename)

                # NOTE(hughsaunders): Skip non config files
                # (bug https://bugs.launchpad.net/rally/+bug/1314369)
                if not matcher.search(filename):
                    continue
                with open(full_path) as task_file:
                    try:
                        input_task = task_file.read()
                        rendered_task = api.Task.render_template(input_task)
                        task_config = json.loads(rendered_task)
                        api.Task.validate("MAIN", task_config)
                    except Exception as e:
                        if not self._skip(six.text_type(e)):
                            print (traceback.format_exc())
                            print ("Failed on task config %s with error." %
                                   full_path)
                            raise
예제 #7
0
    def run(self):
        plugins.load()
        bases = self._get_all_plugins_bases()
        if "base_cls" in self.options:
            for _category_name, base_name, base_cls in bases:
                if base_name == self.options["base_cls"]:
                    return self._make_plugin_base_section(base_cls)
            raise Exception("Failed to generate plugins reference for '%s'"
                            " plugin base." % self.options["base_cls"])

        categories = {}

        for category_name, base_name, base_cls in bases:
            # FIXME(andreykurilin): do not ignore anything
            if base_name in IGNORED_BASES:
                continue
            if category_name not in categories:
                categories[category_name] = utils.category(category_name)
            category_of_base = categories[category_name]
            category_of_base.append(
                self._make_plugin_base_section(base_cls, base_name))
        return [content for _name, content in sorted(categories.items())]
예제 #8
0
    def run(self):
        plugins.load()
        bases = self._get_all_plugins_bases()
        if "base_cls" in self.options:
            for _category_name, base_name, base_cls in bases:
                if base_name == self.options["base_cls"]:
                    return self._make_plugin_base_section(base_cls)
            raise Exception("Failed to generate plugins reference for '%s'"
                            " plugin base." % self.options["base_cls"])

        categories = {}

        for category_name, base_name, base_cls in bases:
            # FIXME(andreykurilin): do not ignore anything
            if base_name in IGNORED_BASES:
                continue
            if category_name not in categories:
                categories[category_name] = utils.category(category_name)
            category_of_base = categories[category_name]
            category_of_base.append(self._make_plugin_base_section(base_cls,
                                                                   base_name))
        return [content for _name, content in sorted(categories.items())]
예제 #9
0
 def setUp(self):
     super(TestCase, self).setUp()
     self.addCleanup(mock.patch.stopall)
     plugins.load()
예제 #10
0
def main():
    plugins.load()
    parser = optparse.OptionParser()
    parser.add_option("--task",
                      dest="task_file",
                      help="[REQUIRED] path to the task file")
    parser.add_option("--deployment",
                      dest="deployment_file",
                      help="[REQUIRED] path to the rally deployment file")
    parser.add_option(
        "--deployments-count",
        dest="deployments_count",
        default=1,
        help="[OPTIONAL] number of created deployments. By default 1.",
        type="int")
    parser.add_option(
        "--tasks-count",
        dest="tasks_count",
        default=1,
        help=("[OPTIONAL] number of tasks per deployment. For progression "
              "fill this is the base of progression. By default 1."),
        type="int")
    parser.add_option(
        "--type",
        dest="fill_type",
        type="int",
        help=
        ("type of filling Rally db. 1st - creates <deployments-count> deployments "
         "each will have <tasks-count> tasks. 2nd - create <deployments-count> deployments "
         "every deployment will have <tasks-count> as it should due to progression."
         ))
    parser.add_option("--times",
                      dest="times",
                      type="int",
                      help="[OPTIONAL] number of iteration in tasks.")
    parser.add_option(
        "--diff",
        dest="progression_diff",
        type="int",
        default=1,
        help="difference use in progression fill. When --type=2. By default 1."
    )
    parser.add_option("--destroy",
                      dest="destroy",
                      type="int",
                      default=1,
                      help=("bigger then 0 - if need to destroy, "
                            "0 - if not needed. By default it destroy."))
    parser.add_option("--use-fill",
                      dest="use_fill",
                      type="int",
                      default=1,
                      help=("bigger then 0 - if need to fill db, "
                            "0 - if not needed. By default it fills."))

    fh = logging.FileHandler("fill_db.log")
    formatter = logging.Formatter(
        "%(asctime)s - %(name)s - %(levelname)s - %(message)s")
    fh.setFormatter(formatter)
    fh.setLevel(logging.NOTSET)
    LOG.addHandler(fh)

    (options, args) = parser.parse_args()
    checkRequiredArguments(options, parser)

    task_file = options.task_file
    deployment_file = options.deployment_file
    deployments_count = options.deployments_count
    tasks_count = options.tasks_count
    progression_difference = options.progression_diff
    use_fill = options.use_fill
    destroy = options.destroy

    if options.times is not None:
        task_file = update_times(options.times, task_file)
    if not (use_fill or destroy):
        parser.error(
            "You must specify at least one of the options --destroy or --use-fill"
        )
    if use_fill:
        if options.fill_type is None:
            parser.error(
                "--type should be specified if u use --use-fill argument")
        if str(options.fill_type) == "1":
            round_robin_fill(task_file, deployment_file, deployments_count,
                             tasks_count)
        elif str(options.fill_type) == "2":
            progression_fill(task_file, deployment_file, deployments_count,
                             progression_difference, tasks_count)
    if destroy:
        start = time.time()
        destroy_all_deployments(deployments_count)
        LOG.warn("Deployment destroy takes %f seconds." %
                 (time.time() - start))
예제 #11
0
def setup(app):
    plugins.load()
    app.add_directive("generate_plugin_reference", PluginsReferenceDirective)
예제 #12
0
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.
"""
Ensure that plugins and configuration options are loaded and registered.
"""

from rally import plugins

plugins.load()
예제 #13
0
 def setUp(self):
     super(DocstringsTestCase, self).setUp()
     plugins.load()
예제 #14
0
    def setUp(self):
        super(DocstringsTestCase, self).setUp()
        plugins.load()

        self.exceptions = self._open_file(EXCEPTIONS_DOCSTR) + self._open_file(
            EXCEPTIONS_FORMAT)
예제 #15
0
파일: test.py 프로젝트: paboldin/rally
 def setUp(self):
     super(TestCase, self).setUp()
     self.addCleanup(mock.patch.stopall)
     plugins.load()
예제 #16
0
 def setUp(self):
     super(DocstringsTestCase, self).setUp()
     plugins.load()
예제 #17
0
파일: test.py 프로젝트: jacobwagner/rally
 def setUp(self):
     super(TestCase, self).setUp()
     self.addCleanup(mock.patch.stopall)
     plugins.load()
     self.useFixture(TempHomeDir())
예제 #18
0
def main():
    plugins.load()
    parser = optparse.OptionParser()
    parser.add_option("--task", dest="task_file",
                      help="[REQUIRED] path to the task file")
    parser.add_option("--deployment", dest="deployment_file",
                      help="[REQUIRED] path to the rally deployment file")
    parser.add_option("--deployments-count", dest="deployments_count", default=1,
                      help="[OPTIONAL] number of created deployments. By default 1.", type="int")
    parser.add_option("--tasks-count", dest="tasks_count", default=1,
                      help=("[OPTIONAL] number of tasks per deployment. For progression "
                            "fill this is the base of progression. By default 1."), type="int")
    parser.add_option("--type", dest="fill_type", type="int",
                      help=("type of filling Rally db. 1st - creates <deployments-count> deployments "
                            "each will have <tasks-count> tasks. 2nd - create <deployments-count> deployments "
                            "every deployment will have <tasks-count> as it should due to progression."))
    parser.add_option("--times", dest="times", type="int",
                      help="[OPTIONAL] number of iteration in tasks.")
    parser.add_option("--diff", dest="progression_diff", type="int", default=1,
                      help="difference use in progression fill. When --type=2. By default 1.")
    parser.add_option("--destroy", dest="destroy", type="int", default=1,
                      help=("bigger then 0 - if need to destroy, "
                            "0 - if not needed. By default it destroy."))
    parser.add_option("--use-fill", dest="use_fill", type="int", default=1,
                      help=("bigger then 0 - if need to fill db, "
                            "0 - if not needed. By default it fills."))

    fh = logging.FileHandler("fill_db.log")
    formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
    fh.setFormatter(formatter)
    fh.setLevel(logging.NOTSET)
    LOG.addHandler(fh)

    (options, args) = parser.parse_args()
    checkRequiredArguments(options, parser)

    task_file = options.task_file
    deployment_file = options.deployment_file
    deployments_count = options.deployments_count
    tasks_count = options.tasks_count
    progression_difference = options.progression_diff
    use_fill = options.use_fill
    destroy = options.destroy

    if options.times is not None:
        task_file = update_times(options.times, task_file)
    if not (use_fill or destroy):
        parser.error("You must specify at least one of the options --destroy or --use-fill")  
    if use_fill:
        if options.fill_type is None:
            parser.error("--type should be specified if u use --use-fill argument")
        if str(options.fill_type) == "1":
            round_robin_fill(task_file, deployment_file, deployments_count,
                             tasks_count)
        elif str(options.fill_type) == "2":
            progression_fill(task_file, deployment_file, deployments_count,
                             progression_difference, tasks_count)
    if destroy:
        start = time.time()
        destroy_all_deployments(deployments_count)
        LOG.warn("Deployment destroy takes %f seconds." % (time.time() - start))
예제 #19
0
 def setUp(self):
     super(TestCase, self).setUp()
     self.addCleanup(mock.patch.stopall)
     plugins.load()
     self.useFixture(TempHomeDir())
예제 #20
0
def setup(app):
    plugins.load()
    app.add_directive("generate_plugin_reference", PluginsReferenceDirective)
예제 #21
0
    def test_task_samples_is_valid(self):
        rally = utils.Rally(force_new_db=True)
        # In TestTaskSamples, Rally API will be called directly (not via
        # subprocess), so we need to change database options to temp database.
        db.db_options.set_defaults(db.CONF,
                                   connection="sqlite:///%s/db" %
                                   rally.tmp_dir,
                                   sqlite_db="rally.sqlite")

        # let's use pre-created users to make TestTaskSamples quicker
        deployment = api.Deployment.get("MAIN")
        admin_cred = objects.Credential(**deployment["admin"])

        ctx = {
            "admin": {
                "credential": admin_cred
            },
            "task": {
                "uuid": self.__class__.__name__
            }
        }
        user_ctx = users.UserGenerator(ctx)
        user_ctx.setup()
        self.addCleanup(user_ctx.cleanup)

        config = deployment["config"]
        config["users"] = [{
            "username":
            ctx["users"][0]["credential"].username,
            "password":
            ctx["users"][0]["credential"].password,
            "tenant_name":
            ctx["users"][0]["credential"].tenant_name
        }]

        rally("deployment destroy MAIN", write_report=False)
        deployment_cfg = os.path.join(rally.tmp_dir, "new_deployment.json")
        with open(deployment_cfg, "w") as f:
            f.write(json.dumps(config))
        rally("deployment create --name MAIN --filename %s" % deployment_cfg,
              write_report=False)

        plugins.load()
        samples_path = os.path.join(os.path.dirname(__file__), os.pardir,
                                    os.pardir, "samples", "tasks")
        matcher = re.compile("\.json$")

        for dirname, dirnames, filenames in os.walk(samples_path):
            # NOTE(rvasilets): Skip by suggest of boris-42 because in
            # future we don't what to maintain this dir
            if dirname.find("tempest-do-not-run-against-production") != -1:
                continue
            for filename in filenames:
                full_path = os.path.join(dirname, filename)

                # NOTE(hughsaunders): Skip non config files
                # (bug https://bugs.launchpad.net/rally/+bug/1314369)
                if not matcher.search(filename):
                    continue
                with open(full_path) as task_file:
                    try:
                        input_task = task_file.read()
                        rendered_task = api.Task.render_template(input_task)
                        task_config = json.loads(rendered_task)
                        api.Task.validate("MAIN", task_config)
                    except Exception as e:
                        if not self._skip(six.text_type(e)):
                            print(traceback.format_exc())
                            print("Failed on task config %s with error." %
                                  full_path)
                            raise