public async Task UploadFileWithOverWrite() { client = new WebHdfsClient(DataTestUtility.HdfsConnStr); var filePath = $"{DataTestUtility.HdfsRootDir}/{nameof(UploadFileWithOverWrite)}/sample2"; await client.UploadFile(filePath, File.OpenRead("Samples/SampleTextFile.txt"), Overwrite : true); var fileStat = await client.GetFileStatus(filePath); var oldLenght = fileStat.Length; await client.UploadFile(filePath, File.OpenRead("Samples/SampleTextFile2.txt"), Overwrite : true); fileStat = await client.GetFileStatus(filePath); Assert.True(fileStat.Length != oldLenght); }
public async Task RemoveDirectory() { client = new WebHdfsClient(DataTestUtility.HdfsConnStr); var filePath = $"{DataTestUtility.HdfsRootDir}/{nameof(RemoveDirectory)}/"; await client.MakeDirectory(filePath, "770"); await client.Delete(filePath, Recursive : true); await Assert.ThrowsAsync <System.InvalidOperationException>(() => client.GetFileStatus(filePath)); }
public async Task RemoveNonexistentFile() { client = new WebHdfsClient(DataTestUtility.HdfsConnStr); var filePath = $"{DataTestUtility.HdfsRootDir}/{nameof(RemoveNonexistentFile)}/sample2"; await client.Delete(filePath); await client.Delete(filePath); await Assert.ThrowsAsync <System.InvalidOperationException>(() => client.GetFileStatus(filePath)); }
public async Task Remove() { client = new WebHdfsClient(DataTestUtility.HdfsConnStr); var filePath = $"{DataTestUtility.HdfsRootDir}/{nameof(Remove)}/sample2"; await client.UploadFile(filePath, File.OpenRead("Samples/SampleTextFile.txt"), Overwrite : true); await client.Delete(filePath); await Assert.ThrowsAsync <System.InvalidOperationException>(() => client.GetFileStatus(filePath)); }
public async Task UploadFileWithReplication() { client = new WebHdfsClient(DataTestUtility.HdfsConnStr); var filePath = $"{DataTestUtility.HdfsRootDir}/{nameof(UploadFileWithReplication)}/sample2"; await client.UploadFile(filePath, File.OpenRead("Samples/SampleTextFile.txt"), Overwrite : true, Replication : 3); var fileStat = await client.GetFileStatus(filePath); Assert.True(fileStat.Replication == 3); }
public async Task UploadFileWithPermission() { client = new WebHdfsClient(DataTestUtility.HdfsConnStr); var filePath = $"{DataTestUtility.HdfsRootDir}/{nameof(UploadFileWithPermission)}/sample2"; await client.UploadFile(filePath, File.OpenRead("Samples/SampleTextFile.txt"), Permission : 700, Overwrite : true); var fileStat = await client.GetFileStatus(filePath); Assert.True(fileStat.Type == "FILE"); Assert.True(fileStat.Permission == "700"); }
public async Task GetStatusOfDirectory() { client = new WebHdfsClient(DataTestUtility.HdfsConnStr); var dirPath = $"{DataTestUtility.HdfsRootDir}/{nameof(GetStatusOfDirectory)}"; await client.MakeDirectory(dirPath, "755"); var fileStat = await client.GetFileStatus(dirPath); Assert.True(fileStat.Length == 0); Assert.True(fileStat.Type == "DIRECTORY"); Assert.True(fileStat.Permission == "755"); }
public async Task UploadFileWithoutParams() { client = new WebHdfsClient(DataTestUtility.HdfsConnStr); var filePath = $"{DataTestUtility.HdfsRootDir}/{nameof(UploadFileWithoutParams)}/sample2"; await client.Delete(filePath); await client.UploadFile(filePath, File.OpenRead("Samples/SampleTextFile.txt")); var fileStat = await client.GetFileStatus(filePath); Assert.True(fileStat.Type == "FILE"); Assert.True(fileStat.Permission == "755"); }
public async Task CreateNewDirWithControl() { client = new WebHdfsClient(DataTestUtility.HdfsConnStr); var dirPath = $"{DataTestUtility.HdfsRootDir}/{nameof(CreateNewDirWithControl)}/MakeDirTest"; await client.Delete(dirPath, Recursive : true); var result = await client.MakeDirectory(dirPath, "770"); var dirStatus = await client.GetFileStatus(dirPath); Assert.True(dirStatus.Type == "DIRECTORY" && dirStatus.Permission == "770"); Assert.True(result); }
public async Task CreateSnapshot() { client = new WebHdfsClient(DataTestUtility.HdfsConnStr); var dirPath = $"{DataTestUtility.HdfsRootDir}/{nameof(CreateSnapshot)}/"; await client.MakeDirectory(dirPath, "770"); var result = await client.CreateSnapshot(dirPath); var fileStat = await client.GetFileStatus($"{dirPath}SNAPSHOT"); Assert.True(false); }
public async Task AppendTest() { client = new WebHdfsClient(DataTestUtility.HdfsConnStr); var dirPath = $"{DataTestUtility.HdfsRootDir}/{nameof(AppendTest)}"; await client.Delete(dirPath, Recursive : true); await client.UploadFile($"{dirPath}/sample", File.OpenRead("Samples/SampleTextFile.txt"), Overwrite : true); await client.Append($"{dirPath}/sample", File.OpenRead("Samples/SampleTextFile2.txt")); var fileStat = await client.GetFileStatus($"{dirPath}/sample"); Assert.True(fileStat.Length == 12); }
public async Task SetOwnerOfFile() { client = new WebHdfsClient(DataTestUtility.HdfsConnStr); var filePath = $"{DataTestUtility.HdfsRootDir}/{nameof(SetOwnerOfFile)}/sample"; await client.Delete(filePath); await client.UploadFile(filePath, File.OpenRead("Samples/SampleTextFile.txt")); await client.SetOwner(filePath, "USER"); var fileStat = await client.GetFileStatus(filePath); Assert.True(fileStat.Owner == "USER"); }
public async Task SetPermissOfDirectory() { client = new WebHdfsClient(DataTestUtility.HdfsConnStr); var dirPath = $"{DataTestUtility.HdfsRootDir}/{nameof(SetPermissOfDirectory)}"; await client.Delete(dirPath, Recursive : true); await client.MakeDirectory(dirPath, "750"); await client.SetPermission(dirPath, 700); var fileStat = await client.GetFileStatus(dirPath); Assert.True(fileStat.Permission == "700"); }
public async Task SetPermissOfFile() { client = new WebHdfsClient(DataTestUtility.HdfsConnStr); var filePath = $"{DataTestUtility.HdfsRootDir}/{nameof(SetPermissOfFile)}/sample"; await client.Delete(filePath, Recursive : true); await client.UploadFile(filePath, File.OpenRead("Samples/SampleTextFile.txt"), Permission : 750); await client.SetPermission(filePath, 700); var fileStat = await client.GetFileStatus(filePath); Assert.True(fileStat.Permission == "700"); }
public async Task SetTimes() { client = new WebHdfsClient(DataTestUtility.HdfsConnStr); var filePath = $"{DataTestUtility.HdfsRootDir}/{nameof(SetTimes)}/sample"; await client.Delete(filePath, Recursive : true); await client.UploadFile(filePath, File.OpenRead("Samples/SampleTextFile.txt")); await client.SetTimes(filePath, 12345678, 87654321); var fileStat = await client.GetFileStatus(filePath); Assert.True(fileStat.ModificationTime == 12345678 && fileStat.AccessTime == 87654321); }
public async Task SetReplic() { client = new WebHdfsClient(DataTestUtility.HdfsConnStr); var filePath = $"{DataTestUtility.HdfsRootDir}/{nameof(SetReplic)}/sample"; await client.Delete(filePath, Recursive : true); await client.UploadFile(filePath, File.OpenRead("Samples/SampleTextFile.txt"), Replication : 5); var result = await client.SetReplicationFactor(filePath, 7); var fileStat = await client.GetFileStatus(filePath); Assert.True(fileStat.Replication == 7); Assert.True(result); }