-
Notifications
You must be signed in to change notification settings - Fork 94
Added PUT Update LAN Coordinates endpoints, added tests for it #348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added PUT Update LAN Coordinates endpoints, added tests for it #348
Conversation
…olchanov/consuldotnet into add-update-lan-coordinates
marcin-krystianc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some suggestions
| Task<QueryResult<CoordinateEntry[]>> Node(string node, QueryOptions q, CancellationToken ct = default); | ||
| Task<QueryResult<CoordinateEntry[]>> Node(string node, CancellationToken ct = default); | ||
| Task<QueryResult<CoordinateEntry[]>> Nodes(QueryOptions q, CancellationToken ct = default); | ||
| Task<WriteResult> Update(CoordinateEntry entry, CancellationToken ct = default); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we also need a variant with WriteOptions
Consul.Test/CoordinateTest.cs
Outdated
| Assert.Equal("OK", response.StatusCode.ToString()); | ||
|
|
||
| var newCoordResult = await _client.Coordinate.Node(nodeName); | ||
| for (int i = 0; i < 5; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of that loop.
I think there is a reliable way to query the node without using the loop.
You can use so called "blocking queries", i.e.: use query options with a non-zero wait-index:
await _client.Catalog.Register(registration);
var nodeResult = await _client.Catalog.Node(nodeName);
Assert.Equal(HttpStatusCode.OK, nodeResult.StatusCode);
...
await _client.Coordinate.Update(coord);
...
var q = new QueryOptions{ WaitIndex = nodeResult.LastIndex, };
var newCoordResult = await _client.Coordinate.Node(nodeName, q);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
I tried this locally and it seemed working reliably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair, there wasn't really a similar situation in the previous code, so I went for something similar to Golang code's retry loop. Should we change waitTime to around 10 seconds, to avoid hanging for the default 5 minutes? And I have a little question, I am a bit confused on how is the index of node registered in catalog connected to the coordinate node? I am still working on my familiarity with all consul features, sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, it is sometimes a bit of unknown for me as well 😄 I'm concerned about the loop because it introduces a risk of flakiness. We run each test many times (we have a matrix with os, consul version and runtime version), thus we need to have really robust tests.
I think the "LastIndex"/"WaitIndex" are global, so it doesn't matter that they are from different endpoints.
Should we change waitTime to around 10 seconds, to avoid hanging for the default 5 minutes
I think it is better to wait longer, but have more robust tests. Therefore I wouldn't change the default waitTime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!) Makes sense, I will commit all the changes and we see how the tests go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: I've just updated my code snipped from above, to make it clear that the Catalog.Node() call should be before the Coordinate.Update() call.
Co-authored-by: Marcin Krystianc <[email protected]>
Co-authored-by: Marcin Krystianc <[email protected]>
…olchanov/consuldotnet into add-update-lan-coordinates
Okey, everything should be good |
marcin-krystianc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍
|
PS: I think you need to push some dummy changes, so the last commit is not from whitespace fixing bot. Otherwise, It is impossible to merge it. |
Resolves #322
@marcin-krystianc