|
20 | 20 |
|
21 | 21 | import java.io.FileNotFoundException; |
22 | 22 | import java.io.IOException; |
| 23 | +import java.net.SocketException; |
23 | 24 | import java.net.SocketTimeoutException; |
24 | 25 | import java.net.URL; |
25 | 26 | import java.util.ArrayList; |
|
31 | 32 |
|
32 | 33 | import org.assertj.core.api.Assertions; |
33 | 34 | import org.junit.Test; |
| 35 | +import org.mockito.Mock; |
34 | 36 | import org.mockito.Mockito; |
35 | 37 | import org.mockito.stubbing.Stubber; |
36 | 38 |
|
|
40 | 42 | import org.apache.hadoop.fs.FileStatus; |
41 | 43 | import org.apache.hadoop.fs.LocatedFileStatus; |
42 | 44 | import org.apache.hadoop.fs.Path; |
| 45 | +import org.apache.hadoop.fs.azurebfs.constants.AbfsServiceType; |
43 | 46 | import org.apache.hadoop.fs.azurebfs.constants.FSOperationType; |
44 | 47 | import org.apache.hadoop.fs.azurebfs.constants.HttpHeaderConfigurations; |
| 48 | +import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsDriverException; |
45 | 49 | import org.apache.hadoop.fs.azurebfs.contracts.exceptions.AbfsRestOperationException; |
46 | 50 | import org.apache.hadoop.fs.azurebfs.services.AbfsBlobClient; |
47 | 51 | import org.apache.hadoop.fs.azurebfs.services.AbfsClientHandler; |
|
63 | 67 | import static org.apache.hadoop.fs.azurebfs.constants.AbfsHttpConstants.TRUE; |
64 | 68 | import static org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys.AZURE_LIST_MAX_RESULTS; |
65 | 69 | import static org.apache.hadoop.fs.azurebfs.constants.HttpHeaderConfigurations.X_MS_METADATA_PREFIX; |
| 70 | +import static org.apache.hadoop.fs.azurebfs.contracts.services.AzureServiceErrorCode.COPY_BLOB_ABORTED; |
| 71 | +import static org.apache.hadoop.fs.azurebfs.services.AbfsErrors.ERR_BLOB_LIST_PARSING; |
66 | 72 | import static org.apache.hadoop.fs.azurebfs.services.RenameAtomicity.SUFFIX; |
| 73 | +import static org.apache.hadoop.fs.azurebfs.services.RetryReasonConstants.CONNECTION_RESET_MESSAGE; |
67 | 74 | import static org.apache.hadoop.fs.azurebfs.services.RetryReasonConstants.CONNECTION_TIMEOUT_JDK_MESSAGE; |
68 | 75 | import static org.apache.hadoop.fs.contract.ContractTestUtils.assertMkdirs; |
69 | 76 | import static org.apache.hadoop.fs.contract.ContractTestUtils.createFile; |
@@ -176,6 +183,31 @@ public void testListPathTracingContext() throws Exception { |
176 | 183 | Mockito.verify(spiedTracingContext, times(0)).constructHeader(any(), any(), any()); |
177 | 184 | } |
178 | 185 |
|
| 186 | + @Test |
| 187 | + public void testListPathParsingFailure() throws Exception { |
| 188 | + assumeBlobServiceType(); |
| 189 | + AzureBlobFileSystem spiedFs = Mockito.spy(getFileSystem()); |
| 190 | + AzureBlobFileSystemStore spiedStore = Mockito.spy(spiedFs.getAbfsStore()); |
| 191 | + AbfsBlobClient spiedClient = Mockito.spy(spiedStore.getClientHandler() |
| 192 | + .getBlobClient()); |
| 193 | + Mockito.doReturn(spiedStore).when(spiedFs).getAbfsStore(); |
| 194 | + Mockito.doReturn(spiedClient).when(spiedStore).getClient(); |
| 195 | + |
| 196 | + Mockito.doThrow(new SocketException(CONNECTION_RESET_MESSAGE)).when(spiedClient).filterDuplicateEntriesAndRenamePendingFiles(any(), any()); |
| 197 | + List<FileStatus> fileStatuses = new ArrayList<>(); |
| 198 | + AbfsDriverException ex = intercept(AbfsDriverException.class, |
| 199 | + () -> { |
| 200 | + spiedStore.listStatus(new Path("/"), "", fileStatuses, |
| 201 | + true, null, getTestTracingContext(spiedFs, true)); |
| 202 | + }); |
| 203 | + Assertions.assertThat(ex.getStatusCode()) |
| 204 | + .describedAs("Expecting Network Error status code") |
| 205 | + .isEqualTo(-1); |
| 206 | + Assertions.assertThat(ex.getErrorMessage()) |
| 207 | + .describedAs("Expecting COPY_ABORTED error code") |
| 208 | + .contains(ERR_BLOB_LIST_PARSING); |
| 209 | + } |
| 210 | + |
179 | 211 | /** |
180 | 212 | * Creates a file, verifies that listStatus returns it, |
181 | 213 | * even while the file is still open for writing. |
|
0 commit comments