Skip to content

Commit 0471806

Browse files
authored
Added tests for error case of query (#14788)
1 parent 5fd43cd commit 0471806

File tree

4 files changed

+303
-0
lines changed

4 files changed

+303
-0
lines changed

sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/specialized/BlobBaseAPITest.groovy

+17
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,23 @@ class BlobBaseAPITest extends APISpec {
594594
false | true || _
595595
}
596596

597+
def "Query error"() {
598+
setup:
599+
bc = cc.getBlobClient(generateBlobName())
600+
601+
when:
602+
bc.openQueryInputStream("SELECT * from BlobStorage") /* Don't need to call read. */
603+
604+
then:
605+
thrown(BlobStorageException)
606+
607+
when:
608+
bc.query(new ByteArrayOutputStream(), "SELECT * from BlobStorage")
609+
610+
then:
611+
thrown(BlobStorageException)
612+
}
613+
597614
@Unroll
598615
def "Query AC"() {
599616
setup:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
{
2+
"networkCallRecords" : [ {
3+
"Method" : "PUT",
4+
"Uri" : "https://REDACTED.blob.core.windows.net/jtcqueryerror0blobbaseapitestqueryerror269087320a47c23e?restype=container",
5+
"Headers" : {
6+
"x-ms-version" : "2019-12-12",
7+
"User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)",
8+
"x-ms-client-request-id" : "2c4caf43-c4a8-4a91-bc60-5589f59eca44"
9+
},
10+
"Response" : {
11+
"x-ms-version" : "2019-12-12",
12+
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
13+
"ETag" : "0x8D850406D498931",
14+
"Last-Modified" : "Thu, 03 Sep 2020 19:34:51 GMT",
15+
"retry-after" : "0",
16+
"Content-Length" : "0",
17+
"StatusCode" : "201",
18+
"x-ms-request-id" : "094521b5-b01e-0040-3b29-8254cc000000",
19+
"Date" : "Thu, 03 Sep 2020 19:34:50 GMT",
20+
"x-ms-client-request-id" : "2c4caf43-c4a8-4a91-bc60-5589f59eca44"
21+
},
22+
"Exception" : null
23+
}, {
24+
"Method" : "PUT",
25+
"Uri" : "https://REDACTED.blob.core.windows.net/jtcqueryerror0blobbaseapitestqueryerror269087320a47c23e/javablobqueryerror1blobbaseapitestqueryerror26926881d5842",
26+
"Headers" : {
27+
"x-ms-version" : "2019-12-12",
28+
"User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)",
29+
"x-ms-client-request-id" : "ae5493b7-d5d0-4a21-bbd7-766fe3bc7b86",
30+
"Content-Type" : "application/octet-stream"
31+
},
32+
"Response" : {
33+
"x-ms-version" : "2019-12-12",
34+
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
35+
"x-ms-content-crc64" : "AAAAAAAAAAA=",
36+
"Last-Modified" : "Thu, 03 Sep 2020 19:34:51 GMT",
37+
"retry-after" : "0",
38+
"StatusCode" : "201",
39+
"x-ms-request-server-encrypted" : "true",
40+
"Date" : "Thu, 03 Sep 2020 19:34:50 GMT",
41+
"Content-MD5" : "1B2M2Y8AsgTpgAmY7PhCfg==",
42+
"ETag" : "0x8D850406D7F5FAD",
43+
"Content-Length" : "0",
44+
"x-ms-request-id" : "09452275-b01e-0040-6129-8254cc000000",
45+
"x-ms-client-request-id" : "ae5493b7-d5d0-4a21-bbd7-766fe3bc7b86"
46+
},
47+
"Exception" : null
48+
}, {
49+
"Method" : "POST",
50+
"Uri" : "https://REDACTED.blob.core.windows.net/jtcqueryerror0blobbaseapitestqueryerror269087320a47c23e/javablobqueryerror2blobbaseapitestqueryerror269148364ac38?comp=query",
51+
"Headers" : {
52+
"x-ms-version" : "2019-12-12",
53+
"User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)",
54+
"x-ms-client-request-id" : "783b394d-659b-4ec5-ac87-0d2b6b68369b",
55+
"Content-Type" : "application/xml; charset=utf-8"
56+
},
57+
"Response" : {
58+
"x-ms-version" : "2019-12-12",
59+
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
60+
"x-ms-error-code" : "BlobNotFound",
61+
"retry-after" : "0",
62+
"Content-Length" : "216",
63+
"StatusCode" : "404",
64+
"x-ms-request-id" : "094522b5-b01e-0040-1829-8254cc000000",
65+
"Body" : "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.\nRequestId:094522b5-b01e-0040-1829-8254cc000000\nTime:2020-09-03T19:34:54.6582500Z</Message></Error>",
66+
"Date" : "Thu, 03 Sep 2020 19:34:53 GMT",
67+
"x-ms-client-request-id" : "783b394d-659b-4ec5-ac87-0d2b6b68369b",
68+
"Content-Type" : "application/xml"
69+
},
70+
"Exception" : null
71+
}, {
72+
"Method" : "POST",
73+
"Uri" : "https://REDACTED.blob.core.windows.net/jtcqueryerror0blobbaseapitestqueryerror269087320a47c23e/javablobqueryerror2blobbaseapitestqueryerror269148364ac38?comp=query",
74+
"Headers" : {
75+
"x-ms-version" : "2019-12-12",
76+
"User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)",
77+
"x-ms-client-request-id" : "b852f6d6-e4dd-41a2-bc52-a95a688dedc9",
78+
"Content-Type" : "application/xml; charset=utf-8"
79+
},
80+
"Response" : {
81+
"x-ms-version" : "2019-12-12",
82+
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
83+
"x-ms-error-code" : "BlobNotFound",
84+
"retry-after" : "0",
85+
"Content-Length" : "216",
86+
"StatusCode" : "404",
87+
"x-ms-request-id" : "09452817-b01e-0040-6b29-8254cc000000",
88+
"Body" : "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.\nRequestId:09452817-b01e-0040-6b29-8254cc000000\nTime:2020-09-03T19:34:54.7643247Z</Message></Error>",
89+
"Date" : "Thu, 03 Sep 2020 19:34:53 GMT",
90+
"x-ms-client-request-id" : "b852f6d6-e4dd-41a2-bc52-a95a688dedc9",
91+
"Content-Type" : "application/xml"
92+
},
93+
"Exception" : null
94+
}, {
95+
"Method" : "GET",
96+
"Uri" : "https://REDACTED.blob.core.windows.net?prefix=jtcqueryerror&comp=list",
97+
"Headers" : {
98+
"x-ms-version" : "2019-12-12",
99+
"User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)",
100+
"x-ms-client-request-id" : "f033ed25-59f0-4962-b55c-37548bb983b6"
101+
},
102+
"Response" : {
103+
"Transfer-Encoding" : "chunked",
104+
"x-ms-version" : "2019-12-12",
105+
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
106+
"Vary" : "Origin",
107+
"retry-after" : "0",
108+
"StatusCode" : "200",
109+
"x-ms-request-id" : "09452856-b01e-0040-2329-8254cc000000",
110+
"Body" : "<?xml version=\"1.0\" encoding=\"utf-8\"?><EnumerationResults ServiceEndpoint=\"https://emilydevtest.blob.core.windows.net/\"><Prefix>jtcqueryerror</Prefix><Containers><Container><Name>jtcqueryerror0blobbaseapitestqueryerror269087320a47c23e</Name><Properties><Last-Modified>Thu, 03 Sep 2020 19:34:51 GMT</Last-Modified><Etag>\"0x8D850406D498931\"</Etag><LeaseStatus>unlocked</LeaseStatus><LeaseState>available</LeaseState><DefaultEncryptionScope>$account-encryption-key</DefaultEncryptionScope><DenyEncryptionScopeOverride>false</DenyEncryptionScopeOverride><HasImmutabilityPolicy>false</HasImmutabilityPolicy><HasLegalHold>false</HasLegalHold></Properties></Container></Containers><NextMarker /></EnumerationResults>",
111+
"Date" : "Thu, 03 Sep 2020 19:34:54 GMT",
112+
"x-ms-client-request-id" : "f033ed25-59f0-4962-b55c-37548bb983b6",
113+
"Content-Type" : "application/xml"
114+
},
115+
"Exception" : null
116+
}, {
117+
"Method" : "DELETE",
118+
"Uri" : "https://REDACTED.blob.core.windows.net/jtcqueryerror0blobbaseapitestqueryerror269087320a47c23e?restype=container",
119+
"Headers" : {
120+
"x-ms-version" : "2019-12-12",
121+
"User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)",
122+
"x-ms-client-request-id" : "47d4ea53-c0d1-43ea-9a00-21856fa5a770"
123+
},
124+
"Response" : {
125+
"x-ms-version" : "2019-12-12",
126+
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
127+
"retry-after" : "0",
128+
"Content-Length" : "0",
129+
"StatusCode" : "202",
130+
"x-ms-request-id" : "09452892-b01e-0040-5e29-8254cc000000",
131+
"Date" : "Thu, 03 Sep 2020 19:34:54 GMT",
132+
"x-ms-client-request-id" : "47d4ea53-c0d1-43ea-9a00-21856fa5a770"
133+
},
134+
"Exception" : null
135+
} ],
136+
"variables" : [ "jtcqueryerror0blobbaseapitestqueryerror269087320a47c23e", "javablobqueryerror1blobbaseapitestqueryerror26926881d5842", "javablobqueryerror2blobbaseapitestqueryerror269148364ac38" ]
137+
}

sdk/storage/azure-storage-file-datalake/src/test/java/com/azure/storage/file/datalake/FileAPITest.groovy

+17
Original file line numberDiff line numberDiff line change
@@ -3291,6 +3291,23 @@ class FileAPITest extends APISpec {
32913291
false | true || _
32923292
}
32933293

3294+
def "Query error"() {
3295+
setup:
3296+
fc = fsc.getFileClient(generatePathName())
3297+
3298+
when:
3299+
fc.openQueryInputStream("SELECT * from BlobStorage") /* Don't need to call read. */
3300+
3301+
then:
3302+
thrown(DataLakeStorageException)
3303+
3304+
when:
3305+
fc.query(new ByteArrayOutputStream(), "SELECT * from BlobStorage")
3306+
3307+
then:
3308+
thrown(DataLakeStorageException)
3309+
}
3310+
32943311
@Unroll
32953312
def "Query AC"() {
32963313
setup:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
{
2+
"networkCallRecords" : [ {
3+
"Method" : "PUT",
4+
"Uri" : "https://REDACTED.blob.core.windows.net/jtfsqueryerror0fileapitestqueryerror0ef90156a6885ca61?restype=container",
5+
"Headers" : {
6+
"x-ms-version" : "2019-12-12",
7+
"User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)",
8+
"x-ms-client-request-id" : "214d41e1-3185-40a0-aea4-3d8769b1c394"
9+
},
10+
"Response" : {
11+
"x-ms-version" : "2019-12-12",
12+
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
13+
"ETag" : "0x8D85040C37A1A60",
14+
"Last-Modified" : "Thu, 03 Sep 2020 19:37:16 GMT",
15+
"retry-after" : "0",
16+
"Content-Length" : "0",
17+
"StatusCode" : "201",
18+
"x-ms-request-id" : "d817ae3e-001e-0074-1529-827950000000",
19+
"Date" : "Thu, 03 Sep 2020 19:37:16 GMT",
20+
"x-ms-client-request-id" : "214d41e1-3185-40a0-aea4-3d8769b1c394"
21+
},
22+
"Exception" : null
23+
}, {
24+
"Method" : "PUT",
25+
"Uri" : "https://REDACTED.dfs.core.windows.net/jtfsqueryerror0fileapitestqueryerror0ef90156a6885ca61/javapathqueryerror1fileapitestqueryerror0ef33545c8ec03d?resource=file",
26+
"Headers" : {
27+
"x-ms-version" : "2019-12-12",
28+
"User-Agent" : "azsdk-java-azure-storage-file-datalake/12.3.0-beta.1 (11.0.7; Windows 10; 10.0)",
29+
"x-ms-client-request-id" : "5096c9b8-57c1-4084-a3cb-1ed1f1af44e5"
30+
},
31+
"Response" : {
32+
"x-ms-version" : "2019-12-12",
33+
"Server" : "Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0",
34+
"ETag" : "0x8D85040C46F1645",
35+
"Last-Modified" : "Thu, 03 Sep 2020 19:37:17 GMT",
36+
"retry-after" : "0",
37+
"Content-Length" : "0",
38+
"StatusCode" : "201",
39+
"x-ms-request-id" : "7f16a623-501f-009d-7729-82bf1a000000",
40+
"Date" : "Thu, 03 Sep 2020 19:37:17 GMT",
41+
"x-ms-client-request-id" : "5096c9b8-57c1-4084-a3cb-1ed1f1af44e5"
42+
},
43+
"Exception" : null
44+
}, {
45+
"Method" : "POST",
46+
"Uri" : "https://REDACTED.blob.core.windows.net/jtfsqueryerror0fileapitestqueryerror0ef90156a6885ca61/javapathqueryerror2fileapitestqueryerror0ef796212aec7e7?comp=query",
47+
"Headers" : {
48+
"x-ms-version" : "2019-12-12",
49+
"User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)",
50+
"x-ms-client-request-id" : "bcc7d55f-83bc-4117-9409-2751407f82a5",
51+
"Content-Type" : "application/xml; charset=utf-8"
52+
},
53+
"Response" : {
54+
"x-ms-version" : "2019-12-12",
55+
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
56+
"x-ms-error-code" : "BlobNotFound",
57+
"retry-after" : "0",
58+
"Content-Length" : "216",
59+
"StatusCode" : "404",
60+
"x-ms-request-id" : "d817af14-001e-0074-3229-827950000000",
61+
"Body" : "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.\nRequestId:d817af14-001e-0074-3229-827950000000\nTime:2020-09-03T19:37:18.1648360Z</Message></Error>",
62+
"Date" : "Thu, 03 Sep 2020 19:37:17 GMT",
63+
"x-ms-client-request-id" : "bcc7d55f-83bc-4117-9409-2751407f82a5",
64+
"Content-Type" : "application/xml"
65+
},
66+
"Exception" : null
67+
}, {
68+
"Method" : "POST",
69+
"Uri" : "https://REDACTED.blob.core.windows.net/jtfsqueryerror0fileapitestqueryerror0ef90156a6885ca61/javapathqueryerror2fileapitestqueryerror0ef796212aec7e7?comp=query",
70+
"Headers" : {
71+
"x-ms-version" : "2019-12-12",
72+
"User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)",
73+
"x-ms-client-request-id" : "4691ab77-77d8-4884-82bc-da8920b7e871",
74+
"Content-Type" : "application/xml; charset=utf-8"
75+
},
76+
"Response" : {
77+
"x-ms-version" : "2019-12-12",
78+
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
79+
"x-ms-error-code" : "BlobNotFound",
80+
"retry-after" : "0",
81+
"Content-Length" : "216",
82+
"StatusCode" : "404",
83+
"x-ms-request-id" : "d817af40-001e-0074-5329-827950000000",
84+
"Body" : "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.\nRequestId:d817af40-001e-0074-5329-827950000000\nTime:2020-09-03T19:37:18.3749859Z</Message></Error>",
85+
"Date" : "Thu, 03 Sep 2020 19:37:17 GMT",
86+
"x-ms-client-request-id" : "4691ab77-77d8-4884-82bc-da8920b7e871",
87+
"Content-Type" : "application/xml"
88+
},
89+
"Exception" : null
90+
}, {
91+
"Method" : "GET",
92+
"Uri" : "https://REDACTED.blob.core.windows.net?prefix=jtfsqueryerror&comp=list",
93+
"Headers" : {
94+
"x-ms-version" : "2019-12-12",
95+
"User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)",
96+
"x-ms-client-request-id" : "8343d3cb-e24e-4403-83c2-4e492227df49"
97+
},
98+
"Response" : {
99+
"Transfer-Encoding" : "chunked",
100+
"x-ms-version" : "2019-12-12",
101+
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
102+
"retry-after" : "0",
103+
"StatusCode" : "200",
104+
"x-ms-request-id" : "d817af4f-001e-0074-6129-827950000000",
105+
"Body" : "<?xml version=\"1.0\" encoding=\"utf-8\"?><EnumerationResults ServiceEndpoint=\"https://gaprahnscanary.blob.core.windows.net/\"><Prefix>jtfsqueryerror</Prefix><Containers><Container><Name>jtfsqueryerror0fileapitestqueryerror0ef90156a6885ca61</Name><Properties><Last-Modified>Thu, 03 Sep 2020 19:37:16 GMT</Last-Modified><Etag>\"0x8D85040C37A1A60\"</Etag><LeaseStatus>unlocked</LeaseStatus><LeaseState>available</LeaseState><DefaultEncryptionScope>$account-encryption-key</DefaultEncryptionScope><DenyEncryptionScopeOverride>false</DenyEncryptionScopeOverride><HasImmutabilityPolicy>false</HasImmutabilityPolicy><HasLegalHold>false</HasLegalHold></Properties></Container></Containers><NextMarker /></EnumerationResults>",
106+
"Date" : "Thu, 03 Sep 2020 19:37:18 GMT",
107+
"x-ms-client-request-id" : "8343d3cb-e24e-4403-83c2-4e492227df49",
108+
"Content-Type" : "application/xml"
109+
},
110+
"Exception" : null
111+
}, {
112+
"Method" : "DELETE",
113+
"Uri" : "https://REDACTED.blob.core.windows.net/jtfsqueryerror0fileapitestqueryerror0ef90156a6885ca61?restype=container",
114+
"Headers" : {
115+
"x-ms-version" : "2019-12-12",
116+
"User-Agent" : "azsdk-java-azure-storage-blob/12.9.0-beta.1 (11.0.7; Windows 10; 10.0)",
117+
"x-ms-client-request-id" : "3d4beb12-3bce-4c8f-85d1-40d4a69b1713"
118+
},
119+
"Response" : {
120+
"x-ms-version" : "2019-12-12",
121+
"Server" : "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0",
122+
"retry-after" : "0",
123+
"Content-Length" : "0",
124+
"StatusCode" : "202",
125+
"x-ms-request-id" : "d817af65-001e-0074-7229-827950000000",
126+
"Date" : "Thu, 03 Sep 2020 19:37:18 GMT",
127+
"x-ms-client-request-id" : "3d4beb12-3bce-4c8f-85d1-40d4a69b1713"
128+
},
129+
"Exception" : null
130+
} ],
131+
"variables" : [ "jtfsqueryerror0fileapitestqueryerror0ef90156a6885ca61", "javapathqueryerror1fileapitestqueryerror0ef33545c8ec03d", "javapathqueryerror2fileapitestqueryerror0ef796212aec7e7" ]
132+
}

0 commit comments

Comments
 (0)