From 00767734a99204c405131ad42f27dc8d485e1fa7 Mon Sep 17 00:00:00 2001 From: Hongyi Wang Date: Tue, 10 Dec 2019 13:44:09 -0800 Subject: [PATCH] Fix unit tests 2 --- ducktape/cluster/node_container.py | 12 ++++++++---- tests/cluster/check_remoteaccount.py | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ducktape/cluster/node_container.py b/ducktape/cluster/node_container.py index 344d27162..fd937fb73 100644 --- a/ducktape/cluster/node_container.py +++ b/ducktape/cluster/node_container.py @@ -182,9 +182,12 @@ def satisfy(avail_node, req_node): """ Return true if available node satisfies the minimum requirement of requested node. """ - if avail_node.machine_type.cpu_core < req_node.machine_type.cpu_core or \ - avail_node.machine_type.mem_size_gb < req_node.machine_type.mem_size_gb or \ - avail_node.machine_type.disk_size_gb < req_node.machine_type.disk_size_gb: + if req_node.machine_type is None: + return True + elif avail_node.machine_type is None or \ + avail_node.machine_type.cpu_core < req_node.machine_type.cpu_core or \ + avail_node.machine_type.mem_size_gb < req_node.machine_type.mem_size_gb or \ + avail_node.machine_type.disk_size_gb < req_node.machine_type.disk_size_gb: return False for d_name, d_size in req_node.machine_type.additional_disks.items(): if avail_node.machine_type.additional_disks.get(d_name, 0) < d_size: @@ -205,7 +208,8 @@ def sort(nodes, reverse=False): type_based_nodes.append(node) sorted_nodes.extend(sorted(type_based_nodes, key=attrgetter('machine_type.cpu_core', 'machine_type.mem_size_gb', - 'machine_type.disk_size_gb', 'machine_type.additional_disks'))) + 'machine_type.disk_size_gb', + 'machine_type.additional_disks'))) return list(reversed(sorted_nodes)) if reverse else sorted_nodes def clone(self): diff --git a/tests/cluster/check_remoteaccount.py b/tests/cluster/check_remoteaccount.py index 57c1c2f6a..6a76b8b9e 100644 --- a/tests/cluster/check_remoteaccount.py +++ b/tests/cluster/check_remoteaccount.py @@ -100,7 +100,8 @@ def check_remote_account_equality(self): kwargs = { "ssh_config": ssh_config, "externally_routable_ip": "345", - "logger": logging.getLogger(__name__) + "logger": logging.getLogger(__name__), + "is_type_based": False } r1 = RemoteAccount(**kwargs) r2 = RemoteAccount(**kwargs)