public async Task SetPropertiesAsync_DeleteRetentionPolicy() { // Arrange DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); DataLakeServiceProperties properties = await service.GetPropertiesAsync(); DataLakeRetentionPolicy originalRetentionPolicy = properties.DeleteRetentionPolicy; properties.DeleteRetentionPolicy = new DataLakeRetentionPolicy { Enabled = true, Days = 3 }; // Act await service.SetPropertiesAsync(properties); // Assert properties = await service.GetPropertiesAsync(); Assert.IsTrue(properties.DeleteRetentionPolicy.Enabled); Assert.AreEqual(3, properties.DeleteRetentionPolicy.Days); // Cleanup properties.DeleteRetentionPolicy = originalRetentionPolicy; await service.SetPropertiesAsync(properties); properties = await service.GetPropertiesAsync(); Assert.AreEqual(originalRetentionPolicy.Enabled, properties.DeleteRetentionPolicy.Enabled); Assert.AreEqual(originalRetentionPolicy.Days, properties.DeleteRetentionPolicy.Days); }
public async Task SetProperties_HourAndMinuteMetrics() { // Arrange DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); DataLakeServiceProperties properties = await service.GetPropertiesAsync(); DataLakeMetrics originalHourMetrics = properties.HourMetrics; DataLakeMetrics originalMinuteMetrics = properties.MinuteMetrics; properties.HourMetrics = new DataLakeMetrics { Version = "1.0", Enabled = true, RetentionPolicy = new DataLakeRetentionPolicy { Enabled = true, Days = 1 }, IncludeApis = false }; properties.MinuteMetrics = new DataLakeMetrics { Version = "1.0", Enabled = true, RetentionPolicy = new DataLakeRetentionPolicy { Enabled = true, Days = 2 }, IncludeApis = false }; // Act await service.SetPropertiesAsync(properties); // Assert properties = await service.GetPropertiesAsync(); Assert.AreEqual("1.0", properties.HourMetrics.Version); Assert.IsTrue(properties.HourMetrics.Enabled); Assert.IsTrue(properties.HourMetrics.RetentionPolicy.Enabled); Assert.AreEqual(1, properties.HourMetrics.RetentionPolicy.Days); Assert.IsFalse(properties.HourMetrics.IncludeApis); Assert.AreEqual("1.0", properties.MinuteMetrics.Version); Assert.IsTrue(properties.MinuteMetrics.Enabled); Assert.IsTrue(properties.MinuteMetrics.RetentionPolicy.Enabled); Assert.AreEqual(2, properties.MinuteMetrics.RetentionPolicy.Days); Assert.IsFalse(properties.MinuteMetrics.IncludeApis); // Cleanup properties.HourMetrics = originalHourMetrics; properties.MinuteMetrics = originalMinuteMetrics; await service.SetPropertiesAsync(properties); properties = await service.GetPropertiesAsync(); Assert.AreEqual(originalHourMetrics.RetentionPolicy.Days, properties.HourMetrics.RetentionPolicy.Days); Assert.AreEqual(originalMinuteMetrics.RetentionPolicy.Days, properties.MinuteMetrics.RetentionPolicy.Days); }
public async Task PathClient_CanGetParentDirectoryClient_WithContainerSAS() { // Arrange var parentDirName = DataLakeClientBuilder.GetNewDirectoryName(); await using DisposingFileSystem test = await DataLakeClientBuilder.GetNewFileSystem(); var fileName = DataLakeClientBuilder.GetNewFileName(); DataLakeFileClient fileClient = InstrumentClient( GetServiceClient_DataLakeServiceSas_FileSystem(test.Container.Name) .GetFileSystemClient(test.FileSystem.Name) .GetRootDirectoryClient() .GetSubDirectoryClient(parentDirName) .GetFileClient(fileName)); await fileClient.CreateAsync(); // Act DataLakeDirectoryClient parentDirClient = fileClient.GetParentDirectoryClient(); // make sure that client is functional var pathItems = await parentDirClient.GetPathsAsync().ToListAsync(); // Assert Assert.AreEqual(fileClient.Path.GetParentPath(), parentDirClient.Path); Assert.AreEqual(fileClient.AccountName, parentDirClient.AccountName); Assert.IsNotNull(pathItems); }
public async Task UndeleteFileSystemAsync() { // Arrange DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); string fileSystemName = GetNewFileSystemName(); DataLakeFileSystemClient fileSystem = InstrumentClient(service.GetFileSystemClient(fileSystemName)); await fileSystem.CreateAsync(); await fileSystem.DeleteAsync(); IList <FileSystemItem> fileSystems = await service.GetFileSystemsAsync(states : FileSystemStates.Deleted).ToListAsync(); FileSystemItem fileSystemItem = fileSystems.Where(c => c.Name == fileSystemName).FirstOrDefault(); // It takes some time for the FileSystem to be deleted. await Delay(30000); // Act Response <DataLakeFileSystemClient> response = await service.UndeleteFileSystemAsync( fileSystemItem.Name, fileSystemItem.VersionId); // Assert await response.Value.GetPropertiesAsync(); // Cleanup await response.Value.DeleteAsync(); }
public async Task GetUserDelegationKey_Error() { // Arrange DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); // Act await TestHelper.AssertExpectedExceptionAsync <RequestFailedException>( service.GetUserDelegationKeyAsync(startsOn: null, expiresOn: Recording.UtcNow.AddHours(1)), e => Assert.AreEqual("AuthenticationFailed", e.ErrorCode)); }
public async Task GetPropertiesAsync() { // Arrange DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); // Act Response <DataLakeServiceProperties> response = await service.GetPropertiesAsync(); // Assert Assert.IsNotNull(response.Value.DeleteRetentionPolicy); }
public async Task DeleteFileSystemAsync() { var name = GetNewFileSystemName(); DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); DataLakeFileSystemClient fileSystem = InstrumentClient((await service.CreateFileSystemAsync(name)).Value); await service.DeleteFileSystemAsync(name); Assert.ThrowsAsync <RequestFailedException>( async() => await fileSystem.GetPropertiesAsync()); }
public async Task UndeleteFileSystemAsync_Error() { // Arrange DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); string fileSytemName = GetNewFileSystemName(); DataLakeFileSystemClient fileSystem = InstrumentClient(service.GetFileSystemClient(fileSytemName)); // Act await TestHelper.AssertExpectedExceptionAsync <RequestFailedException>( service.UndeleteFileSystemAsync(GetNewFileSystemName(), "01D60F8BB59A4652"), e => Assert.AreEqual("ContainerNotFound", e.ErrorCode)); }
public async Task Ctor_AzureSasCredential() { // Arrange string sas = GetNewAccountSasCredentials().ToString(); Uri uri = DataLakeClientBuilder.GetServiceClient_Hns().Uri; // Act var sasClient = InstrumentClient(new DataLakeServiceClient(uri, new AzureSasCredential(sas), GetOptions())); var fileSystems = await sasClient.GetFileSystemsAsync().ToListAsync(); // Assert Assert.IsNotNull(fileSystems); }
public async Task GetPropertiesAsync_Error() { // Arrange DataLakeServiceClient service = InstrumentClient( new DataLakeServiceClient( DataLakeClientBuilder.GetServiceClient_Hns().Uri, GetOptions())); // Act await TestHelper.AssertExpectedExceptionAsync <RequestFailedException>( service.GetPropertiesAsync(), e => { }); }
public void Ctor_AzureSasCredential_VerifyNoSasInUri() { // Arrange string sas = GetNewAccountSasCredentials().ToString(); Uri uri = DataLakeClientBuilder.GetServiceClient_Hns().Uri; uri = new Uri(uri.ToString() + "?" + sas); // Act TestHelper.AssertExpectedException <ArgumentException>( () => new DataLakeServiceClient(uri, new AzureSasCredential(sas)), e => e.Message.Contains($"You cannot use {nameof(AzureSasCredential)} when the resource URI also contains a Shared Access Signature")); }
public async Task GetFileSystemsAsync_Error() { // Arrange DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); // Act await TestHelper.AssertExpectedExceptionAsync <RequestFailedException>( service.GetFileSystemsAsync().AsPages(continuationToken : "garbage").FirstAsync(), e => { Assert.AreEqual("OutOfRangeInput", e.ErrorCode); Assert.AreEqual("One of the request inputs is out of range.", e.Message.Split('\n')[0]); }); }
public async Task SetPropertiesAsync_Error() { // Arrange DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); DataLakeServiceProperties properties = (await service.GetPropertiesAsync()).Value; DataLakeServiceClient invalidService = InstrumentClient( new DataLakeServiceClient( DataLakeClientBuilder.GetServiceClient_Hns().Uri, GetOptions())); // Act await TestHelper.AssertExpectedExceptionAsync <RequestFailedException>( invalidService.SetPropertiesAsync(properties), e => { }); }
public async Task GetFileSystemsAsync() { // Arrange DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); // Ensure at least one container await using (await GetNewFileSystem(service: service)) { // Act IList <FileSystemItem> fileSystems = await service.GetFileSystemsAsync().ToListAsync(); // Assert Assert.IsTrue(fileSystems.Count >= 1); var accountName = new DataLakeUriBuilder(service.Uri).AccountName; TestHelper.AssertCacheableProperty(accountName, () => service.AccountName); } }
public async Task CreateFileSystemAsync() { var name = GetNewFileSystemName(); DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); try { DataLakeFileSystemClient fileSystem = InstrumentClient((await service.CreateFileSystemAsync(name)).Value); Response <FileSystemProperties> properties = await fileSystem.GetPropertiesAsync(); Assert.IsNotNull(properties.Value); } finally { await service.DeleteFileSystemAsync(name); } }
public async Task PathClient_CanGetParentContainerClient() { // Arrange await using DisposingFileSystem test = await DataLakeClientBuilder.GetNewFileSystem(); DataLakeFileClient fileClient = InstrumentClient(test.Container.GetRootDirectoryClient().GetFileClient(DataLakeClientBuilder.GetNewFileName())); // Act DataLakeFileSystemClient filesystemClient = fileClient.GetParentFileSystemClient(); // make sure that client is functional var containerProperties = await filesystemClient.GetPropertiesAsync(); // Assert Assert.AreEqual(fileClient.FileSystemName, filesystemClient.Name); Assert.AreEqual(fileClient.AccountName, filesystemClient.AccountName); Assert.IsNotNull(containerProperties); }
public async Task GetFileSystemsAsync_Prefix() { DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); var prefix = "aaa"; var fileSystemName = prefix + GetNewFileSystemName(); // Ensure at least one container await using DisposingFileSystem test = await GetNewFileSystem(service : service, fileSystemName : fileSystemName); // Act AsyncPageable <FileSystemItem> fileSystems = service.GetFileSystemsAsync(prefix: prefix); IList <FileSystemItem> items = await fileSystems.ToListAsync(); // Assert Assert.AreNotEqual(0, items.Count()); Assert.IsTrue(items.All(c => c.Name.StartsWith(prefix))); Assert.IsNotNull(items.Single(c => c.Name == fileSystemName)); }
public async Task GetFileSystemsAsync_MaxResults() { DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); // Ensure at least one container await GetNewFileSystem(service : service); await using DisposingFileSystem test = await GetNewFileSystem(service : service); // Act Page <FileSystemItem> page = await service.GetFileSystemsAsync() .AsPages(pageSizeHint: 1) .FirstAsync(); // Assert Assert.AreEqual(1, page.Values.Count()); }
public async Task GetFileSystemsAsync_Metadata() { DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); // Ensure at least one container await using DisposingFileSystem test = await GetNewFileSystem(service : service); // Arrange IDictionary <string, string> metadata = BuildMetadata(); await test.FileSystem.SetMetadataAsync(metadata); // Act IList <FileSystemItem> items = await service.GetFileSystemsAsync(FileSystemTraits.Metadata).ToListAsync(); // Assert AssertDictionaryEquality( metadata, items.Where(i => i.Name == test.FileSystem.Name).FirstOrDefault().Properties.Metadata); }
public async Task GetFileSystemsAsync_Marker() { DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); // Ensure at least one container await using DisposingFileSystem test = await GetNewFileSystem(service : service); var marker = default(string); var fileSystems = new List <FileSystemItem>(); await foreach (Page <FileSystemItem> page in service.GetFileSystemsAsync().AsPages(marker)) { fileSystems.AddRange(page.Values); } Assert.AreNotEqual(0, fileSystems.Count); Assert.AreEqual(fileSystems.Count, fileSystems.Select(c => c.Name).Distinct().Count()); Assert.IsTrue(fileSystems.Any(c => test.FileSystem.Uri == InstrumentClient(service.GetFileSystemClient(c.Name)).Uri)); }
public async Task SetPropertiesAsync_Logging() { // Arrange DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); DataLakeServiceProperties properties = await service.GetPropertiesAsync(); DataLakeAnalyticsLogging originalLogging = properties.Logging; properties.Logging = new DataLakeAnalyticsLogging { Version = "1.0", Delete = true, Read = true, Write = true, RetentionPolicy = new DataLakeRetentionPolicy { Enabled = true, Days = 1 } }; // Act await service.SetPropertiesAsync(properties); // Assert properties = await service.GetPropertiesAsync(); Assert.AreEqual("1.0", properties.Logging.Version); Assert.IsTrue(properties.Logging.Delete); Assert.IsTrue(properties.Logging.Read); Assert.IsTrue(properties.Logging.Write); Assert.IsTrue(properties.Logging.RetentionPolicy.Enabled); Assert.AreEqual(1, properties.Logging.RetentionPolicy.Days); // Cleanup properties.Logging = originalLogging; await service.SetPropertiesAsync(properties); properties = await service.GetPropertiesAsync(); Assert.AreEqual(originalLogging.RetentionPolicy.Days, properties.Logging.RetentionPolicy.Days); }
public async Task GetFileSystemsAsync_Deleted() { // Arrange DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); string fileSystemName = GetNewFileSystemName(); DataLakeFileSystemClient fileSystemClient = InstrumentClient(service.GetFileSystemClient(fileSystemName)); await fileSystemClient.CreateAsync(); await fileSystemClient.DeleteAsync(); // Act IList <FileSystemItem> fileSystems = await service.GetFileSystemsAsync(states : FileSystemStates.Deleted).ToListAsync(); FileSystemItem fileSystemItem = fileSystems.Where(c => c.Name == fileSystemName).FirstOrDefault(); // Assert Assert.IsTrue(fileSystemItem.IsDeleted); Assert.IsNotNull(fileSystemItem.VersionId); Assert.IsNotNull(fileSystemItem.Properties.DeletedOn); Assert.IsNotNull(fileSystemItem.Properties.RemainingRetentionDays); }
public async Task SetPropertiesAsync_StaticWebsite() { // Arrange DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); DataLakeServiceProperties properties = await service.GetPropertiesAsync(); DataLakeStaticWebsite originalStaticWebsite = properties.StaticWebsite; string errorDocument404Path = "error/404.html"; string defaultIndexDocumentPath = "index2.html"; properties.StaticWebsite = new DataLakeStaticWebsite { Enabled = true, ErrorDocument404Path = errorDocument404Path, DefaultIndexDocumentPath = defaultIndexDocumentPath }; // Act await service.SetPropertiesAsync(properties); // Assert properties = await service.GetPropertiesAsync(); Assert.IsTrue(properties.StaticWebsite.Enabled); Assert.AreEqual(errorDocument404Path, properties.StaticWebsite.ErrorDocument404Path); Assert.AreEqual(defaultIndexDocumentPath, properties.StaticWebsite.DefaultIndexDocumentPath); // Cleanup properties.StaticWebsite = originalStaticWebsite; await service.SetPropertiesAsync(properties); properties = await service.GetPropertiesAsync(); Assert.AreEqual(originalStaticWebsite.Enabled, properties.StaticWebsite.Enabled); Assert.AreEqual(originalStaticWebsite.IndexDocument, properties.StaticWebsite.IndexDocument); Assert.AreEqual(originalStaticWebsite.ErrorDocument404Path, properties.StaticWebsite.ErrorDocument404Path); Assert.AreEqual(originalStaticWebsite.DefaultIndexDocumentPath, properties.StaticWebsite.DefaultIndexDocumentPath); }
public async Task PathClient_CanGetParentDirectoryClient() { // Arrange var parentDirName = DataLakeClientBuilder.GetNewDirectoryName(); await using DisposingFileSystem test = await DataLakeClientBuilder.GetNewFileSystem(); DataLakeFileClient fileClient = InstrumentClient(test.Container .GetRootDirectoryClient() .GetSubDirectoryClient(parentDirName) .GetFileClient(DataLakeClientBuilder.GetNewFileName())); await fileClient.CreateAsync(); // Act DataLakeDirectoryClient parentDirClient = fileClient.GetParentDirectoryClient(); // make sure that client is functional var dirProperties = await parentDirClient.GetPropertiesAsync(); // Assert Assert.AreEqual(fileClient.Path.GetParentPath(), parentDirClient.Path); Assert.AreEqual(fileClient.AccountName, parentDirClient.AccountName); Assert.IsNotNull(dirProperties); }
public async Task SetPropertiesAsync_Cors() { // Arrange DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); DataLakeServiceProperties properties = await service.GetPropertiesAsync(); DataLakeCorsRule[] originalCors = properties.Cors.ToArray(); properties.Cors = new[] { new DataLakeCorsRule { MaxAgeInSeconds = 1000, AllowedHeaders = "x-ms-meta-data*,x-ms-meta-target*,x-ms-meta-abc", AllowedMethods = "PUT,GET", AllowedOrigins = "*", ExposedHeaders = "x-ms-meta-*" } }; // Act await service.SetPropertiesAsync(properties); // Assert properties = await service.GetPropertiesAsync(); Assert.AreEqual(1, properties.Cors.Count()); Assert.IsTrue(properties.Cors[0].MaxAgeInSeconds == 1000); // Cleanup properties.Cors = originalCors; await service.SetPropertiesAsync(properties); properties = await service.GetPropertiesAsync(); Assert.AreEqual(originalCors.Count(), properties.Cors.Count()); }
public async Task GetFileSystemsAsync_System() { // Arrange DataLakeServiceClient service = DataLakeClientBuilder.GetServiceClient_Hns(); DataLakeServiceProperties properties = await service.GetPropertiesAsync(); DataLakeStaticWebsite originalStaticWebsite = properties.StaticWebsite; string errorDocument404Path = "error/404.html"; string defaultIndexDocumentPath = "index2.html"; properties.StaticWebsite = new DataLakeStaticWebsite { Enabled = true, ErrorDocument404Path = errorDocument404Path, DefaultIndexDocumentPath = defaultIndexDocumentPath }; // Act await service.SetPropertiesAsync(properties); // Act IList <FileSystemItem> fileSystems = await service.GetFileSystemsAsync(states : FileSystemStates.System).ToListAsync(); FileSystemItem webFileSystemItem = fileSystems.Where(r => r.Name == "$web").FirstOrDefault(); // Assert Assert.IsTrue(fileSystems.Count > 0); Assert.IsNotNull(webFileSystemItem); // Cleanup properties = await service.GetPropertiesAsync(); properties.StaticWebsite = originalStaticWebsite; await service.SetPropertiesAsync(properties); }