tests: include the number of mons as a attribute on node

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
pull/1150/head
Andrew Schoen 2016-12-06 10:55:20 -06:00
parent 1abbc948d9
commit 2464b69612
2 changed files with 5 additions and 2 deletions

View File

@ -28,11 +28,15 @@ def node(Ansible, Interface, Command, request):
# boxes we test with use that interface # boxes we test with use that interface
address = Interface("eth1").addresses[0] address = Interface("eth1").addresses[0]
subnet = ".".join(ansible_vars["public_network"].split(".")[0:-1]) subnet = ".".join(ansible_vars["public_network"].split(".")[0:-1])
num_mons = len(ansible_vars["groups"]["mons"])
cluster_name = ansible_vars.get("cluster", "ceph")
conf_path = "/etc/ceph/{}.conf".format(cluster_name)
data = dict( data = dict(
address=address, address=address,
subnet=subnet, subnet=subnet,
vars=ansible_vars, vars=ansible_vars,
osd_ids=osd_ids, osd_ids=osd_ids,
num_mons=num_mons,
) )
return data return data

View File

@ -32,9 +32,8 @@ class TestCephConf(object):
assert File("/etc/ceph/ceph.conf").contains("^mon host = .*$") assert File("/etc/ceph/ceph.conf").contains("^mon host = .*$")
def test_mon_host_line_has_correct_value(self, node, File): def test_mon_host_line_has_correct_value(self, node, File):
num_mons = len(node["vars"]["groups"]["mons"])
mon_ips = [] mon_ips = []
for x in range(0, num_mons): for x in range(0, node["num_mons"]):
mon_ips.append("{}.1{}".format(node["subnet"], x)) mon_ips.append("{}.1{}".format(node["subnet"], x))
line = "mon host = {}".format(",".join(mon_ips)) line = "mon host = {}".format(",".join(mon_ips))
assert File("/etc/ceph/ceph.conf").contains(line) assert File("/etc/ceph/ceph.conf").contains(line)