public void TestGetCurrentReplicaChain() { var conf = new ReplicatedTableConfigurationStore(); conf.ReplicaChain.Add(new ReplicaInfo { Status = ReplicaStatus.None, }); conf.ReplicaChain.Add(new ReplicaInfo { Status = ReplicaStatus.ReadOnly, }); conf.ReplicaChain.Add(new ReplicaInfo { Status = ReplicaStatus.None, }); conf.ReplicaChain.Add(new ReplicaInfo { Status = ReplicaStatus.ReadWrite, }); conf.ReplicaChain.Add(new ReplicaInfo { Status = ReplicaStatus.WriteOnly, }); conf.ReplicaChain.Add(new ReplicaInfo { Status = ReplicaStatus.None, }); conf.ReplicaChain.Add(new ReplicaInfo { Status = ReplicaStatus.ReadWrite, }); conf.ReplicaChain.Add(new ReplicaInfo { Status = ReplicaStatus.None, }); // only Active replicas are returned i.e. RO, WO and RW var chain = conf.GetCurrentReplicaChain(); Assert.IsFalse(chain.Any(r => r.Status == ReplicaStatus.None)); }
private void UploadHeadTailView(string viewName, int leaseDuration, ReplicatedTableConfigurationServiceV2 configService) { // Download config using provided instance ReplicatedTableConfiguration config; ReplicatedTableQuorumReadResult readStatus = configService.RetrieveConfiguration(out config); Assert.IsTrue(readStatus.Code == ReplicatedTableQuorumReadCode.Success); // [Head] -> [Tail] ReplicatedTableConfigurationStore viewConfg = config.GetView(viewName); Assert.IsTrue(viewConfg.GetCurrentReplicaChain().Count == 2); // Force Reads on Head replica viewConfg.ReadViewTailIndex = 0; viewConfg.ViewId++; config.LeaseDuration = leaseDuration; // Upload config using provided instance configService.UpdateConfiguration(config); }