Incorrect work rally info find for SLA

If you type 'rally info find <query>' rally will suggest us docs that
 will be match by query. Even if you have one typo. otherwise it sugest
 you list of docs that you are possibly looking for. But if you type
'rally info find failure_rate' there output would be: "Failed to find
any docs for query: 'failure_rate'". Instead there must be information
about SLA(failure_rate): "Failure rate minimum and maximum in percents.".

Change-Id: Ie6c59e4091cddd8f5e81e2123cad1367b397a9b6
Closes-bug: 1399675
This commit is contained in:
Roman Vasilets 2014-12-08 15:27:55 +02:00
parent dbd2a2448a
commit 4ff925dfd0
2 changed files with 26 additions and 7 deletions

View File

@ -266,12 +266,16 @@ class InfoCommands(object):
scenarios = scenario_base.Scenario.list_benchmark_scenarios()
scenario_groups = list(set(s.split(".")[0] for s in scenarios))
scenario_methods = list(set(s.split(".")[1] for s in scenarios))
sla_info = [cls.__name__ for cls in utils.itersubclasses(
sla_base.SLA)]
sla_info.extend([cls.OPTION_NAME for cls in utils.itersubclasses(
sla_base.SLA)])
deploy_engines = [cls.__name__ for cls in utils.itersubclasses(
deploy.EngineFactory)]
deploy.EngineFactory)]
server_providers = [cls.__name__ for cls in utils.itersubclasses(
serverprovider.ProviderFactory)]
serverprovider.ProviderFactory)]
candidates = (scenarios + scenario_groups + scenario_methods +
deploy_engines + server_providers)
sla_info + deploy_engines + server_providers)
suggestions = []
# NOTE(msdubov): Incorrect query may either have typos or be truncated.
for candidate in candidates:

View File

@ -40,30 +40,45 @@ class InfoTestCase(unittest.TestCase):
def test_find_scenario(self):
self.assertIn("(benchmark scenario)", self.rally("info find dummy"))
def test_find_scenario_misspelling_typos(self):
self.assertIn("(benchmark scenario)", self.rally("info find dummi"))
def test_find_sla(self):
expected = "failure_rate (SLA)"
self.assertIn(expected, self.rally("info find failure_rate"))
def test_find_sla_misspelling_typos(self):
expected = "failure_rate (SLA)"
self.assertIn(expected, self.rally("info find failure_rte"))
def test_find_sla_by_class_name(self):
expected = "failure_rate (SLA)"
self.assertIn(expected, self.rally("info find FailureRate"))
def test_find_sla_by_class_name_misspelling_typos(self):
expected = "failure_rate (SLA)"
self.assertIn(expected, self.rally("info find FailureRte"))
def test_find_deployment_engine(self):
marker_string = "ExistingCloud (deploy engine)"
self.assertIn(marker_string, self.rally("info find ExistingCloud"))
def test_find_deployment_engine_misspelling_typos(self):
marker_string = "ExistingCloud (deploy engine)"
self.assertIn(marker_string, self.rally("info find ExistinCloud"))
def test_find_server_provider(self):
marker_string = "ExistingServers (server provider)"
self.assertIn(marker_string, self.rally("info find ExistingServers"))
def test_find_server_provider_misspelling_typos(self):
marker_string = "ExistingServers (server provider)"
self.assertIn(marker_string, self.rally("info find ExistingServer"))
def test_find_fails(self):
self.assertRaises(utils.RallyCmdError, self.rally,
("info find NonExistingStuff"))
def test_find_misspelling_typos(self):
marker_string = "ExistingServers (server provider)"
self.assertIn(marker_string, self.rally("info find ExistinfServert"))
def test_find_misspelling_truncated(self):
marker_string = ("NovaServers.boot_and_list_server "
"(benchmark scenario)")