Skip to content

Commit

Permalink
Fix broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
whynick1 committed Feb 4, 2019
1 parent 3177db2 commit 5ed531c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
12 changes: 6 additions & 6 deletions tests/cluster/check_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
from ducktape.cluster.cluster_spec import NodeSpec, ClusterSpec, LINUX, WINDOWS
from tests.ducktape_mock import FakeCluster

FakeRemoteAccount = collections.namedtuple('FakeRemoteAccount', ['operating_system'])
FakeRemoteAccount = collections.namedtuple('FakeRemoteAccount', ['operating_system', 'host_type'])


class CheckCluster(object):

def setup_method(self, _):
self.cluster = FakeCluster(0)
self.cluster._available_nodes.add_node(ClusterNode(FakeRemoteAccount(operating_system=LINUX)))
self.cluster._available_nodes.add_node(ClusterNode(FakeRemoteAccount(operating_system=LINUX)))
self.cluster._available_nodes.add_node(ClusterNode(FakeRemoteAccount(operating_system=WINDOWS)))
self.cluster._available_nodes.add_node(ClusterNode(FakeRemoteAccount(operating_system=WINDOWS)))
self.cluster._available_nodes.add_node(ClusterNode(FakeRemoteAccount(operating_system=WINDOWS)))
self.cluster._available_nodes.add_node(ClusterNode(FakeRemoteAccount(operating_system=LINUX, host_type=LINUX)))
self.cluster._available_nodes.add_node(ClusterNode(FakeRemoteAccount(operating_system=LINUX, host_type=LINUX)))
self.cluster._available_nodes.add_node(ClusterNode(FakeRemoteAccount(operating_system=WINDOWS, host_type=WINDOWS)))
self.cluster._available_nodes.add_node(ClusterNode(FakeRemoteAccount(operating_system=WINDOWS, host_type=WINDOWS)))
self.cluster._available_nodes.add_node(ClusterNode(FakeRemoteAccount(operating_system=WINDOWS, host_type=WINDOWS)))

def spec(self, linux_nodes, windows_nodes):
nodes = []
Expand Down
9 changes: 8 additions & 1 deletion tests/cluster/check_cluster_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@ def check_to_string(self):
empty = ClusterSpec.empty()
assert "[]" == str(empty)
simple_linux_5 = ClusterSpec.simple_linux(5)
assert '[{"num_nodes": 5, "os": "linux"}]' == str(simple_linux_5)
assert '[{"num_nodes": 5, "type": "linux"}]' == str(simple_linux_5)

def check_from_dict(self):
empty = ClusterSpec.empty()
assert "[]" == str(empty)
node_specs_dict = {"linux": 2, "windows": 3}
linux_2_windows_3 = ClusterSpec.from_dict(node_specs_dict)
assert '[{"num_nodes": 2, "type": "linux"}, {"num_nodes": 3, "type": "windows"}]' == str(linux_2_windows_3)
3 changes: 3 additions & 0 deletions tests/cluster/check_finite_subcluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class MockFiniteSubclusterNode:
def operating_system(self):
return LINUX

@property
def host_type(self):
return LINUX

class CheckFiniteSubcluster(object):
single_node_cluster_json = {"nodes": [{"hostname": "localhost"}]}
Expand Down
2 changes: 1 addition & 1 deletion tests/cluster/check_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def check_cluster_size(self):
n = 10
cluster = JsonCluster(
{"nodes": [
{"ssh_config": {"hostname": "localhost%d" % x}} for x in range(n)]})
{"ssh_config": {"host": "localhost%d" % x}} for x in range(n)]})

assert len(cluster) == n

Expand Down
3 changes: 3 additions & 0 deletions tests/ducktape_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class FakeClusterNode(object):
def operating_system(self):
return LINUX

@property
def host_type(self):
return LINUX

class FakeCluster(Cluster):
"""A cluster class with counters, but no actual node objects"""
Expand Down

0 comments on commit 5ed531c

Please sign in to comment.