コード例 #1
0
ファイル: loader_test.py プロジェクト: saliormoon/rally
 def test_create_filters_from_mixed_included_tasks(self):
     from esrally.track import track
     filters = loader.filters_from_included_tasks(
         ["force-merge", "type:search"])
     self.assertListEqual([
         track.TaskOpNameFilter("force-merge"),
         track.TaskOpTypeFilter("search")
     ], filters)
コード例 #2
0
ファイル: loader.py プロジェクト: trendsoa/rally
def filters_from_included_tasks(included_tasks):
    filters = []
    if included_tasks:
        for t in included_tasks:
            spec = t.split(":")
            if len(spec) == 1:
                filters.append(track.TaskOpNameFilter(spec[0]))
            elif len(spec) == 2:
                if spec[0] == "type":
                    filters.append(track.TaskOpTypeFilter(spec[1]))
                else:
                    raise exceptions.SystemSetupError("Invalid format for included tasks: [%s]. Expected [type] but got [%s]." % (t, spec[0]))
            else:
                raise exceptions.SystemSetupError("Invalid format for included tasks: [%s]" % t)
    return filters
コード例 #3
0
ファイル: loader_test.py プロジェクト: saliormoon/rally
    def test_filters_tasks(self):
        from esrally.track import track
        track_specification = {
            "short-description":
            "short description for unit test",
            "description":
            "longer description of this track for unit test",
            "indices": [{
                "name": "test-index",
                "auto-managed": False
            }],
            "operations": [
                {
                    "name": "index-1",
                    "operation-type": "index"
                },
                {
                    "name": "index-2",
                    "operation-type": "index"
                },
                {
                    "name": "index-3",
                    "operation-type": "index"
                },
                {
                    "name": "node-stats",
                    "operation-type": "node-stats"
                },
                {
                    "name": "cluster-stats",
                    "operation-type": "custom-operation-type"
                },
                {
                    "name": "match-all",
                    "operation-type": "search",
                    "body": {
                        "query": {
                            "match_all": {}
                        }
                    }
                },
            ],
            "challenges": [{
                "name":
                "default-challenge",
                "description":
                "Default challenge",
                "schedule": [{
                    "parallel": {
                        "tasks": [
                            {
                                "operation": "index-1",
                            },
                            {
                                "operation": "index-2",
                            },
                            {
                                "operation": "index-3",
                            },
                            {
                                "operation": "match-all",
                            },
                        ]
                    }
                }, {
                    "operation": "node-stats"
                }, {
                    "operation": "match-all"
                }, {
                    "operation": "cluster-stats"
                }]
            }]
        }
        reader = loader.TrackSpecificationReader()
        full_track = reader("unittest", track_specification, "/mappings")
        self.assertEqual(4, len(full_track.challenges[0].schedule))

        filtered = loader.filter_included_tasks(
            full_track,
            [
                track.TaskOpNameFilter("index-3"),
                track.TaskOpTypeFilter("search"),
                # Filtering should also work for non-core operation types.
                track.TaskOpTypeFilter("custom-operation-type")
            ])

        schedule = filtered.challenges[0].schedule
        self.assertEqual(3, len(schedule))
        self.assertEqual(["index-3", "match-all"],
                         [t.operation.name for t in schedule[0].tasks])
        self.assertEqual("match-all", schedule[1].operation.name)
        self.assertEqual("cluster-stats", schedule[2].operation.name)