コード例 #1
0
        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");
            }
        }
コード例 #2
0
        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));
                        }
                    }
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
            }
        }
コード例 #5
0
        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));
            }
        }
コード例 #6
0
        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"));
        }
コード例 #7
0
ファイル: Task3Tests.cs プロジェクト: slogger/courses
        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));
            }
        }