//[Fact] //public void Persistence_Silo_StorageProvider_SimpleSQL(Type providerType) //{ // List<SiloHandle> silos = testingHost.GetActiveSilos().ToList(); // foreach (var silo in silos) // { // string provider = providerType.FullName; // List<string> providers = silo.Silo.TestHook.GetStorageProviderNames().ToList(); // Assert.IsTrue(providers.Contains(provider), "No storage provider found: {0}", provider); // } //} #region Utility functions // ---------- Utility functions ---------- void RunPerfTest(int n, string testName, TimeSpan target, Func <ISimpleSQLStorageTestGrain, Task> actionSimpleSQL) { ISimpleSQLStorageTestGrain[] simpleSQLStoreGrains = new ISimpleSQLStorageTestGrain[n]; for (int i = 0; i < n; i++) { Guid id = Guid.NewGuid(); simpleSQLStoreGrains[i] = GrainClient.GrainFactory.GetGrain <ISimpleSQLStorageTestGrain>(id); } TimeSpan baseline = new TimeSpan(0, 0, 5), elapsed; elapsed = TimeRun(n, baseline, testName + " (SimpleSQL Store)", () => RunIterations(testName, n, i => actionSimpleSQL(simpleSQLStoreGrains[i]))); if (elapsed > target.Multiply(timingFactor)) { string msg = string.Format("{0}: Elapsed time {1} exceeds target time {2}", testName, elapsed, target); if (elapsed > target.Multiply(2.0 * timingFactor)) { Assert.True(false, msg); } else { //this is from xunit //throw new SkipException(msg); } } }
public async Task Grain_GuidKey_SimpleSQLStore_Read_Write() { Guid id = Guid.NewGuid(); ISimpleSQLStorageTestGrain grain = GrainClient.GrainFactory.GetGrain <ISimpleSQLStorageTestGrain>(id); int val = await grain.GetValue(); Assert.Equal(0, val); // "Initial value"); await grain.DoWrite(1); val = await grain.GetValue(); Assert.Equal(1, val); // "Value after Write-1"); await grain.DoWrite(2); val = await grain.GetValue(); Assert.Equal(2, val); // "Value after Write-2"); val = await grain.DoRead(); Assert.Equal(2, val); // "Value after Re-Read"); }
public async Task SimpleSQLStore_Delete() { Guid id = Guid.NewGuid(); if (!GrainClient.IsInitialized) { GrainClient.Initialize(HostedCluster.ClientConfiguration); } ISimpleSQLStorageTestGrain grain = GrainClient.GrainFactory.GetGrain <ISimpleSQLStorageTestGrain>(id); await grain.DoWrite(1); await grain.DoDelete(); int val = await grain.GetValue(); // Should this throw instead? Assert.Equal(0, val); // "Value after Delete"); await grain.DoWrite(2); val = await grain.GetValue(); Assert.Equal(2, val); // "Value after Delete + New Write"); }
public async Task Grain_SimpleSQLStore_Read() { Guid id = Guid.NewGuid(); ISimpleSQLStorageTestGrain grain = GrainClient.GrainFactory.GetGrain <ISimpleSQLStorageTestGrain>(id); int val = await grain.GetValue(); Assert.Equal(0, val); // "Initial value"); }
public async Task Grain_SimpleSQLStore_SiloRestart() { var initialServiceId = this.HostedCluster.ClusterConfiguration.Globals.ServiceId; var initialDeploymentId = this.HostedCluster.DeploymentId; Console.WriteLine("DeploymentId={0} ServiceId={1}", this.HostedCluster.DeploymentId, this.HostedCluster.ClusterConfiguration.Globals.ServiceId); Guid id = Guid.NewGuid(); if (!GrainClient.IsInitialized) { GrainClient.Initialize(HostedCluster.ClientConfiguration); } ISimpleSQLStorageTestGrain grain = GrainClient.GrainFactory.GetGrain <ISimpleSQLStorageTestGrain>(id); int val = await grain.GetValue(); Assert.Equal(0, val); // "Initial value"); await grain.DoWrite(1); Console.WriteLine("About to reset Silos"); //this.HostedCluster.RestartDefaultSilos(true); //only TestSiloHost supports this, make TestCluster a public get/set to force a recreate this.HostedCluster.StopAllSilos(); this.HostedCluster = null; this.HostedCluster = CreateTestCluster(); this.HostedCluster.Deploy(); Console.WriteLine("Silos restarted"); Console.WriteLine("DeploymentId={0} ServiceId={1}", this.HostedCluster.DeploymentId, this.HostedCluster.ClusterConfiguration.Globals.ServiceId); Assert.Equal(initialServiceId, this.HostedCluster.ClusterConfiguration.Globals.ServiceId); // "ServiceId same after restart."); Assert.NotEqual(initialDeploymentId, this.HostedCluster.DeploymentId); // "DeploymentId different after restart."); //something wonky with the global GrainClient in 1.5 - probably should stop using that guy anyway but for now, hard restart it if (GrainClient.IsInitialized) { GrainClient.Uninitialize(); GrainClient.Initialize(HostedCluster.ClientConfiguration); } grain = GrainClient.GrainFactory.GetGrain <ISimpleSQLStorageTestGrain>(id); val = await grain.GetValue(); Assert.Equal(1, val); // "Value after Write-1"); await grain.DoWrite(2); val = await grain.GetValue(); Assert.Equal(2, val); // "Value after Write-2"); val = await grain.DoRead(); Assert.Equal(2, val); // "Value after Re-Read"); }
public async Task Grain_SimpleSQLStore_Read() { Guid id = Guid.NewGuid(); if (!GrainClient.IsInitialized) { GrainClient.Initialize(HostedCluster.ClientConfiguration); } ISimpleSQLStorageTestGrain grain = GrainClient.GrainFactory.GetGrain <ISimpleSQLStorageTestGrain>(id); int val = await grain.GetValue(); Assert.Equal(0, val); // "Initial value"); }
public async Task SimpleSQLStore_Delete() { Guid id = Guid.NewGuid(); ISimpleSQLStorageTestGrain grain = GrainClient.GrainFactory.GetGrain <ISimpleSQLStorageTestGrain>(id); await grain.DoWrite(1); await grain.DoDelete(); int val = await grain.GetValue(); // Should this throw instead? Assert.Equal(0, val); // "Value after Delete"); await grain.DoWrite(2); val = await grain.GetValue(); Assert.Equal(2, val); // "Value after Delete + New Write"); }
public async Task Grain_SimpleSQLStore_SiloRestart() { var initialServiceId = this.HostedCluster.ClusterConfiguration.Globals.ServiceId; var initialDeploymentId = this.HostedCluster.DeploymentId; Console.WriteLine("DeploymentId={0} ServiceId={1}", this.HostedCluster.DeploymentId, this.HostedCluster.ClusterConfiguration.Globals.ServiceId); Guid id = Guid.NewGuid(); ISimpleSQLStorageTestGrain grain = GrainClient.GrainFactory.GetGrain <ISimpleSQLStorageTestGrain>(id); int val = await grain.GetValue(); Assert.Equal(0, val); // "Initial value"); await grain.DoWrite(1); Console.WriteLine("About to reset Silos"); //this.HostedCluster.RestartDefaultSilos(true); //only TestSiloHost supports this, make TestCluster a public get/set to force a recreate this.HostedCluster.StopAllSilos(); this.HostedCluster = null; this.HostedCluster = CreateTestCluster(); this.HostedCluster.Deploy(); Console.WriteLine("Silos restarted"); Console.WriteLine("DeploymentId={0} ServiceId={1}", this.HostedCluster.DeploymentId, this.HostedCluster.ClusterConfiguration.Globals.ServiceId); Assert.Equal(initialServiceId, this.HostedCluster.ClusterConfiguration.Globals.ServiceId); // "ServiceId same after restart."); Assert.NotEqual(initialDeploymentId, this.HostedCluster.DeploymentId); // "DeploymentId different after restart."); val = await grain.GetValue(); Assert.Equal(1, val); // "Value after Write-1"); await grain.DoWrite(2); val = await grain.GetValue(); Assert.Equal(2, val); // "Value after Write-2"); val = await grain.DoRead(); Assert.Equal(2, val); // "Value after Re-Read"); }
//[Fact] //public void Persistence_Silo_StorageProvider_SimpleSQL(Type providerType) //{ // List<SiloHandle> silos = testingHost.GetActiveSilos().ToList(); // foreach (var silo in silos) // { // string provider = providerType.FullName; // List<string> providers = silo.Silo.TestHook.GetStorageProviderNames().ToList(); // Assert.IsTrue(providers.Contains(provider), "No storage provider found: {0}", provider); // } //} #region Utility functions // ---------- Utility functions ---------- void RunPerfTest(int n, string testName, TimeSpan target, Func<ISimpleSQLStorageTestGrain, Task> actionSimpleSQL) { ISimpleSQLStorageTestGrain[] simpleSQLStoreGrains = new ISimpleSQLStorageTestGrain[n]; for (int i = 0; i < n; i++) { Guid id = Guid.NewGuid(); simpleSQLStoreGrains[i] = GrainClient.GrainFactory.GetGrain<ISimpleSQLStorageTestGrain>(id); } TimeSpan baseline = new TimeSpan(0, 0, 5), elapsed; elapsed = TimeRun(n, baseline, testName + " (SimpleSQL Store)", () => RunIterations(testName, n, i => actionSimpleSQL(simpleSQLStoreGrains[i]))); if (elapsed > target.Multiply(timingFactor)) { string msg = string.Format("{0}: Elapsed time {1} exceeds target time {2}", testName, elapsed, target); if (elapsed > target.Multiply(2.0 * timingFactor)) { Assert.True(false,msg); } else { //this is from xunit //throw new SkipException(msg); } } }