示例#1
0
    def test_create_endpoint_for_nonexistent_node(self):
        """Tests create endpoint for a nonexistent node from Endpoint

        objects API.
        """
        api_endpoint_dict = func_utils.get_test_endpoint_dict()
        api_endpoint = objects.Endpoint(**api_endpoint_dict)
        self.validate_endpoint_values(api_endpoint_dict, api_endpoint)
        self.assertRaises(oslo_exception.DBReferenceError, api_endpoint.create,
                          self.context)
示例#2
0
    def test_endpoint_api_to_object_to_api(self):
        """Tests Endpoint api object conversion to Endpoint object and back

        to api object.
        """
        endpoint_dict = func_utils.get_test_endpoint_dict()
        api_endpoint = cluster.EndPoint(**endpoint_dict)
        object_endpoint = objects.Endpoint(**endpoint_dict)
        self.validate_endpoint_values(api_endpoint, object_endpoint)
        api_endpoint_2 = cluster.EndPoint(**object_endpoint.as_dict())
        self.validate_endpoint_values(api_endpoint, api_endpoint_2)
示例#3
0
    def create_object_endpoint(self, node_id, **kw):
        """Create an endpoint object for the given node."""
        endpoint_dict = func_utils.get_test_endpoint_dict(node_id=node_id,
                                                          **kw)
        api_endpoint = objects.Endpoint(**endpoint_dict)
        self.validate_endpoint_values(endpoint_dict, api_endpoint)
        api_endpoint.create(self.context)

        new_endpoint = self.dbapi.get_endpoints_in_node(
            self.context, api_endpoint.node_id)
        return new_endpoint[0]
示例#4
0
 def test_create_endpoint(self):
     """Tests create endpoint from Endpoint objects API."""
     new_cluster = func_utils.create_object_cluster(self.context)
     cluster_nodes = self.dbapi.get_nodes_in_cluster(
         self.context, new_cluster.id)
     endpoint_dict = func_utils.get_test_endpoint_dict(
         node_id=cluster_nodes[0].id)
     endpoint = objects.Endpoint(**endpoint_dict)
     self.validate_endpoint_values(endpoint_dict, endpoint)
     endpoint.create(self.context)
     new_endpoint = self.dbapi.get_endpoints_in_node(
         self.context, endpoint.node_id)
     self.validate_endpoint_values(endpoint, new_endpoint[0])
示例#5
0
    def test_endpoint_db_to_object_to_db(self):
        """Tests Endpoint db object conversion to Endpoint object and back

        to db object.
        """
        endpoint_dict = func_utils.get_test_endpoint_dict()
        db_endpoint_object = models.Endpoint()
        db_endpoint_object.update(endpoint_dict)
        object_endpoint = objects.Endpoint._from_db_object(
            objects.Endpoint(), db_endpoint_object)
        self.validate_endpoint_values(db_endpoint_object, object_endpoint)

        endpoint_changes = object_endpoint.obj_get_changes()
        db_endpoint_object_2 = models.Endpoint()
        db_endpoint_object_2.update(endpoint_changes)
        self.validate_endpoint_values(db_endpoint_object, db_endpoint_object_2)
示例#6
0
 def test_endpoint_object_generation(self):
     """Test Endpoint Object generation from a cluster dictionary object."""
     endpoint_dict = func_utils.get_test_endpoint_dict()
     endpoint_object = objects.Endpoint(**endpoint_dict)
     self.validate_endpoint_values(endpoint_dict, endpoint_object)