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 Discovery Chain GET and POST and tests for it #356

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

IvanKolchanov
Copy link
Contributor

@IvanKolchanov IvanKolchanov commented Jul 30, 2024

@marcin-krystianc
Added the Discovery Chain Endpoint, tests for it, edits in Client.cs and IConsulClient.cs for adding new class DiscoveryChain.cs. Changes in Configuration for consistency - TimeSpan? ConnectTimeout, changes to ServiceResolverEntry

@IvanKolchanov IvanKolchanov marked this pull request as ready for review August 1, 2024 11:33
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.

Looks good, few minor comments. Please also update the PR description.

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public bool OnlyPassing { get; set; }
//[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
//public bool OnlyPassing { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it intentional change?

Copy link
Contributor Author

@IvanKolchanov IvanKolchanov Aug 2, 2024

Choose a reason for hiding this comment

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

@marcin-krystianc
Yep, the class structure is different from Golang code, and with OnlyPassing not commented out it causes an error. I was still kinda testing things out, so I guess I should edit the structure to align with Golang code?
image
https://github.com/hashicorp/consul/blob/v1.9.17/api/config_entry_discoverychain.go#L136

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, please update this struct to align it with the golang code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, please update this struct to align it with the golang code.

Just did, waiting for the tests to run

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marcin-krystianc tests just finished, went good

yes, please update this struct to align it with the golang code.

Just did, waiting for the tests to run


/// <summary>
/// OverrideMeshGateway allows for the mesh gateway setting to be overridden
/// For any resolver in the compiled chain.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: formatting


/// <summary>
/// OverrideConnectTimeout allows for the ConnectTimeout setting to be
/// Overridden for any resolver in the compiled chain.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: fromatting

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string ConnectTimeout { get; set; }
public TimeSpan? ConnectTimeout { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

It breaks backward compatibility, but it is ok to do here. Configuration is a fresh addition and I anticipate it is not heavily used yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okey, sounds good, I was going off of existing code and changed it for consistency

Comment on lines 1038 to 1080
public class ServiceResolverSubset
{
public string Filter { get; set; }
public bool OnlyPassing { get; set; }
}

public class ServiceResolverRedirect
{
public string Service { get; set; }
public string ServiceSubset { get; set; }
public string Namespace { get; set; }
public string Partition { get; set; }
public string Datacenter { get; set; }
public string Peer { get; set; }
public string SamenessGroup { get; set; }
}

public class ServiceResolverFailover
{
public string Service { get; set; }
public string ServiceSubset { get; set; }
// Referencing other partitions is not supported.
public string Namespace { get; set; }
public List<string> Datacenters { get; set; }
public List<ServiceResolverFailoverTarget> Targets { get; set; }
public ServiceResolverFailoverPolicy Policy { get; set; }
public string SamenessGroup { get; set; }
}

public class ServiceResolverFailoverTarget
{
public string Service { get; set; }
public string ServiceSubset { get; set; }
public string Partition { get; set; }
public string Namespace { get; set; }
public string Datacenter { get; set; }
public string Peer { get; set; }
}

public class ServiceResolverFailoverPolicy
{
public string Mode { get; set; }
public List<string> Regions { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to test these structs as well?
In the past we added some new structs without proper tests and they turned out to be incorrectly defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marcin-krystianc So, I am working on the tests right now, and I also realized, that I have implimented ServiceResolverEntry according with the latests version of Consul API. That shouldn't harm backwards compitability, but that should provide some compatibility with future versions and less work in the future. Should I just leave it at that, or cut out the new fields to avoid confusion? Also, the Golang tests for the ServiceResolver class include some other test - for ServiceSplitter and ServiceRouter, should I write tests for them too, or just leave it at ServiceResolver? https://github.com/hashicorp/consul/blob/v1.9.17/api/config_entry_discoverychain_test.go . I will push the tests I currently have for it in a minute

Would it be possible to test these structs as well? In the past we added some new structs without proper tests and they turned out to be incorrectly defined.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should I just leave it at that, or cut out the new fields to avoid confusion?
Please keep the new fields in.

Copy link
Contributor Author

@IvanKolchanov IvanKolchanov Aug 7, 2024

Choose a reason for hiding this comment

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

Should I just leave it at that, or cut out the new fields to avoid confusion?
Please keep the new fields in.

@marcin-krystianc
I think I have gotten the tests sorted up. Could you check the code?

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.

3 participants