def test_remove_nodes2(self): clouds = [Cloud(cloud) for cloud in ['iaas', 'cloud2', 'cloud3', 'cloud4']] gc = CloudGroups(clouds, 'iaas') reg_key1 = gc.register_node('iaas') reg_key2 = gc.register_node('cloud2') reg_key3 = gc.register_node('cloud3') reg_key4 = gc.register_node('cloud4') gc.complete_registration('firstnode_iaas', reg_key1, 'iaas') gc.complete_registration('firstnode_cloud2', reg_key2, 'cloud2') gc.complete_registration('firstnode_cloud3', reg_key3, 'cloud3') gc.complete_registration('firstnode_cloud4', reg_key4, 'cloud4') for i in range(1000): reg_key1 = gc.register_node('iaas') reg_key2 = gc.register_node('cloud2') reg_key3 = gc.register_node('cloud3') reg_key4 = gc.register_node('cloud4') gc.complete_registration('node_'+ str(i) + '_iaas', reg_key1, 'iaas') gc.complete_registration('node_'+ str(i) + '_cloud2', reg_key2, 'cloud2') gc.complete_registration('node_'+ str(i) + '_cloud3', reg_key3, 'cloud3') gc.complete_registration('node_'+ str(i) + '_cloud4', reg_key4, 'cloud4') for i in range(4000): gc.remove_node() for cloud in clouds: group = gc._cloud2group[cloud.get_cloud_name()] node = group.remove_node() self.assertEqual(node, 'firstnode_' + cloud.get_cloud_name()) self.assertEqual(len(gc.nodes), 0)
def test_remove_nodes1(self): gc = CloudGroups(self.clouds, 'iaas') reg_key1 = gc.register_node('iaas') reg_key2 = gc.register_node('cloud1') reg_key3 = gc.register_node('cloud2') reg_key4 = gc.register_node('cloud3') reg_key5 = gc.register_node('iaas') gc.complete_registration('node1', reg_key1, 'iaas') gc.complete_registration('node2', reg_key2, 'cloud1') gc.complete_registration('node3', reg_key3, 'cloud2') gc.complete_registration('node4', reg_key4, 'cloud3') gc.complete_registration('node5', reg_key5, 'iaas') node = gc.remove_node() self.assertIn(node, ['node1', 'node5']) node = gc.remove_node() self.assertIn(node, ['node2', 'node3', 'node4'])