コード例 #1
0
    def test_a_list_resources(self):
        oh = OrchestratorHelper()
        response = oh.resources()
        self.assertEqual(NOT_FOUND, response.status_code)
        self.assertEqual("Resource(s) not found!", response.content)

        response = oh.portal_resources()
        self.assertEqual(NOT_FOUND, response.status_code)
        self.assertEqual("Resource(s) not found!", response.content)
コード例 #2
0
    def test_e_create_delete_slice_two_vms_no_components(self):
        # Create Slice
        slice_graph = self.build_slice_with_compute_only()
        oh = OrchestratorHelper()
        status, response = oh.create(slice_graph=slice_graph, slice_name=self.TEST_SLICE_NAME)
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(response, list))
        self.assertEqual(len(response), 2)
        self.slice_id = response[0].slice_id

        # Attempt creating the slice again with same name and verify it fails
        status, response = oh.create(slice_graph=slice_graph, slice_name=self.TEST_SLICE_NAME)
        self.assertEqual(Status.FAILURE, status)
        self.assertEqual(f"Slice {self.TEST_SLICE_NAME} already exists", response.content)

        # Wait for Slice to be Stable
        slice_state = None
        while slice_state != self.STABLE_OK:
            status, slice_obj = oh.slice_status(slice_id=self.slice_id)
            self.assertEqual(Status.OK, status)
            self.assertTrue(isinstance(slice_obj, Slice))
            slice_state = slice_obj.slice_state
            time.sleep(5)

        # check Slivers and verify there states at all 3 actors
        status, slivers = oh.slivers(slice_id=self.slice_id)
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(slivers, list))
        for s in slivers:
            self.assertEqual(ReservationStates.Active.name, s.get_state())
            self.assertIsNotNone(s.management_ip)
            self.assertIsNotNone(s.graph_node_id)
            self.assertEqual(self.slice_id, s.slice_id)

            self.assert_am_broker_reservations(slice_id=self.slice_id, res_id=s.reservation_id,
                                               am_res_state=ReservationStates.Active.value,
                                               broker_res_state=ReservationStates.Ticketed.value)

        # Delete Slice
        status, response = oh.delete(self.slice_id)
        self.assertEqual(Status.OK, status)

        time.sleep(5)

        # check Slivers and verify there states at all 3 actors
        status, slivers = oh.slivers(slice_id=self.slice_id)
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(slivers, list))
        for s in slivers:
            self.assertEqual(ReservationStates.Closed.name, s.get_state())
            self.assertIsNotNone(s.graph_node_id)
            self.assertEqual(self.slice_id, s.slice_id)

            self.assert_am_broker_reservations(slice_id=self.slice_id, res_id=s.reservation_id,
                                               am_res_state=ReservationStates.Closed.value,
                                               broker_res_state=ReservationStates.Closed.value)
コード例 #3
0
    def test_c_list_resources(self):
        oh = OrchestratorHelper()
        response = oh.resources()
        self.assertEqual(OK, response.status_code)
        status = response.json()[self.VALUE][self.STATUS]
        self.assertEqual(status, self.STATUS_OK)
        json_obj = response.json()[self.VALUE]
        self.assertIsNotNone(json_obj)
        self.assertIsNotNone(json_obj.get(Constants.BROKER_QUERY_MODEL, None))

        response = oh.portal_resources()
        self.assertEqual(OK, response.status_code)
        status = response.json()[self.VALUE][self.STATUS]
        self.assertEqual(status, self.STATUS_OK)
        json_obj = response.json()[self.VALUE]
        self.assertIsNotNone(json_obj)
        self.assertIsNotNone(json_obj.get(Constants.BROKER_QUERY_MODEL, None))
コード例 #4
0
    def test_i_create_delete_slice_network_service(self):

        # Create Slice
        slice_graph = self.build_slice()
        oh = OrchestratorHelper()
        status, response = oh.create(slice_graph=slice_graph, slice_name=self.TEST_SLICE_NAME)
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(response, list))
        self.assertEqual(len(response), 2)
        self.slice_id = response[0].slice_id

        # wait for slice to be Stable
        slice_state = None
        while slice_state != self.STABLE_OK:
            status, slice_obj = oh.slice_status(slice_id=self.slice_id)
            self.assertEqual(Status.OK, status)
            self.assertTrue(isinstance(slice_obj, Slice))
            slice_state = slice_obj.slice_state
            time.sleep(5)

        # check Slivers and verify there states at all 3 actors
        status, slivers = oh.slivers(slice_id=self.slice_id)
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(slivers, list))
        for s in slivers:
            self.assertEqual(ReservationStates.Active.name, s.get_state())
            self.assertIsNotNone(s.graph_node_id)
            self.assertEqual(self.slice_id, s.slice_id)

            #self.assert_am_broker_reservations(slice_id=self.slice_id, res_id=s.reservation_id,
            #                                   am_res_state=ReservationStates.Active.value,
            #                                   broker_res_state=ReservationStates.Ticketed.value)

        # Delete Slice
        status, response = oh.delete(self.slice_id)
        self.assertEqual(Status.OK, status)

        time.sleep(5)

        # check Slivers and verify there states at all 3 actors
        status, slivers = oh.slivers(slice_id=self.slice_id)
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(slivers, list))
        for s in slivers:
            self.assertEqual(ReservationStates.Closed.name, s.get_state())
            self.assertIsNotNone(s.graph_node_id)
            self.assertEqual(self.slice_id, s.slice_id)
コード例 #5
0
    def test_g_create_delete_slice_two_vms_with_components_not_available(self):
        # Create Slice
        slice_graph = self.build_slice_with_compute_only(exceed_components=True, include_components=True)
        oh = OrchestratorHelper()
        status, response = oh.create(slice_graph=slice_graph, slice_name=self.TEST_SLICE_NAME)
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(response, list))
        self.assertEqual(len(response), 2)
        self.slice_id = response[0].slice_id

        # Wait for slice to be closed
        slice_state = None
        while slice_state != self.CLOSING:
            status, slice_obj = oh.slice_status(slice_id=self.slice_id)
            self.assertEqual(Status.OK, status)
            self.assertTrue(isinstance(slice_obj, Slice))
            slice_state = slice_obj.slice_state
            time.sleep(5)

        # check Slivers and verify there states at all 3 actors
        status, slivers = oh.slivers(slice_id=self.slice_id)
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(slivers, list))
        error_messages = [Constants.CLOSURE_BY_TICKET_REVIEW_POLICY,
                          "Insufficient resources: No candidates nodes found to serve res"]
        i = 0
        for s in slivers:
            self.assertEqual(s.get_state(), ReservationStates.Closed.name)
            self.assertIsNone(s.management_ip)
            self.assertIsNotNone(s.graph_node_id)
            self.assertEqual(self.slice_id, s.slice_id)
            self.assert_am_broker_reservations(slice_id=self.slice_id, res_id=s.reservation_id,
                                               am_res_state=-1,
                                               broker_res_state=ReservationStates.Closed.value)
            status, sliver_status = oh.sliver_status(slice_id=self.slice_id, sliver_id=s.reservation_id)
            self.assertEqual(Status.OK, status)
            self.assertTrue(sliver_status.get_notices().__contains__(error_messages[i]))
            i += 1

        # Verify delete slice fails as slices is already closed
        status, response = oh.delete(self.slice_id)
        self.assertEqual(status, Status.FAILURE)
        self.assertEqual(f"Slice# {self.slice_id} already closed", response.content)
コード例 #6
0
    def test_h_create_slice_with_lease_end_and_renew_slice(self):
        # Create Slice
        slice_graph = self.build_slice_with_compute_only(include_components=True)
        oh = OrchestratorHelper()
        now = datetime.utcnow()
        new_time = now + timedelta(days=2)
        new_time_str = new_time.strftime(Constants.LEASE_TIME_FORMAT)
        status, response = oh.create(slice_graph=slice_graph, slice_name=self.TEST_SLICE_NAME,
                                     lease_end_time=new_time_str)
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(response, list))
        self.assertEqual(len(response), 2)
        self.slice_id = response[0].slice_id

        # wait for slice to be Stable
        slice_state = None
        while slice_state != self.STABLE_OK:
            status, slice_obj = oh.slice_status(slice_id=self.slice_id)
            self.assertEqual(Status.OK, status)
            self.assertTrue(isinstance(slice_obj, Slice))
            slice_state = slice_obj.slice_state
            time.sleep(5)

        # check Slivers and verify there states at all 3 actors
        new_time_str_without_seconds = new_time.strftime(self.TIME_FORMAT_IN_SECONDS)

        status, slivers = oh.slivers(slice_id=self.slice_id)
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(slivers, list))
        for s in slivers:
            self.assertEqual(ReservationStates.Active.name, s.get_state())
            self.assertIsNotNone(s.management_ip)
            self.assertIsNotNone(s.graph_node_id)
            self.assertEqual(self.slice_id, s.slice_id)
            lease_end = datetime.strptime(s.lease_end, Constants.LEASE_TIME_FORMAT)
            lease_end_without_seconds = lease_end.strftime(self.TIME_FORMAT_IN_SECONDS)
            self.assertEqual(new_time_str_without_seconds, lease_end_without_seconds)

            self.assert_am_broker_reservations(slice_id=self.slice_id, res_id=s.reservation_id,
                                               am_res_state=ReservationStates.Active.value,
                                               broker_res_state=ReservationStates.Ticketed.value,
                                               new_time=new_time_str_without_seconds)

        # Renew Slice
        now = datetime.utcnow()
        new_time = now + timedelta(days=14)

        new_time_str = new_time.strftime(self.TIME_FORMAT_IN_SECONDS)
        status, response = oh.renew(slice_id=self.slice_id, new_lease_end_time=new_time_str)
        self.assertEqual(Status.FAILURE, status)
        self.assertEqual(BAD_REQUEST, response.status_code)

        new_time_str = new_time.strftime(Constants.LEASE_TIME_FORMAT)

        status, response = oh.renew(slice_id="Slice_not-exists", new_lease_end_time=new_time_str)
        self.assertEqual(Status.FAILURE, status)
        self.assertEqual(NOT_FOUND, response.status_code)

        status, response = oh.renew(slice_id=self.slice_id, new_lease_end_time=new_time_str)
        self.assertEqual(Status.OK, status)

        time.sleep(10)

        # check Slivers and verify there states at all 3 actors
        status, slivers = oh.slivers(slice_id=self.slice_id)
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(slivers, list))
        new_time_str_without_seconds = new_time.strftime(self.TIME_FORMAT_IN_SECONDS)
        for s in slivers:
            self.assertEqual(ReservationStates.Active.name, s.get_state())
            self.assertIsNotNone(s.management_ip)
            self.assertIsNotNone(s.graph_node_id)
            self.assertEqual(self.slice_id, s.slice_id)

            lease_end = datetime.strptime(s.lease_end, Constants.LEASE_TIME_FORMAT)
            lease_end_without_seconds = lease_end.strftime(self.TIME_FORMAT_IN_SECONDS)
            self.assertEqual(new_time_str_without_seconds, lease_end_without_seconds)

            self.assert_am_broker_reservations(slice_id=self.slice_id, res_id=s.reservation_id,
                                               am_res_state=ReservationStates.Active.value,
                                               broker_res_state=ReservationStates.Ticketed.value,
                                               new_time=new_time_str_without_seconds)

        # Delete Slice
        status, response = oh.delete(self.slice_id)
        self.assertEqual(Status.OK, status)

        time.sleep(5)

        # check Slivers and verify there states at all 3 actors
        status, slivers = oh.slivers(slice_id=self.slice_id)
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(slivers, list))
        for s in slivers:
            self.assertEqual(ReservationStates.Closed.name, s.get_state())
            self.assertIsNotNone(s.graph_node_id)
            self.assertEqual(self.slice_id, s.slice_id)

            self.assert_am_broker_reservations(slice_id=self.slice_id, res_id=s.reservation_id,
                                               am_res_state=ReservationStates.Closed.value,
                                               broker_res_state=ReservationStates.Closed.value)
コード例 #7
0
    def test_f_create_delete_slice_with_instance_type(self):
        # Create Slice
        slice_graph = self.build_slice_with_compute_only(no_cap=True)
        oh = OrchestratorHelper()

        # Create Slice with no capacities and hints
        status, response = oh.create(slice_graph=slice_graph, slice_name=self.TEST_SLICE_NAME)
        self.assertEqual(Status.FAILURE, status)
        print(response)
        self.assertEqual(BAD_REQUEST, response.status_code)

        # Create Slice with exceeding capacities
        slice_graph = self.build_slice_with_compute_only(use_hints=True, instance_type="fabric.c64.m384.d4000")
        status, response = oh.create(slice_graph=slice_graph, slice_name=self.TEST_SLICE_NAME)
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(response, list))
        self.assertEqual(len(response), 2)
        self.slice_id = response[0].slice_id

        # Wait for the Slice to be closed
        slice_state = None
        while slice_state != self.CLOSING:
            status, slice_obj = oh.slice_status(slice_id=self.slice_id)
            self.assertEqual(Status.OK, status)
            self.assertTrue(isinstance(slice_obj, Slice))
            slice_state = slice_obj.slice_state
            time.sleep(5)

        # check Slivers and verify there states at all 3 actors
        status, slivers = oh.slivers(slice_id=self.slice_id)
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(slivers, list))
        error_messages = "Insufficient resources : ['core']"
        for s in slivers:
            self.assertEqual(s.get_state(), ReservationStates.Closed.name)
            self.assertIsNone(s.management_ip)
            self.assertIsNotNone(s.graph_node_id)
            self.assertEqual(self.slice_id, s.slice_id)
            self.assert_am_broker_reservations(slice_id=self.slice_id, res_id=s.reservation_id,
                                               am_res_state=-1,
                                               broker_res_state=ReservationStates.Closed.value)
            status, sliver_status = oh.sliver_status(slice_id=self.slice_id, sliver_id=s.reservation_id)

            self.assertEqual(Status.OK, status)
            self.assertTrue(sliver_status.get_notices().__contains__(error_messages))

        # Create Slice with capacities and hints
        slice_graph = self.build_slice_with_compute_only(use_hints=True)
        status, response = oh.create(slice_graph=slice_graph, slice_name=self.TEST_SLICE_NAME)
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(response, list))
        self.assertEqual(len(response), 2)
        self.slice_id = response[0].slice_id

        # Wait for the Slice to be Stable
        slice_state = None
        while slice_state != self.STABLE_OK:
            status, slice_obj = oh.slice_status(slice_id=self.slice_id)
            self.assertEqual(Status.OK, status)
            self.assertTrue(isinstance(slice_obj, Slice))
            slice_state = slice_obj.slice_state
            time.sleep(5)

        # check Slivers and verify there states at all 3 actors
        status, slivers = oh.slivers(slice_id=self.slice_id)
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(slivers, list))
        for s in slivers:
            self.assertEqual(ReservationStates.Active.name, s.get_state())
            self.assertIsNotNone(s.management_ip)
            self.assertIsNotNone(s.graph_node_id)
            self.assertEqual(self.slice_id, s.slice_id)

            self.assert_am_broker_reservations(slice_id=self.slice_id, res_id=s.reservation_id,
                                               am_res_state=ReservationStates.Active.value,
                                               broker_res_state=ReservationStates.Ticketed.value)

        # Verify delete slice fails as slices is already closed
        # Delete Slice
        status, response = oh.delete(self.slice_id)
        self.assertEqual(Status.OK, status)

        time.sleep(5)

        # check Slivers and verify there states at all 3 actors
        status, slivers = oh.slivers(slice_id=self.slice_id)
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(slivers, list))
        for s in slivers:
            self.assertEqual(ReservationStates.Closed.name, s.get_state())
            self.assertIsNotNone(s.graph_node_id)
            self.assertEqual(self.slice_id, s.slice_id)

            self.assert_am_broker_reservations(slice_id=self.slice_id, res_id=s.reservation_id,
                                               am_res_state=ReservationStates.Closed.value,
                                               broker_res_state=ReservationStates.Closed.value)

        # Check Slices API
        status, slices = oh.slices()
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(slices, list))
        self.assertEqual(0, len(slices))

        status, slices = oh.slices(state="All")
        self.assertEqual(Status.OK, status)
        self.assertTrue(isinstance(slices, list))
        self.assertTrue(len(slices) > 0)