Skip to content

Commit a9bd7f1

Browse files
author
Alex McAuliffe
committed
Starting writing tests for Sticky pool #1810
1 parent 73184d5 commit a9bd7f1

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Collections.Concurrent;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Threading;
6+
using Elasticsearch.Net;
7+
using FluentAssertions;
8+
using Tests.Framework;
9+
10+
namespace Tests.ClientConcepts.ConnectionPooling.Sticky
11+
{
12+
public class Sticky
13+
{
14+
protected int NumberOfNodes = 10;
15+
16+
[U] public void EachViewStartsAtNexPositionAndWrapsOver()
17+
{
18+
var uris = Enumerable.Range(9200, NumberOfNodes).Select(p => new Uri("http://localhost:" + p));
19+
var staticPool = new StickyConnectionPool(uris);
20+
21+
this.AssertCreateView(staticPool);
22+
}
23+
24+
public void AssertCreateView(StickyConnectionPool pool)
25+
{
26+
var startingPositions = Enumerable.Range(0, NumberOfNodes)
27+
.Select(i => pool.CreateView().First())
28+
.Select(n => n.Uri.Port)
29+
.ToList();
30+
31+
var expectedOrder = Enumerable.Range(9200, NumberOfNodes);
32+
startingPositions.Should().ContainInOrder(expectedOrder);
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)