Exemplo n.º 1
0
        public void ChangeActive_NewActiveValueGiven_ActiveChangedPassiveStaysSame(DestinationHealth oldActive, DestinationHealth newActive)
        {
            var compositeHealth = new CompositeDestinationHealth(DestinationHealth.Healthy, oldActive);

            compositeHealth = compositeHealth.ChangeActive(newActive);

            Assert.Equal(newActive, compositeHealth.Active);
            Assert.Equal(DestinationHealth.Healthy, compositeHealth.Passive);
        }
Exemplo n.º 2
0
 public CompositeDestinationHealth(DestinationHealth passive, DestinationHealth active)
 {
     Passive = passive;
     Active  = active;
     if (passive == DestinationHealth.Unknown && active == DestinationHealth.Unknown)
     {
         Current = DestinationHealth.Unknown;
     }
     else
     {
         Current = passive == DestinationHealth.Unhealthy || active == DestinationHealth.Unhealthy ? DestinationHealth.Unhealthy : DestinationHealth.Healthy;
     }
 }
        public async Task SetPassiveAsync_HealthSateIsNotChanged_DoNothing(DestinationHealth health)
        {
            var destination = new DestinationInfo("destination0");

            destination.Health.Active  = DestinationHealth.Healthy;
            destination.Health.Passive = health;
            var cluster = CreateCluster(passive: true, active: false, destination);

            using var timerFactory = new TestTimerFactory();
            var updater = new DestinationHealthUpdater(timerFactory, new Mock <ILogger <DestinationHealthUpdater> >().Object);

            await updater.SetPassiveAsync(cluster, destination, health, TimeSpan.FromSeconds(2));

            Assert.Equal(0, timerFactory.Count);
            Assert.Equal(DestinationHealth.Healthy, destination.Health.Active);
            Assert.Equal(health, destination.Health.Passive);
        }
Exemplo n.º 4
0
 public NewActiveDestinationHealth(DestinationState destination, DestinationHealth newActiveHealth)
 {
     Destination     = destination;
     NewActiveHealth = newActiveHealth;
 }
 public void SetPassive(ClusterInfo cluster, DestinationInfo destination, DestinationHealth newHealth, TimeSpan reactivationPeriod)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public CompositeDestinationHealth ChangeActive(DestinationHealth active)
 {
     return(new CompositeDestinationHealth(Passive, active));
 }
Exemplo n.º 7
0
 public CompositeDestinationHealth ChangePassive(DestinationHealth passive)
 {
     return(new CompositeDestinationHealth(passive, Active));
 }
 public static void ActiveDestinationHealthStateIsSet(ILogger logger, string destinationId, string clusterId, DestinationHealth newHealthState)
 {
     _activeDestinationHealthStateIsSet(logger, destinationId, clusterId, newHealthState, null);
 }
Exemplo n.º 9
0
    public void GetAvailableDestinations_OneHealthCheckDisabled_UseUnknownState(bool activeEnabled, DestinationHealth active, bool passiveEnabled, DestinationHealth passive, bool isAvailable)
    {
        var cluster = new ClusterConfig()
        {
            ClusterId   = "cluster1",
            HealthCheck = new HealthCheckConfig
            {
                Active = new ActiveHealthCheckConfig {
                    Enabled = activeEnabled
                },
                Passive = new PassiveHealthCheckConfig {
                    Enabled = passiveEnabled
                }
            }
        };

        var policy = new HealthyAndUnknownDestinationsPolicy();

        var destination = new DestinationState("d0")
        {
            Health = { Active = active, Passive = passive }
        };
        var availableDestinations = policy.GetAvailalableDestinations(cluster, new[] { destination });

        if (isAvailable)
        {
            Assert.Single(availableDestinations, destination);
        }
        else
        {
            Assert.Empty(availableDestinations);
        }
    }
Exemplo n.º 10
0
        public void Current_CalculatedAsBooleanOrOfActiveAndPassiveStates(DestinationHealth passive, DestinationHealth active, DestinationHealth expectedCurrent)
        {
            var compositeHealth = new CompositeDestinationHealth(passive, active);

            Assert.Equal(expectedCurrent, compositeHealth.Current);
        }
 public DestinationDynamicState(
     DestinationHealth health)
 {
     Health = health;
 }