G-Research / consuldotnet

Consul.NET is a .NET client library for the Consul HTTP API
https://consuldot.net/
Apache License 2.0
319 stars 82 forks source link

Read LAN Coordinates for a specific node #314

Closed JocelynVelarde closed 2 months ago

JocelynVelarde commented 3 months ago

Changes made

  1. Added GET /v1/coordinate/node/+node into Coordinate.cs
  2. Included new endpoints into ICoordinateEndpoint.cs
  3. Added test CoordinateTest.cs

Issue ticket number and link

Refers to issue #313

JocelynVelarde commented 3 months ago

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.

I already fixed this on the recent commit, let me know if it needs further adjustments :)

marcin-krystianc commented 3 months ago

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.

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.

marcin-krystianc commented 3 months ago

Hi @JocelynVelarde,

there is a problem with the coordinates endpoint, which returns empty responses for some time after starting the consul agent (e.g. https://github.com/G-Research/consuldotnet/actions/runs/8692709325/job/23862884528). We can fix this by bumping the wait time and adding another check in the Base Fixture class:

image
JocelynVelarde commented 3 months ago

Hi @JocelynVelarde,

there is a problem with the coordinates endpoint, which returns empty responses for some time after starting the consul agent (e.g. https://github.com/G-Research/consuldotnet/actions/runs/8692709325/job/23862884528).

We can fix this by bumping the wait time and adding another check in the Base Fixture class:

image

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?

marcin-krystianc commented 3 months ago

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

JocelynVelarde commented 3 months ago

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?