public void TestApplcationWithNullDeltaHealthPolicy() { CommandParameterGenerator generator = new CommandParameterGenerator(new TestFabricClientWrapper()); PaasClusterUpgradePolicy clusterUpgradePolicy = CreateDefaultPaasClusterUpgradePolicy(); clusterUpgradePolicy.DeltaHealthPolicy = null; ClusterHealth defaultClusterHealth = CreateDefaultClusterHealth( totalApplicationCount: 6, totalNodeCount: 5, unhealthyApplicationsCount: 0, unhealthyNodeCount: 0); CommandProcessorClusterUpgradeDescription result = generator.GetClusterUpgradeDescriptionAsync( clusterUpgradePolicy, defaultClusterHealth, CancellationToken.None).Result; VerifyCommandProcessorClusterUpgradeDescription( clusterUpgradePolicy, result, maxPercentageUnhealthyApplication: 100, expectedtMaxPercentUnhealthyPerServicesType: null); }
public void TestDefaultHealthPolicy() { CommandParameterGenerator generator = new CommandParameterGenerator(new TestFabricClientWrapper()); PaasClusterUpgradePolicy defaultPaasClusterUpgradePolicy = CreateDefaultPaasClusterUpgradePolicy(); ClusterHealth defaultClusterHealth = CreateDefaultClusterHealth(5, 5); CommandProcessorClusterUpgradeDescription result = generator.GetClusterUpgradeDescriptionAsync( defaultPaasClusterUpgradePolicy, defaultClusterHealth, CancellationToken.None).Result; VerifyCommandProcessorClusterUpgradeDescription( defaultPaasClusterUpgradePolicy, result, maxPercentageUnhealthyApplication: 0, expectedtMaxPercentUnhealthyPerServicesType: null); }
public void TestApplcationWithUnhealthySystemServiceHealthPolicy() { var testFabricClientWrapper = new TestFabricClientWrapper(); CommandParameterGenerator generator = new CommandParameterGenerator(testFabricClientWrapper); PaasClusterUpgradePolicy clusterUpgradePolicy = CreateDefaultPaasClusterUpgradePolicyWithSystemServicesPolicies(); ClusterHealth defaultClusterHealth = CreateDefaultClusterHealth( totalApplicationCount: 6, totalNodeCount: 5, unhealthyApplicationsCount: 0, unhealthyNodeCount: 0, isSystemServicesUnhealthy: true); Service fssService = new StatefulService(new Uri("fabric:/System/ImageStoreService"), "FileStoreService", "1.0", true, HealthState.Error, ServiceStatus.Active); Service cmService = new StatefulService(new Uri("fabric:/System/ClusterManagerService"), "ClusterManager", "1.0", true, HealthState.Ok, ServiceStatus.Active); Service hmService = new StatefulService(new Uri("fabric:/System/HealthManagerService"), "HealthManager", "1.0", true, HealthState.Ok, ServiceStatus.Active); testFabricClientWrapper.GetServicesResult = new ServiceList(new List <Service>() { fssService, cmService, hmService }); CommandProcessorClusterUpgradeDescription result = generator.GetClusterUpgradeDescriptionAsync( clusterUpgradePolicy, defaultClusterHealth, CancellationToken.None).Result; var expectedtMaxPercentUnhealthyPerServicesType = new Dictionary <string, byte>(); expectedtMaxPercentUnhealthyPerServicesType.Add("FileStoreService", 100); expectedtMaxPercentUnhealthyPerServicesType.Add("ClusterManager", 0); expectedtMaxPercentUnhealthyPerServicesType.Add("HealthManager", 0); VerifyCommandProcessorClusterUpgradeDescription( clusterUpgradePolicy, result, 0, expectedtMaxPercentUnhealthyPerServicesType); }
public Task UpgradeFabricAsync(CommandProcessorClusterUpgradeDescription commandDescription, string targetCodeVersion, string targetConfigVersion, TimeSpan timeout, CancellationToken cancellationToken) { throw new NotImplementedException(); }
private void VerifyCommandProcessorClusterUpgradeDescription( PaasClusterUpgradePolicy source, CommandProcessorClusterUpgradeDescription result, byte maxPercentageUnhealthyApplication, Dictionary <string, byte> expectedtMaxPercentUnhealthyPerServicesType) { Assert.AreEqual(source.ForceRestart, result.ForceRestart); Assert.AreEqual(source.HealthCheckRetryTimeout, result.HealthCheckRetryTimeout); Assert.AreEqual(source.HealthCheckStableDuration, result.HealthCheckStableDuration); Assert.AreEqual(source.HealthCheckWaitDuration, result.HealthCheckWaitDuration); Assert.AreEqual(source.UpgradeDomainTimeout, result.UpgradeDomainTimeout); Assert.AreEqual(source.UpgradeTimeout, result.UpgradeTimeout); Assert.AreEqual(source.UpgradeReplicaSetCheckTimeout, result.UpgradeReplicaSetCheckTimeout); if (source.HealthPolicy == null) { Assert.IsNull(result.HealthPolicy); } else { Assert.IsNotNull(result.HealthPolicy); Assert.AreEqual(source.HealthPolicy.MaxPercentUnhealthyNodes, result.HealthPolicy.MaxPercentUnhealthyNodes); Assert.AreEqual(maxPercentageUnhealthyApplication, result.HealthPolicy.MaxPercentUnhealthyApplications); if (source.HealthPolicy.ApplicationHealthPolicies == null) { Assert.IsNull(result.HealthPolicy.ApplicationHealthPolicies); } else { Assert.IsNotNull(result.HealthPolicy.ApplicationHealthPolicies); Assert.AreEqual(source.HealthPolicy.ApplicationHealthPolicies.Count(), result.HealthPolicy.ApplicationHealthPolicies.Count()); foreach (var keyVaulePair in result.HealthPolicy.ApplicationHealthPolicies) { Assert.AreEqual( source.HealthPolicy.ApplicationHealthPolicies[keyVaulePair.Key].DefaultServiceTypeHealthPolicy.MaxPercentUnhealthyServices, keyVaulePair.Value.DefaultServiceTypeHealthPolicy.MaxPercentUnhealthyServices); if (keyVaulePair.Value.SerivceTypeHealthPolicies != null) { foreach (var serviceTypeHealthPolicyKeyValue in keyVaulePair.Value.SerivceTypeHealthPolicies) { string serviceTypeName = serviceTypeHealthPolicyKeyValue.Key; byte expectedtMaxPercentUnhealthy; if (expectedtMaxPercentUnhealthyPerServicesType.TryGetValue( serviceTypeName, out expectedtMaxPercentUnhealthy)) { Assert.AreEqual(expectedtMaxPercentUnhealthy, serviceTypeHealthPolicyKeyValue.Value.MaxPercentUnhealthyServices); } else { Assert.AreEqual( source.HealthPolicy.ApplicationHealthPolicies[keyVaulePair.Key].SerivceTypeHealthPolicies[serviceTypeName].MaxPercentUnhealthyServices, serviceTypeHealthPolicyKeyValue.Value); } } } } } } if (source.DeltaHealthPolicy == null) { Assert.IsNull(result.DeltaHealthPolicy); } else { Assert.IsNotNull(result.DeltaHealthPolicy); Assert.AreEqual(source.DeltaHealthPolicy.MaxPercentDeltaUnhealthyNodes, result.DeltaHealthPolicy.MaxPercentDeltaUnhealthyNodes); Assert.AreEqual(source.DeltaHealthPolicy.MaxPercentUpgradeDomainDeltaUnhealthyNodes, result.DeltaHealthPolicy.MaxPercentUpgradeDomainDeltaUnhealthyNodes); } }