|
105 | 105 | import java.util.List;
|
106 | 106 | import java.util.Map;
|
107 | 107 | import java.util.regex.Pattern;
|
| 108 | +import java.util.concurrent.atomic.AtomicReference; |
108 | 109 |
|
109 | 110 | import static org.junit.Assert.assertArrayEquals;
|
110 | 111 | import static org.junit.Assert.assertEquals;
|
@@ -2158,35 +2159,45 @@ private void testGetECCodecs() throws Exception {
|
2158 | 2159 | return;
|
2159 | 2160 | }
|
2160 | 2161 | final Path path = new Path("/foo");
|
| 2162 | + |
2161 | 2163 | FileSystem fs = FileSystem.get(path.toUri(), this.getProxiedFSConf());
|
2162 |
| - if (fs instanceof DistributedFileSystem) { |
2163 |
| - DistributedFileSystem dfs = |
2164 |
| - (DistributedFileSystem) FileSystem.get(path.toUri(), this.getProxiedFSConf()); |
2165 |
| - FileSystem httpFs = this.getHttpFSFileSystem(); |
| 2164 | + LambdaTestUtils.intercept(AssertionError.class, () -> { |
| 2165 | + if (!(fs instanceof DistributedFileSystem)) { |
| 2166 | + throw new AssertionError(fs.getClass().getSimpleName() + |
| 2167 | + " is not of type DistributedFileSystem."); |
| 2168 | + } |
| 2169 | + }); |
2166 | 2170 |
|
2167 |
| - Map<String, String> dfsAllErasureCodingCodecs = dfs.getAllErasureCodingCodecs(); |
2168 |
| - Map<String, String> diffErasureCodingCodecs = null; |
| 2171 | + DistributedFileSystem dfs = |
| 2172 | + (DistributedFileSystem) FileSystem.get(path.toUri(), this.getProxiedFSConf()); |
| 2173 | + FileSystem httpFs = this.getHttpFSFileSystem(); |
2169 | 2174 |
|
| 2175 | + Map<String, String> dfsErasureCodingCodecs = dfs.getAllErasureCodingCodecs(); |
| 2176 | + |
| 2177 | + final AtomicReference<Map<String, String>> diffErasureCodingCodecsRef = |
| 2178 | + new AtomicReference<>(); |
| 2179 | + LambdaTestUtils.intercept(AssertionError.class, () -> { |
2170 | 2180 | if (httpFs instanceof HttpFSFileSystem) {
|
2171 |
| - HttpFSFileSystem httpFS = (HttpFSFileSystem) httpFs; |
2172 |
| - diffErasureCodingCodecs = httpFS.getAllErasureCodingCodecs(); |
| 2181 | + HttpFSFileSystem httpFSFileSystem = (HttpFSFileSystem) httpFs; |
| 2182 | + diffErasureCodingCodecsRef.set(httpFSFileSystem.getAllErasureCodingCodecs()); |
2173 | 2183 | } else if (httpFs instanceof WebHdfsFileSystem) {
|
2174 | 2184 | WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) httpFs;
|
2175 |
| - diffErasureCodingCodecs = webHdfsFileSystem.getAllErasureCodingCodecs(); |
| 2185 | + diffErasureCodingCodecsRef.set(webHdfsFileSystem.getAllErasureCodingCodecs()); |
2176 | 2186 | } else {
|
2177 |
| - Assert.fail(fs.getClass().getSimpleName() + |
| 2187 | + throw new AssertionError(httpFs.getClass().getSimpleName() + |
2178 | 2188 | " is not of type HttpFSFileSystem or WebHdfsFileSystem");
|
2179 | 2189 | }
|
| 2190 | + }); |
| 2191 | + Map<String, String> diffErasureCodingCodecs = diffErasureCodingCodecsRef.get(); |
2180 | 2192 |
|
2181 |
| - //Validate testGetECCodecs are the same as DistributedFileSystem |
2182 |
| - Assert.assertEquals(dfsAllErasureCodingCodecs.size(), diffErasureCodingCodecs.size()); |
| 2193 | + //Validate testGetECCodecs are the same as DistributedFileSystem |
| 2194 | + Assert.assertEquals(dfsErasureCodingCodecs.size(), diffErasureCodingCodecs.size()); |
2183 | 2195 |
|
2184 |
| - for (Map.Entry<String, String> entry : dfsAllErasureCodingCodecs.entrySet()) { |
2185 |
| - Assert.assertTrue(diffErasureCodingCodecs.containsKey(entry.getKey())); |
2186 |
| - Assert.assertEquals(entry.getValue(), diffErasureCodingCodecs.get(entry.getKey())); |
2187 |
| - } |
2188 |
| - } else { |
2189 |
| - Assert.fail(fs.getClass().getSimpleName() + " is not of type DistributedFileSystem."); |
| 2196 | + for (Map.Entry<String, String> entry : dfsErasureCodingCodecs.entrySet()) { |
| 2197 | + String key = entry.getKey(); |
| 2198 | + String value = entry.getValue(); |
| 2199 | + Assert.assertTrue(diffErasureCodingCodecs.containsKey(key)); |
| 2200 | + Assert.assertEquals(value, diffErasureCodingCodecs.get(key)); |
2190 | 2201 | }
|
2191 | 2202 | }
|
2192 | 2203 |
|
|
0 commit comments