Skip to content
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

Merged
merged 3 commits into from
Jul 13, 2023
Merged

Conversation

firerain-fd
Copy link
Contributor

class Selectors:
Add Property ServiceName

class ServiceSelector:
Add operator ==
Add operator !=
Add Tests

class Agent:
Add method Checks with filter
Add Tests

+ Property ServiceName

class ServiceSelector:
+ operator ==
+ operator !=
+ Tests

class Agent:
+ method Checks with filter
+ Tests
Copy link
Contributor

@marcin-krystianc marcin-krystianc left a 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);
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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));
Copy link
Contributor

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()
Copy link
Contributor

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());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@marcin-krystianc marcin-krystianc left a 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!

@marcin-krystianc marcin-krystianc merged commit 5345f41 into G-Research:master Jul 13, 2023
147 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants