Skip to content

Commit 420a1a8

Browse files
committed
Merge branch 'master' into snapshot
2 parents dc76df3 + aee480a commit 420a1a8

File tree

5 files changed

+191
-6
lines changed

5 files changed

+191
-6
lines changed

pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818
<artifactId>hadoop-core</artifactId>
1919
<version>0.20.2</version>
2020
</dependency>
21+
<dependency>
22+
<groupId>org.apache.hadoop</groupId>
23+
<artifactId>hadoop-common-test</artifactId>
24+
<version>0.22.0</version>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.apache.hadoop</groupId>
28+
<artifactId>hadoop-test</artifactId>
29+
<version>1.0.0</version>
30+
</dependency>
2131
<dependency>
2232
<groupId>org.slf4j</groupId>
2333
<artifactId>slf4j-api</artifactId>

src/test/java/org/gluster/test/GFSUtil.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public static Configuration initializeConfig(File mount, boolean automount) thro
6161
conf.set("fs.glusterfs.mount", mount.getAbsolutePath());
6262
conf.set("fs.glusterfs.server", glusterHost);
6363
conf.set("fs.default.name", "glusterfs://"+glusterHost+":9000");
64-
64+
//Not necessary - but for 1.0 might be.
65+
conf.set("fs.glusterfs.impl", "org.apache.hadoop.fs.glusterfs.GlusterFileSystem");
6566
return conf;
6667
}
6768

@@ -91,10 +92,7 @@ public static File initializeMounts(File tempDirectory) throws Exception {
9192
*/
9293
static GlusterFileSystem gfs ;
9394

94-
/**
95-
* Use this method to create a new instance of a gluster file system class.
96-
*/
97-
public static GlusterFileSystem create(boolean automount) throws Exception{
95+
public static Configuration createConfiguration(boolean automount) throws Exception{
9896
if(gfs != null){
9997
gfs.close();
10098
}
@@ -105,7 +103,14 @@ public static GlusterFileSystem create(boolean automount) throws Exception{
105103

106104
//Now set up the config object, with automount=true
107105
final Configuration conf = initializeConfig(mount,automount);
108-
106+
return conf;
107+
}
108+
/**
109+
* Use this method to create a new instance of a gluster file system class.
110+
*/
111+
public static GlusterFileSystem create(boolean automount) throws Exception{
112+
113+
Configuration conf = createConfiguration(automount);
109114
//Initialize GlusterFileSystem
110115
gfs.initialize(getTempDirectory().toURI(), conf);
111116

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.gluster.test;
2+
3+
import java.io.IOException;
4+
5+
import junit.framework.Assert;
6+
7+
import org.apache.hadoop.conf.Configuration;
8+
import org.apache.hadoop.fs.FSMainOperationsBaseTest;
9+
import org.apache.hadoop.fs.FileSystem;
10+
import org.apache.hadoop.fs.FileSystemTestHelper;
11+
import org.apache.hadoop.fs.Path;
12+
import org.apache.tools.ant.util.FileUtils;
13+
import org.junit.After;
14+
import org.junit.AfterClass;
15+
import org.junit.Before;
16+
import org.junit.Test;
17+
18+
public class TestFSMainOperationsGlusterFileSystem extends FSMainOperationsBaseTest {
19+
20+
@Before
21+
public void setUp() throws Exception {
22+
fSys =GFSUtil.create(true);
23+
super.setUp();
24+
}
25+
26+
static Path wd = null;
27+
protected Path getDefaultWorkingDirectory() throws IOException {
28+
if (wd == null)
29+
wd = fSys.getWorkingDirectory();
30+
return wd;
31+
}
32+
33+
@After
34+
public void tearDown() throws Exception {
35+
fSys.close();
36+
FileUtils.delete(GFSUtil.getTempDirectory());
37+
}
38+
39+
@Test
40+
@Override
41+
public void testWDAbsolute() throws IOException {
42+
Path absoluteDir = FileSystemTestHelper.getTestRootPath(fSys,
43+
"test/existingDir");
44+
fSys.mkdirs(absoluteDir);
45+
fSys.setWorkingDirectory(absoluteDir);
46+
Assert.assertEquals(absoluteDir, fSys.getWorkingDirectory());
47+
}
48+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.gluster.test;
2+
3+
import java.io.File;
4+
import java.io.FileOutputStream;
5+
import java.io.IOException;
6+
7+
import org.apache.hadoop.conf.Configuration;
8+
import org.apache.hadoop.fs.TestGetFileBlockLocations;
9+
10+
public class TestGlusterFileBlockLocations extends TestGetFileBlockLocations{
11+
12+
@Override
13+
protected void setUp() throws IOException{
14+
try{
15+
Configuration cfg = GFSUtil.createConfiguration(true);
16+
cfg.writeXml(new FileOutputStream(new File("/tmp/core-site.xml")));
17+
Configuration.addDefaultResource("/tmp/core-site.xml");
18+
cfg.writeXml(System.out);
19+
}
20+
catch(Exception e)
21+
{
22+
throw new IOException(e);
23+
}
24+
super.setUp();
25+
}
26+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
19+
package org.gluster.test;
20+
21+
import java.io.IOException;
22+
23+
import org.apache.hadoop.fs.FileSystemContractBaseTest;
24+
import org.slf4j.LoggerFactory;
25+
26+
/**
27+
* This is the full filesystem contract test -which requires the
28+
* Default config set up to point to a filesystem
29+
*/
30+
public class TestGlusterFileSystemContract
31+
extends FileSystemContractBaseTest {
32+
private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(TestGlusterFileSystemContract.class);
33+
34+
@Override
35+
protected void setUp() throws Exception{
36+
fs=GFSUtil.create(true);
37+
super.setUp();
38+
}
39+
40+
/**
41+
* junit.framework.AssertionFailedError: Rename result expected:<false> but was:<true>
42+
*/
43+
@Override
44+
public void testRenameFileAsExistingFile() throws Exception{
45+
super.testRenameFileAsExistingFile();
46+
}
47+
48+
/**
49+
* java.lang.RuntimeException: org.apache.hadoop.util.Shell$ExitCodeException: chmod: cannot access `/tmp/gluster-test-mount-point/mount/test/hadoop/file/subdir': Not a directory
50+
*/
51+
@Override
52+
public void testMkdirsFailsForSubdirectoryOfExistingFile() throws Exception{
53+
super.testMkdirsFailsForSubdirectoryOfExistingFile();
54+
}
55+
56+
/**
57+
* java.io.IOException: Stream closed.
58+
*/
59+
@Override
60+
public void testOutputStreamClosedTwice() throws IOException{
61+
super.testOutputStreamClosedTwice();
62+
}
63+
64+
/**
65+
* junit.framework.AssertionFailedError: Rename result expected:<false> but was:<true>
66+
*/
67+
@Override
68+
public void testListStatusThrowsExceptionForNonExistentFile() throws Exception{
69+
super.testListStatusThrowsExceptionForNonExistentFile();
70+
}
71+
72+
/**
73+
* junit.framework.AssertionFailedError: expected:<file://null/user/root> but was:</tmp/gluster-test-mount-point/mount>
74+
*/
75+
@Override
76+
public void testWorkingDirectory() throws Exception{
77+
super.testWorkingDirectory();
78+
}
79+
80+
/**
81+
* AssertionFailedError: null
82+
*/
83+
@Override
84+
public void testMkdirs() throws Exception{
85+
super.testMkdirs();
86+
}
87+
88+
/**
89+
java.lang.NoSuchMethodError: org.apache.hadoop.fs.FileSystem.getStatus()Lorg/apache/hadoop/fs/FsStatus;
90+
*/
91+
@Override
92+
public void testFsStatus() throws Exception{
93+
super.testFsStatus();
94+
}
95+
96+
}

0 commit comments

Comments
 (0)