def test_run(self):
        self.accessor.drop_all_metrics()

        cmd = command_list.CommandList()

        parser = argparse.ArgumentParser()
        bg_settings.add_argparse_arguments(parser)
        cmd.add_arguments(parser)

        name = "foo.bar"
        metadata = bg_metric.MetricMetadata(
            retention=bg_metric.Retention.from_string("1440*60s"))

        self.accessor.create_metric(bg_test_utils.make_metric(name, metadata))

        opts = parser.parse_args(["foo.*"])
        cmd.run(self.accessor, opts)
        metrics = command_list.list_metrics(self.accessor, opts.glob,
                                            opts.graphite)
        self.assertEqual(name, list(metrics)[0].name)

        opts = parser.parse_args(["--graphite", "foo.{bar}"])
        metrics = command_list.list_metrics(self.accessor, opts.glob,
                                            opts.graphite)
        self.assertEqual(name, list(metrics)[0].name)
Exemple #2
0
    def test_run(self):
        self.accessor.drop_all_metrics()

        cmd = command_list.CommandList()

        parser = argparse.ArgumentParser()
        bg_utils.add_argparse_arguments(parser)
        cmd.add_arguments(parser)

        name = 'foo.bar'
        metadata = bg_accessor.MetricMetadata(
            retention=bg_accessor.Retention.from_string('1440*60s'))

        self.accessor.create_metric(self.make_metric(name, metadata))

        opts = parser.parse_args(['foo.*'])
        cmd.run(self.accessor, opts)
        metrics = command_list.list_metrics(self.accessor, opts.glob,
                                            opts.graphite)
        self.assertEqual(name, list(metrics)[0].name)

        opts = parser.parse_args(['--graphite', 'foo.{bar}'])
        metrics = command_list.list_metrics(self.accessor, opts.glob,
                                            opts.graphite)
        self.assertEqual(name, list(metrics)[0].name)
Exemple #3
0
    command_shell,
    command_stats,
    command_syncdb,
    command_test,
    command_write,
)

COMMANDS = [
    command_clean.CommandClean(),
    command_copy.CommandCopy(),
    command_daemon.CommandDaemon(),
    command_delete.CommandDelete(),
    command_du.CommandDu(),
    command_graphite_web.CommandGraphiteWeb(),
    command_info.CommandInfo(),
    command_list.CommandList(),
    command_read.CommandRead(),
    command_repair.CommandRepair(),
    command_shell.CommandShell(),
    command_stats.CommandStats(),
    command_syncdb.CommandSyncdb(),
    command_test.CommandTest(),
    command_write.CommandWrite(),
]


def _parse_opts(args):
    """Parse command line arguments."""
    parser = argparse.ArgumentParser(
        description="BigGraphite command line utility.")
    bg_utils.add_argparse_arguments(parser)