def test_get_node_disks(self):
     basedn = BASEDN + '/cluster1/nodes/master0'
     basedn_disks = basedn + '/disks'
     node = registry.Node(basedn)
     disks = REGISTRY[PREFIX][USER][PRODUCT][VERSION]['cluster1']['nodes']['master0']['disks'].keys()
     expected = [
         registry.Disk('{}/{}'.format(basedn_disks, d)) for d in disks]
     self.assertEqual(sorted(node.disks), sorted(expected))
 def test_get_service_nodes(self):
     basedn = BASEDN + '/cluster1/services/service0'
     basedn_nodes = BASEDN + '/cluster1/nodes'
     service = registry.Service(basedn)
     nodes = REGISTRY[PREFIX][USER][PRODUCT][VERSION]['cluster1']['services']['service0']['nodes']
     expected = [
         registry.Node('{}/{}'.format(basedn_nodes, n)) for n in nodes]
     self.assertEqual(sorted(service.nodes), sorted(expected))
Beispiel #3
0
 def test_get_cluster_instance(self):
     nodes = REGISTRY['clusters']['cluster1']['nodes']
     services = REGISTRY['clusters']['cluster1']['services']
     dn = registry.instantiate(user='******',
                               product='a',
                               version='1.0.0',
                               nodes=nodes,
                               services=services)
     instance = registry.get_cluster(dn=dn)
     expected_dn = registry.PREFIX + '/jlopez/a/1.0.0/1'
     expected_nodes = [
         registry.Node('{}/nodes/{}'.format(expected_dn, e)) for e in nodes
     ]
     expected_services = [
         registry.Service('{}/services/{}'.format(expected_dn, e))
         for e in services
     ]
     self.assertEqual(sorted(instance.nodes), sorted(expected_nodes))
     self.assertEqual(sorted(instance.services), sorted(expected_services))
Beispiel #4
0
 def test_set_node_disks_two_disks(self):
     basedn = BASEDN + '/cluster1/nodes/master0'
     basedn_disks = basedn + '/disks'
     expected = [
         {
             'name': 'disk1',
             'origin': '/data/1/instances-jlopez-cdh-5.7.0-1',
             'destination': '/data/1',
             'mode': 'rw'
         },
         {
             'name': 'disk2',
             'origin': '/data/2/instances-jlopez-cdh-5.7.0-1',
             'destination': '/data/2',
             'mode': 'rw'
         },
     ]
     node = registry.Node(basedn)
     node.disks = expected
     self.assertEqual(node.disks, sorted(expected))
 def test_get_cluster_nodes(self):
     cluster = registry.Cluster(BASEDN + '/cluster1')
     nodes = REGISTRY[PREFIX][USER][PRODUCT][VERSION]['cluster1']['nodes'].keys()
     expected = [
         registry.Node('{}/cluster1/nodes/{}'.format(BASEDN, e)) for e in nodes]
     self.assertEqual(sorted(cluster.nodes), sorted(expected))
 def test_get_cluster_instance(self):
     basedn = BASEDN + '/cluster1/nodes/master0'
     node = registry.Node(basedn)
     cluster = node.cluster
     expected = registry.Cluster(BASEDN + '/cluster1')
     self.assertEqual(cluster, expected)
 def test_set_node_name_not_allowed(self):
     node = registry.Node(BASEDN + '/cluster1/nodes/master0')
     with self.assertRaises(registry.ReadOnlyAttributeError):
         node.name = 'new.local'
 def test_get_node_name(self):
     node = registry.Node(BASEDN + '/cluster1/nodes/master0')
     expected = 'master0'
     name = node.name
     self.assertEqual(name, expected)
 def test_set_node_status(self):
     node = registry.Node(BASEDN + '/cluster1/nodes/master0')
     node.status = 'configured'
     self.assertEqual(node.status, 'configured')
 def test_get_node_status(self):
     node = registry.Node(BASEDN + '/cluster1/nodes/master0')
     expected = REGISTRY[PREFIX][USER][PRODUCT][VERSION]['cluster1']['nodes']['master0']['status']
     status = node.status
     self.assertEqual(status, expected)