protected async Task MembershipTable_GetGateways() { var membershipEntries = Enumerable.Range(0, 10).Select(i => CreateMembershipEntryForTest()).ToArray(); membershipEntries[3].Status = SiloStatus.Active; membershipEntries[3].ProxyPort = 0; membershipEntries[5].Status = SiloStatus.Active; membershipEntries[9].Status = SiloStatus.Active; var data = await membershipTable.ReadAll(); Assert.NotNull(data); Assert.Equal(0, data.Members.Count); var version = data.Version; foreach (var membershipEntry in membershipEntries) { Assert.True(await membershipTable.InsertRow(membershipEntry, version)); version = (await membershipTable.ReadRow(membershipEntry.SiloAddress)).Version; } var gateways = await gatewayListProvider.GetGateways(); var entries = new List <string>(gateways.Select(g => g.ToString())); // only members with a non-zero Gateway port Assert.DoesNotContain(membershipEntries[3].SiloAddress.ToGatewayUri().ToString(), entries); // only Active members Assert.Contains(membershipEntries[5].SiloAddress.ToGatewayUri().ToString(), entries); Assert.Contains(membershipEntries[9].SiloAddress.ToGatewayUri().ToString(), entries); Assert.Equal(2, entries.Count); }
internal static async Task MembershipTable_ReadRow_Insert_Read(IMembershipTable membership) { MembershipTableData data = await membership.ReadAll(); //TableVersion tableVersion = data.Version; logger.Info("Membership.ReadAll returned VableVersion={0} Data={1}", data.Version, data); Assert.AreEqual(0, data.Members.Count, "Number of records returned - no table version row"); TableVersion newTableVersion = data.Version.Next(); MembershipEntry newEntry = CreateMembershipEntryForTest(); bool ok = await membership.InsertRow(newEntry, newTableVersion); Assert.IsTrue(ok, "InsertRow completed successfully"); data = await membership.ReadRow(newEntry.SiloAddress); logger.Info("Membership.ReadRow returned VableVersion={0} Data={1}", data.Version, data); Assert.AreEqual(1, data.Members.Count, "Number of records returned - data row only"); Assert.IsNotNull(data.Version.VersionEtag, "New version ETag should not be null"); Assert.AreNotEqual(newTableVersion.VersionEtag, data.Version.VersionEtag, "New VersionEtag differetnfrom last"); Assert.AreEqual(newTableVersion.Version, data.Version.Version, "New table version number"); MembershipEntry MembershipEntry = data.Members[0].Item1; string eTag = data.Members[0].Item2; logger.Info("Membership.ReadRow returned MembershipEntry ETag={0} Entry={1}", eTag, MembershipEntry); Assert.IsNotNull(eTag, "ETag should not be null"); Assert.IsNotNull(MembershipEntry, "MembershipEntry should not be null"); }
internal static async Task MembershipTable_ReadRow_Insert_Read(IMembershipTable membership) { MembershipTableData data = await membership.ReadAll(); //TableVersion tableVersion = data.Version; logger.Info("Membership.ReadAll returned VableVersion={0} Data={1}", data.Version, data); Assert.AreEqual(0, data.Members.Count, "Number of records returned - no table version row"); TableVersion newTableVersion = data.Version.Next(); MembershipEntry newEntry = CreateMembershipEntryForTest(); bool ok = await membership.InsertRow(newEntry, newTableVersion); Assert.IsTrue(ok, "InsertRow completed successfully"); data = await membership.ReadRow(newEntry.SiloAddress); logger.Info("Membership.ReadRow returned VableVersion={0} Data={1}", data.Version, data); Assert.AreEqual(1, data.Members.Count, "Number of records returned - data row only"); Assert.IsNotNull(data.Version.VersionEtag, "New version ETag should not be null"); Assert.AreNotEqual(newTableVersion.VersionEtag, data.Version.VersionEtag, "New VersionEtag differetnfrom last"); Assert.AreEqual(newTableVersion.Version, data.Version.Version, "New table version number"); MembershipEntry MembershipEntry = data.Members[0].Item1; string eTag = data.Members[0].Item2; logger.Info("Membership.ReadRow returned MembershipEntry ETag={0} Entry={1}", eTag, MembershipEntry); Assert.IsNotNull(eTag, "ETag should not be null"); Assert.IsNotNull(MembershipEntry, "MembershipEntry should not be null"); }
protected async Task MembershipTable_ReadRow_Insert_Read() { MembershipTableData data = await membershipTable.ReadAll(); //TableVersion tableVersion = data.Version; logger.Info("Membership.ReadAll returned VableVersion={0} Data={1}", data.Version, data); Assert.AreEqual(0, data.Members.Count, "Number of records returned - no table version row"); TableVersion newTableVersion = data.Version.Next(); MembershipEntry newEntry = CreateMembershipEntryForTest(); bool ok = await membershipTable.InsertRow(newEntry, newTableVersion); Assert.IsTrue(ok, "InsertRow failed"); ok = await membershipTable.InsertRow(newEntry, newTableVersion); Assert.IsFalse(ok, "InsertRow should have failed - same entry, old table version"); ok = await membershipTable.InsertRow(CreateMembershipEntryForTest(), newTableVersion); Assert.IsFalse(ok, "InsertRow should have failed - new entry, old table version"); data = await membershipTable.ReadAll(); var nextTableVersion = data.Version.Next(); ok = await membershipTable.InsertRow(newEntry, nextTableVersion); Assert.IsFalse(ok, "InsertRow should have failed - duplicate entry"); data = await membershipTable.ReadAll(); Assert.AreEqual(1, data.Members.Count, "only one row should have been inserted"); data = await membershipTable.ReadRow(newEntry.SiloAddress); Assert.AreEqual(newTableVersion.Version, data.Version.Version); logger.Info("Membership.ReadRow returned VableVersion={0} Data={1}", data.Version, data); Assert.AreEqual(1, data.Members.Count, "Number of records returned - data row only"); Assert.IsNotNull(data.Version.VersionEtag, "New version ETag should not be null"); Assert.AreNotEqual(newTableVersion.VersionEtag, data.Version.VersionEtag, "New VersionEtag differetnfrom last"); Assert.AreEqual(newTableVersion.Version, data.Version.Version); MembershipEntry MembershipEntry = data.Members[0].Item1; string eTag = data.Members[0].Item2; logger.Info("Membership.ReadRow returned MembershipEntry ETag={0} Entry={1}", eTag, MembershipEntry); Assert.IsNotNull(eTag, "ETag should not be null"); Assert.IsNotNull(MembershipEntry, "MembershipEntry should not be null"); }
internal static async Task MembershipTable_ReadRow_EmptyTable(IMembershipTable membership, SiloAddress siloAddress) { MembershipTableData data = await membership.ReadRow(siloAddress); TableVersion tableVersion = data.Version; logger.Info("Membership.ReadRow returned VableVersion={0} Data={1}", tableVersion, data); Assert.AreEqual(0, data.Members.Count, "Number of records returned - no table version row"); string eTag = tableVersion.VersionEtag; int ver = tableVersion.Version; logger.Info("Membership.ReadRow returned MembershipEntry ETag={0} TableVersion={1}", eTag, tableVersion); Assert.IsNotNull(eTag, "ETag should not be null"); Assert.AreEqual(0, ver, "Initial table version should be zero"); }
internal static async Task MembershipTable_ReadRow_EmptyTable(IMembershipTable membership, SiloAddress siloAddress) { MembershipTableData data = await membership.ReadRow(siloAddress); TableVersion tableVersion = data.Version; logger.Info("Membership.ReadRow returned VableVersion={0} Data={1}", tableVersion, data); Assert.AreEqual(0, data.Members.Count, "Number of records returned - no table version row"); string eTag = tableVersion.VersionEtag; int ver = tableVersion.Version; logger.Info("Membership.ReadRow returned MembershipEntry ETag={0} TableVersion={1}", eTag, tableVersion); Assert.IsNotNull(eTag, "ETag should not be null"); Assert.AreEqual(0, ver, "Initial table version should be zero"); }
internal static async Task MembershipTable_ReadRow_Insert_Read(IMembershipTable membership, SiloAddress siloAddress) { MembershipTableData data = await membership.ReadAll(); TableVersion tableVersion = data.Version; logger.Info("Membership.ReadAll returned VableVersion={0} Data={1}", tableVersion, data); Assert.AreEqual(0, data.Members.Count, "Number of records returned - no table version row"); DateTime now = DateTime.UtcNow; MembershipEntry entry = new MembershipEntry { SiloAddress = siloAddress, StartTime = now, Status = SiloStatus.Active, }; TableVersion newTableVersion = tableVersion.Next(); bool ok = await membership.InsertRow(entry, newTableVersion); Assert.IsTrue(ok, "InsertRow completed successfully"); data = await membership.ReadRow(siloAddress); tableVersion = data.Version; logger.Info("Membership.ReadRow returned VableVersion={0} Data={1}", tableVersion, data); Assert.AreEqual(1, data.Members.Count, "Number of records returned - data row only"); Assert.IsNotNull(tableVersion.VersionEtag, "New version ETag should not be null"); Assert.AreNotEqual(newTableVersion.VersionEtag, tableVersion.VersionEtag, "New VersionEtag differetnfrom last"); Assert.AreEqual(newTableVersion.Version, tableVersion.Version, "New table version number"); MembershipEntry MembershipEntry = data.Members[0].Item1; string eTag = data.Members[0].Item2; logger.Info("Membership.ReadRow returned MembershipEntry ETag={0} Entry={1}", eTag, MembershipEntry); Assert.IsNotNull(eTag, "ETag should not be null"); Assert.IsNotNull(MembershipEntry, "MembershipEntry should not be null"); }
internal static async Task MembershipTable_ReadRow_Insert_Read(IMembershipTable membership, SiloAddress siloAddress) { MembershipTableData data = await membership.ReadAll(); TableVersion tableVersion = data.Version; logger.Info("Membership.ReadAll returned VableVersion={0} Data={1}", tableVersion, data); Assert.AreEqual(0, data.Members.Count, "Number of records returned - no table version row"); DateTime now = DateTime.UtcNow; MembershipEntry entry = new MembershipEntry { SiloAddress = siloAddress, StartTime = now, Status = SiloStatus.Active, }; TableVersion newTableVersion = tableVersion.Next(); bool ok = await membership.InsertRow(entry, newTableVersion); Assert.IsTrue(ok, "InsertRow completed successfully"); data = await membership.ReadRow(siloAddress); tableVersion = data.Version; logger.Info("Membership.ReadRow returned VableVersion={0} Data={1}", tableVersion, data); Assert.AreEqual(1, data.Members.Count, "Number of records returned - data row only"); Assert.IsNotNull(tableVersion.VersionEtag, "New version ETag should not be null"); Assert.AreNotEqual(newTableVersion.VersionEtag, tableVersion.VersionEtag, "New VersionEtag differetnfrom last"); Assert.AreEqual(newTableVersion.Version, tableVersion.Version, "New table version number"); MembershipEntry MembershipEntry = data.Members[0].Item1; string eTag = data.Members[0].Item2; logger.Info("Membership.ReadRow returned MembershipEntry ETag={0} Entry={1}", eTag, MembershipEntry); Assert.IsNotNull(eTag, "ETag should not be null"); Assert.IsNotNull(MembershipEntry, "MembershipEntry should not be null"); }