private void TestReplicaDown(string replica, string id) { using (var httpClient = new HttpClient()) { ActionOnReplica(replica, httpClient, "stop"); for (int i = 0; i < 10; ++i) { fullTopologyClient.Get(id); } ActionOnReplica(replica, httpClient, "start"); } }
public void Sharding_Always_ShouldSaveAllData() { using (SimpleStorageTestHelpers.StartService(port1)) using (SimpleStorageTestHelpers.StartService(port2)) using (SimpleStorageTestHelpers.StartService(port3)) { 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)); simpleStorageClient.Put(id, value); } foreach (var item in items) { var actual = simpleStorageClient.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_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 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_ShouldSaveAllData() { 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) { var actual = client.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)); } }