private ApplicationTypeVersionResource CreateAppTypeVersion( ServiceFabricManagedClustersManagementClient serviceFabricMcClient, string resourceGroup, string clusterName, string clusterId, string appTypeName, string appTypeVersionName, string appPackageUrl) { var appTypeVersionResourceId = $"{clusterId}/applicationTypes/{appTypeName}/versions/{appTypeVersionName}"; var appTypeVersionParams = new ApplicationTypeVersionResource( name: AppTypeVersionName, location: Location, id: appTypeVersionResourceId, appPackageUrl: appPackageUrl); var appTypeVersionResult = serviceFabricMcClient.ApplicationTypeVersions.CreateOrUpdate( resourceGroup, clusterName, appTypeName, appTypeVersionName, appTypeVersionParams); Assert.Equal("Succeeded", appTypeVersionResult.ProvisioningState); Assert.Equal(appPackageUrl, appTypeVersionResult.AppPackageUrl); return(appTypeVersionResult); }
protected void WaitForClusterReadyState( ServiceFabricManagedClustersManagementClient serviceFabricMcClient, string resourceGroupName, string clusterName) { var timeout = TimeSpan.FromMinutes(10); var stopWatch = new Stopwatch(); stopWatch.Start(); while (true) { var cluster = serviceFabricMcClient.ManagedClusters.Get(resourceGroupName, clusterName); if (cluster.ClusterState == "Ready") { break; } if (stopWatch.Elapsed >= timeout) { throw new TimeoutException($"Timeout waiting for cluster to be ready. Current state: {cluster.ClusterState}"); } TestUtilities.Wait(TimeSpan.FromSeconds(30)); } }
private void CreateApplication( ServiceFabricManagedClustersManagementClient serviceFabricMcClient, string resourceGroup, string clusterName, string clusterId, string appName, string versionResourceId) { var applicationResourceId = $"{clusterId}/applications/{appName}"; var applicationParams = new ApplicationResource( name: appName, location: Location, id: applicationResourceId, version: versionResourceId, upgradePolicy: new ApplicationUpgradePolicy(recreateApplication: true)); var applicationResult = serviceFabricMcClient.Applications.CreateOrUpdate( resourceGroup, clusterName, appName, applicationParams); Assert.Equal("Succeeded", applicationResult.ProvisioningState); Assert.True(applicationResult.UpgradePolicy.RecreateApplication); Assert.Equal(versionResourceId, applicationResult.Version); }
protected ManagedCluster CreateManagedCluster( ResourceManagementClient resouceClient, ServiceFabricManagedClustersManagementClient serviceFabricMcClient, string rg, string rgLocation, string clusterName, string sku) { var testTP = "123BDACDCDFB2C7B250192C6078E47D1E1DB119B"; var userName = "******"; var newCluster = new ManagedCluster( location: rgLocation, sku: new Sku() { Name = sku }, dnsName: clusterName, adminPassword: "******", adminUserName: userName, clientConnectionPort: 19000, httpGatewayConnectionPort: 19080, clients: new List <ClientCertificate>() { new ClientCertificate() { IsAdmin = true, Thumbprint = testTP } }); resouceClient.ResourceGroups.CreateOrUpdate( rg, new ResourceGroup(rgLocation)); var cluster = serviceFabricMcClient.ManagedClusters.CreateOrUpdate(rg, clusterName, newCluster); Assert.NotNull(cluster); Assert.Equal("Succeeded", cluster.ProvisioningState); Assert.Equal("WaitingForNodes", cluster.ClusterState); Assert.NotNull(cluster.Sku.Name); Assert.Equal(sku, cluster.Sku.Name); Assert.Equal("Wave0", cluster.ClusterUpgradeCadence); Assert.Equal(userName, cluster.AdminUserName); Assert.Equal(clusterName, cluster.DnsName); Assert.Equal($"{clusterName}.southcentralus.cloudapp.azure.com", cluster.Fqdn); Assert.NotNull(cluster.ClusterCertificateThumbprints); Assert.Single(cluster.ClusterCertificateThumbprints); Assert.Equal(19000, cluster.ClientConnectionPort); Assert.Equal(19080, cluster.HttpGatewayConnectionPort); Assert.False(cluster.AllowRdpAccess); Assert.NotNull(cluster.Clients); Assert.Single(cluster.Clients); Assert.True(cluster.Clients[0].IsAdmin); Assert.Equal(testTP, cluster.Clients[0].Thumbprint); Assert.False(cluster.EnableAutoOSUpgrade); return(cluster); }
private void CreateService( ServiceFabricManagedClustersManagementClient serviceFabricMcClient, string resourceGroup, string clusterName, string clusterId, string appName, string serviceTypeName, string serviceName) { var serviceResourceId = $"{clusterId}/applications/{appName}/services/{serviceName}"; var count = 1; var lowKey = 0; var highKey = 25; var targetReplicaSetSize = 5; var minReplicaSetSize = 3; var serviceParams = new ServiceResource( name: serviceName, location: Location, id: serviceResourceId, properties: new StatefulServiceProperties( serviceTypeName: serviceTypeName, partitionDescription: new UniformInt64RangePartitionScheme( count: count, lowKey: lowKey, highKey: highKey), hasPersistedState: true, targetReplicaSetSize: targetReplicaSetSize, minReplicaSetSize: minReplicaSetSize)); var serviceResult = serviceFabricMcClient.Services.CreateOrUpdate( resourceGroup, clusterName, appName, serviceName, serviceParams); Assert.Equal("Succeeded", serviceResult.Properties.ProvisioningState); Assert.IsAssignableFrom <StatefulServiceProperties>(serviceResult.Properties); var serviceProperties = serviceResult.Properties as StatefulServiceProperties; Assert.Equal("VotingDataType", serviceResult.Properties.ServiceTypeName); Assert.IsAssignableFrom <UniformInt64RangePartitionScheme>(serviceResult.Properties.PartitionDescription); var partitionDescription = serviceProperties.PartitionDescription as UniformInt64RangePartitionScheme; Assert.Equal(count, partitionDescription.Count); Assert.Equal(lowKey, partitionDescription.LowKey); Assert.Equal(highKey, partitionDescription.HighKey); Assert.True(serviceProperties.HasPersistedState); Assert.Equal(targetReplicaSetSize, serviceProperties.TargetReplicaSetSize); Assert.Equal(minReplicaSetSize, serviceProperties.MinReplicaSetSize); }
protected NodeType CreateNodeType( ServiceFabricManagedClustersManagementClient serviceFabricMcClient, string rg, string clusterName, string nodeTypeName, bool isPrimary, int vmInstanceCount, string vmSize = "Standard_D2", string vmImagePublisher = "MicrosoftWindowsServer", string vmImageOffer = "WindowsServer", string vmImageSku = "2019-Datacenter", string vmImageVersion = "latest", int dataDiskSizeGB = 100, string dataDiskType = DiskType.StandardSSDLRS, bool isStateless = false) { var newNodeType = new NodeType( isPrimary: isPrimary, vmInstanceCount: vmInstanceCount, dataDiskSizeGB: dataDiskSizeGB, vmSize: vmSize, vmImagePublisher: vmImagePublisher, vmImageOffer: vmImageOffer, vmImageSku: vmImageSku, vmImageVersion: vmImageVersion, dataDiskType: dataDiskType, isStateless: isStateless); var nodeType = serviceFabricMcClient.NodeTypes.CreateOrUpdate(rg, clusterName, nodeTypeName, newNodeType); Assert.NotNull(nodeType); Assert.Equal(ManagedResourceProvisioningState.Succeeded, nodeType.ProvisioningState); Assert.Equal(isPrimary, nodeType.IsPrimary); Assert.Equal(vmImagePublisher, nodeType.VmImagePublisher); Assert.Equal(vmImageOffer, nodeType.VmImageOffer); Assert.Equal(vmImageSku, nodeType.VmImageSku); Assert.Equal(vmImageVersion, nodeType.VmImageVersion); Assert.Equal(vmSize, nodeType.VmSize); Assert.Equal(vmInstanceCount, nodeType.VmInstanceCount); Assert.Equal(dataDiskSizeGB, nodeType.DataDiskSizeGB); Assert.Equal(dataDiskType, nodeType.DataDiskType); Assert.Equal(isStateless, nodeType.IsStateless); return(nodeType); }
private void DeleteAppType( ServiceFabricManagedClustersManagementClient serviceFabricMcClient, string resourceGroup, string clusterName, string clusterId, string appTypeName) { var appTypeResourceId = $"{clusterId}/applicationTypes/{appTypeName}"; serviceFabricMcClient.ApplicationTypes.Delete( resourceGroup, clusterName, appTypeName); var ex = Assert.ThrowsAsync <ErrorModelException>( () => serviceFabricMcClient.ApplicationTypes.GetAsync(resourceGroup, clusterName, appTypeName)).Result; Assert.True(ex.Response.StatusCode == System.Net.HttpStatusCode.NotFound); }
private void CreateAppType( ServiceFabricManagedClustersManagementClient serviceFabricMcClient, string resourceGroup, string clusterName, string clusterId, string appTypeName) { var appTypeResourceId = $"{clusterId}/applicationTypes/{appTypeName}"; var appTypeParams = new ApplicationTypeResource( name: appTypeName, location: Location, id: appTypeResourceId); var appTypeResult = serviceFabricMcClient.ApplicationTypes.CreateOrUpdate( resourceGroup, clusterName, appTypeName, appTypeParams); Assert.Equal("Succeeded", appTypeResult.ProvisioningState); }