| 64 | |
| 65 | |
| 66 | class MockCluster(object): |
| 67 | |
| 68 | max_schema_agreement_wait = 5 |
| 69 | profile_manager = ProfileManager() |
| 70 | reconnection_policy = ConstantReconnectionPolicy(2) |
| 71 | address_translator = IdentityTranslator() |
| 72 | down_host = None |
| 73 | contact_points = [] |
| 74 | is_shutdown = False |
| 75 | |
| 76 | def __init__(self): |
| 77 | self.metadata = MockMetadata() |
| 78 | self.added_hosts = [] |
| 79 | self.removed_hosts = [] |
| 80 | self.scheduler = Mock(spec=_Scheduler) |
| 81 | self.executor = Mock(spec=ThreadPoolExecutor) |
| 82 | self.profile_manager.profiles[EXEC_PROFILE_DEFAULT] = ExecutionProfile(RoundRobinPolicy()) |
| 83 | self.endpoint_factory = DefaultEndPointFactory().configure(self) |
| 84 | |
| 85 | def add_host(self, endpoint, datacenter, rack, signal=False, refresh_nodes=True): |
| 86 | host = Host(endpoint, SimpleConvictionPolicy, datacenter, rack) |
| 87 | self.added_hosts.append(host) |
| 88 | return host, True |
| 89 | |
| 90 | def remove_host(self, host): |
| 91 | self.removed_hosts.append(host) |
| 92 | |
| 93 | def on_up(self, host): |
| 94 | pass |
| 95 | |
| 96 | def on_down(self, host, is_host_addition): |
| 97 | self.down_host = host |
| 98 | |
| 99 | |
| 100 | def _node_meta_results(local_results, peer_results): |