1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  *  or more contributor license agreements.  See the NOTICE file
4  *  distributed with this work for additional information
5  *  regarding copyright ownership.  The ASF licenses this file
6  *  to you under the Apache License, Version 2.0 (the
7  *  "License"); you may not use this file except in compliance
8  *  with the License.  You may obtain a copy of the License at
9  *
10  *       http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  */
18 package org.apache.hadoop.fs.swift;
19 
20 
21 import org.apache.hadoop.conf.Configuration;
22 import org.apache.hadoop.fs.FSMainOperationsBaseTest;
23 import org.apache.hadoop.fs.FileSystem;
24 import org.apache.hadoop.fs.Path;
25 import org.apache.hadoop.fs.swift.http.SwiftProtocolConstants;
26 import org.apache.hadoop.fs.swift.util.SwiftTestUtils;
27 import org.junit.Assert;
28 import org.junit.Before;
29 import org.junit.Test;
30 import static org.apache.hadoop.fs.swift.SwiftTestConstants.SWIFT_TEST_TIMEOUT;
31 import java.io.IOException;
32 import java.net.URI;
33 
34 public class TestFSMainOperationsSwift extends FSMainOperationsBaseTest {
35 
36   @Override
37   @Before
setUp()38   public void setUp() throws Exception {
39     Configuration conf = new Configuration();
40     //small blocksize for faster remote tests
41     conf.setInt(SwiftProtocolConstants.SWIFT_BLOCKSIZE, 2);
42     URI serviceURI = SwiftTestUtils.getServiceURI(conf);
43     fSys = FileSystem.get(serviceURI, conf);
44     super.setUp();
45   }
46 
47   private Path wd = null;
48 
49   @Override
createFileSystem()50   protected FileSystem createFileSystem() throws Exception {
51     return fSys;
52   }
53 
54   @Override
getDefaultWorkingDirectory()55   protected Path getDefaultWorkingDirectory() throws IOException {
56     if (wd == null) {
57       wd = fSys.getWorkingDirectory();
58     }
59     return wd;
60   }
61 
62   @Test(timeout = SWIFT_TEST_TIMEOUT)
63   @Override
testWDAbsolute()64   public void testWDAbsolute() throws IOException {
65     Path absoluteDir = getTestRootPath(fSys, "test/existingDir");
66     fSys.mkdirs(absoluteDir);
67     fSys.setWorkingDirectory(absoluteDir);
68     Assert.assertEquals(absoluteDir, fSys.getWorkingDirectory());
69   }
70 
71   @Test(timeout = SWIFT_TEST_TIMEOUT)
72   @Override
testListStatusThrowsExceptionForUnreadableDir()73   public void testListStatusThrowsExceptionForUnreadableDir() {
74     SwiftTestUtils.skip("unsupported");
75   }
76 
77   @Test(timeout = SWIFT_TEST_TIMEOUT)
78   @Override
testFsStatus()79   public void testFsStatus() throws Exception {
80     super.testFsStatus();
81   }
82 
83   @Test(timeout = SWIFT_TEST_TIMEOUT)
84   @Override
testWorkingDirectory()85   public void testWorkingDirectory() throws Exception {
86     super.testWorkingDirectory();
87   }
88 
89   @Test(timeout = SWIFT_TEST_TIMEOUT)
90   @Override
testMkdirs()91   public void testMkdirs() throws Exception {
92     super.testMkdirs();
93   }
94 
95   @Test(timeout = SWIFT_TEST_TIMEOUT)
96   @Override
testMkdirsFailsForSubdirectoryOfExistingFile()97   public void testMkdirsFailsForSubdirectoryOfExistingFile() throws Exception {
98     super.testMkdirsFailsForSubdirectoryOfExistingFile();
99   }
100 
101   @Test(timeout = SWIFT_TEST_TIMEOUT)
102   @Override
testGetFileStatusThrowsExceptionForNonExistentFile()103   public void testGetFileStatusThrowsExceptionForNonExistentFile() throws
104                                                                    Exception {
105     super.testGetFileStatusThrowsExceptionForNonExistentFile();
106   }
107 
108   @Test(timeout = SWIFT_TEST_TIMEOUT)
109   @Override
testListStatusThrowsExceptionForNonExistentFile()110   public void testListStatusThrowsExceptionForNonExistentFile() throws
111                                                                 Exception {
112     super.testListStatusThrowsExceptionForNonExistentFile();
113   }
114 
115   @Test(timeout = SWIFT_TEST_TIMEOUT)
116   @Override
testListStatus()117   public void testListStatus() throws Exception {
118     super.testListStatus();
119   }
120 
121   @Test(timeout = SWIFT_TEST_TIMEOUT)
122   @Override
testListStatusFilterWithNoMatches()123   public void testListStatusFilterWithNoMatches() throws Exception {
124     super.testListStatusFilterWithNoMatches();
125   }
126 
127   @Test(timeout = SWIFT_TEST_TIMEOUT)
128   @Override
testListStatusFilterWithSomeMatches()129   public void testListStatusFilterWithSomeMatches() throws Exception {
130     super.testListStatusFilterWithSomeMatches();
131   }
132 
133   @Test(timeout = SWIFT_TEST_TIMEOUT)
134   @Override
testGlobStatusNonExistentFile()135   public void testGlobStatusNonExistentFile() throws Exception {
136     super.testGlobStatusNonExistentFile();
137   }
138 
139   @Test(timeout = SWIFT_TEST_TIMEOUT)
140   @Override
testGlobStatusWithNoMatchesInPath()141   public void testGlobStatusWithNoMatchesInPath() throws Exception {
142     super.testGlobStatusWithNoMatchesInPath();
143   }
144 
145   @Test(timeout = SWIFT_TEST_TIMEOUT)
146   @Override
testGlobStatusSomeMatchesInDirectories()147   public void testGlobStatusSomeMatchesInDirectories() throws Exception {
148     super.testGlobStatusSomeMatchesInDirectories();
149   }
150 
151   @Test(timeout = SWIFT_TEST_TIMEOUT)
152   @Override
testGlobStatusWithMultipleWildCardMatches()153   public void testGlobStatusWithMultipleWildCardMatches() throws Exception {
154     super.testGlobStatusWithMultipleWildCardMatches();
155   }
156 
157   @Test(timeout = SWIFT_TEST_TIMEOUT)
158   @Override
testGlobStatusWithMultipleMatchesOfSingleChar()159   public void testGlobStatusWithMultipleMatchesOfSingleChar() throws Exception {
160     super.testGlobStatusWithMultipleMatchesOfSingleChar();
161   }
162 
163   @Test(timeout = SWIFT_TEST_TIMEOUT)
164   @Override
testGlobStatusFilterWithEmptyPathResults()165   public void testGlobStatusFilterWithEmptyPathResults() throws Exception {
166     super.testGlobStatusFilterWithEmptyPathResults();
167   }
168 
169   @Test(timeout = SWIFT_TEST_TIMEOUT)
170   @Override
testGlobStatusFilterWithSomePathMatchesAndTrivialFilter()171   public void testGlobStatusFilterWithSomePathMatchesAndTrivialFilter() throws
172                                                                         Exception {
173     super.testGlobStatusFilterWithSomePathMatchesAndTrivialFilter();
174   }
175 
176   @Test(timeout = SWIFT_TEST_TIMEOUT)
177   @Override
testGlobStatusFilterWithMultipleWildCardMatchesAndTrivialFilter()178   public void testGlobStatusFilterWithMultipleWildCardMatchesAndTrivialFilter() throws
179                                                                                 Exception {
180     super.testGlobStatusFilterWithMultipleWildCardMatchesAndTrivialFilter();
181   }
182 
183   @Test(timeout = SWIFT_TEST_TIMEOUT)
184   @Override
testGlobStatusFilterWithMultiplePathMatchesAndNonTrivialFilter()185   public void testGlobStatusFilterWithMultiplePathMatchesAndNonTrivialFilter() throws
186                                                                                Exception {
187     super.testGlobStatusFilterWithMultiplePathMatchesAndNonTrivialFilter();
188   }
189 
190   @Test(timeout = SWIFT_TEST_TIMEOUT)
191   @Override
testGlobStatusFilterWithNoMatchingPathsAndNonTrivialFilter()192   public void testGlobStatusFilterWithNoMatchingPathsAndNonTrivialFilter() throws
193                                                                            Exception {
194     super.testGlobStatusFilterWithNoMatchingPathsAndNonTrivialFilter();
195   }
196 
197   @Test(timeout = SWIFT_TEST_TIMEOUT)
198   @Override
testGlobStatusFilterWithMultiplePathWildcardsAndNonTrivialFilter()199   public void testGlobStatusFilterWithMultiplePathWildcardsAndNonTrivialFilter() throws
200                                                                                  Exception {
201     super.testGlobStatusFilterWithMultiplePathWildcardsAndNonTrivialFilter();
202   }
203 
204   @Test(timeout = SWIFT_TEST_TIMEOUT)
205   @Override
testWriteReadAndDeleteEmptyFile()206   public void testWriteReadAndDeleteEmptyFile() throws Exception {
207     super.testWriteReadAndDeleteEmptyFile();
208   }
209 
210   @Test(timeout = SWIFT_TEST_TIMEOUT)
211   @Override
testWriteReadAndDeleteHalfABlock()212   public void testWriteReadAndDeleteHalfABlock() throws Exception {
213     super.testWriteReadAndDeleteHalfABlock();
214   }
215 
216   @Test(timeout = SWIFT_TEST_TIMEOUT)
217   @Override
testWriteReadAndDeleteOneBlock()218   public void testWriteReadAndDeleteOneBlock() throws Exception {
219     super.testWriteReadAndDeleteOneBlock();
220   }
221 
222   @Test(timeout = SWIFT_TEST_TIMEOUT)
223   @Override
testWriteReadAndDeleteOneAndAHalfBlocks()224   public void testWriteReadAndDeleteOneAndAHalfBlocks() throws Exception {
225     super.testWriteReadAndDeleteOneAndAHalfBlocks();
226   }
227 
228   @Test(timeout = SWIFT_TEST_TIMEOUT)
229   @Override
testWriteReadAndDeleteTwoBlocks()230   public void testWriteReadAndDeleteTwoBlocks() throws Exception {
231     super.testWriteReadAndDeleteTwoBlocks();
232   }
233 
234   @Test(timeout = SWIFT_TEST_TIMEOUT)
235   @Override
testOverwrite()236   public void testOverwrite() throws IOException {
237     super.testOverwrite();
238   }
239 
240   @Test(timeout = SWIFT_TEST_TIMEOUT)
241   @Override
testWriteInNonExistentDirectory()242   public void testWriteInNonExistentDirectory() throws IOException {
243     super.testWriteInNonExistentDirectory();
244   }
245 
246   @Test(timeout = SWIFT_TEST_TIMEOUT)
247   @Override
testDeleteNonExistentFile()248   public void testDeleteNonExistentFile() throws IOException {
249     super.testDeleteNonExistentFile();
250   }
251 
252   @Test(timeout = SWIFT_TEST_TIMEOUT)
253   @Override
testDeleteRecursively()254   public void testDeleteRecursively() throws IOException {
255     super.testDeleteRecursively();
256   }
257 
258   @Test(timeout = SWIFT_TEST_TIMEOUT)
259   @Override
testDeleteEmptyDirectory()260   public void testDeleteEmptyDirectory() throws IOException {
261     super.testDeleteEmptyDirectory();
262   }
263 
264   @Test(timeout = SWIFT_TEST_TIMEOUT)
265   @Override
testRenameNonExistentPath()266   public void testRenameNonExistentPath() throws Exception {
267     super.testRenameNonExistentPath();
268   }
269 
270   @Test(timeout = SWIFT_TEST_TIMEOUT)
271   @Override
testRenameFileToNonExistentDirectory()272   public void testRenameFileToNonExistentDirectory() throws Exception {
273     super.testRenameFileToNonExistentDirectory();
274   }
275 
276   @Test(timeout = SWIFT_TEST_TIMEOUT)
277   @Override
testRenameFileToDestinationWithParentFile()278   public void testRenameFileToDestinationWithParentFile() throws Exception {
279     super.testRenameFileToDestinationWithParentFile();
280   }
281 
282   @Test(timeout = SWIFT_TEST_TIMEOUT)
283   @Override
testRenameFileToExistingParent()284   public void testRenameFileToExistingParent() throws Exception {
285     super.testRenameFileToExistingParent();
286   }
287 
288   @Test(timeout = SWIFT_TEST_TIMEOUT)
289   @Override
testRenameFileToItself()290   public void testRenameFileToItself() throws Exception {
291     super.testRenameFileToItself();
292   }
293 
294   @Test(timeout = SWIFT_TEST_TIMEOUT)
295   @Override
testRenameFileAsExistingFile()296   public void testRenameFileAsExistingFile() throws Exception {
297     super.testRenameFileAsExistingFile();
298   }
299 
300   @Test(timeout = SWIFT_TEST_TIMEOUT)
301   @Override
testRenameFileAsExistingDirectory()302   public void testRenameFileAsExistingDirectory() throws Exception {
303     super.testRenameFileAsExistingDirectory();
304   }
305 
306   @Test(timeout = SWIFT_TEST_TIMEOUT)
307   @Override
testRenameDirectoryToItself()308   public void testRenameDirectoryToItself() throws Exception {
309     super.testRenameDirectoryToItself();
310   }
311 
312   @Test(timeout = SWIFT_TEST_TIMEOUT)
313   @Override
testRenameDirectoryToNonExistentParent()314   public void testRenameDirectoryToNonExistentParent() throws Exception {
315     super.testRenameDirectoryToNonExistentParent();
316   }
317 
318   @Test(timeout = SWIFT_TEST_TIMEOUT)
319   @Override
testRenameDirectoryAsNonExistentDirectory()320   public void testRenameDirectoryAsNonExistentDirectory() throws Exception {
321     super.testRenameDirectoryAsNonExistentDirectory();
322   }
323 
324   @Test(timeout = SWIFT_TEST_TIMEOUT)
325   @Override
testRenameDirectoryAsEmptyDirectory()326   public void testRenameDirectoryAsEmptyDirectory() throws Exception {
327     super.testRenameDirectoryAsEmptyDirectory();
328   }
329 
330   @Test(timeout = SWIFT_TEST_TIMEOUT)
331   @Override
testRenameDirectoryAsNonEmptyDirectory()332   public void testRenameDirectoryAsNonEmptyDirectory() throws Exception {
333     super.testRenameDirectoryAsNonEmptyDirectory();
334   }
335 
336   @Test(timeout = SWIFT_TEST_TIMEOUT)
337   @Override
testRenameDirectoryAsFile()338   public void testRenameDirectoryAsFile() throws Exception {
339     super.testRenameDirectoryAsFile();
340   }
341 
342   @Test(timeout = SWIFT_TEST_TIMEOUT)
343   @Override
testInputStreamClosedTwice()344   public void testInputStreamClosedTwice() throws IOException {
345     super.testInputStreamClosedTwice();
346   }
347 
348   @Test(timeout = SWIFT_TEST_TIMEOUT)
349   @Override
testOutputStreamClosedTwice()350   public void testOutputStreamClosedTwice() throws IOException {
351     super.testOutputStreamClosedTwice();
352   }
353 
354   @Test(timeout = SWIFT_TEST_TIMEOUT)
355   @Override
testGetWrappedInputStream()356   public void testGetWrappedInputStream() throws IOException {
357     super.testGetWrappedInputStream();
358   }
359 
360   @Test(timeout = SWIFT_TEST_TIMEOUT)
361   @Override
testCopyToLocalWithUseRawLocalFileSystemOption()362   public void testCopyToLocalWithUseRawLocalFileSystemOption() throws
363                                                                Exception {
364     super.testCopyToLocalWithUseRawLocalFileSystemOption();
365   }
366 }
367