Esempio n. 1
0
 def test_get_real_metric_path_symlink_inside(self, dummy_realpath):
     input_abs_path = '/opt/graphite/storage/whisper/some/symbolic/path/NumConnections.wsp'
     input_metric_path = 'some.symbolic.path.NumConnections'
     expected_metric_path = 'this.is.the.real.path.NumConnections'
     output_metric_path = get_real_metric_path(input_abs_path,
                                               input_metric_path)
     self.assertEqual(output_metric_path, expected_metric_path)
Esempio n. 2
0
 def test_get_real_metric_path_symlink_inside(self, dummy_realpath2):
     input_abs_path = '/opt/graphite/storage/whisper/foo/bar/Env/HTTP/NumConnections.wsp'
     input_metric_path = 'bar.Env.HTTP.NumConnections'
     expected_metric_path = 'bar.Env.HTTP.NumConnections'
     output_metric_path = get_real_metric_path(input_abs_path,
                                               input_metric_path)
     self.assertEqual(output_metric_path, expected_metric_path)
Esempio n. 3
0
 def test_get_real_metric_path_symlink_outside(self, dummy_realpath):
     input_abs_path = '/some/symbolic/path/graphite/whisper/Env/HTTP/NumConnections.wsp'
     input_metric_path = 'Env.HTTP.NumConnections'
     expected_metric_path = 'Env.HTTP.NumConnections'
     output_metric_path = get_real_metric_path(input_abs_path,
                                               input_metric_path)
     self.assertEqual(output_metric_path, expected_metric_path)
Esempio n. 4
0
    def find_nodes(self, query):
        # translate query pattern if it is tagged
        tagged = not query.pattern.startswith('_tagged.') and ';' in query.pattern
        if tagged:
            # tagged series are stored in ceres using encoded names, so to retrieve them we need to
            # encode the query pattern using the same scheme used in carbon when they are written.
            variants = [
                TaggedSeries.encode(query.pattern, hash_only=True),
                TaggedSeries.encode(query.pattern, hash_only=False),
            ]
        else:
            variants = extract_variants(query.pattern)

        for variant in variants:
            for fs_path in glob(self.tree.getFilesystemPath(variant)):
                metric_path = self.tree.getNodePath(fs_path)

                if CeresNode.isNodeDir(fs_path):
                    ceres_node = self.tree.getNode(metric_path)

                    if ceres_node.hasDataForInterval(query.startTime, query.endTime):
                        real_metric_path = get_real_metric_path(fs_path, metric_path)
                        reader = CeresReader(ceres_node, real_metric_path)
                        # if we're finding by tag, return the proper metric path
                        if tagged:
                            metric_path = query.pattern
                        yield LeafNode(metric_path, reader)

                elif os.path.isdir(fs_path):
                    yield BranchNode(metric_path)
Esempio n. 5
0
    def find_nodes(self, query):

        # translate query pattern if it is tagged
        tagged = not query.pattern.startswith(
            '_tagged.') and ';' in query.pattern
        if tagged:
            # tagged series are stored in ceres using encoded names, so to retrieve them we need to encode the
            # query pattern using the same scheme used in carbon when they are written.
            variants = [TaggedSeries.encode(query.pattern)]
        else:
            variants = extract_variants(query.pattern)

        for variant in variants:
            for fs_path in glob(self.tree.getFilesystemPath(variant)):
                metric_path = self.tree.getNodePath(fs_path)

                if CeresNode.isNodeDir(fs_path):
                    ceres_node = self.tree.getNode(metric_path)

                    if ceres_node.hasDataForInterval(query.startTime,
                                                     query.endTime):
                        real_metric_path = get_real_metric_path(
                            fs_path, metric_path)
                        reader = CeresReader(ceres_node, real_metric_path)
                        # if we're finding by tag, return the proper metric path
                        if tagged:
                            metric_path = query.pattern
                        yield LeafNode(metric_path, reader)

                elif os.path.isdir(fs_path):
                    yield BranchNode(metric_path)
Esempio n. 6
0
 def test_get_real_metric_path(self):
     real_wsp_file = os.path.join(self.tmp, "real.wsp")
     fake_wsp_file = os.path.join(self.tmp_2, "fake.wsp")
     relative_wsp_path = "fake.wsp"
     with open(real_wsp_file, "w+") as fh:
         fh.write("")
     os.symlink(fake_wsp_file, fake_wsp_file)
     assert get_real_metric_path(real_wsp_file, relative_wsp_path) == "real"
Esempio n. 7
0
    def find_nodes(self, query):

        variants = extract_variants(query.pattern)

        for variant in variants:
            for fs_path in glob(self.tree.getFilesystemPath(variant)):
                metric_path = self.tree.getNodePath(fs_path)

                if CeresNode.isNodeDir(fs_path):
                    ceres_node = self.tree.getNode(metric_path)

                    if ceres_node.hasDataForInterval(query.startTime,
                                                     query.endTime):
                        real_metric_path = get_real_metric_path(
                            fs_path, metric_path)
                        reader = CeresReader(ceres_node, real_metric_path)
                        yield LeafNode(metric_path, reader)

                elif os.path.isdir(fs_path):
                    yield BranchNode(metric_path)
Esempio n. 8
0
 def test_get_real_metric_path_symlink_inside(self, dummy_realpath):
     input_abs_path='/opt/graphite/storage/whisper/some/symbolic/path/NumConnections.wsp'
     input_metric_path='some.symbolic.path.NumConnections'
     expected_metric_path='this.is.the.real.path.NumConnections'
     output_metric_path = get_real_metric_path(input_abs_path, input_metric_path)
     self.assertEqual(output_metric_path, expected_metric_path)
Esempio n. 9
0
 def test_get_real_metric_path_symlink_outside(self, dummy_realpath):
     input_abs_path='/some/symbolic/path/graphite/whisper/Env/HTTP/NumConnections.wsp'
     input_metric_path='Env.HTTP.NumConnections'
     expected_metric_path='Env.HTTP.NumConnections'
     output_metric_path = get_real_metric_path(input_abs_path, input_metric_path)
     self.assertEqual(output_metric_path, expected_metric_path)
Esempio n. 10
0
 def test_get_real_metric_path_symlink_inside(self, dummy_realpath2):
     input_abs_path='/opt/graphite/storage/whisper/foo/bar/Env/HTTP/NumConnections.wsp'
     input_metric_path='bar.Env.HTTP.NumConnections'
     expected_metric_path='bar.Env.HTTP.NumConnections'
     output_metric_path = get_real_metric_path(input_abs_path, input_metric_path)
     self.assertEqual(output_metric_path, expected_metric_path)