@@ -70,44 +70,50 @@ suite("test_load_with_transfer_encoding", "p0") {
7070
7171
7272 String db = context. config. getDbNameByFile(context. file)
73- String url = """ ${ getS3Url()} /regression/load/data/test_load_with_transfer_encoding.json"""
74- String fileName
7573
76- HttpClients . createDefault(). withCloseable { client ->
77- def file = new File (" ${ context.config.cacheDataPath} /test_load_with_transfer_encoding.json" )
78- if (file. exists()) {
79- log. info(" Found ${ url} in ${ file.getAbsolutePath()} " );
80- fileName = file. getAbsolutePath()
81- return ;
82- }
74+ def load_data = { inputFile , int count ->
75+ String url = """ ${ getS3Url()} /regression/load/data/${ inputFile} .json"""
76+ String fileName
77+
78+ HttpClients . createDefault(). withCloseable { client ->
79+ def file = new File (" ${ context.config.cacheDataPath} /${ inputFile} .json" )
80+ if (file. exists()) {
81+ log. info(" Found ${ url} in ${ file.getAbsolutePath()} " );
82+ fileName = file. getAbsolutePath()
83+ return ;
84+ }
8385
84- log. info(" Start to down data from ${ url} to $context . config . cacheDataPath }/" );
85- CloseableHttpResponse resp = client. execute(RequestBuilder . get(url). build())
86- int code = resp. getStatusLine(). getStatusCode()
86+ log. info(" Start to down data from ${ url} to $context . config . cacheDataPath }/" );
87+ CloseableHttpResponse resp = client. execute(RequestBuilder . get(url). build())
88+ int code = resp. getStatusLine(). getStatusCode()
8789
88- if (code != HttpStatus . SC_OK ) {
89- String streamBody = EntityUtils . toString(resp. getEntity())
90- log. info(" Fail to download data ${ url} , code: ${ code} , body:\n ${ streamBody} " )
91- throw new IllegalStateException (" Get http stream failed, status code is ${ code} , body:\n ${ streamBody} " )
90+ if (code != HttpStatus . SC_OK ) {
91+ String streamBody = EntityUtils . toString(resp. getEntity())
92+ log. info(" Fail to download data ${ url} , code: ${ code} , body:\n ${ streamBody} " )
93+ throw new IllegalStateException (" Get http stream failed, status code is ${ code} , body:\n ${ streamBody} " )
94+ }
95+
96+ InputStream httpFileStream = resp. getEntity(). getContent()
97+ java.nio.file.Files . copy(httpFileStream, file. toPath(), java.nio.file.StandardCopyOption . REPLACE_EXISTING )
98+ httpFileStream. close()
99+ fileName = file. getAbsolutePath()
100+ log. info(" File downloaded to: ${ fileName} " )
92101 }
93102
94- InputStream httpFileStream = resp. getEntity(). getContent()
95- java.nio.file.Files . copy(httpFileStream, file. toPath(), java.nio.file.StandardCopyOption . REPLACE_EXISTING )
96- httpFileStream. close()
97- fileName = file. getAbsolutePath()
98- log. info(" File downloaded to: ${ fileName} " )
103+ def command = """ curl --location-trusted -u ${ context.config.feHttpUser} :${ context.config.feHttpPassword} -H read_json_by_line:false -H Expect:100-continue -H max_filter_ratio:1 -H strict_mode:false -H strip_outer_array:true -H columns:id,created,creater,deleted,updated,card_id,card_type_id,card_type_name,cash_balance,cashier_id,client_id,cost,creater_name,details,id_name,id_number,last_client_id,login_id,operation_type,place_id,present,present_balance,remark,shift_id,source_type,online_account -H format:json -H Transfer-Encoding:chunked -T ${ fileName} -XPUT http://${ context.config.feHttpAddress} /api/${ db} /${ table_name} /_stream_load"""
104+ log. info(" stream load: ${ command} " )
105+ def process = command. execute()
106+ def code = process. waitFor()
107+ def out = process. text
108+ def json = parseJson(out)
109+ log. info(" stream load result is:: ${ out} " . toString())
110+ assertEquals (" success" , json.Status . toLowerCase())
111+ assertEquals (count, json.NumberLoadedRows )
112+ qt_sql """ select count() from ${ table_name} """
99113 }
100114
101- def command = """ curl --location-trusted -u ${ context.config.feHttpUser} :${ context.config.feHttpPassword} -H read_json_by_line:false -H Expect:100-continue -H max_filter_ratio:1 -H strict_mode:false -H strip_outer_array:true -H columns:id,created,creater,deleted,updated,card_id,card_type_id,card_type_name,cash_balance,cashier_id,client_id,cost,creater_name,details,id_name,id_number,last_client_id,login_id,operation_type,place_id,present,present_balance,remark,shift_id,source_type,online_account -H format:json -H Transfer-Encoding:chunked -T ${ fileName} -XPUT http://${ context.config.feHttpAddress} /api/${ db} /${ table_name} /_stream_load"""
102- log. info(" stream load: ${ command} " )
103- def process = command. execute()
104- def code = process. waitFor()
105- def out = process. text
106- def json = parseJson(out)
107- log. info(" stream load result is:: ${ out} " . toString())
108- assertEquals (" success" , json.Status . toLowerCase())
109- assertEquals (15272 , json.NumberLoadedRows )
110-
111- qt_sql """ select count() from ${ table_name} """
115+ load_data. call(" test_load_with_transfer_encoding" , 15272 )
116+ load_data. call(" test_transfer_encoding_small" , 10 )
117+
112118}
113119
0 commit comments