public void Store_Delete() { string name = Guid.NewGuid().ToString();//TestContext.TestName; ILocalDataStore store = new HierarchicalKeyStore(2); GrainReference reference = this.fixture.InternalGrainFactory.GetGrain(LegacyGrainId.NewId()); var data = TestStoreGrainState.NewRandomState(); output.WriteLine("Using store = {0}", store.GetType().FullName); Stopwatch sw = new Stopwatch(); var keys = GetKeys(name, reference); sw.Restart(); string eTag = store.WriteRow(keys, AsDictionary(data.State), null); output.WriteLine("Write returned Etag={0} after {1} {2}", eTag, sw.Elapsed, StorageProviderUtils.PrintOneWrite(keys, data, eTag)); sw.Restart(); var storedData = store.ReadRow(keys); output.WriteLine("Read returned {0} after {1}", StorageProviderUtils.PrintOneWrite(keys, storedData, eTag), sw.Elapsed); Assert.NotNull(data); // Should get some data from Read sw.Restart(); bool ok = store.DeleteRow(keys, eTag); Assert.True(ok, $"Row deleted OK after {sw.Elapsed}. Etag={eTag} Keys={StorageProviderUtils.PrintKeys(keys)}"); sw.Restart(); storedData = store.ReadRow(keys); // Try to re-read after delete output.WriteLine("Re-Read took {0} and returned {1}", sw.Elapsed, StorageProviderUtils.PrintData(storedData)); Assert.NotNull(data); // Should not get null data from Re-Read Assert.True(storedData.Count == 0, $"Should get no data from Re-Read but got: {StorageProviderUtils.PrintData(storedData)}"); sw.Restart(); const string oldEtag = null; eTag = store.WriteRow(keys, storedData, oldEtag); output.WriteLine("Write for Keys={0} Etag={1} Data={2} returned New Etag={3} after {4}", StorageProviderUtils.PrintKeys(keys), oldEtag, StorageProviderUtils.PrintData(storedData), eTag, sw.Elapsed); sw.Restart(); ok = store.DeleteRow(keys, eTag); Assert.True(ok, $"Row deleted OK after {sw.Elapsed}. Etag={eTag} Keys={StorageProviderUtils.PrintKeys(keys)}"); }
public void Store_WriteRead() { string name = Guid.NewGuid().ToString();//TestContext.TestName; ILocalDataStore store = new HierarchicalKeyStore(2); GrainReference reference = fixture.InternalGrainFactory.GetGrain(LegacyGrainId.NewId()); var state = TestStoreGrainState.NewRandomState(); Stopwatch sw = new Stopwatch(); sw.Start(); var keys = GetKeys(name, reference); var stateProperties = AsDictionary(state.State); store.WriteRow(keys, stateProperties, state.ETag); TimeSpan writeTime = sw.Elapsed; sw.Restart(); var data = store.ReadRow(keys); TimeSpan readTime = sw.Elapsed; output.WriteLine("{0} - Write time = {1} Read time = {2}", store.GetType().FullName, writeTime, readTime); Assert.Equal(state.State.A, data["A"]); // "A" Assert.Equal(state.State.B, data["B"]); // "B" Assert.Equal(state.State.C, data["C"]); // "C" }
public void HKS_3Key_Read_Write() { string testName = Guid.NewGuid().ToString(); //TestContext.TestName; int key1 = _keyCounter++; int key2 = _keyCounter++; int key3 = _keyCounter++; var keys = new[] { Tuple.Create(KeyName1, key1.ToString(CultureInfo.InvariantCulture)), Tuple.Create(KeyName2, key2.ToString(CultureInfo.InvariantCulture)), Tuple.Create(KeyName3, key3.ToString(CultureInfo.InvariantCulture)) }.ToList(); var data = new Dictionary <string, object>(); data[ValueName1] = testName + 1; data[ValueName2] = testName + 2; data[ValueName3] = testName + 3; var store = new HierarchicalKeyStore(3); string eTag = store.WriteRow(keys, data, null); var result = store.ReadRow(keys); Assert.NotNull(result); // Null result foreach (string valueName in data.Keys) { Assert.Equal(data[valueName], result[valueName]); } }
public void GrainState_Store_WriteRead() { string name = Guid.NewGuid().ToString();//TestContext.TestName; ILocalDataStore store = new HierarchicalKeyStore(2); GrainReference reference = this.fixture.InternalGrainFactory.GetGrain(LegacyGrainId.NewId()); var grainState = TestStoreGrainState.NewRandomState(); var state = grainState.State; Stopwatch sw = new Stopwatch(); sw.Start(); IList <Tuple <string, string> > keys = new[] { Tuple.Create("GrainType", name), Tuple.Create("GrainId", reference.GrainId.ToString()) }.ToList(); store.WriteRow(keys, AsDictionary(state), grainState.ETag); TimeSpan writeTime = sw.Elapsed; sw.Restart(); var data = store.ReadRow(keys); TimeSpan readTime = sw.Elapsed; output.WriteLine("{0} - Write time = {1} Read time = {2}", store.GetType().FullName, writeTime, readTime); Assert.Equal(state.A, data["A"]); // "A" Assert.Equal(state.B, data["B"]); // "B" Assert.Equal(state.C, data["C"]); // "C" }
public void HKS_Write2() { string testName = Guid.NewGuid().ToString(); //TestContext.TestName; int key1 = _keyCounter++; int key2 = _keyCounter++; List <Tuple <string, string> > keys = MakeKeys(key1, key2); var data = new Dictionary <string, object>(); data[ValueName1] = testName; var store = new HierarchicalKeyStore(keys.Count); // Write #1 string eTag = store.WriteRow(keys, data, null); data[ValueName1] = "One"; data[ValueName2] = "Two"; data[ValueName3] = "Three"; // Write #2 string newEtag = store.WriteRow(keys, data, eTag); var result = store.ReadRow(keys); Assert.NotNull(result); // Null result foreach (string valueName in data.Keys) { Assert.Equal(data[valueName], result[valueName]); } }
public void HKS_1Key_Read_Write() { string testName = Guid.NewGuid().ToString(); //TestContext.TestName; int key1 = _keyCounter++; var keys = new[] { Tuple.Create(KeyName1, key1.ToString(CultureInfo.InvariantCulture)) }.ToList(); var data = new Dictionary <string, object>(); data.Add(ValueName1, testName); var store = new HierarchicalKeyStore(1); string eTag = store.WriteRow(keys, data, null); var result = store.ReadRow(keys); Assert.IsNotNull(result, "Null result"); foreach (string valueName in data.Keys) { Assert.AreEqual(data[valueName], result[valueName], valueName); } }
public void Store_WriteRead() { string name = TestContext.TestName; ILocalDataStore store = new HierarchicalKeyStore(2); GrainReference reference = GrainReference.FromGrainId(GrainId.NewId()); TestStoreGrainState state = TestStoreGrainState.NewRandomState(); Stopwatch sw = new Stopwatch(); sw.Start(); var keys = GetKeys(name, reference); store.WriteRow(keys, state.AsDictionary(), state.Etag); TimeSpan writeTime = sw.Elapsed; sw.Restart(); TestStoreGrainState storedState = new TestStoreGrainState(); var data = store.ReadRow(keys); storedState.SetAll(data); TimeSpan readTime = sw.Elapsed; Console.WriteLine("{0} - Write time = {1} Read time = {2}", store.GetType().FullName, writeTime, readTime); Assert.AreEqual(state.A, storedState.A, "A"); Assert.AreEqual(state.B, storedState.B, "B"); Assert.AreEqual(state.C, storedState.C, "C"); }
public void GrainState_Store_WriteRead() { string name = TestContext.TestName; ILocalDataStore store = new HierarchicalKeyStore(2); GrainReference reference = GrainReference.FromGrainId(GrainId.NewId()); var grainState = TestStoreGrainState.NewRandomState(); var state = grainState.State; Stopwatch sw = new Stopwatch(); sw.Start(); IList <Tuple <string, string> > keys = new[] { Tuple.Create("GrainType", name), Tuple.Create("GrainId", reference.GrainId.GetPrimaryKey().ToString("N")) }.ToList(); store.WriteRow(keys, AsDictionary(state), grainState.ETag); TimeSpan writeTime = sw.Elapsed; sw.Restart(); var data = store.ReadRow(keys); TimeSpan readTime = sw.Elapsed; Console.WriteLine("{0} - Write time = {1} Read time = {2}", store.GetType().FullName, writeTime, readTime); Assert.AreEqual(state.A, data["A"], "A"); Assert.AreEqual(state.B, data["B"], "B"); Assert.AreEqual(state.C, data["C"], "C"); }
public void Store_Delete() { string name = TestContext.TestName; ILocalDataStore store = new HierarchicalKeyStore(2); GrainReference reference = GrainReference.FromGrainId(GrainId.NewId()); IDictionary <string, object> data = TestStoreGrainState.NewRandomState().AsDictionary(); Console.WriteLine("Using store = {0}", store.GetType().FullName); Stopwatch sw = new Stopwatch(); var keys = GetKeys(name, reference); sw.Restart(); string eTag = store.WriteRow(keys, data, null); Console.WriteLine("Write returned Etag={0} after {1} {2}", eTag, sw.Elapsed, StorageProviderUtils.PrintOneWrite(keys, data, eTag)); sw.Restart(); data = store.ReadRow(keys); Console.WriteLine("Read returned {0} after {1}", StorageProviderUtils.PrintOneWrite(keys, data, eTag), sw.Elapsed); Assert.IsNotNull(data, "Should get some data from Read"); sw.Restart(); bool ok = store.DeleteRow(keys, eTag); Assert.IsTrue(ok, "Row deleted OK after {0}. Etag={1} Keys={2}", sw.Elapsed, eTag, StorageProviderUtils.PrintKeys(keys)); sw.Restart(); data = store.ReadRow(keys); // Try to re-read after delete Console.WriteLine("Re-Read took {0} and returned {1}", sw.Elapsed, StorageProviderUtils.PrintData(data)); Assert.IsNotNull(data, "Should not get null data from Re-Read"); Assert.IsTrue(data.Count == 0, "Should get no data from Re-Read but got: {0}", StorageProviderUtils.PrintData(data)); sw.Restart(); const string oldEtag = null; eTag = store.WriteRow(keys, data, oldEtag); Console.WriteLine("Write for Keys={0} Etag={1} Data={2} returned New Etag={3} after {4}", StorageProviderUtils.PrintKeys(keys), oldEtag, StorageProviderUtils.PrintData(data), eTag, sw.Elapsed); sw.Restart(); ok = store.DeleteRow(keys, eTag); Assert.IsTrue(ok, "Row deleted OK after {0}. Etag={1} Keys={2}", sw.Elapsed, eTag, StorageProviderUtils.PrintKeys(keys)); }
public void HKS_DeleteRow() { string testName = Guid.NewGuid().ToString(); //TestContext.TestName; int key1 = _keyCounter++; int key2 = _keyCounter++; int key3 = _keyCounter++; int key4 = _keyCounter++; List <Tuple <string, string> > keys1 = MakeKeys(key1, key2); List <Tuple <string, string> > keys2 = MakeKeys(key3, key4); var data = new Dictionary <string, object>(); data[ValueName1] = testName; var store = new HierarchicalKeyStore(keys1.Count); // Write #1 string eTag = store.WriteRow(keys1, data, null); data[ValueName1] = "One"; data[ValueName2] = "Two"; data[ValueName3] = "Three"; // Write #2 string newEtag = store.WriteRow(keys2, data, eTag); store.DeleteRow(keys1, newEtag); var result = store.ReadRow(keys1); Assert.IsNotNull(result, "Should not be Null result after DeleteRow"); Assert.AreEqual(0, result.Count, "No data after DeleteRow"); result = store.ReadRow(keys2); Assert.IsNotNull(result, "Null result"); foreach (string valueName in data.Keys) { Assert.AreEqual(data[valueName], result[valueName], valueName); } }
public void HKS_KeyNotFound() { string testName = Guid.NewGuid().ToString(); //TestContext.TestName; int key1 = _keyCounter++; int key2 = _keyCounter++; List <Tuple <string, string> > keys = MakeKeys(key1, key2); var store = new HierarchicalKeyStore(keys.Count); var result = store.ReadRow(keys); Assert.NotNull(result); // Null result Assert.Equal(0, result.Count); // No data }
public void HKS_KeyNotFound() { string testName = TestContext.TestName; int key1 = _keyCounter++; int key2 = _keyCounter++; List <Tuple <string, string> > keys = MakeKeys(key1, key2); var store = new HierarchicalKeyStore(keys.Count); var result = store.ReadRow(keys); Assert.IsNotNull(result, "Null result"); Assert.AreEqual(0, result.Count, "No data"); }
public void Store_Read() { string name = Guid.NewGuid().ToString();//TestContext.TestName; ILocalDataStore store = new HierarchicalKeyStore(2); GrainReference reference = GrainReference.FromGrainId(GrainId.NewId()); TestStoreGrainState state = new TestStoreGrainState(); var stateProperties = AsDictionary(state); var keys = GetKeys(name, reference); store.WriteRow(keys, stateProperties, null); Stopwatch sw = new Stopwatch(); sw.Start(); var data = store.ReadRow(keys); TimeSpan readTime = sw.Elapsed; output.WriteLine("{0} - Read time = {1}", store.GetType().FullName, readTime); Assert.AreEqual(state.A, data["A"], "A"); Assert.AreEqual(state.B, data["B"], "B"); Assert.AreEqual(state.C, data["C"], "C"); }