Ejemplo n.º 1
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));
        }
Ejemplo 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));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
0
        public async Task RenameTest()
        {
            client = new WebHdfsClient(DataTestUtility.HdfsConnStr);
            var dirPath = $"{DataTestUtility.HdfsRootDir}/{nameof(RenameTest)}";
            await client.Delete(dirPath, Recursive : true);

            await client.UploadFile($"{dirPath}/sample", File.OpenRead("Samples/SampleTextFile.txt"));

            var result = await client.Rename($"{dirPath}/sample", $"{dirPath}/notsample");

            Assert.True(result);
        }
Ejemplo n.º 5
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");
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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");
        }
Ejemplo n.º 9
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");
        }
Ejemplo n.º 10
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");
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
0
        public async Task ReadWithLenght()
        {
            client = new WebHdfsClient(DataTestUtility.HdfsConnStr);
            var filePath = $"{DataTestUtility.HdfsRootDir}/{nameof(ReadWithLenght)}/sample";
            await client.Delete($"{DataTestUtility.HdfsRootDir}/sample");

            await client.UploadFile(filePath, File.OpenRead("Samples/SampleTextFile.txt"), Overwrite : true);

            var openResponse = await client.OpenStream(filePath, new OpenParams()
            {
                Length = 2
            });

            using (StreamReader reader = new StreamReader(openResponse))
            {
                var openResult = reader.ReadToEnd();
                Assert.True("So" == openResult);
            }
        }