Пример #1
0
 def as_track(self, track_specification):
     reader = loader.TrackSpecificationReader(
         source=io.DictStringFileSourceFactory({
             "/mappings/type-mappings.json":
             ['{"test-type": "empty-for-test"}']
         }))
     return reader("unittest", track_specification, "/mappings")
Пример #2
0
 def test_unique_challenge_names(self):
     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-append",
             "operation-type": "index"
         }],
         "challenges": [{
             "name": "test-challenge",
             "description": "Some challenge",
             "default": True,
             "schedule": [{
                 "operation": "index-append"
             }]
         }, {
             "name": "test-challenge",
             "description": "Another challenge with the same name",
             "schedule": [{
                 "operation": "index-append"
             }]
         }]
     }
     reader = loader.TrackSpecificationReader()
     with self.assertRaises(loader.TrackSyntaxError) as ctx:
         reader("unittest", track_specification, "/mappings")
     self.assertEqual(
         "Track 'unittest' is invalid. Duplicate challenge with name 'test-challenge'.",
         ctx.exception.args[0])
Пример #3
0
 def test_exactly_one_default_challenge(self):
     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-append",
             "operation-type": "index"
         }],
         "challenges": [{
             "name": "challenge",
             "description": "Some challenge",
             "default": True,
             "schedule": [{
                 "operation": "index-append"
             }]
         }, {
             "name": "another-challenge",
             "description": "Another challenge",
             "schedule": [{
                 "operation": "index-append"
             }]
         }]
     }
     reader = loader.TrackSpecificationReader()
     resulting_track = reader("unittest", track_specification, "/mappings")
     self.assertEqual(2, len(resulting_track.challenges))
     self.assertEqual("challenge", resulting_track.challenges[0].name)
     self.assertTrue(resulting_track.challenges[0].default)
     self.assertFalse(resulting_track.challenges[1].default)
Пример #4
0
 def test_document_count_mandatory_if_file_present(self):
     track_specification = {
         "short-description":
         "short description for unit test",
         "description":
         "longer description of this track for unit test",
         "data-url":
         "https://localhost/data",
         "indices": [{
             "name":
             "test-index",
             "types": [{
                 "name": "docs",
                 "documents": "documents.json.bz2"
             }]
         }],
         "operations": [],
         "challenges": []
     }
     reader = loader.TrackSpecificationReader()
     with self.assertRaises(loader.TrackSyntaxError) as ctx:
         reader("unittest", track_specification, "/mappings")
     self.assertEqual(
         "Track 'unittest' is invalid. Mandatory element 'document-count' is missing.",
         ctx.exception.args[0])
Пример #5
0
 def test_parse_valid_track_specification_with_index_template(self):
     track_specification = {
         "short-description":
         "short description for unit test",
         "description":
         "longer description of this track for unit test",
         "templates": [{
             "name": "my-index-template",
             "index-pattern": "*",
             "template": "default-template.json"
         }],
         "operations": [],
         "challenges": []
     }
     reader = loader.TrackSpecificationReader(
         source=io.DictStringFileSourceFactory({
             "/mappings/default-template.json":
             ['{"some-index-template": "empty-for-test"}'],
         }))
     resulting_track = reader("unittest", track_specification, "/mappings")
     self.assertEqual("unittest", resulting_track.name)
     self.assertEqual("short description for unit test",
                      resulting_track.short_description)
     self.assertEqual("longer description of this track for unit test",
                      resulting_track.description)
     self.assertEqual(0, len(resulting_track.indices))
     self.assertEqual(1, len(resulting_track.templates))
     self.assertEqual("my-index-template",
                      resulting_track.templates[0].name)
     self.assertEqual("*", resulting_track.templates[0].pattern)
     self.assertEqual({"some-index-template": "empty-for-test"},
                      resulting_track.templates[0].content)
     self.assertEqual(0, len(resulting_track.challenges))
Пример #6
0
 def test_selects_sole_challenge_implicitly_as_default(self):
     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-append",
             "operation-type": "index"
         }],
         "challenges": [{
             "name": "challenge",
             "description": "Some challenge",
             "schedule": [{
                 "operation": "index-append"
             }]
         }]
     }
     reader = loader.TrackSpecificationReader()
     resulting_track = reader("unittest", track_specification, "/mappings")
     self.assertEqual(1, len(resulting_track.challenges))
     self.assertEqual("challenge", resulting_track.challenges[0].name)
     self.assertTrue(resulting_track.challenges[0].default)
Пример #7
0
 def test_parse_valid_track_specification_with_index_template(self):
     track_specification = {
         "short-description":
         "short description for unit test",
         "description":
         "longer description of this track for unit test",
         "templates": [{
             "name": "my-index-template",
             "index-pattern": "*",
             "template": "default-template.json"
         }],
         "operations": [],
         "challenges": []
     }
     reader = loader.TrackSpecificationReader()
     resulting_track = reader("unittest", track_specification, "/mappings",
                              "/data")
     self.assertEqual("unittest", resulting_track.name)
     self.assertEqual("short description for unit test",
                      resulting_track.short_description)
     self.assertEqual("longer description of this track for unit test",
                      resulting_track.description)
     self.assertEqual(0, len(resulting_track.indices))
     self.assertEqual(1, len(resulting_track.templates))
     self.assertEqual("my-index-template",
                      resulting_track.templates[0].name)
     self.assertEqual("*", resulting_track.templates[0].pattern)
     self.assertEqual("/mappings/default-template.json",
                      resulting_track.templates[0].template_file)
     self.assertEqual(0, len(resulting_track.challenges))
Пример #8
0
 def test_supports_target_interval(self):
     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-append",
             "operation-type": "index"
         }],
         "challenges": [{
             "name":
             "default-challenge",
             "description":
             "Default challenge",
             "schedule": [{
                 "operation": "index-append",
                 "target-interval": 5,
             }]
         }]
     }
     reader = loader.TrackSpecificationReader()
     resulting_track = reader("unittest", track_specification, "/mappings")
     self.assertEqual(
         5, resulting_track.challenges[0].schedule[0].
         params["target-interval"])
Пример #9
0
 def test_either_target_throughput_or_target_interval(self):
     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-append",
             "operation-type": "index"
         }],
         "challenges": [{
             "name":
             "default-challenge",
             "description":
             "Default challenge",
             "schedule": [{
                 "operation": "index-append",
                 "target-throughput": 10,
                 "target-interval": 3
             }]
         }]
     }
     reader = loader.TrackSpecificationReader()
     with self.assertRaises(loader.TrackSyntaxError) as ctx:
         reader("unittest", track_specification, "/mappings", "/data")
     self.assertEqual(
         "Track 'unittest' is invalid. Operation 'index-append' in challenge 'default-challenge' specifies target-interval "
         "and target-throughput but only one of them is allowed.",
         ctx.exception.args[0])
Пример #10
0
 def test_can_read_track_info_from_meta_block(self):
     # This test checks for the old syntax where track info was contained in a meta-block
     track_specification = {
         "meta": {
             "short-description": "short description for unit test",
             "description":
             "longer description of this track for unit test",
             "data-url": "https://localhost/data"
         },
         "indices": [{
             "name": "test-index",
             "auto-managed": False
         }],
         "operations": [],
         "challenges": []
     }
     reader = loader.TrackSpecificationReader()
     resulting_track = reader("unittest", track_specification, "/mappings",
                              "/data")
     self.assertEqual("unittest", resulting_track.name)
     self.assertEqual("short description for unit test",
                      resulting_track.short_description)
     self.assertEqual("longer description of this track for unit test",
                      resulting_track.description)
     self.assertEqual("https://localhost/data",
                      resulting_track.source_root_url)
Пример #11
0
 def test_at_least_one_default_challenge(self):
     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-append",
             "operation-type": "index"
         }],
         "challenges": [{
             "name": "challenge",
             "description": "Some challenge",
             "schedule": [{
                 "operation": "index-append"
             }]
         }, {
             "name": "another-challenge",
             "description": "Another challenge",
             "schedule": [{
                 "operation": "index-append"
             }]
         }]
     }
     reader = loader.TrackSpecificationReader()
     with self.assertRaises(loader.TrackSyntaxError) as ctx:
         reader("unittest", track_specification, "/mappings")
     self.assertEqual(
         "Track 'unittest' is invalid. No default challenge specified. Please edit the track and add \"default\": true "
         "to one of the challenges challenge, another-challenge.",
         ctx.exception.args[0])
Пример #12
0
 def test_missing_description_raises_syntax_error(self):
     track_specification = {"description": "unittest track"}
     reader = loader.TrackSpecificationReader()
     with self.assertRaises(loader.TrackSyntaxError) as ctx:
         reader("unittest", track_specification, "/mappings")
     self.assertEqual(
         "Track 'unittest' is invalid. Mandatory element 'short-description' is missing.",
         ctx.exception.args[0])
Пример #13
0
    def test_parallel_tasks_with_completed_by_set(self):
        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"
            }],
            "challenges": [{
                "name":
                "default-challenge",
                "description":
                "Default challenge",
                "schedule": [{
                    "parallel": {
                        "warmup-time-period":
                        2400,
                        "time-period":
                        36000,
                        "completed-by":
                        "index-2",
                        "tasks": [{
                            "operation": "index-1"
                        }, {
                            "operation": "index-2"
                        }]
                    }
                }]
            }]
        }
        reader = loader.TrackSpecificationReader()
        resulting_track = reader("unittest", track_specification, "/mappings",
                                 "/data")
        parallel_element = resulting_track.challenges[0].schedule[0]
        parallel_tasks = parallel_element.tasks

        # we will only have two clients *in total*
        self.assertEqual(2, parallel_element.clients)
        self.assertEqual(2, len(parallel_tasks))

        self.assertEqual("index-1", parallel_tasks[0].operation.name)
        self.assertFalse(parallel_tasks[0].completes_parent)

        self.assertEqual("index-2", parallel_tasks[1].operation.name)
        self.assertTrue(parallel_tasks[1].completes_parent)
Пример #14
0
    def test_parse_with_mixed_warmup_iterations_and_measurement(self):
        track_specification = {
            "meta": {
                "short-description": "short description for unit test",
                "description": "longer description of this track for unit test",
                "data-url": "https://localhost/data"
            },
            "indices": [
                {
                    "name": "test-index",
                    "types": [
                        {
                            "name": "main",
                            "documents": "documents-main.json.bz2",
                            "document-count": 10,
                            "compressed-bytes": 100,
                            "uncompressed-bytes": 10000,
                            "mapping": "main-type-mappings.json"
                        }
                    ]
                }
            ],
            "operations": [
                {
                    "name": "index-append",
                    "operation-type": "index",
                    "bulk-size": 5000,
                }
            ],
            "challenges": [
                {
                    "name": "default-challenge",
                    "description": "Default challenge",
                    "schedule": [
                        {
                            "index-settings": {},
                            "clients": 8,
                            "operation": "index-append",
                            "warmup-iterations": 3,
                            "time-period": 60
                        }
                    ]
                }

            ]
        }

        reader = loader.TrackSpecificationReader()
        with self.assertRaises(loader.TrackSyntaxError) as ctx:
            reader("unittest", track_specification, "/mappings", "/data")
        self.assertEqual("Track 'unittest' is invalid. Operation 'index-append' in challenge 'default-challenge' mixes warmup iterations "
                         "with time periods. Please do not mix time periods and iterations.", ctx.exception.args[0])
Пример #15
0
    def test_parse_with_mixed_warmup_time_period_and_iterations(self):
        track_specification = {
            "short-description":
            "short description for unit test",
            "description":
            "longer description of this track for unit test",
            "data-url":
            "https://localhost/data",
            "indices": [{
                "name":
                "test-index",
                "types": [{
                    "name": "main",
                    "documents": "documents-main.json.bz2",
                    "document-count": 10,
                    "compressed-bytes": 100,
                    "uncompressed-bytes": 10000,
                    "mapping": "main-type-mappings.json"
                }]
            }],
            "operations": [{
                "name": "index-append",
                "operation-type": "index",
                "bulk-size": 5000,
            }],
            "challenges": [{
                "name":
                "default-challenge",
                "description":
                "Default challenge",
                "index-settings": {},
                "schedule": [{
                    "clients": 8,
                    "operation": "index-append",
                    "warmup-time-period": 20,
                    "iterations": 1000
                }]
            }]
        }

        reader = loader.TrackSpecificationReader(
            source=io.DictStringFileSourceFactory({
                "/mappings/main-type-mappings.json":
                ['{"main": "empty-for-test"}'],
            }))
        with self.assertRaises(loader.TrackSyntaxError) as ctx:
            reader("unittest", track_specification, "/mappings")
        self.assertEqual(
            "Track 'unittest' is invalid. Operation 'index-append' in challenge 'default-challenge' defines a warmup time "
            "period of '20' seconds and '1000' iterations. Please do not mix time periods and iterations.",
            ctx.exception.args[0])
Пример #16
0
    def test_parallel_tasks_with_default_clients_does_not_propagate(self):
        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"
            }],
            "challenges": [{
                "name":
                "default-challenge",
                "description":
                "Default challenge",
                "schedule": [{
                    "parallel": {
                        "warmup-time-period":
                        2400,
                        "time-period":
                        36000,
                        "clients":
                        2,
                        "tasks": [{
                            "operation": "index-1"
                        }, {
                            "operation": "index-1"
                        }, {
                            "operation": "index-1"
                        }, {
                            "operation": "index-1"
                        }]
                    }
                }]
            }]
        }
        reader = loader.TrackSpecificationReader()
        resulting_track = reader("unittest", track_specification, "/mappings",
                                 "/data")
        parallel_element = resulting_track.challenges[0].schedule[0]
        parallel_tasks = parallel_element.tasks

        # we will only have two clients *in total*
        self.assertEqual(2, parallel_element.clients)
        self.assertEqual(4, len(parallel_tasks))
        for task in parallel_tasks:
            self.assertEqual(1, task.clients)
Пример #17
0
    def test_parallel_tasks_with_completed_by_set_no_task_matches(self):
        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"
            }],
            "challenges": [{
                "name":
                "default-challenge",
                "description":
                "Default challenge",
                "schedule": [{
                    "parallel": {
                        "completed-by":
                        "non-existing-task",
                        "tasks": [{
                            "operation": "index-1"
                        }, {
                            "operation": "index-2"
                        }]
                    }
                }]
            }]
        }
        reader = loader.TrackSpecificationReader()

        with self.assertRaises(loader.TrackSyntaxError) as ctx:
            reader("unittest", track_specification, "/mappings")
        self.assertEqual(
            "Track 'unittest' is invalid. 'parallel' element for challenge 'default-challenge' is marked with 'completed-by' "
            "with task name 'non-existing-task' but no task with this name exists.",
            ctx.exception.args[0])
Пример #18
0
 def test_types_are_optional_for_user_managed_indices(self):
     track_specification = {
         "meta": {
             "short-description": "short description for unit test",
             "description": "longer description of this track for unit test"
         },
         "indices": [{"name": "test-index", "auto-managed": False}],
         "operations": [],
         "challenges": []
     }
     reader = loader.TrackSpecificationReader()
     resulting_track = reader("unittest", track_specification, "/mappings", "/data")
     self.assertEqual("unittest", resulting_track.name)
     self.assertEqual("short description for unit test", resulting_track.short_description)
     self.assertEqual("longer description of this track for unit test", resulting_track.description)
     self.assertEqual(1, len(resulting_track.indices))
     self.assertEqual(0, len(resulting_track.templates))
     self.assertEqual("test-index", resulting_track.indices[0].name)
     self.assertEqual(0, len(resulting_track.indices[0].types))
Пример #19
0
 def test_can_read_track_info(self):
     track_specification = {
         "short-description": "short description for unit test",
         "description": "longer description of this track for unit test",
         "data-url": "https://localhost/data",
         "indices": [{
             "name": "test-index",
             "auto-managed": False
         }],
         "operations": [],
         "challenges": []
     }
     reader = loader.TrackSpecificationReader()
     resulting_track = reader("unittest", track_specification, "/mappings")
     self.assertEqual("unittest", resulting_track.name)
     self.assertEqual("short description for unit test",
                      resulting_track.short_description)
     self.assertEqual("longer description of this track for unit test",
                      resulting_track.description)
     self.assertEqual("https://localhost/data",
                      resulting_track.source_root_url)
Пример #20
0
    def test_parallel_tasks_with_completed_by_set_multiple_tasks_match(self):
        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"
            }],
            "challenges": [{
                "name":
                "default-challenge",
                "description":
                "Default challenge",
                "schedule": [{
                    "parallel": {
                        "completed-by":
                        "index-1",
                        "tasks": [{
                            "operation": "index-1"
                        }, {
                            "operation": "index-1"
                        }]
                    }
                }]
            }]
        }
        reader = loader.TrackSpecificationReader()

        with self.assertRaises(loader.TrackSyntaxError) as ctx:
            reader("unittest", track_specification, "/mappings")
        self.assertEqual(
            "Track 'unittest' is invalid. 'parallel' element for challenge 'default-challenge' contains multiple tasks with "
            "the name 'index-1' which are marked with 'completed-by' but only task is allowed to match.",
            ctx.exception.args[0])
Пример #21
0
 def test_not_more_than_one_default_challenge_possible(self):
     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-append",
             "operation-type": "index"
         }],
         "challenges": [{
             "name": "default-challenge",
             "description": "Default challenge",
             "default": True,
             "schedule": [{
                 "operation": "index-append"
             }]
         }, {
             "name": "another-challenge",
             "description": "See if we can sneek it in as another default",
             "default": True,
             "schedule": [{
                 "operation": "index-append"
             }]
         }]
     }
     reader = loader.TrackSpecificationReader()
     with self.assertRaises(loader.TrackSyntaxError) as ctx:
         reader("unittest", track_specification, "/mappings")
     self.assertEqual(
         "Track 'unittest' is invalid. Both 'default-challenge' and 'another-challenge' are defined as default challenges. "
         "Please define only one of them as default.",
         ctx.exception.args[0])
Пример #22
0
    def test_parallel_tasks_with_default_values(self):
        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"
                },
            ],
            "challenges": [{
                "name":
                "default-challenge",
                "description":
                "Default challenge",
                "schedule": [{
                    "parallel": {
                        "warmup-time-period":
                        2400,
                        "time-period":
                        36000,
                        "tasks": [
                            {
                                "operation": "index-1",
                                "warmup-time-period": 300,
                                "clients": 2
                            },
                            {
                                "operation": "index-2",
                                "time-period": 3600,
                                "clients": 4
                            },
                            {
                                "operation": "index-3",
                                "target-throughput": 10,
                                "clients": 16
                            },
                        ]
                    }
                }]
            }]
        }
        reader = loader.TrackSpecificationReader()
        resulting_track = reader("unittest", track_specification, "/mappings")
        parallel_element = resulting_track.challenges[0].schedule[0]
        parallel_tasks = parallel_element.tasks

        self.assertEqual(22, parallel_element.clients)
        self.assertEqual(3, len(parallel_tasks))

        self.assertEqual("index-1", parallel_tasks[0].operation.name)
        self.assertEqual(300, parallel_tasks[0].warmup_time_period)
        self.assertEqual(36000, parallel_tasks[0].time_period)
        self.assertEqual(2, parallel_tasks[0].clients)
        self.assertFalse("target-throughput" in parallel_tasks[0].params)

        self.assertEqual("index-2", parallel_tasks[1].operation.name)
        self.assertEqual(2400, parallel_tasks[1].warmup_time_period)
        self.assertEqual(3600, parallel_tasks[1].time_period)
        self.assertEqual(4, parallel_tasks[1].clients)
        self.assertFalse("target-throughput" in parallel_tasks[1].params)

        self.assertEqual("index-3", parallel_tasks[2].operation.name)
        self.assertEqual(2400, parallel_tasks[2].warmup_time_period)
        self.assertEqual(36000, parallel_tasks[2].time_period)
        self.assertEqual(16, parallel_tasks[2].clients)
        self.assertEqual(10, parallel_tasks[2].params["target-throughput"])
Пример #23
0
 def test_parse_valid_track_specification(self):
     track_specification = {
         "meta": {
             "short-description": "short description for unit test",
             "description":
             "longer description of this track for unit test",
             "data-url": "https://localhost/data"
         },
         "indices": [{
             "name":
             "index-historical",
             "types": [{
                 "name": "main",
                 "documents": "documents-main.json.bz2",
                 "document-count": 10,
                 "compressed-bytes": 100,
                 "uncompressed-bytes": 10000,
                 "mapping": "main-type-mappings.json"
             }, {
                 "name": "secondary",
                 "documents": "documents-secondary.json.bz2",
                 "document-count": 20,
                 "compressed-bytes": 200,
                 "uncompressed-bytes": 20000,
                 "mapping": "secondary-type-mappings.json"
             }]
         }],
         "operations": [{
             "name": "index-append",
             "operation-type": "index",
             "bulk-size": 5000,
         }, {
             "name": "search",
             "operation-type": "search",
             "index": "index-historical"
         }],
         "challenges": [{
             "name":
             "default-challenge",
             "description":
             "Default challenge",
             "schedule": [{
                 "index-settings": {},
                 "clients": 8,
                 "operation": "index-append"
             }, {
                 "clients": 1,
                 "operation": "search"
             }]
         }]
     }
     reader = loader.TrackSpecificationReader()
     resulting_track = reader("unittest", track_specification, "/mappings",
                              "/data")
     self.assertEqual("unittest", resulting_track.name)
     self.assertEqual("short description for unit test",
                      resulting_track.short_description)
     self.assertEqual("longer description of this track for unit test",
                      resulting_track.description)
     self.assertEqual(1, len(resulting_track.indices))
     self.assertEqual("index-historical", resulting_track.indices[0].name)
     self.assertEqual(2, len(resulting_track.indices[0].types))
     self.assertEqual("main", resulting_track.indices[0].types[0].name)
     self.assertEqual("/data/documents-main.json.bz2",
                      resulting_track.indices[0].types[0].document_archive)
     self.assertEqual("/data/documents-main.json",
                      resulting_track.indices[0].types[0].document_file)
     self.assertEqual("/mappings/main-type-mappings.json",
                      resulting_track.indices[0].types[0].mapping_file)
     self.assertEqual("secondary", resulting_track.indices[0].types[1].name)
     self.assertEqual(1, len(resulting_track.challenges))
     self.assertEqual("default-challenge",
                      resulting_track.challenges[0].name)
Пример #24
0
 def as_track(self, track_specification):
     reader = loader.TrackSpecificationReader()
     return reader("unittest", track_specification, "/mappings", "/data")
Пример #25
0
    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)
Пример #26
0
 def test_parse_valid_track_specification(self):
     track_specification = {
         "short-description":
         "short description for unit test",
         "description":
         "longer description of this track for unit test",
         "data-url":
         "https://localhost/data",
         "indices": [{
             "name":
             "index-historical",
             "types": [{
                 "name": "main",
                 "documents": "documents-main.json.bz2",
                 "document-count": 10,
                 "compressed-bytes": 100,
                 "uncompressed-bytes": 10000,
                 "mapping": "main-type-mappings.json"
             }, {
                 "name": "secondary",
                 "documents": "documents-secondary.json.bz2",
                 "includes-action-and-meta-data": True,
                 "document-count": 20,
                 "compressed-bytes": 200,
                 "uncompressed-bytes": 20000,
                 "mapping": "secondary-type-mappings.json"
             }]
         }],
         "operations": [{
             "name": "index-append",
             "operation-type": "index",
             "bulk-size": 5000,
             "meta": {
                 "append": True
             }
         }, {
             "name": "search",
             "operation-type": "search",
             "index": "index-historical"
         }],
         "challenges": [{
             "name":
             "default-challenge",
             "description":
             "Default challenge",
             "meta": {
                 "mixed": True,
                 "max-clients": 8
             },
             "index-settings": {
                 "index.number_of_replicas": 2
             },
             "schedule": [{
                 "clients": 8,
                 "operation": "index-append",
                 "meta": {
                     "operation-index": 0
                 }
             }, {
                 "clients": 1,
                 "operation": "search"
             }]
         }]
     }
     reader = loader.TrackSpecificationReader(
         source=io.DictStringFileSourceFactory({
             "/mappings/main-type-mappings.json":
             ['{"main": "empty-for-test"}'],
             "/mappings/secondary-type-mappings.json":
             ['{"secondary": "empty-for-test"}'],
         }))
     resulting_track = reader("unittest", track_specification, "/mappings")
     self.assertEqual("unittest", resulting_track.name)
     self.assertEqual("short description for unit test",
                      resulting_track.short_description)
     self.assertEqual("longer description of this track for unit test",
                      resulting_track.description)
     self.assertEqual(1, len(resulting_track.indices))
     self.assertEqual("index-historical", resulting_track.indices[0].name)
     self.assertEqual(2, len(resulting_track.indices[0].types))
     self.assertEqual("main", resulting_track.indices[0].types[0].name)
     self.assertFalse(
         resulting_track.indices[0].types[0].includes_action_and_meta_data)
     self.assertEqual("unittest/documents-main.json.bz2",
                      resulting_track.indices[0].types[0].document_archive)
     self.assertEqual("unittest/documents-main.json",
                      resulting_track.indices[0].types[0].document_file)
     self.assertDictEqual({"main": "empty-for-test"},
                          resulting_track.indices[0].types[0].mapping)
     self.assertEqual("secondary", resulting_track.indices[0].types[1].name)
     self.assertDictEqual({"secondary": "empty-for-test"},
                          resulting_track.indices[0].types[1].mapping)
     self.assertTrue(
         resulting_track.indices[0].types[1].includes_action_and_meta_data)
     self.assertEqual(1, len(resulting_track.challenges))
     self.assertEqual("default-challenge",
                      resulting_track.challenges[0].name)
     self.assertEqual(1, len(resulting_track.challenges[0].index_settings))
     self.assertEqual(
         2, resulting_track.challenges[0].
         index_settings["index.number_of_replicas"])
     self.assertEqual({
         "mixed": True,
         "max-clients": 8
     }, resulting_track.challenges[0].meta_data)
     self.assertEqual(
         {"append": True},
         resulting_track.challenges[0].schedule[0].operation.meta_data)
     self.assertEqual({"operation-index": 0},
                      resulting_track.challenges[0].schedule[0].meta_data)