-
Notifications
You must be signed in to change notification settings - Fork 94
Added GET GatewayService endpoint, tests for it #347
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 GET GatewayService endpoint, tests for it #347
Conversation
Had to Add TerminatingGatewayConfigEntry and IngressGatewayConfigEntry classes for testing purposes
|
@marcin-krystianc should be a working version of #321 |
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.
Nicely done! Just left a comment that we've already a configuration.cs file with all possible config structures defined.
Consul/Catalog.cs
Outdated
| public bool FromWildcard { get; set; } | ||
| } | ||
|
|
||
| public class TerminatingGatewayConfigEntry : IConfigurationEntry |
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.
We already have a TerminalGatewayEntry in the Configuration.cs file so there is no need to re-define it.
I think the TerminalGatewayEntry and associated LinkedService are incorrectly defined, but feel free to fix them.
It will break backward compatibility, but those structs are likely not used by anyone since they are not correctly defined.
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.
Oh, I am surprised how I missed it. Some of the classes were a bit incorrect. TerminatingGatewayEntry had a wrong name, LinkedService has wrong class structure, TerminatingGatewayEntry had excess fields. IngressGatewayEntry wasn't implementing IConfigEntry. Also I could rename them to TerminatingGatewayConfigEntry and IngressGatewayConfigEntry as in Golang client code, but that isn't critical.
…ed Configuration.cs to have correct classes Changed name TerminalGatewayEntry to TerminatingGatewayEntry
|
@marcin-krystianc Tests for backward compatibility fail as expected, but everything else seems to be working. |
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.
I think it is almost ready to go, see the comments.
Consul.Test/CatalogTest.cs
Outdated
| Assert.DoesNotContain(services.Response.Services, n => n.ID == svcID2); | ||
| } | ||
|
|
||
| [Fact] |
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 test fails for consul 1.6 and 1.7, you can skip running it for these consul versions: see
consuldotnet/Consul.Test/AgentTest.cs
Lines 542 to 546 in 18a429e
| [SkippableFact] | |
| public async Task Agent_MonitorJSON() | |
| { | |
| var cutOffVersion = SemanticVersion.Parse("1.7.0"); | |
| Skip.If(AgentVersion < cutOffVersion, $"Current version is {AgentVersion}, but `logjson` is only supported from Consul {cutOffVersion}"); |
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.
Okey, let me fix that!
Consul.Test/CatalogTest.cs
Outdated
| c.Address = TestHelper.HttpUri; | ||
| })) | ||
| { | ||
| var terminatingGatewayName = "terminating-gateway"; |
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 would use a non-standard name, e.g.:
| var terminatingGatewayName = "terminating-gateway"; | |
| var terminatingGatewayName = "my-terminating-gateway"; |
Consul.Test/CatalogTest.cs
Outdated
| })) | ||
| { | ||
| var terminatingGatewayName = "terminating-gateway"; | ||
| var ingressGatewayName = "ingress-gateway"; |
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 would use a non-standard name, e.g.:
| var ingressGatewayName = "ingress-gateway"; | |
| var ingressGatewayName = "my-ingress-gateway"; |
…4 and earlier Catalog GET GatewayServices is only supported after 1.7.14
Consul.Test/CatalogTest.cs
Outdated
| var gatewayServices = await client.Catalog.GatewayService(terminatingGatewayName); | ||
|
|
||
| Assert.NotEmpty(gatewayServices.Response); | ||
| Assert.Equal(ServiceKind.TerminatingGateway, gatewayServices.Response[0].GatewayKind); |
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.
It would also be good to check if other fields in the response are non-null, hence we know that the struct is correctly defined.
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.
Yep, that's a good idea, let me do that real quick
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.
It would also be good to check if other fields in the response are non-null, hence we know that the struct is correctly defined.
Just added the checks, you can see that we can't check all fields, cause some fields are just not present in the response for both gateways, and some just for ingress one
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.
We can add checks for port and protocol for the ingress one. Apart from that, it looks good.
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.
@marcin-krystianc
Sorry, just saw your message, added the assertions, tests went good
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!
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!
Thanks for help with the PRs!
Had to Add TerminatingGatewayConfigEntry and IngressGatewayConfigEntry classes for testing purposes
Resolves #315