Skip to content

Commit aac854d

Browse files
committed
Multiple volume unit test, along with a fix to remove canonicalization of the URI when not always desirable.
1 parent 05d4e23 commit aac854d

File tree

2 files changed

+59
-2
lines changed

2 files changed

+59
-2
lines changed

src/main/java/org/apache/hadoop/fs/glusterfs/GlusterVolume.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ protected URI canonicalizeUri(URI uri) {
9292

9393
/* check if a path is on the same volume as this instance */
9494
public boolean sameVolume(Path p){
95-
URI thisUri = canonicalizeUri(this.NAME);
96-
URI thatUri = canonicalizeUri(p.toUri());
95+
URI thisUri = this.NAME;
96+
URI thatUri = p.toUri();
9797
if(!thatUri.getScheme().equalsIgnoreCase(thisUri.getScheme())) return false;
9898
if((thatUri.getAuthority()==null && thisUri.getAuthority()==null)) return true;
9999
return (thatUri.getAuthority()!=null && thatUri.getAuthority().equalsIgnoreCase(thisUri.getAuthority()));
@@ -179,7 +179,9 @@ public void setConf(Configuration conf){
179179
}
180180

181181
public File pathToFile(Path path) {
182+
182183
if(path==null) return null;
184+
183185
checkPath(path);
184186

185187
if (!path.isAbsolute()) {
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package org.apache.hadoop.fs.test.unit;
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.FileSystem;
9+
import org.apache.hadoop.fs.Path;
10+
import org.apache.hadoop.fs.test.connector.HcfsTestConnectorFactory;
11+
import org.apache.hadoop.fs.test.connector.HcfsTestConnectorInterface;
12+
import org.junit.After;
13+
import org.junit.AfterClass;
14+
import org.junit.BeforeClass;
15+
import org.junit.Test;
16+
import org.slf4j.Logger;
17+
import org.slf4j.LoggerFactory;
18+
19+
public class GlusterMultipleVolumeTest {
20+
21+
Logger log = LoggerFactory.getLogger(HCFSPerformanceIOTests.class);
22+
static Configuration config = null;
23+
24+
25+
@BeforeClass
26+
public static void setup() throws Exception {
27+
HcfsTestConnectorInterface connector = HcfsTestConnectorFactory.getHcfsTestConnector();
28+
config = connector.createConfiguration();
29+
}
30+
31+
public static FileSystem getFileSystem(Path p) throws IOException{
32+
return FileSystem.get(p.toUri(), config);
33+
}
34+
35+
@Test
36+
public void testDefaultPath() throws IOException{
37+
Path p1 = new Path("glusterfs:///test1.txt");
38+
Path p2 = new Path("glusterfs://gv0/test1.txt");
39+
Path p3 = new Path("glusterfs://gv1/test1.txt");
40+
41+
FileSystem fs1 = getFileSystem(p1);
42+
FileSystem fs2 = getFileSystem(p2);
43+
FileSystem fs3 = getFileSystem(p3);
44+
fs1.create(p1);
45+
46+
/* the gluster volume and default is based on configuration settings, but expected that default = gv0 */
47+
Assert.assertTrue(fs1.exists(p1));
48+
Assert.assertTrue(fs2.exists(p2));
49+
Assert.assertFalse(fs3.exists(p3));
50+
51+
fs1.delete(p1);
52+
}
53+
54+
55+
}

0 commit comments

Comments
 (0)