-
Notifications
You must be signed in to change notification settings - Fork 86
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
Read LAN Coordinates for a specific node #314
Read LAN Coordinates for a specific node #314
Conversation
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.
Tests are failing to compile (because of missing query options parameter).
Please note also that the 'Node' endpoint returns an array (https://developer.hashicorp.com/consul/api-docs/v1.9.x/coordinate#sample-response-2), instead of a single object.
I'm not sure how to handle it. It seems unlikely that there will be more than one entry in the result, but since the endpoint returns an array we probably should use an array in the result as well.
@@ -29,6 +29,7 @@ public interface ICoordinateEndpoint | |||
{ | |||
Task<QueryResult<CoordinateDatacenterMap[]>> Datacenters(CancellationToken ct = default); | |||
Task<QueryResult<CoordinateEntry[]>> Nodes(CancellationToken ct = default); | |||
Task<QueryResult<CoordinateEntry>> Node(string node, QueryOptions q, 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.
There are two overloads of Nodes
endpoint (with and without QueryOptions q
parameter).
We can Apply the same pattern for the new Node
endpoint`
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.
Sure noted! Already fixed 🚀
I already fixed this on the recent commit, let me know if it needs further adjustments :) |
I've run the CI and there are some compilation issues. Please have a look. |
Hi @JocelynVelarde, there is a problem with the |
Alright noted! Is there any way I can test the endpoint locally (making the request) so I can check the output before submitting for review? |
Sure thing, there is a description how to to start local agent for tests -> https://consuldot.net/docs/getting-started/setting-up-server |
Yeaaa! That's how I started running tests yesterday, so on the CLI I have to write the fetch request? |
….com/JocelynVelarde/consuldotnet into G-Research#313-read-node-coordinates
Consul/Coordinate.cs
Outdated
|
||
public Task<QueryResult<CoordinateEntry[]>> Node(string node, CancellationToken ct = default) | ||
{ | ||
return _client.Get<CoordinateEntry[]>(string.Format("/v1/coordinate/node/{0}", node)).Execute(ct); |
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.
Can be replaced with:
return _client.Get<CoordinateEntry[]>(string.Format("/v1/coordinate/node/{0}", node)).Execute(ct); | |
return Node(node, QueryOptions.Default, ct); |
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.
Alright done
Consul.Test/BaseFixture.cs
Outdated
@@ -67,6 +67,10 @@ public class BaseFixture : IAsyncLifetime | |||
// Workaround for https://github.com/hashicorp/consul/issues/15061 | |||
await client.Agent.GetAgentMetrics(); | |||
|
|||
/*var nodesResponse = await client.Coordinate.Nodes(); |
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.
Is it commented out by mistake?
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.
Ohh let me activate it again
|
||
[Fact] | ||
public async Task Coordinate_GetNode() | ||
{ |
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.
Previous version of the test was better, we did actually use a real node name in the query before.
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.
The thing is that with the node name I was receiving errors in the base fixture class
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, looks good. Just one final remark about removing unnecessary code.
Consul.Test/CoordinateTest.cs
Outdated
|
||
// Additional assertions can be added based on the expected properties of each node | ||
// For example, if you expect certain properties like node name, ID, etc. to be present in each node detail | ||
// Assert.NotNull(nodeDetails[0].PropertyName); | ||
// Assert.Equal(expectedValue, nodeDetails[0].PropertyName); |
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.
Please remove that unnecessary lines:
// Additional assertions can be added based on the expected properties of each node | |
// For example, if you expect certain properties like node name, ID, etc. to be present in each node detail | |
// Assert.NotNull(nodeDetails[0].PropertyName); | |
// Assert.Equal(expectedValue, nodeDetails[0].PropertyName); |
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.
Now it is perfect, thank you!
I need to sort out macOS CI failures before merging it.
Changes made
Coordinate.cs
ICoordinateEndpoint.cs
CoordinateTest.cs
Issue ticket number and link
Refers to issue #313