forked from TrueCloudLab/s3-tests
s3select: align s3select tests with ceph
Update s3-tests to handle the error-response (return 400, and error-description) Signed-off-by: Albin Antony <aantony@redhat.com>
This commit is contained in:
parent
d1a38df407
commit
89363e8fef
1 changed files with 22 additions and 5 deletions
|
@ -3,6 +3,7 @@ import random
|
||||||
import string
|
import string
|
||||||
import re
|
import re
|
||||||
from nose.plugins.attrib import attr
|
from nose.plugins.attrib import attr
|
||||||
|
from botocore.exceptions import ClientError
|
||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
from nose.tools import eq_ as eq
|
from nose.tools import eq_ as eq
|
||||||
|
@ -221,7 +222,8 @@ def upload_csv_object(bucket_name,new_key,obj):
|
||||||
def run_s3select(bucket,key,query,column_delim=",",row_delim="\n",quot_char='"',esc_char='\\',csv_header_info="NONE"):
|
def run_s3select(bucket,key,query,column_delim=",",row_delim="\n",quot_char='"',esc_char='\\',csv_header_info="NONE"):
|
||||||
|
|
||||||
s3 = get_client()
|
s3 = get_client()
|
||||||
|
result = ""
|
||||||
|
try:
|
||||||
r = s3.select_object_content(
|
r = s3.select_object_content(
|
||||||
Bucket=bucket,
|
Bucket=bucket,
|
||||||
Key=key,
|
Key=key,
|
||||||
|
@ -230,7 +232,10 @@ def run_s3select(bucket,key,query,column_delim=",",row_delim="\n",quot_char='"',
|
||||||
OutputSerialization = {"CSV": {}},
|
OutputSerialization = {"CSV": {}},
|
||||||
Expression=query,)
|
Expression=query,)
|
||||||
|
|
||||||
result = ""
|
except ClientError as c:
|
||||||
|
result += str(c)
|
||||||
|
return result
|
||||||
|
|
||||||
for event in r['Payload']:
|
for event in r['Payload']:
|
||||||
if 'Records' in event:
|
if 'Records' in event:
|
||||||
records = event['Records']['Payload'].decode('utf-8')
|
records = event['Records']['Payload'].decode('utf-8')
|
||||||
|
@ -334,11 +339,13 @@ def test_column_sum_min_max():
|
||||||
|
|
||||||
# the following queries, validates on *random* input an *accurate* relation between condition result,sum operation and count operation.
|
# the following queries, validates on *random* input an *accurate* relation between condition result,sum operation and count operation.
|
||||||
res_s3select = remove_xml_tags_from_result( run_s3select(bucket_name_2,csv_obj_name_2,"select count(0),sum(int(_1)),sum(int(_2)) from s3object where (int(_1)-int(_2)) = 2;" ) )
|
res_s3select = remove_xml_tags_from_result( run_s3select(bucket_name_2,csv_obj_name_2,"select count(0),sum(int(_1)),sum(int(_2)) from s3object where (int(_1)-int(_2)) = 2;" ) )
|
||||||
|
|
||||||
count,sum1,sum2,d = res_s3select.split(",")
|
count,sum1,sum2,d = res_s3select.split(",")
|
||||||
|
|
||||||
s3select_assert_result( int(count)*2 , int(sum1)-int(sum2 ) )
|
s3select_assert_result( int(count)*2 , int(sum1)-int(sum2 ) )
|
||||||
|
|
||||||
res_s3select = remove_xml_tags_from_result( run_s3select(bucket_name,csv_obj_name,"select count(0),sum(int(_1)),sum(int(_2)) from s3object where (int(_1)-int(_2)) = 4;" ) )
|
res_s3select = remove_xml_tags_from_result( run_s3select(bucket_name,csv_obj_name,"select count(0),sum(int(_1)),sum(int(_2)) from s3object where (int(_1)-int(_2)) = 4;" ) )
|
||||||
|
|
||||||
count,sum1,sum2,d = res_s3select.split(",")
|
count,sum1,sum2,d = res_s3select.split(",")
|
||||||
|
|
||||||
s3select_assert_result( int(count)*4 , int(sum1)-int(sum2) )
|
s3select_assert_result( int(count)*4 , int(sum1)-int(sum2) )
|
||||||
|
@ -605,6 +612,12 @@ def test_like_expressions():
|
||||||
|
|
||||||
s3select_assert_result( res_s3select_like, res_s3select )
|
s3select_assert_result( res_s3select_like, res_s3select )
|
||||||
|
|
||||||
|
res_s3select_like = remove_xml_tags_from_result( run_s3select(bucket_name,csv_obj_name,'select count(*) from stdin where _1 like "%aeio%" like;')).replace("\n","")
|
||||||
|
|
||||||
|
find_like = res_s3select_like.find("s3select-Syntax-Error")
|
||||||
|
|
||||||
|
assert int(find_like) >= 0
|
||||||
|
|
||||||
res_s3select_like = remove_xml_tags_from_result( run_s3select(bucket_name,csv_obj_name,'select (_1 like "cbcd%") from s3object;')).replace("\n","")
|
res_s3select_like = remove_xml_tags_from_result( run_s3select(bucket_name,csv_obj_name,'select (_1 like "cbcd%") from s3object;')).replace("\n","")
|
||||||
|
|
||||||
res_s3select = remove_xml_tags_from_result( run_s3select(bucket_name,csv_obj_name, 'select (substring(_1,1,4) = "cbcd") from s3object;')).replace("\n","")
|
res_s3select = remove_xml_tags_from_result( run_s3select(bucket_name,csv_obj_name, 'select (substring(_1,1,4) = "cbcd") from s3object;')).replace("\n","")
|
||||||
|
@ -939,6 +952,10 @@ def test_schema_definition():
|
||||||
|
|
||||||
assert res_multiple_defintion.find("alias {c11} or column not exist in schema") > 0
|
assert res_multiple_defintion.find("alias {c11} or column not exist in schema") > 0
|
||||||
|
|
||||||
|
find_processing_error = res_multiple_defintion.find("s3select-ProcessingTime-Error")
|
||||||
|
|
||||||
|
assert int(find_processing_error) >= 0
|
||||||
|
|
||||||
# alias-name is identical to column-name
|
# alias-name is identical to column-name
|
||||||
res_multiple_defintion = remove_xml_tags_from_result( run_s3select(bucket_name,csv_obj_name,"select int(c1)+int(c2) as c4,c4 from s3object;",csv_header_info="USE") ).replace("\n","")
|
res_multiple_defintion = remove_xml_tags_from_result( run_s3select(bucket_name,csv_obj_name,"select int(c1)+int(c2) as c4,c4 from s3object;",csv_header_info="USE") ).replace("\n","")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue