storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/mint/run/core/s3select/tests.py (about) 1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 # MinIO Python Library for Amazon S3 Compatible Cloud Storage, 4 # (C) 2015-2020 MinIO, Inc. 5 # 6 # Licensed under the Apache License, Version 2.0 (the "License"); 7 # you may not use this file except in compliance with the License. 8 # You may obtain a copy of the License at 9 # 10 # http://www.apache.org/licenses/LICENSE-2.0 11 # 12 # Unless required by applicable law or agreed to in writing, software 13 # distributed under the License is distributed on an "AS IS" BASIS, 14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 # See the License for the specific language governing permissions and 16 # limitations under the License. 17 18 import os 19 import sys 20 from csv import (test_csv_input_custom_quote_char, 21 test_csv_output_custom_quote_char) 22 23 from minio import Minio 24 25 from sql_ops import (test_sql_datatypes, test_sql_functions_agg_cond_conv, 26 test_sql_functions_date, test_sql_functions_string, 27 test_sql_operators, test_sql_operators_precedence, 28 test_sql_select, test_sql_select_csv_no_header, 29 test_sql_select_json) 30 from utils import LogOutput 31 32 33 def main(): 34 """ 35 Functional testing for S3 select. 36 """ 37 38 try: 39 access_key = os.getenv('ACCESS_KEY', 'Q3AM3UQ867SPQQA43P2F') 40 secret_key = os.getenv('SECRET_KEY', 41 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG') 42 server_endpoint = os.getenv('SERVER_ENDPOINT', 'play.min.io') 43 secure = os.getenv('ENABLE_HTTPS', '1') == '1' 44 if server_endpoint == 'play.min.io': 45 access_key = 'Q3AM3UQ867SPQQA43P2F' 46 secret_key = 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG' 47 secure = True 48 49 client = Minio(server_endpoint, access_key, secret_key, secure=secure) 50 51 log_output = LogOutput(client.select_object_content, 52 'test_csv_input_quote_char') 53 test_csv_input_custom_quote_char(client, log_output) 54 55 log_output = LogOutput(client.select_object_content, 56 'test_csv_output_quote_char') 57 test_csv_output_custom_quote_char(client, log_output) 58 59 log_output = LogOutput( 60 client.select_object_content, 'test_sql_operators') 61 test_sql_operators(client, log_output) 62 63 log_output = LogOutput(client.select_object_content, 64 'test_sql_operators_precedence') 65 test_sql_operators_precedence(client, log_output) 66 67 log_output = LogOutput(client.select_object_content, 68 'test_sql_functions_agg_cond_conv') 69 test_sql_functions_agg_cond_conv(client, log_output) 70 71 log_output = LogOutput( 72 client.select_object_content, 'test_sql_functions_date') 73 test_sql_functions_date(client, log_output) 74 75 log_output = LogOutput(client.select_object_content, 76 'test_sql_functions_string') 77 test_sql_functions_string(client, log_output) 78 79 log_output = LogOutput( 80 client.select_object_content, 'test_sql_datatypes') 81 test_sql_datatypes(client, log_output) 82 83 log_output = LogOutput(client.select_object_content, 'test_sql_select') 84 test_sql_select(client, log_output) 85 86 log_output = LogOutput( 87 client.select_object_content, 'test_sql_select_json') 88 test_sql_select_json(client, log_output) 89 90 log_output = LogOutput( 91 client.select_object_content, 'test_sql_select_csv') 92 test_sql_select_csv_no_header(client, log_output) 93 94 except Exception as err: 95 print(log_output.json_report(err)) 96 sys.exit(1) 97 98 99 if __name__ == "__main__": 100 # Execute only if run as a script 101 main()