Ejemplo n.º 1
0
    def test_deleted_storage_exception(self, mock_collect_telemetry):
        ctx = context.get_admin_context()
        perf_collection_handler = PerformanceCollectionHandler(
            ctx, fake_task_id, fake_storage_id, "", 100, fake_executor)
        perf_collection_handler()

        # Verify that collect telemetry for deleted storage
        self.assertEqual(mock_collect_telemetry.call_count, 0)
Ejemplo n.º 2
0
    def test_performance_collection_success(self, mock_collect_telemetry,
                                            mock_task_update):
        mock_collect_telemetry.return_value = TelemetryTaskStatus. \
            TASK_EXEC_STATUS_SUCCESS
        ctx = context.get_admin_context()
        perf_collection_handler = PerformanceCollectionHandler.get_instance(
            ctx, fake_task_id)
        # call performance collection handler
        perf_collection_handler()

        self.assertEqual(mock_collect_telemetry.call_count, 1)
        self.assertEqual(mock_task_update.call_count, 1)
    def test_performance_collection_failure(self, mock_collect_telemetry,
                                            mock_failed_task_create):
        mock_collect_telemetry.return_value = TelemetryTaskStatus. \
            TASK_EXEC_STATUS_FAILURE
        ctx = context.get_admin_context()
        perf_collection_handler = PerformanceCollectionHandler.get_instance(
            ctx, fake_task_id)
        # call performance collection handler
        perf_collection_handler()

        # Verify that failed task create is called if collect telemetry fails
        self.assertEqual(mock_failed_task_create.call_count, 1)
Ejemplo n.º 4
0
    def test_performance_collection_deleted_storage(self,
                                                    mock_collect_telemetry,
                                                    mock_task_update):
        mock_collect_telemetry.return_value = TelemetryTaskStatus. \
            TASK_EXEC_STATUS_SUCCESS
        ctx = context.get_admin_context()
        perf_collection_handler = PerformanceCollectionHandler.get_instance(
            ctx, fake_task_id)
        perf_collection_handler()

        # Verify that collect telemetry and db updated is not called
        # for deleted storage
        self.assertEqual(mock_collect_telemetry.call_count, 0)
        self.assertEqual(mock_task_update.call_count, 0)