本文整理汇总了Python中ariane_clip3.mapping.Node.sync方法的典型用法代码示例。如果您正苦于以下问题:Python Node.sync方法的具体用法?Python Node.sync怎么用?Python Node.sync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ariane_clip3.mapping.Node
的用法示例。
在下文中一共展示了Node.sync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EndpointTest
# 需要导入模块: from ariane_clip3.mapping import Node [as 别名]
# 或者: from ariane_clip3.mapping.Node import sync [as 别名]
class EndpointTest(unittest.TestCase):
def setUp(self):
args = {'type': 'REST', 'base_url': 'http://localhost:6969/ariane/', 'user': 'yoda', 'password': 'secret'}
MappingService(args)
self.container1 = Container(name="test_endpoint_container1",
gate_uri="ssh://my_host/docker/test_endpoint_container1",
primary_admin_gate_name="container name space (pid)", company="Docker",
product="Docker", c_type="container")
self.container1.save()
self.node1 = Node(name="mysqld", container_id=self.container1.id)
self.node1.save()
def tearDown(self):
self.node1.remove()
self.container1.remove()
def test_create_remove_endpoint_basic(self):
endpoint = Endpoint(url="mysql://test_create_remove_endpoint_basic:4385", parent_node_id=self.node1.id)
endpoint.save()
self.assertIsNotNone(endpoint.id)
self.node1.sync()
self.assertTrue(endpoint.id in self.node1.endpoints_id)
self.assertIsNone(endpoint.remove())
self.node1.sync()
self.assertFalse(endpoint.id in self.node1.endpoints_id)
def test_create_remove_endpoint_parent_node(self):
container2 = Container(name="test_create_remove_endpoint_parent_node_container2",
gate_uri="ssh://my_host/docker/test_create_remove_endpoint_parent_node_container2",
primary_admin_gate_name="container name space (pid)", company="Docker",
product="Docker", c_type="container")
node2 = Node(name="mysqld", container=container2)
node2.save()
endpoint2 = Endpoint(url="mysql://test_create_remove_endpoint_parent_node_container2:4385", parent_node=node2)
endpoint2.save()
self.assertIsNotNone(endpoint2.id)
self.assertTrue(endpoint2.id in node2.endpoints_id)
self.assertIsNone(endpoint2.remove())
self.assertFalse(endpoint2.id in node2.endpoints_id)
node2.remove()
container2.remove()
def test_find_endpoint_by_id(self):
endpoint = Endpoint(url="mysql://test_find_endpoint_by_id_container1:4385", parent_node_id=self.node1.id)
endpoint.save()
self.assertIsNotNone(EndpointService.find_endpoint(eid=endpoint.id))
endpoint.remove()
self.assertIsNone(EndpointService.find_endpoint(eid=endpoint.id))
def test_find_endpoint_by_url(self):
endpoint = Endpoint(url="mysql://test_find_endpoint_by_url_container1:4385", parent_node_id=self.node1.id)
endpoint.save()
self.assertIsNotNone(EndpointService.find_endpoint(url=endpoint.url))
endpoint.remove()
self.assertIsNone(EndpointService.find_endpoint(url=endpoint.url))
def test_find_endpoint_by_selector(self):
endpoint = Endpoint(url="mysql://test_find_endpoint_by_selector_container1:4385", parent_node_id=self.node1.id)
endpoint.save()
self.assertTrue(endpoint in EndpointService.find_endpoint(selector="endpointURL =~ 'mysql:.*'"))
self.assertTrue(endpoint in EndpointService.find_endpoint(selector="endpointURL =~ 'mysql:.*'", cid=self.container1.id))
self.assertTrue(endpoint in EndpointService.find_endpoint(selector="endpointURL =~ 'mysql:.*'", nid=self.node1.id))
endpoint.remove()
self.assertIsNone(EndpointService.find_endpoint(selector="endpointURL =~ 'mysql:.*'"))
def test_get_endpoints(self):
endpoint = Endpoint(url="mysql://test_get_endpoints_container1:4385", parent_node_id=self.node1.id)
endpoint.save()
self.assertTrue(endpoint in EndpointService.get_endpoints())
endpoint.remove()
self.assertFalse(endpoint in EndpointService.get_endpoints())
def test_endpoint_properties(self):
endpoint = Endpoint(url="mysql://test_endpoint_properties_container1:4385", parent_node_id=self.node1.id)
endpoint.add_property(('int_prop', 10), sync=False)
endpoint.add_property(('long_prop', 10000000), sync=False)
endpoint.add_property(('double_prop', 3.1414), sync=False)
endpoint.add_property(('boolean_prop', True), sync=False)
endpoint.add_property(('string_prop', "value"), sync=False)
datacenter = {"dc": "Sagittarius", "gpsLng": 2.251088, "address": "2 rue Baudin", "gpsLat": 48.895345,
"town": "Courbevoie", "country": "France"}
endpoint.add_property(('map_prop_datacenter', datacenter), sync=False)
endpoint.add_property(('array_prop', [1, 2, 3, 4, 5]), sync=False)
self.assertIsNone(endpoint.properties)
endpoint.save()
self.assertTrue('boolean_prop' in endpoint.properties)
self.assertTrue('double_prop' in endpoint.properties)
self.assertTrue('int_prop' in endpoint.properties)
self.assertTrue('long_prop' in endpoint.properties)
self.assertTrue('map_prop_datacenter' in endpoint.properties)
self.assertTrue('string_prop' in endpoint.properties)
self.assertTrue('array_prop' in endpoint.properties)
endpoint.del_property('int_prop', sync=False)
endpoint.del_property('long_prop', sync=False)
endpoint.del_property('double_prop', sync=False)
endpoint.del_property('boolean_prop', sync=False)
endpoint.del_property('string_prop', sync=False)
endpoint.del_property('map_prop_datacenter', sync=False)
endpoint.del_property('array_prop', sync=False)
#.........这里部分代码省略.........