def handle_after_bundle(self, event, when, env_deployment=None, *args, **kwargs): """Handle when the test run is complete. This is the stage when the logs are finalised, processed, and then uploaded to where they should be stored (according to the config). :param event: This must be NotifyEvents.BUNDLE :type event: NotifyEvents :param when: This must be NotifyType.AFTER :type when: NotifyType :param *args: Any additional args passed; these are ignored. :type *args: Tuple(ANY) :param env_deployment: The deployment details for this model. :type env_deployment: EnvironmentDeploy :param **kwargs: Any additional kwargs; these are ignored. :type **kwargs: Dict[str, ANY] """ assert event is NotifyEvents.BUNDLE assert when is NotifyType.AFTER events = get_global_event_logger_instance() events.log(Events.END_TEST, comment="Test ended") collection = ze_collection.get_collection() collection.finalise() for (name, type_, filename) in collection.log_files(): logger.debug("Found logs for %s type(%s) %s", name, type_, filename) upload_collection_by_config(collection, context=event_context_vars(env_deployment)) logger.info("Completed event logging and uploads for for %s.", collection.collection)
def test_upload_collection_by_config__config_type_is_influxdb(self): self.mock_get_option.return_value = [{'type': 'InfluxDB'}] uploaders.upload_collection_by_config('a-collection') self.mock_logger.error.assert_not_called() self.mock_upload_influxdb.assert_called_once_with({'type': 'InfluxDB'}, 'a-collection', None)
def test_upload_collection_by_config__config_type_is_not_influxdb(self): self.mock_get_option.return_value = [{'type': 'S3'}] uploaders.upload_collection_by_config('a-collection') self.mock_logger.error.assert_called_once_with(mock.ANY, 's3')
def test_upload_collection_by_config__config_has_no_type(self): self.mock_get_option.return_value = [{'some': 'config'}] uploaders.upload_collection_by_config('a-collection') self.mock_logger.error.assert_called_once_with(mock.ANY, {'some': 'config'})
def test_upload_collection_by_config__config_is_str_list(self): self.mock_get_option.return_value = ['a-list-of-strings-is-bad'] uploaders.upload_collection_by_config('a-collection') self.mock_logger.error.assert_called_once_with( mock.ANY, 'a-list-of-strings-is-bad')
def test_upload_collection_by_config__no_config(self): self.mock_get_option.return_value = None uploaders.upload_collection_by_config('a-collection') self.mock_logger.error.assert_called_once_with(mock.ANY, None)