def test_upload_file(self, mocker): import minio mock_minio = mocker.MagicMock(minio.api.Minio) mock_minio.fput_object = mocker.Mock() mocker.patch('minio.Minio', return_value=mock_minio) result = ObjectStoreManager('localhost:9999', 'foo', 'bar') result.upload_file("my-bucket", "foo.txt", "/tmp/foo.txt") mock_minio.fput_object.assert_called()
def test_init(self, mocker): mock_minio = mocker.patch('minio.Minio') ObjectStoreManager('localhost:9999', 'foo', 'bar') called_config = mock_minio.call_args[1] assert called_config['endpoint'] == 'localhost:9999' assert called_config['access_key'] == 'foo' assert called_config['secret_key'] == 'bar' assert not called_config['secure']
def test_init_from_env(self, mocker): os.environ['MINIO_URL'] = 'localhost:9999' os.environ['MINIO_ACCESS_KEY'] = 'test' os.environ['MINIO_SECRET_KEY'] = 'shhh' mock_minio = mocker.patch('minio.Minio') ObjectStoreManager() called_config = mock_minio.call_args[1] assert called_config['endpoint'] == 'localhost:9999' assert called_config['access_key'] == 'test' assert called_config['secret_key'] == 'shhh' assert not called_config['secure']
# this file. r = os.system('bash /generated/runner.sh -c | tee log.txt') if r != 0: with open('log.txt', 'r') as f: errors = f.read() raise RuntimeError("Unable to compile the code - error return: " + str(r) + 'errors: \n' + errors) if __name__ == "__main__": parser = TransformerArgumentParser(description="xAOD CPP Transformer") args = parser.parse_args() kafka_brokers = TransformerArgumentParser.extract_kafka_brokers( args.brokerlist) if args.result_destination == 'kafka': messaging = KafkaMessaging(kafka_brokers, args.max_message_size) object_store = None elif not args.output_dir and args.result_destination == 'object-store': messaging = None object_store = ObjectStoreManager() compile_code() if args.request_id and not args.path: rabbitmq = RabbitMQManager(args.rabbit_uri, args.request_id, callback) if args.path: transform_single_file(args.path, args.output_dir)
action='store', default='/code', help= 'Path where the 6 files have been written containing the code that is to be compiled and run.' ) # Print help if no args are provided if len(sys.argv[1:]) == 0: parser.print_help() parser.exit() args = parser.parse_args() if args.result_destination == 'object-store': object_store = ObjectStoreManager(os.environ['MINIO_URL'], os.environ['MINIO_ACCESS_KEY'], os.environ['MINIO_SECRET_KEY']) print("Object store initialized to ", object_store.minio_client) # Get RabbitMQ set up rabbitmq = pika.BlockingConnection(pika.URLParameters(args.rabbit_uri)) _channel = rabbitmq.channel() # Do pre-running setup. This is done before we have to start grabbing any files off the queue presetup() # Next start picking files off the input queue. # Each operation is going to take a very long time (10-15 seconds or so), so don't # prefetch anything. _channel.basic_qos(prefetch_count=1)