public static async Task Initialize(Silo silo) { var config = silo.GlobalConfig; var serviceType = config.ReminderServiceType; switch (serviceType) { default: throw new NotSupportedException( String.Format( "The reminder table does not currently support service provider {0}.", serviceType)); case GlobalConfiguration.ReminderServiceProviderType.SqlServer: Singleton = new SqlReminderTable(config); return; case GlobalConfiguration.ReminderServiceProviderType.AzureTable: Singleton = await AzureBasedReminderTable.GetAzureBasedReminderTable( config.ServiceId, config.DeploymentId, config.DataConnectionString); return; case GlobalConfiguration.ReminderServiceProviderType.ReminderTableGrain: Singleton = ReminderTableFactory.GetGrain(Constants.ReminderTableGrainId); return; case GlobalConfiguration.ReminderServiceProviderType.MockTable: Singleton = new MockReminderTable(config.MockReminderTableTimeout); return; } }
public async Task Reminders_AzureTable_InsertNewRowAndReadBack() { log.Info(TestContext.TestName); string deploymentId = NewDeploymentId(); IReminderTable table = new AzureBasedReminderTable(); var config = new GlobalConfiguration() { ServiceId = ServiceId, DeploymentId = deploymentId, DataConnectionString = StorageTestConstants.DataConnectionString }; await table.Init(config, log); ReminderEntry[] rows = (await GetAllRows(table)).ToArray(); Assert.AreEqual(0, rows.Count(), "The reminder table (sid={0}, did={1}) was not empty.", ServiceId, deploymentId); ReminderEntry expected = NewReminderEntry(); await table.UpsertRow(expected); rows = (await GetAllRows(table)).ToArray(); Assert.AreEqual(1, rows.Count(), "The reminder table (sid={0}, did={1}) did not contain the correct number of rows (1).", ServiceId, deploymentId); ReminderEntry actual = rows[0]; Assert.AreEqual(expected.GrainRef, actual.GrainRef, "The newly inserted reminder table (sid={0}, did={1}) row did not contain the expected grain reference.", ServiceId, deploymentId); Assert.AreEqual(expected.ReminderName, actual.ReminderName, "The newly inserted reminder table (sid={0}, did={1}) row did not have the expected reminder name.", ServiceId, deploymentId); Assert.AreEqual(expected.Period, actual.Period, "The newly inserted reminder table (sid={0}, did={1}) row did not have the expected period.", ServiceId, deploymentId); // the following assertion fails but i don't know why yet-- the timestamps appear identical in the error message. it's not really a priority to hunt down the reason, however, because i have high confidence it is working well enough for the moment. /*Assert.AreEqual(expected.StartAt, actual.StartAt, "The newly inserted reminder table (sid={0}, did={1}) row did not contain the correct start time.", ServiceId, deploymentId);*/ Assert.IsFalse(string.IsNullOrWhiteSpace(actual.ETag), "The newly inserted reminder table (sid={0}, did={1}) row contains an invalid etag.", ServiceId, deploymentId); }
public static async Task <AzureBasedReminderTable> GetAzureBasedReminderTable(Guid serviceId, string deploymentId, string connectionString) { var table = new AzureBasedReminderTable(); table.remTableManager = await RemindersTableManager.GetManager(serviceId, deploymentId, connectionString); return(table); }
public async Task Reminders_AzureTable_InsertRate() { IReminderTable table = new AzureBasedReminderTable(); var config = new GlobalConfiguration() { ServiceId = ServiceId, DeploymentId = "TMSLocalTesting", DataConnectionString = StorageTestConstants.DataConnectionString }; await table.Init(config, log); await TestTableInsertRate(table, 10); await TestTableInsertRate(table, 500); }