public void When_Replica_Index_Postive_LocatePrimary_Returns_It()
        {
            var server = new Server(
                new FakeIOService(IPEndPointExtensions.GetEndPoint("127.0.0.1:8091"),
                                  new FakeConnectionPool(), false),
                new NodeAdapter(new Node {
                Hostname = "127.0.0.1"
            },
                                new NodeExt()),
                new ClientConfiguration(),
                new BucketConfig {
                Name = "default"
            },
                new FakeTranscoder());

            var vbucket =
                new VBucket(new Dictionary <IPAddress, IServer>
            {
                { IPEndPointExtensions.GetEndPoint("127.0.0.1:10210").Address, server },
                { IPEndPointExtensions.GetEndPoint("127.0.0.2:10210").Address, server }
            },
                            100, -1, new[] { 0 }, 0, new VBucketServerMap {
                ServerList = new[] { "127.0.0.1:10210", "127.0.0.2:10210" }
            });
            var found = vbucket.LocatePrimary();

            Assert.IsNotNull(found);
        }
        public void When_Replica_Index_Postive_LocatePrimary_Returns_It()
        {
            var mockBucketConfig = new Mock <IBucketConfig>();

            var server = new Server(
                new FakeIOService(IPEndPointExtensions.GetEndPoint("127.0.0.1:8091"),
                                  new FakeConnectionPool(), false),
                new NodeAdapter(new Node {
                Hostname = "127.0.0.1"
            }, new NodeExt(), mockBucketConfig.Object),
                new FakeTranscoder(),
                ContextFactory.GetCouchbaseContext());

            var vbucket =
                new VBucket(new Dictionary <IPEndPoint, IServer>
            {
                { IPEndPointExtensions.GetEndPoint("127.0.0.1:10210"), server },
                { IPEndPointExtensions.GetEndPoint("127.0.0.2:10210"), server }
            },
                            100, -1, new[] { 0 }, 0, new VBucketServerMap {
                ServerList = new[] { "127.0.0.1:10210", "127.0.0.2:10210" }
            }, "default");
            var found = vbucket.LocatePrimary();

            Assert.IsNotNull(found);
        }
示例#3
0
        public void When_Replica_Index_1_LocatePrimary_Returns_Random_Server()
        {
            var vbucket = new VBucket(new List <IServer> {
            }, 100, -1, new[] { 0 });
            var found   = vbucket.LocatePrimary();

            Assert.IsNull(found);//should be null
        }
        public void When_Replica_Index_1_LocatePrimary_Returns_Random_Server()
        {
            var vbucket = new VBucket(new Dictionary <IPAddress, IServer> {
            }, 100, -1, new[] { 0 }, 0, new VBucketServerMap {
                ServerList = new [] { "127.0.0.1:10210" }
            });
            var found = vbucket.LocatePrimary();

            Assert.IsNull(found);//should be null
        }
示例#5
0
        public void When_Replica_Index_Positive_LocatePrimary_Returns_It()
        {
            var(vBucketServerMap, ipEndPoints) = GetServerMapAndIpEndPoints("127.0.0.1:10210", "127.0.0.2:10210");

            var vBucket = new VBucket(ipEndPoints, 100, -1, new short[] { 0 }, 0,
                                      vBucketServerMap, "default", new Mock <ILogger <VBucket> >().Object);
            var found = vBucket.LocatePrimary();

            Assert.NotNull(found);
        }
示例#6
0
        public void When_Replica_Index_1_LocatePrimary_Returns_Random_Server()
        {
            var(vBucketServerMap, ipEndPoints) = GetServerMapAndIpEndPoints();

            var vBucket = new VBucket(ipEndPoints, 100, -1, new short[] { 0 }, 0,
                                      vBucketServerMap, "default", new Mock <ILogger <VBucket> >().Object);
            var found = vBucket.LocatePrimary();

            Assert.Null(found);//should be null
        }
示例#7
0
        public void When_Replica_Index_1_LocatePrimary_Returns_Random_Server()
        {
            var vbucket = new VBucket(new List <IPEndPoint> {
            }, 100, -1, new short[] { 0 }, 0, new VBucketServerMap {
                ServerList = new [] { "127.0.0.1:10210" }
            }, "default");
            var found = vbucket.LocatePrimary();

            Assert.Null(found);//should be null
        }
        public void When_Replica_Index_Negative_LocatePrimary_Returns_Random_Server()
        {
            var vBucketServerMap = GetServerMap("127.0.0.1:10210");

            var vBucket = new VBucket(vBucketServerMap.EndPoints, 100, -1, new short[] { -1 }, 0,
                                      vBucketServerMap, "default", new Mock <ILogger <VBucket> >().Object);
            var found = vBucket.LocatePrimary();

            Assert.NotNull(found);
        }
示例#9
0
        public void When_Replica_Index_Negative_LocatePrimary_Returns_Random_Server()
        {
            var server = new Server(null, new Node {
                Hostname = "127.0.0.1"
            }, new ClientConfiguration());
            var vbucket = new VBucket(new List <IServer> {
                server, server
            }, 100, -1, new[] { -1 });
            var found = vbucket.LocatePrimary();

            Assert.IsNotNull(found);
        }
示例#10
0
        public void When_Replica_Index_OOR_LocatePrimary_Returns_Random_Server()
        {
            var server = new Server(null, new NodeAdapter(new Node {
                Hostname = "127.0.0.1"
            }, new NodeExt()), new ClientConfiguration(), new BucketConfig {
                Name = "default"
            });
            var vbucket = new VBucket(new List <IServer> {
                server, server
            }, 100, -1, new [] { 2 });
            var found = vbucket.LocatePrimary();

            Assert.IsNotNull(found);
        }
示例#11
0
        public void When_Replica_Index_Postive_LocatePrimary_Returns_It()
        {
            var vbucket =
                new VBucket(new List <IPEndPoint>
            {
                IpEndPointExtensions.GetEndPoint("127.0.0.1:10210"),
                IpEndPointExtensions.GetEndPoint("127.0.0.2:10210")
            },
                            100, -1, new short[] { 0 }, 0, new VBucketServerMap {
                ServerList = new[] { "127.0.0.1:10210", "127.0.0.2:10210" }
            }, "default");
            var found = vbucket.LocatePrimary();

            Assert.NotNull(found);
        }
示例#12
0
        public void When_Replica_Index_Negative_LocatePrimary_Returns_Random_Server()
        {
            var vbucket =
                new VBucket(new List <IPEndPoint>
            {
                IpEndPointExtensions.GetEndPoint("127.0.0.1:10210"),
                IpEndPointExtensions.GetEndPoint("127.0.0.2:10210")
            },
                            100, -1, new short[] { -1 }, 0, new VBucketServerMap {
                ServerList = new[] { "127.0.0.1:10210" }
            }, "default",
                            new Mock <ILogger <VBucket> >().Object);
            var found = vbucket.LocatePrimary();

            Assert.NotNull(found);
        }