Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Consul.Test/AgentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,5 +602,36 @@ public async Task Agent_ReRegister_ReplaceExistingChecks(bool replaceExistingChe

await _client.Agent.ServiceDeregister(svcID);
}

[Fact]
public async Task Agent_Register_UseCustomCheckId()
{
var svcID = KVTest.GenerateTestKeyName();
var check1Id = svcID + "_checkId";
var check1Name = svcID + "_checkName";
var registration1 = new AgentServiceRegistration
{
Name = svcID,
Port = 8000,
Checks = new[]
{
new AgentServiceCheck
{
Name = check1Name,
CheckId = check1Id,
TTL = TimeSpan.FromSeconds(15),
},
}
};

await _client.Agent.ServiceRegister(registration1);

var checks = await _client.Agent.Checks();
Assert.Contains(check1Id, checks.Response.Keys);

var check = checks.Response[check1Id];
Assert.Equal(check.Name, check1Name);
Assert.Equal(check.CheckID, check1Id);
}
}
}
6 changes: 5 additions & 1 deletion Consul/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,14 @@ public class AgentCheckRegistration : AgentServiceCheck
/// </summary>
public class AgentServiceCheck
{

// See https://github.com/G-Research/consuldotnet/issues/184
[Obsolete("Use CheckId instead")]
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string ID { get; set; }

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string CheckId { get; set; }

[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public string Name { get; set; }

Expand Down