|
| 1 | +import json |
| 2 | +import os |
| 3 | +import yaml |
| 4 | + |
| 5 | +from apmserver import ServerSetUpBaseTest |
| 6 | + |
| 7 | + |
| 8 | +class SubCommandTest(ServerSetUpBaseTest): |
| 9 | + def wait_until_started(self): |
| 10 | + self.apmserver_proc.check_wait() |
| 11 | + |
| 12 | + # command and go test output is combined in log, pull out the command output |
| 13 | + log = self.get_log() |
| 14 | + pos = -1 |
| 15 | + for _ in range(2): |
| 16 | + # export always uses \n, not os.linesep |
| 17 | + pos = log[:pos].rfind("\n") |
| 18 | + self.command_output = log[:pos] |
| 19 | + for trimmed in log[pos:].strip().splitlines(): |
| 20 | + # ensure only skipping expected lines |
| 21 | + assert trimmed.split(None, 1)[0] in ("PASS", "coverage:"), trimmed |
| 22 | + |
| 23 | + |
| 24 | +class ExportConfigTest(SubCommandTest): |
| 25 | + """ |
| 26 | + Test export config subcommand. |
| 27 | + """ |
| 28 | + |
| 29 | + def start_args(self): |
| 30 | + return { |
| 31 | + "extra_args": ["export", "config"], |
| 32 | + "logging_args": None, |
| 33 | + } |
| 34 | + |
| 35 | + def test_export_config(self): |
| 36 | + """ |
| 37 | + Test export config works |
| 38 | + """ |
| 39 | + config = yaml.load(self.command_output) |
| 40 | + total_fields_limit = config['setup']['template']['settings']['index']['mapping']['total_fields']['limit'] |
| 41 | + assert total_fields_limit == 2000, total_fields_limit |
| 42 | + |
| 43 | + |
| 44 | +class ExportTemplateTest(SubCommandTest): |
| 45 | + """ |
| 46 | + Test export template subcommand. |
| 47 | + """ |
| 48 | + |
| 49 | + def start_args(self): |
| 50 | + return { |
| 51 | + "extra_args": ["export", "template"], |
| 52 | + "logging_args": None, |
| 53 | + } |
| 54 | + |
| 55 | + def test_export_template(self): |
| 56 | + """ |
| 57 | + Test export template works |
| 58 | + """ |
| 59 | + template = json.loads(self.command_output) |
| 60 | + total_fields_limit = template['settings']['index']['mapping']['total_fields']['limit'] |
| 61 | + assert total_fields_limit == 2000, total_fields_limit |
0 commit comments