fix: regression introduced in aws-sdk-go tests

regression was introduced by cce5d7152a
which incorrectly implemented the tests and fixed a wrong requirement,
CompleteMultipart should never succeed in the tests.
master
Harshavardhana 4 years ago
parent e63a10e505
commit 6128304f6e
  1. 4
      mint/build/minio-py/install.sh
  2. 34
      mint/run/core/aws-sdk-go/main.go
  3. 13
      mint/run/core/s3select/csv.py
  4. 11
      mint/run/core/s3select/sql_ops.py

@ -23,5 +23,5 @@ fi
test_run_dir="$MINT_RUN_CORE_DIR/minio-py" test_run_dir="$MINT_RUN_CORE_DIR/minio-py"
pip3 install --user faker pip3 install --user faker
pip3 install git+http://github.com/minio/minio-py pip3 install minio==${MINIO_PY_VERSION}
$WGET --output-document="$test_run_dir/tests.py" "https://raw.githubusercontent.com/minio/minio-py/master/tests/functional/tests.py" $WGET --output-document="$test_run_dir/tests.py" "https://raw.githubusercontent.com/minio/minio-py/${MINIO_PY_VERSION}/tests/functional/tests.py"

@ -885,7 +885,7 @@ func testListMultipartUploads(s3Client *s3.S3) {
failureLog(function, args, startTime, "", "AWS SDK Go createMultipartupload API failed", err).Fatal() failureLog(function, args, startTime, "", "AWS SDK Go createMultipartupload API failed", err).Fatal()
return return
} }
parts := make(map[*int64]*string) parts := make([]*string, 5)
for i := 0; i < 5; i++ { for i := 0; i < 5; i++ {
result, errUpload := s3Client.UploadPart(&s3.UploadPartInput{ result, errUpload := s3Client.UploadPart(&s3.UploadPartInput{
Bucket: aws.String(bucket), Bucket: aws.String(bucket),
@ -903,7 +903,7 @@ func testListMultipartUploads(s3Client *s3.S3) {
failureLog(function, args, startTime, "", "AWS SDK Go uploadPart API failed for", errUpload).Fatal() failureLog(function, args, startTime, "", "AWS SDK Go uploadPart API failed for", errUpload).Fatal()
return return
} }
parts[aws.Int64(int64(i+1))] = result.ETag parts[i] = result.ETag
} }
listParts, errParts := s3Client.ListParts(&s3.ListPartsInput{ listParts, errParts := s3Client.ListParts(&s3.ListPartsInput{
@ -917,21 +917,20 @@ func testListMultipartUploads(s3Client *s3.S3) {
} }
if len(parts) != len(listParts.Parts) { if len(parts) != len(listParts.Parts) {
failureLog(function, args, startTime, "", fmt.Sprintf("AWS SDK Go ListParts.Parts len mismatch want: %v got: %v", len(parts), len(listParts.Parts)), err).Fatal() failureLog(function, args, startTime, "", fmt.Sprintf("AWS SDK Go ListParts.Parts len mismatch want: %d got: %d", len(parts), len(listParts.Parts)), err).Fatal()
return return
} }
completedParts := make([]*s3.CompletedPart, len(parts)) completedParts := make([]*s3.CompletedPart, len(parts))
for _, part := range listParts.Parts { for i, part := range listParts.Parts {
if tag, ok := parts[part.PartNumber]; ok { tag := parts[i]
if tag != part.ETag { if *tag != *part.ETag {
failureLog(function, args, startTime, "", fmt.Sprintf("AWS SDK Go ListParts.Parts output mismatch want: %v got: %v", tag, part.ETag), err).Fatal() failureLog(function, args, startTime, "", fmt.Sprintf("AWS SDK Go ListParts.Parts output mismatch want: %#v got: %#v", tag, part.ETag), err).Fatal()
return return
} }
completedParts = append(completedParts, &s3.CompletedPart{ completedParts[i] = &s3.CompletedPart{
ETag: part.ETag, ETag: part.ETag,
PartNumber: part.PartNumber, PartNumber: part.PartNumber,
})
} }
} }
@ -942,8 +941,13 @@ func testListMultipartUploads(s3Client *s3.S3) {
Parts: completedParts}, Parts: completedParts},
UploadId: multipartUpload.UploadId, UploadId: multipartUpload.UploadId,
}) })
if err != nil { if err == nil {
failureLog(function, args, startTime, "", fmt.Sprintf("AWS SDK Go CompleteMultipartUpload failed"), err).Fatal() failureLog(function, args, startTime, "", "AWS SDK Go CompleteMultipartUpload is expected to fail but succeeded", errors.New("expected nil")).Fatal()
return
}
if err.(s3.RequestFailure).Code() != "EntityTooSmall" {
failureLog(function, args, startTime, "", "AWS SDK Go CompleteMultipartUpload is expected to fail with EntityTooSmall", err).Fatal()
return return
} }

@ -19,12 +19,11 @@ import io
import os import os
from minio import Minio from minio import Minio
from minio.selectrequest import (COMPRESSION_TYPE_NONE, FILE_HEADER_INFO_NONE, from minio.select import (COMPRESSION_TYPE_NONE, FILE_HEADER_INFO_NONE,
JSON_TYPE_DOCUMENT, QUOTE_FIELDS_ALWAYS, JSON_TYPE_DOCUMENT, QUOTE_FIELDS_ALWAYS,
QUOTE_FIELDS_ASNEEDED, CSVInputSerialization, QUOTE_FIELDS_ASNEEDED, CSVInputSerialization,
CSVOutputSerialization, CSVOutputSerialization, JSONInputSerialization,
JSONInputSerialization, JSONOutputSerialization, SelectRequest)
JSONOutputSerialization, SelectRequest)
from utils import * from utils import *
@ -41,7 +40,7 @@ def test_sql_api(test_name, client, bucket_name, input_data, sql_opts, expected_
# Get the records # Get the records
records = io.BytesIO() records = io.BytesIO()
for d in data.stream(10*1024): for d in data.stream(10*1024):
records.write(d.encode('utf-8')) records.write(d)
got_output = records.getvalue() got_output = records.getvalue()
except Exception as select_err: except Exception as select_err:
if not isinstance(expected_output, Exception): if not isinstance(expected_output, Exception):

@ -18,11 +18,10 @@
import io import io
from datetime import datetime from datetime import datetime
from minio.selectrequest import (FILE_HEADER_INFO_NONE, JSON_TYPE_DOCUMENT, from minio.select import (FILE_HEADER_INFO_NONE, JSON_TYPE_DOCUMENT,
QUOTE_FIELDS_ASNEEDED, CSVInputSerialization, QUOTE_FIELDS_ASNEEDED, CSVInputSerialization,
CSVOutputSerialization, CSVOutputSerialization, JSONInputSerialization,
JSONInputSerialization, JSONOutputSerialization, SelectRequest)
JSONOutputSerialization, SelectRequest)
from utils import generate_bucket_name, generate_object_name from utils import generate_bucket_name, generate_object_name
@ -58,7 +57,7 @@ def test_sql_expressions_custom_input_output(client, input_bytes, sql_input,
# Get the records # Get the records
records = io.BytesIO() records = io.BytesIO()
for d in data.stream(10*1024): for d in data.stream(10*1024):
records.write(d.encode('utf-8')) records.write(d)
got_output = records.getvalue() got_output = records.getvalue()
if got_output != expected_output: if got_output != expected_output:

Loading…
Cancel
Save