From 646cb320a692b0f132f1db1d6301ff9b9f225ecc Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Mon, 27 Apr 2015 15:54:24 -0600 Subject: [PATCH] Fix filter_hosts() when no filters are specified Signed-off-by: Zack Cerza --- teuthology/task/__init__.py | 3 +++ teuthology/test/task/__init__.py | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/teuthology/task/__init__.py b/teuthology/task/__init__.py index be462c2978..e9112279f3 100644 --- a/teuthology/task/__init__.py +++ b/teuthology/task/__init__.py @@ -49,6 +49,9 @@ class Task(object): """ if not hasattr(self.ctx, 'cluster'): return + elif 'hosts' not in self.config: + self.cluster = self.ctx.cluster + return self.cluster host_specs = self.config.get('hosts', list()) cluster = Cluster() for host_spec in host_specs: diff --git a/teuthology/test/task/__init__.py b/teuthology/test/task/__init__.py index 21f0ed3cae..57b1dc74f9 100644 --- a/teuthology/test/task/__init__.py +++ b/teuthology/test/task/__init__.py @@ -26,6 +26,17 @@ class TestTask(object): assert task.config['key_1'] == 'overridden' assert task.config['key_2'] == 'default' + def test_hosts_no_filter(self): + self.ctx.cluster = Cluster() + self.ctx.cluster.add(Remote('remote1'), ['role1']) + self.ctx.cluster.add(Remote('remote2'), ['role2']) + task_config = dict() + with Task(self.ctx, task_config) as task: + task_hosts = task.cluster.remotes.keys() + assert len(task_hosts) == 2 + assert task_hosts[0].name == 'remote1' + assert task_hosts[1].name == 'remote2' + def test_hosts_no_results(self): self.ctx.cluster = Cluster() self.ctx.cluster.add(Remote('remote1'), ['role1']) -- 2.39.5