public void Read_Always_ShouldReturnAllOperations() { const string id = "id"; var version1 = new Value { Content = "content", IsDeleted = false, Revision = 0 }; using (SimpleStorageTestHelpers.StartService(port)) { storageClient.Put(id, version1); var version2 = new Value { IsDeleted = true, Revision = 1, Content = "anotherContent" }; storageClient.Put(id, version2); var actual = operationLogClient.Read(0, 100).ToArray(); Assert.That(actual.Length, Is.EqualTo(2)); Assert.That(actual[0].Id, Is.EqualTo(id)); Assert.That(actual[0].Value.Content, Is.EqualTo(version1.Content)); Assert.That(actual[0].Value.IsDeleted, Is.False); Assert.That(actual[1].Id, Is.EqualTo(id)); Assert.That(actual[1].Value.IsDeleted, Is.True); } }
public void Sharding_AllShards_ShouldContainSomeData() { for (var i = 0; i < 100; i++) { client.Put(Guid.NewGuid().ToString(), new Value { Content = "content" }); } Assert.That(GetAll(endpoint1).ToArray(), Has.Length.GreaterThan(0)); Assert.That(GetAll(endpoint2).ToArray(), Has.Length.GreaterThan(0)); Assert.That(GetAll(endpoint3).ToArray(), Has.Length.GreaterThan(0)); }
public void Sharding_EachShard_ShouldNotContainAllData() { for (var i = 0; i < 100; i++) { client.Put(Guid.NewGuid().ToString(), new Value { Content = "content" }); } Assert.That(GetAll(endpoint1).ToArray(), Has.Length.LessThan(100)); Assert.That(GetAll(endpoint2).ToArray(), Has.Length.LessThan(100)); Assert.That(GetAll(endpoint3).ToArray(), Has.Length.LessThan(100)); }
public void Get_KnownId_ShouldReturnValue() { const string id = "id"; var value = new Value { Content = "content" }; using (WebApp.Start <Startup>(string.Format("http://+:{0}/", port))) { client.Put(id, value); var actual = client.Get(id); Assert.That(actual.Content, Is.EqualTo(value.Content)); } }
public void Get_KnownId_ShouldReturnValue() { const string id = "id"; var value = new Value { Content = "content" }; using (SimpleStorageTestHelpers.StartService(port)) { client.Put(id, value); var actual = client.Get(id); Assert.That(actual.Content, Is.EqualTo(value.Content)); } }
public void Put_OnMaster_ShouldAvailableOnSlaves() { string id = Guid.NewGuid().ToString(); var value = new Value { Content = "content" }; masterClient.Put(id, value); Thread.Sleep(2000); Value value1 = slave1Client.Get(id); Assert.That(value1.Content, Is.EqualTo("content")); Value value2 = slave2Client.Get(id); Assert.That(value2.Content, Is.EqualTo("content")); }
public void Sharding_Always_ShouldReadAllData() { var client = new SimpleStorageClient(endpoint1); var items = new List <KeyValuePair <string, Value> >(); for (var i = 0; i < 100; i++) { var id = Guid.NewGuid().ToString(); var value = new Value { Content = "content" }; items.Add(new KeyValuePair <string, Value>(id, value)); client.Put(id, value); } foreach (var item in items) { foreach (var endpoint in new[] { endpoint1, endpoint2, endpoint3 }) { var actual = new SimpleStorageClient(endpoint).Get(item.Key); Assert.That(actual.Content, Is.EqualTo(item.Value.Content)); Assert.That(actual.IsDeleted, Is.EqualTo(item.Value.IsDeleted)); Assert.That(actual.Revision, Is.EqualTo(item.Value.Revision)); } } }
public void Get_ManyTimes_ShouldWorkWhenReplicasDown() { string id = Guid.NewGuid().ToString(); var value = new Value { Content = "content" }; fullTopologyClient.Put(id, value); for (int i = 0; i < 100; ++i) { fullTopologyClient.Get(id); } Thread.Sleep(2000); TestReplicaDown(slave1Endpoint, id); TestReplicaDown(slave2Endpoint, id); TestReplicaDown(masterEndpoint, id); }
public void Get_ManyTimes_ShouldFaultTolerant() { string id = Guid.NewGuid().ToString(); var value = new Value { Content = "content" }; fullTopologyClient.Put(id, value); for (int i = 0; i < 100; ++i) { fullTopologyClient.Get(id); } Thread.Sleep(2000); TestReplicaDown(replica1Endpoint, () => fullTopologyClient.Get(id)); TestReplicaDown(replica2Endpoint, () => fullTopologyClient.Get(id)); TestReplicaDown(replica3Endpoint, () => fullTopologyClient.Get(id)); }
public void Sharding_EachShard_ShouldNotContainAllData() { using (SimpleStorageTestHelpers.StartService(port1)) using (SimpleStorageTestHelpers.StartService(port2)) using (SimpleStorageTestHelpers.StartService(port3)) { for (var i = 0; i < 100; i++) { simpleStorageClient.Put(Guid.NewGuid().ToString(), new Value { Content = "content" }); } Assert.That(GetAll(endpoint1).ToArray(), Has.Length.LessThan(100)); Assert.That(GetAll(endpoint2).ToArray(), Has.Length.LessThan(100)); Assert.That(GetAll(endpoint3).ToArray(), Has.Length.LessThan(100)); } }
public void Put_OnSlaves_ShouldThrow() { string id = Guid.NewGuid().ToString(); var value = new Value { Content = "content" }; Assert.Throws(CheckHttpException(HttpStatusCode.NotImplemented), () => slave1Client.Put(id, value)); Assert.Throws(CheckHttpException(HttpStatusCode.NotImplemented), () => slave2Client.Put(id, value)); masterClient.Put(id, value); }