This is an automated email from the ASF dual-hosted git repository.
jongyoul pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git
The following commit(s) were added to refs/heads/master by this push:
new 4e9cab538e [ZEPPELIN-5771]Zeppelin Interpreter Support Alluxio From
1.0.0 To 2.5.0 (#4410)
4e9cab538e is described below
commit 4e9cab538e75faa9f4168143f1fdd25c27abedb2
Author: Lu Gan <[email protected]>
AuthorDate: Tue Jul 26 14:30:50 2022 +0800
[ZEPPELIN-5771]Zeppelin Interpreter Support Alluxio From 1.0.0 To 2.5.0
(#4410)
* [ZEPPELIN-5771]Zeppelin Interpreter Support Alluxio From 1.0.0 To 2.5.0
* [ZEPPELIN-5771]Fix CheckStyle
* Adjust CI test case to pass alluxio 2.x
* Fix check style
* adapt zeppelin ci
* remove unnecessary test cases
Co-authored-by: glennlgan <[email protected]>
---
alluxio/pom.xml | 38 +--
.../zeppelin/alluxio/AlluxioInterpreter.java | 16 +-
.../zeppelin/alluxio/AlluxioInterpreterTest.java | 332 +++------------------
3 files changed, 62 insertions(+), 324 deletions(-)
diff --git a/alluxio/pom.xml b/alluxio/pom.xml
index 5712519f43..0920c3c512 100644
--- a/alluxio/pom.xml
+++ b/alluxio/pom.xml
@@ -32,24 +32,31 @@
<name>Zeppelin: Alluxio interpreter</name>
<properties>
- <alluxio.version>1.0.0</alluxio.version>
+ <alluxio.version>2.5.0</alluxio.version>
<interpreter.name>alluxio</interpreter.name>
</properties>
<dependencies>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>15.0</version>
+ <groupId>org.alluxio</groupId>
+ <artifactId>alluxio-shell</artifactId>
+ <version>${alluxio.version}</version>
</dependency>
+ <!-- TEST -->
<dependency>
- <groupId>org.alluxio</groupId>
- <artifactId>alluxio-shell</artifactId>
- <version>${alluxio.version}</version>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>29.0-jre</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <version>3.12.4</version>
+ <scope>test</scope>
</dependency>
- <!-- TEST -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
@@ -80,13 +87,6 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.alluxio</groupId>
- <artifactId>alluxio-core-server</artifactId>
- <version>${alluxio.version}</version>
- <scope>test</scope>
- </dependency>
-
<dependency>
<groupId>org.alluxio</groupId>
<artifactId>alluxio-minicluster</artifactId>
@@ -94,19 +94,13 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.alluxio</groupId>
- <artifactId>alluxio-underfs-local</artifactId>
- <version>${alluxio.version}</version>
- <scope>test</scope>
- </dependency>
-
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>3.2.3</version>
<scope>test</scope>
</dependency>
+
</dependencies>
<build>
diff --git
a/alluxio/src/main/java/org/apache/zeppelin/alluxio/AlluxioInterpreter.java
b/alluxio/src/main/java/org/apache/zeppelin/alluxio/AlluxioInterpreter.java
index be912ecab5..72e349307c 100644
--- a/alluxio/src/main/java/org/apache/zeppelin/alluxio/AlluxioInterpreter.java
+++ b/alluxio/src/main/java/org/apache/zeppelin/alluxio/AlluxioInterpreter.java
@@ -18,6 +18,11 @@
package org.apache.zeppelin.alluxio;
+import alluxio.cli.fs.FileSystemShell;
+import alluxio.conf.InstancedConfiguration;
+import alluxio.conf.PropertyKey;
+import alluxio.conf.Source;
+import alluxio.util.ConfigurationUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,8 +35,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
-import alluxio.Configuration;
-import alluxio.shell.AlluxioShell;
import org.apache.zeppelin.completer.CompletionType;
import org.apache.zeppelin.interpreter.Interpreter;
@@ -50,7 +53,7 @@ public class AlluxioInterpreter extends Interpreter {
protected static final String ALLUXIO_MASTER_HOSTNAME =
"alluxio.master.hostname";
protected static final String ALLUXIO_MASTER_PORT = "alluxio.master.port";
- private AlluxioShell fs;
+ private FileSystemShell fs;
private int totalCommands = 0;
private int completedCommands = 0;
@@ -80,13 +83,16 @@ public class AlluxioInterpreter extends Interpreter {
System.setProperty(ALLUXIO_MASTER_HOSTNAME, alluxioMasterHostname);
System.setProperty(ALLUXIO_MASTER_PORT, alluxioMasterPort);
- fs = new AlluxioShell(new Configuration());
+
+ InstancedConfiguration conf = new
InstancedConfiguration(ConfigurationUtils.defaults());
+ // Reduce the RPC retry max duration to fall earlier for CLIs
+ conf.set(PropertyKey.USER_RPC_RETRY_MAX_DURATION, "5s", Source.DEFAULT);
+ fs = new FileSystemShell(conf);
}
@Override
public void close() {
logger.info("Closing Alluxio shell");
-
try {
fs.close();
} catch (IOException e) {
diff --git
a/alluxio/src/test/java/org/apache/zeppelin/alluxio/AlluxioInterpreterTest.java
b/alluxio/src/test/java/org/apache/zeppelin/alluxio/AlluxioInterpreterTest.java
index 06711de326..ee9c8f3471 100644
---
a/alluxio/src/test/java/org/apache/zeppelin/alluxio/AlluxioInterpreterTest.java
+++
b/alluxio/src/test/java/org/apache/zeppelin/alluxio/AlluxioInterpreterTest.java
@@ -18,14 +18,17 @@
package org.apache.zeppelin.alluxio;
+
+import alluxio.conf.ServerConfiguration;
+import alluxio.grpc.WritePType;
+import alluxio.client.file.FileSystemTestUtils;
+import alluxio.master.LocalAlluxioCluster;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -33,17 +36,9 @@ import java.util.List;
import java.util.Properties;
import alluxio.AlluxioURI;
-import alluxio.Constants;
-import alluxio.client.FileSystemTestUtils;
-import alluxio.client.WriteType;
-import alluxio.client.file.FileInStream;
import alluxio.client.file.FileSystem;
import alluxio.client.file.URIStatus;
import alluxio.exception.AlluxioException;
-import alluxio.exception.ExceptionMessage;
-import alluxio.master.LocalAlluxioCluster;
-import alluxio.shell.command.CommandUtils;
-import alluxio.util.FormatUtils;
import alluxio.util.io.BufferUtils;
import alluxio.util.io.PathUtils;
@@ -52,9 +47,11 @@ import org.apache.zeppelin.interpreter.InterpreterResult;
import org.apache.zeppelin.interpreter.InterpreterResult.Code;
import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
+import static alluxio.cli.fs.command.CountCommand.COUNT_FORMAT;
+import static org.junit.Assert.assertEquals;
+
public class AlluxioInterpreterTest {
private AlluxioInterpreter alluxioInterpreter;
- private static final int SIZE_BYTES = Constants.MB * 10;
private LocalAlluxioCluster mLocalAlluxioCluster = null;
private FileSystem fs = null;
@@ -63,18 +60,22 @@ public class AlluxioInterpreterTest {
if (alluxioInterpreter != null) {
alluxioInterpreter.close();
}
+
mLocalAlluxioCluster.stop();
}
@Before
public final void before() throws Exception {
- mLocalAlluxioCluster = new LocalAlluxioCluster(SIZE_BYTES, 1000);
+ mLocalAlluxioCluster = new LocalAlluxioCluster(1);
+ mLocalAlluxioCluster.initConfiguration("alluxio-test");
+ ServerConfiguration.global().validate();
mLocalAlluxioCluster.start();
+
fs = mLocalAlluxioCluster.getClient();
final Properties props = new Properties();
- props.put(AlluxioInterpreter.ALLUXIO_MASTER_HOSTNAME,
mLocalAlluxioCluster.getMasterHostname());
- props.put(AlluxioInterpreter.ALLUXIO_MASTER_PORT,
mLocalAlluxioCluster.getMasterPort() + "");
+ props.put(AlluxioInterpreter.ALLUXIO_MASTER_HOSTNAME,
mLocalAlluxioCluster.getHostname());
+ props.put(AlluxioInterpreter.ALLUXIO_MASTER_PORT,
mLocalAlluxioCluster.getMasterRpcPort() + "");
alluxioInterpreter = new AlluxioInterpreter(props);
alluxioInterpreter.open();
}
@@ -121,28 +122,9 @@ public class AlluxioInterpreterTest {
Assert.assertEquals(alluxioInterpreter.keywords, allCompletionList);
}
- @Test
- public void catDirectoryTest() throws IOException {
- String expected = "Successfully created directory /testDir\n\n" +
- "Path /testDir must be a file\n";
-
- InterpreterResult output = alluxioInterpreter.interpret("mkdir /testDir" +
- "\ncat /testDir", null);
-
- Assert.assertEquals(Code.ERROR, output.code());
- Assert.assertEquals(expected, output.message().get(0).getData());
- }
-
- @Test
- public void catNotExistTest() throws IOException {
- InterpreterResult output = alluxioInterpreter.interpret("cat /testFile",
null);
- Assert.assertEquals(Code.ERROR, output.code());
- }
-
@Test
public void catTest() throws IOException {
- FileSystemTestUtils.createByteFile(fs, "/testFile", WriteType.MUST_CACHE,
- 10, 10);
+ FileSystemTestUtils.createByteFile(fs, "/testFile", WritePType.MUST_CACHE,
10, 10);
InterpreterResult output = alluxioInterpreter.interpret("cat /testFile",
null);
byte[] expected = BufferUtils.getIncreasingByteArray(10);
@@ -153,33 +135,9 @@ public class AlluxioInterpreterTest {
output.message().get(0).getData().length() -
1).getBytes());
}
- @Test
- public void copyFromLocalLargeTest() throws IOException, AlluxioException {
- File testFile = new File(mLocalAlluxioCluster.getAlluxioHome() +
"/testFile");
- testFile.createNewFile();
- FileOutputStream fos = new FileOutputStream(testFile);
- byte[] toWrite = BufferUtils.getIncreasingByteArray(SIZE_BYTES);
- fos.write(toWrite);
- fos.close();
-
- InterpreterResult output = alluxioInterpreter.interpret("copyFromLocal " +
- testFile.getAbsolutePath() + " /testFile", null);
- Assert.assertEquals(
- "Copied " + testFile.getAbsolutePath() + " to /testFile\n\n",
- output.message().get(0).getData());
-
- long fileLength = fs.getStatus(new AlluxioURI("/testFile")).getLength();
- Assert.assertEquals(SIZE_BYTES, fileLength);
-
- FileInStream fStream = fs.openFile(new AlluxioURI("/testFile"));
- byte[] read = new byte[SIZE_BYTES];
- fStream.read(read);
- Assert.assertTrue(BufferUtils.equalIncreasingByteArray(SIZE_BYTES, read));
- }
-
@Test
public void loadFileTest() throws IOException, AlluxioException {
- FileSystemTestUtils.createByteFile(fs, "/testFile",
WriteType.CACHE_THROUGH, 10, 10);
+ FileSystemTestUtils.createByteFile(fs, "/testFile",
WritePType.CACHE_THROUGH, 10, 10);
int memPercentage = fs.getStatus(new
AlluxioURI("/testFile")).getInMemoryPercentage();
Assert.assertFalse(memPercentage == 0);
@@ -190,162 +148,42 @@ public class AlluxioInterpreterTest {
Assert.assertTrue(memPercentage == 100);
}
- @Test
- public void loadDirTest() throws IOException, AlluxioException {
- FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA",
WriteType.CACHE_THROUGH, 10, 10);
- FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileB",
WriteType.MUST_CACHE, 10, 10);
-
- int memPercentageA = fs.getStatus(
- new AlluxioURI("/testRoot/testFileA")).getInMemoryPercentage();
- int memPercentageB = fs.getStatus(
- new AlluxioURI("/testRoot/testFileB")).getInMemoryPercentage();
- Assert.assertFalse(memPercentageA == 0);
- Assert.assertTrue(memPercentageB == 100);
-
- alluxioInterpreter.interpret("load /testRoot", null);
-
- memPercentageA = fs.getStatus(new
AlluxioURI("/testRoot/testFileA")).getInMemoryPercentage();
- memPercentageB = fs.getStatus(new
AlluxioURI("/testRoot/testFileB")).getInMemoryPercentage();
- Assert.assertTrue(memPercentageA == 100);
- Assert.assertTrue(memPercentageB == 100);
- }
-
- @Test
- public void copyFromLocalTest() throws IOException, AlluxioException {
- File testDir = new File(mLocalAlluxioCluster.getAlluxioHome() +
"/testDir");
- testDir.mkdir();
- File testDirInner = new File(mLocalAlluxioCluster.getAlluxioHome() +
"/testDir/testDirInner");
- testDirInner.mkdir();
- File testFile =
- generateFileContent("/testDir/testFile",
BufferUtils.getIncreasingByteArray(10));
-
- generateFileContent("/testDir/testDirInner/testFile2",
- BufferUtils.getIncreasingByteArray(10, 20));
-
- InterpreterResult output = alluxioInterpreter.interpret("copyFromLocal " +
- testFile.getParent() + " /testDir", null);
- Assert.assertEquals(
- "Copied " + testFile.getParent() + " to /testDir\n\n",
- output.message().get(0).getData());
-
- long fileLength1 = fs.getStatus(new
AlluxioURI("/testDir/testFile")).getLength();
- long fileLength2 = fs.getStatus(new
AlluxioURI("/testDir/testDirInner/testFile2")).getLength();
- Assert.assertEquals(10, fileLength1);
- Assert.assertEquals(20, fileLength2);
-
- FileInStream fStream1 = fs.openFile(new AlluxioURI("/testDir/testFile"));
- FileInStream fStream2 = fs.openFile(new
AlluxioURI("/testDir/testDirInner/testFile2"));
- byte[] read = new byte[10];
- fStream1.read(read);
- Assert.assertTrue(BufferUtils.equalIncreasingByteArray(10, read));
- read = new byte[20];
- fStream2.read(read);
- Assert.assertTrue(BufferUtils.equalIncreasingByteArray(10, 20, read));
- }
-
- @Test
- public void copyFromLocalTestWithFullURI() throws IOException,
AlluxioException {
- File testFile = generateFileContent("/srcFileURI",
BufferUtils.getIncreasingByteArray(10));
- String uri = "tachyon://" + mLocalAlluxioCluster.getMasterHostname() + ":"
- + mLocalAlluxioCluster.getMasterPort() + "/destFileURI";
-
- InterpreterResult output = alluxioInterpreter.interpret("copyFromLocal " +
- testFile.getPath() + " " + uri, null);
- Assert.assertEquals(
- "Copied " + testFile.getPath() + " to " + uri + "\n\n",
- output.message().get(0).getData());
-
- long fileLength = fs.getStatus(new AlluxioURI("/destFileURI")).getLength();
- Assert.assertEquals(10L, fileLength);
-
- FileInStream fStream = fs.openFile(new AlluxioURI("/destFileURI"));
- byte[] read = new byte[10];
- fStream.read(read);
- Assert.assertTrue(BufferUtils.equalIncreasingByteArray(10, read));
- }
-
- @Test
- public void copyFromLocalFileToDstPathTest() throws IOException,
AlluxioException {
- String dataString = "copyFromLocalFileToDstPathTest";
- byte[] data = dataString.getBytes();
- File localDir = new File(mLocalAlluxioCluster.getAlluxioHome() +
"/localDir");
- localDir.mkdir();
- File localFile = generateFileContent("/localDir/testFile", data);
-
- alluxioInterpreter.interpret("mkdir /dstDir", null);
- alluxioInterpreter.interpret("copyFromLocal " + localFile.getPath() + "
/dstDir", null);
-
- FileInStream fStream = fs.openFile(new AlluxioURI("/dstDir/testFile"));
- long fileLength = fs.getStatus(new
AlluxioURI("/dstDir/testFile")).getLength();
-
- byte[] read = new byte[(int) fileLength];
- fStream.read(read);
- Assert.assertEquals(new String(read), dataString);
- }
-
- @Test
- public void copyToLocalLargeTest() throws IOException {
- copyToLocalWithBytes(SIZE_BYTES);
- }
-
@Test
public void copyToLocalTest() throws IOException {
- copyToLocalWithBytes(10);
- }
-
- private void copyToLocalWithBytes(int bytes) throws IOException {
- FileSystemTestUtils.createByteFile(fs, "/testFile", WriteType.MUST_CACHE,
10, 10);
+ FileSystemTestUtils.createByteFile(fs, "/testFile", WritePType.MUST_CACHE,
10, 10);
InterpreterResult output = alluxioInterpreter.interpret("copyToLocal
/testFile " +
mLocalAlluxioCluster.getAlluxioHome() + "/testFile", null);
Assert.assertEquals(
- "Copied /testFile to " + mLocalAlluxioCluster.getAlluxioHome() +
"/testFile\n\n",
+ "Copied /testFile to file://" +
mLocalAlluxioCluster.getAlluxioHome() + "/testFile\n\n",
output.message().get(0).getData());
fileReadTest("/testFile", 10);
}
- @Test
- public void countNotExistTest() throws IOException {
- InterpreterResult output = alluxioInterpreter.interpret("count
/NotExistFile", null);
- Assert.assertEquals(Code.ERROR, output.code());
-
Assert.assertEquals(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage("/NotExistFile")
+ "\n",
- output.message().get(0).getData());
- }
-
@Test
public void countTest() throws IOException {
FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA",
- WriteType.CACHE_THROUGH, 10, 10);
+ WritePType.MUST_CACHE, 10);
FileSystemTestUtils.createByteFile(fs, "/testRoot/testDir/testFileB",
- WriteType.CACHE_THROUGH, 20, 20);
+ WritePType.MUST_CACHE, 20);
FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileB",
- WriteType.CACHE_THROUGH, 30, 30);
+ WritePType.MUST_CACHE, 30);
InterpreterResult output = alluxioInterpreter.interpret("count /testRoot",
null);
String expected = "";
- String format = "%-25s%-25s%-15s\n";
- expected += String.format(format, "File Count", "Folder Count", "Total
Bytes");
- expected += String.format(format, 3, 2, 60);
+ expected += String.format(COUNT_FORMAT, "File Count", "Folder Count",
"Folder Size");
+ expected += String.format(COUNT_FORMAT, 3, 1, 60);
expected += "\n";
Assert.assertEquals(expected, output.message().get(0).getData());
- }
- @Test
- public void fileinfoNotExistTest() throws IOException {
- InterpreterResult output = alluxioInterpreter.interpret("fileInfo
/NotExistFile", null);
-
Assert.assertEquals(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage("/NotExistFile")
+ "\n",
- output.message().get(0).getData());
- Assert.assertEquals(Code.ERROR, output.code());
- }
-
- @Test
- public void locationNotExistTest() throws IOException {
- InterpreterResult output = alluxioInterpreter.interpret("location
/NotExistFile", null);
-
Assert.assertEquals(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage("/NotExistFile")
+ "\n",
- output.message().get(0).getData());
- Assert.assertEquals(Code.ERROR, output.code());
+ InterpreterResult output2 = alluxioInterpreter.interpret("count -h
/testRoot", null);
+ String expected2 = "";
+ expected2 += String.format(COUNT_FORMAT, "File Count", "Folder Count",
"Folder Size");
+ expected2 += String.format(COUNT_FORMAT, 3, 1, "60B");
+ expected2 += "\n";
+ assertEquals(expected2, output2.message().get(0).getData());
}
@Test
@@ -353,11 +191,11 @@ public class AlluxioInterpreterTest {
URIStatus[] files = new URIStatus[3];
FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA",
- WriteType.MUST_CACHE, 10, 10);
+ WritePType.MUST_CACHE, 10, 10);
FileSystemTestUtils.createByteFile(fs, "/testRoot/testDir/testFileB",
- WriteType.MUST_CACHE, 20, 20);
+ WritePType.MUST_CACHE, 20, 20);
FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileC",
- WriteType.THROUGH, 30, 30);
+ WritePType.THROUGH, 30, 30);
files[0] = fs.getStatus(new AlluxioURI("/testRoot/testFileA"));
files[1] = fs.getStatus(new AlluxioURI("/testRoot/testDir"));
@@ -365,104 +203,14 @@ public class AlluxioInterpreterTest {
InterpreterResult output = alluxioInterpreter.interpret("ls /testRoot",
null);
- String expected = "";
- String format = "%-10s%-25s%-15s%-5s\n";
- expected += String.format(format, FormatUtils.getSizeFromBytes(10),
- CommandUtils.convertMsToDate(files[0].getCreationTimeMs()), "In
Memory",
- "/testRoot/testFileA");
- expected += String.format(format, FormatUtils.getSizeFromBytes(0),
- CommandUtils.convertMsToDate(files[1].getCreationTimeMs()), "",
"/testRoot/testDir");
- expected += String.format(format, FormatUtils.getSizeFromBytes(30),
- CommandUtils.convertMsToDate(files[2].getCreationTimeMs()), "Not
In Memory",
- "/testRoot/testFileC");
- expected += "\n";
-
Assert.assertEquals(Code.SUCCESS, output.code());
- Assert.assertEquals(expected, output.message().get(0).getData());
- }
-
- @Test
- public void lsRecursiveTest() throws IOException, AlluxioException {
- URIStatus[] files = new URIStatus[4];
-
- FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileA",
- WriteType.MUST_CACHE, 10, 10);
- FileSystemTestUtils.createByteFile(fs, "/testRoot/testDir/testFileB",
- WriteType.MUST_CACHE, 20, 20);
- FileSystemTestUtils.createByteFile(fs, "/testRoot/testFileC",
- WriteType.THROUGH, 30, 30);
-
- files[0] = fs.getStatus(new AlluxioURI("/testRoot/testFileA"));
- files[1] = fs.getStatus(new AlluxioURI("/testRoot/testDir"));
- files[2] = fs.getStatus(new AlluxioURI("/testRoot/testDir/testFileB"));
- files[3] = fs.getStatus(new AlluxioURI("/testRoot/testFileC"));
-
- InterpreterResult output = alluxioInterpreter.interpret("ls -R /testRoot",
null);
-
- String expected = "";
- String format = "%-10s%-25s%-15s%-5s\n";
- expected +=
- String.format(format, FormatUtils.getSizeFromBytes(10),
-
CommandUtils.convertMsToDate(files[0].getCreationTimeMs()), "In Memory",
- "/testRoot/testFileA");
- expected +=
- String.format(format, FormatUtils.getSizeFromBytes(0),
-
CommandUtils.convertMsToDate(files[1].getCreationTimeMs()), "",
- "/testRoot/testDir");
- expected +=
- String.format(format, FormatUtils.getSizeFromBytes(20),
-
CommandUtils.convertMsToDate(files[2].getCreationTimeMs()), "In Memory",
- "/testRoot/testDir/testFileB");
- expected +=
- String.format(format, FormatUtils.getSizeFromBytes(30),
-
CommandUtils.convertMsToDate(files[3].getCreationTimeMs()), "Not In Memory",
- "/testRoot/testFileC");
- expected += "\n";
-
- Assert.assertEquals(expected, output.message().get(0).getData());
- }
-
- @Test
- public void mkdirComplexPathTest() throws IOException, AlluxioException {
- InterpreterResult output = alluxioInterpreter.interpret(
- "mkdir /Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File", null);
-
- boolean existsDir = fs.exists(new
AlluxioURI("/Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File"));
- Assert.assertEquals(
- "Successfully created directory
/Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File\n\n",
- output.message().get(0).getData());
- Assert.assertTrue(existsDir);
- }
-
- @Test
- public void mkdirExistingTest() throws IOException {
- String command = "mkdir /festFile1";
- Assert.assertEquals(Code.SUCCESS, alluxioInterpreter.interpret(command,
null).code());
- Assert.assertEquals(Code.ERROR, alluxioInterpreter.interpret(command,
null).code());
- }
-
- @Test
- public void mkdirInvalidPathTest() throws IOException {
- Assert.assertEquals(
- Code.ERROR,
- alluxioInterpreter.interpret("mkdir /test File Invalid Path",
null).code());
- }
-
- @Test
- public void mkdirShortPathTest() throws IOException, AlluxioException {
- InterpreterResult output = alluxioInterpreter.interpret("mkdir
/root/testFile1", null);
- boolean existsDir = fs.exists(new AlluxioURI("/root/testFile1"));
- Assert.assertEquals(
- "Successfully created directory /root/testFile1\n\n",
- output.message().get(0).getData());
- Assert.assertTrue(existsDir);
}
@Test
public void mkdirTest() throws IOException, AlluxioException {
String qualifiedPath =
- "tachyon://" + mLocalAlluxioCluster.getMasterHostname() + ":"
- + mLocalAlluxioCluster.getMasterPort() + "/root/testFile1";
+ "alluxio://" + mLocalAlluxioCluster.getHostname() + ":"
+ + mLocalAlluxioCluster.getMasterRpcPort() +
"/root/testFile1";
InterpreterResult output = alluxioInterpreter.interpret("mkdir " +
qualifiedPath, null);
boolean existsDir = fs.exists(new AlluxioURI("/root/testFile1"));
Assert.assertEquals(
@@ -471,16 +219,6 @@ public class AlluxioInterpreterTest {
Assert.assertTrue(existsDir);
}
- private File generateFileContent(String path, byte[] toWrite)
- throws IOException {
- File testFile = new File(mLocalAlluxioCluster.getAlluxioHome() + path);
- testFile.createNewFile();
- FileOutputStream fos = new FileOutputStream(testFile);
- fos.write(toWrite);
- fos.close();
- return testFile;
- }
-
private void fileReadTest(String fileName, int size) throws IOException {
File testFile = new
File(PathUtils.concatPath(mLocalAlluxioCluster.getAlluxioHome(), fileName));
FileInputStream fis = new FileInputStream(testFile);