Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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");
        }
Exemplo n.º 7
0
        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");
        }
Exemplo n.º 8
0
        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");
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        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");
        }
Exemplo n.º 13
0
        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");
        }
Exemplo n.º 14
0
        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");
        }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        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);
        }