-
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
Adding features #219
Adding features #219
Conversation
+ Property ServiceName class ServiceSelector: + operator == + operator != + Tests class Agent: + method Checks with filter + Tests
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.
Hi @firerain-fd, thanks for being an active contributor.
I've reviewed your changes. I see how the "ServiceName" selector is being used, but I don't see how "Service" selector is being used (or can be even used). Please provide a use case (a test case) or remove that change.
@@ -29,6 +29,9 @@ public sealed class ServiceSelector : Selector | |||
public MetaSelector Meta { get; } = new MetaSelector(Self); | |||
|
|||
public override string Encode() => Self; | |||
|
|||
public static Filter operator ==(ServiceSelector selector, string value) => Filters.Eq(selector, value); |
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 don't think a "service" is a valid selector that can be used for anything. Also, this is not being used in an actual test (apart from encoding tests). I think that it should be removed.
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.
Hi.
The 'Service' selector is used in the following api queries:
https://developer.hashicorp.com/consul/api-docs/agent/service#list-services
https://developer.hashicorp.com/consul/api-docs/catalog#retrieve-map-of-services-for-a-node
https://developer.hashicorp.com/consul/api-docs/catalog#list-services-for-node
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.
Ok, I see. It would be great though if you implement at least one test case which uses this APIs.
@@ -33,6 +33,7 @@ public interface IAgentEndpoint | |||
Task<WriteResult> CheckDeregister(string checkID, CancellationToken ct = default(CancellationToken)); | |||
Task<WriteResult> CheckRegister(AgentCheckRegistration check, CancellationToken ct = default(CancellationToken)); | |||
Task<QueryResult<Dictionary<string, AgentCheck>>> Checks(CancellationToken ct = default(CancellationToken)); | |||
Task<QueryResult<Dictionary<string, AgentCheck>>> Checks(Filter filter, CancellationToken ct = default(CancellationToken)); |
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.
👍
@@ -793,5 +793,42 @@ public async Task Agent_Service_Register_With_Connect() | |||
Assert.Null(destinationProxyService.Proxy.Upstreams); | |||
Assert.Equal(ServiceKind.ConnectProxy, destinationProxyService.Kind); | |||
} | |||
|
|||
[Fact] | |||
public async Task Agent_FilterChecks() |
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.
👍
Fixed filtering test assertion by service identifier (duplicated string). Added filtering test assertion by service name.
Assert.Equal(svcID1, (await _client.Agent.Services(metaSelector[uniqueMeta] == "bar1")).Response.Keys.Single()); | ||
Assert.Equal(svcID2, (await _client.Agent.Services(metaSelector[uniqueMeta] == "bar2")).Response.Keys.Single()); | ||
Assert.Equal(svcID1, (await _client.Agent.Services(Selectors.Service == svcID1)).Response.Keys.Single()); |
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 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, thank you for your contribution!
class Selectors:
Add Property ServiceName
class ServiceSelector:
Add operator ==
Add operator !=
Add Tests
class Agent:
Add method Checks with filter
Add Tests