From 617491a6fed982febfc6a7c91101e54e564afedf Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Thu, 2 Nov 2023 23:02:36 +0100 Subject: [PATCH 01/25] Added Test for Reload --- Consul.Test/AgentTest.cs | 73 +++++++++++++++++++++++++++++ Consul.Test/Consul.Test.csproj | 3 ++ Consul/Agent.cs | 2 +- Consul/Interfaces/IAgentEndpoint.cs | 1 + 4 files changed, 78 insertions(+), 1 deletion(-) diff --git a/Consul.Test/AgentTest.cs b/Consul.Test/AgentTest.cs index 88452c2fb..5465f23ef 100644 --- a/Consul.Test/AgentTest.cs +++ b/Consul.Test/AgentTest.cs @@ -19,12 +19,16 @@ using System; using System.Collections.Generic; +using System.Diagnostics; +using System.IO; using System.Linq; using System.Text.Json; +using System.Threading; using System.Threading.Tasks; using Consul.Filtering; using NuGet.Versioning; using Xunit; +using static System.Net.WebRequestMethods; namespace Consul.Test { @@ -1004,5 +1008,74 @@ public async Task Agent_Metrics() Assert.NotNull(agentMetrics.Response.Points); Assert.NotNull(agentMetrics.Response.Samples); } + + [Fact] + public async Task Agent_Reload() + { + string config1 = @" + { + ""ports"": { + ""http"": 8499, + ""dns"": -1, + ""grpc"": -1, + ""grpc_tls"": -1, + ""serf_lan"": 8100, + ""serf_wan"": -1, + ""server"": 8200, + ""sidecar_min_port"": 0, + ""sidecar_max_port"": 0, + ""expose_min_port"": 0, + ""expose_max_port"": 0 + } + }"; + string config2 = @" + { + ""ports"": { + ""http"": 8499, + ""dns"": -1, + ""grpc"": -1, + ""grpc_tls"": -1, + ""serf_lan"": 8100, + ""serf_wan"": -1, + ""server"": 8200, + ""sidecar_min_port"": 0, + ""sidecar_max_port"": 0, + ""expose_min_port"": 0, + ""expose_max_port"": 0 + }, + ""service"": { + ""name"": ""redis"", + ""port"": 1234, + ""Meta"": { ""some"": ""meta"" } + } + }"; + // Generate a random file name + string fileName = Path.Combine(Path.GetTempPath(), "random_config_" + Guid.NewGuid().ToString() + ".json"); + + // Write the JSON data to the file + System.IO.File.WriteAllText(fileName, config1); + + string consulPath = Path.Combine(Directory.GetCurrentDirectory(),"consul.exe"); + + // Specify the command and arguments + string command = $"agent -dev -config-file \"{fileName}\""; + ProcessStartInfo startInfo = new ProcessStartInfo(consulPath) + { + Arguments = command + + }; + Process.Start(startInfo); + var client = new ConsulClient(c => + { + c.Token = Guid.NewGuid().ToString(); + c.Address = new Uri(" http://127.0.0.1:8499"); + }); + var services = await _client.Agent.Services(); + Assert.Empty(services.Response); + System.IO.File.WriteAllText(fileName, config2); + await client.Agent.Reload(); + services = await client.Agent.Services(); + Assert.True(services.Response.ContainsKey("redis")); + } } } diff --git a/Consul.Test/Consul.Test.csproj b/Consul.Test/Consul.Test.csproj index 1e0af803d..44b257ca7 100644 --- a/Consul.Test/Consul.Test.csproj +++ b/Consul.Test/Consul.Test.csproj @@ -33,5 +33,8 @@ PreserveNewest + + PreserveNewest + diff --git a/Consul/Agent.cs b/Consul/Agent.cs index 86ac63cfc..fed0b8793 100644 --- a/Consul/Agent.cs +++ b/Consul/Agent.cs @@ -757,7 +757,7 @@ public Task Leave(string node, CancellationToken ct = default) /// Reload triggers a configuration reload for the agent we are connected to. /// /// An empty write result - public Task Reload(string node, CancellationToken ct = default) + public Task Reload(CancellationToken ct = default) { return _client.PutNothing("/v1/agent/reload").Execute(ct); } diff --git a/Consul/Interfaces/IAgentEndpoint.cs b/Consul/Interfaces/IAgentEndpoint.cs index 22529cdc7..ebe3a01a1 100644 --- a/Consul/Interfaces/IAgentEndpoint.cs +++ b/Consul/Interfaces/IAgentEndpoint.cs @@ -63,6 +63,7 @@ public interface IAgentEndpoint Task> GetLocalServiceHealthByID(string serviceID, QueryOptions q, CancellationToken ct = default); Task> GetLocalServiceHealthByID(string serviceID, CancellationToken ct = default); Task> GetAgentMetrics(CancellationToken ct = default); + Task Reload(CancellationToken ct = default); Task Leave(string node, CancellationToken ct = default); Task Reload(string node, CancellationToken ct = default); } From 56be74f52e93853dbb60bde7fe857a0d8736deb4 Mon Sep 17 00:00:00 2001 From: octocat Date: Thu, 2 Nov 2023 22:06:59 +0000 Subject: [PATCH 02/25] style: fix whitespaces --- Consul.Test/AgentTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Consul.Test/AgentTest.cs b/Consul.Test/AgentTest.cs index 5465f23ef..d671a34c9 100644 --- a/Consul.Test/AgentTest.cs +++ b/Consul.Test/AgentTest.cs @@ -1055,7 +1055,7 @@ public async Task Agent_Reload() // Write the JSON data to the file System.IO.File.WriteAllText(fileName, config1); - string consulPath = Path.Combine(Directory.GetCurrentDirectory(),"consul.exe"); + string consulPath = Path.Combine(Directory.GetCurrentDirectory(), "consul.exe"); // Specify the command and arguments string command = $"agent -dev -config-file \"{fileName}\""; From 77e1359d1c958c18e2682c33718f4d22d7544c44 Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Thu, 2 Nov 2023 23:13:09 +0100 Subject: [PATCH 03/25] edit --- Consul/Interfaces/IAgentEndpoint.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Consul/Interfaces/IAgentEndpoint.cs b/Consul/Interfaces/IAgentEndpoint.cs index ebe3a01a1..a357b9c15 100644 --- a/Consul/Interfaces/IAgentEndpoint.cs +++ b/Consul/Interfaces/IAgentEndpoint.cs @@ -65,6 +65,5 @@ public interface IAgentEndpoint Task> GetAgentMetrics(CancellationToken ct = default); Task Reload(CancellationToken ct = default); Task Leave(string node, CancellationToken ct = default); - Task Reload(string node, CancellationToken ct = default); } } From f36989a4ae989ae3ec7adb147d73ce0544c56565 Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Fri, 3 Nov 2023 05:20:47 +0100 Subject: [PATCH 04/25] fix --- Consul.Test/AgentTest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Consul.Test/AgentTest.cs b/Consul.Test/AgentTest.cs index d671a34c9..758a11aee 100644 --- a/Consul.Test/AgentTest.cs +++ b/Consul.Test/AgentTest.cs @@ -1061,7 +1061,8 @@ public async Task Agent_Reload() string command = $"agent -dev -config-file \"{fileName}\""; ProcessStartInfo startInfo = new ProcessStartInfo(consulPath) { - Arguments = command + Arguments = command, + CreateNoWindow = true }; Process.Start(startInfo); From e8c24e7f5d1fb55851f6603bca199f78c3f13dc7 Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Fri, 3 Nov 2023 06:12:16 +0100 Subject: [PATCH 05/25] fix --- Consul.Test/AgentTest.cs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/Consul.Test/AgentTest.cs b/Consul.Test/AgentTest.cs index 758a11aee..efd03da27 100644 --- a/Consul.Test/AgentTest.cs +++ b/Consul.Test/AgentTest.cs @@ -1059,24 +1059,33 @@ public async Task Agent_Reload() // Specify the command and arguments string command = $"agent -dev -config-file \"{fileName}\""; + ProcessStartInfo startInfo = new ProcessStartInfo(consulPath) { Arguments = command, - CreateNoWindow = true - + UseShellExecute = false }; - Process.Start(startInfo); - var client = new ConsulClient(c => + using (Process process = new Process + { + StartInfo = startInfo + }) + { + process.Start(); + var client = new ConsulClient(c => { c.Token = Guid.NewGuid().ToString(); c.Address = new Uri(" http://127.0.0.1:8499"); }); - var services = await _client.Agent.Services(); - Assert.Empty(services.Response); - System.IO.File.WriteAllText(fileName, config2); - await client.Agent.Reload(); - services = await client.Agent.Services(); - Assert.True(services.Response.ContainsKey("redis")); + var services = await client.Agent.Services(); + Assert.Empty(services.Response); + System.IO.File.WriteAllText(fileName, config2); + await client.Agent.Reload(); + services = await client.Agent.Services(); + Assert.True(services.Response.ContainsKey("redis")); + process.Kill(); + } + + } } } From 8bef4dfb311b11dfb73571ec4e676920b6e46c96 Mon Sep 17 00:00:00 2001 From: octocat Date: Fri, 3 Nov 2023 05:13:08 +0000 Subject: [PATCH 06/25] style: fix whitespaces --- Consul.Test/AgentTest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Consul.Test/AgentTest.cs b/Consul.Test/AgentTest.cs index efd03da27..098d07ed3 100644 --- a/Consul.Test/AgentTest.cs +++ b/Consul.Test/AgentTest.cs @@ -1059,7 +1059,7 @@ public async Task Agent_Reload() // Specify the command and arguments string command = $"agent -dev -config-file \"{fileName}\""; - + ProcessStartInfo startInfo = new ProcessStartInfo(consulPath) { Arguments = command, @@ -1084,8 +1084,8 @@ public async Task Agent_Reload() Assert.True(services.Response.ContainsKey("redis")); process.Kill(); } - - + + } } } From 7ebc45e810b8ac712d930c0dd53053e3fe209618 Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Fri, 3 Nov 2023 11:43:42 +0100 Subject: [PATCH 07/25] fixed --- Consul.Test/AgentTest.cs | 101 ++++++--------------------------- Consul.Test/Consul.Test.csproj | 5 +- 2 files changed, 19 insertions(+), 87 deletions(-) diff --git a/Consul.Test/AgentTest.cs b/Consul.Test/AgentTest.cs index 098d07ed3..e4834da79 100644 --- a/Consul.Test/AgentTest.cs +++ b/Consul.Test/AgentTest.cs @@ -1,13 +1,12 @@ // ----------------------------------------------------------------------- -// -// Copyright 2015 PlayFab Inc. +// // Copyright 2020 G-Research Limited // -// Licensed under the Apache License, Version 2.0 (the "License"); +// Licensed under the Apache License, Version 2.0 (the "License"), // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -19,16 +18,12 @@ using System; using System.Collections.Generic; -using System.Diagnostics; -using System.IO; using System.Linq; using System.Text.Json; -using System.Threading; using System.Threading.Tasks; using Consul.Filtering; using NuGet.Versioning; using Xunit; -using static System.Net.WebRequestMethods; namespace Consul.Test { @@ -1009,83 +1004,23 @@ public async Task Agent_Metrics() Assert.NotNull(agentMetrics.Response.Samples); } - [Fact] + [SkippableFact] public async Task Agent_Reload() { - string config1 = @" - { - ""ports"": { - ""http"": 8499, - ""dns"": -1, - ""grpc"": -1, - ""grpc_tls"": -1, - ""serf_lan"": 8100, - ""serf_wan"": -1, - ""server"": 8200, - ""sidecar_min_port"": 0, - ""sidecar_max_port"": 0, - ""expose_min_port"": 0, - ""expose_max_port"": 0 - } - }"; - string config2 = @" - { - ""ports"": { - ""http"": 8499, - ""dns"": -1, - ""grpc"": -1, - ""grpc_tls"": -1, - ""serf_lan"": 8100, - ""serf_wan"": -1, - ""server"": 8200, - ""sidecar_min_port"": 0, - ""sidecar_max_port"": 0, - ""expose_min_port"": 0, - ""expose_max_port"": 0 - }, - ""service"": { - ""name"": ""redis"", - ""port"": 1234, - ""Meta"": { ""some"": ""meta"" } - } - }"; - // Generate a random file name - string fileName = Path.Combine(Path.GetTempPath(), "random_config_" + Guid.NewGuid().ToString() + ".json"); - - // Write the JSON data to the file - System.IO.File.WriteAllText(fileName, config1); - - string consulPath = Path.Combine(Directory.GetCurrentDirectory(), "consul.exe"); - - // Specify the command and arguments - string command = $"agent -dev -config-file \"{fileName}\""; - - ProcessStartInfo startInfo = new ProcessStartInfo(consulPath) - { - Arguments = command, - UseShellExecute = false - }; - using (Process process = new Process - { - StartInfo = startInfo - }) - { - process.Start(); - var client = new ConsulClient(c => - { - c.Token = Guid.NewGuid().ToString(); - c.Address = new Uri(" http://127.0.0.1:8499"); - }); - var services = await client.Agent.Services(); - Assert.Empty(services.Response); - System.IO.File.WriteAllText(fileName, config2); - await client.Agent.Reload(); - services = await client.Agent.Services(); - Assert.True(services.Response.ContainsKey("redis")); - process.Kill(); - } - - + string configFile = Environment.GetEnvironmentVariable("AgentConfig"); + Skip.If(string.IsNullOrEmpty(configFile)); + var intialConfig = System.IO.File.ReadAllText(configFile); + var udpatedConfig = intialConfig.Replace("TRACE", "DEBUG"); + var agentDetails = await _client.Agent.Self(); + var agentLogLevel = agentDetails.Response["DebugConfig"]["Logging"]["LogLevel"]; + Assert.Equal("TRACE", agentLogLevel.Value); + System.IO.File.WriteAllText(configFile, udpatedConfig); + await _client.Agent.Reload(); + agentDetails = await _client.Agent.Self(); + agentLogLevel = agentDetails.Response["DebugConfig"]["Logging"]["LogLevel"]; + Assert.Equal("DEBUG", agentLogLevel.Value); + System.IO.File.WriteAllText(configFile, intialConfig); + await _client.Agent.Reload(); } } } diff --git a/Consul.Test/Consul.Test.csproj b/Consul.Test/Consul.Test.csproj index 44b257ca7..3582171a0 100644 --- a/Consul.Test/Consul.Test.csproj +++ b/Consul.Test/Consul.Test.csproj @@ -1,4 +1,4 @@ - + net461;net5.0;net6.0;net7.0 @@ -33,8 +33,5 @@ PreserveNewest - - PreserveNewest - From afb77a4f5c170a95397d5b98d05b24b21fef85a1 Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Fri, 3 Nov 2023 14:29:20 +0100 Subject: [PATCH 08/25] Update Consul.Test/AgentTest.cs Co-authored-by: Marcin Krystianc --- Consul.Test/AgentTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Consul.Test/AgentTest.cs b/Consul.Test/AgentTest.cs index e4834da79..3cae7e91c 100644 --- a/Consul.Test/AgentTest.cs +++ b/Consul.Test/AgentTest.cs @@ -1009,7 +1009,7 @@ public async Task Agent_Reload() { string configFile = Environment.GetEnvironmentVariable("AgentConfig"); Skip.If(string.IsNullOrEmpty(configFile)); - var intialConfig = System.IO.File.ReadAllText(configFile); + var initialConfig= System.IO.File.ReadAllText(configFile); var udpatedConfig = intialConfig.Replace("TRACE", "DEBUG"); var agentDetails = await _client.Agent.Self(); var agentLogLevel = agentDetails.Response["DebugConfig"]["Logging"]["LogLevel"]; From ef7b3cd12dbe91694b91fd3704362252d846e76a Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Fri, 3 Nov 2023 14:29:35 +0100 Subject: [PATCH 09/25] Update Consul.Test/AgentTest.cs Co-authored-by: Marcin Krystianc --- Consul.Test/AgentTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Consul.Test/AgentTest.cs b/Consul.Test/AgentTest.cs index 3cae7e91c..0b2e3b2d2 100644 --- a/Consul.Test/AgentTest.cs +++ b/Consul.Test/AgentTest.cs @@ -1007,7 +1007,7 @@ public async Task Agent_Metrics() [SkippableFact] public async Task Agent_Reload() { - string configFile = Environment.GetEnvironmentVariable("AgentConfig"); + string configFile = Environment.GetEnvironmentVariable("CONSUL_AGENT_CONFIG_PATH"); Skip.If(string.IsNullOrEmpty(configFile)); var initialConfig= System.IO.File.ReadAllText(configFile); var udpatedConfig = intialConfig.Replace("TRACE", "DEBUG"); From e948eb5925d29310af452f8fa1a60b6efa64c608 Mon Sep 17 00:00:00 2001 From: octocat Date: Fri, 3 Nov 2023 13:30:14 +0000 Subject: [PATCH 10/25] style: fix whitespaces --- Consul.Test/AgentTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Consul.Test/AgentTest.cs b/Consul.Test/AgentTest.cs index 0b2e3b2d2..d048ccb70 100644 --- a/Consul.Test/AgentTest.cs +++ b/Consul.Test/AgentTest.cs @@ -1009,7 +1009,7 @@ public async Task Agent_Reload() { string configFile = Environment.GetEnvironmentVariable("CONSUL_AGENT_CONFIG_PATH"); Skip.If(string.IsNullOrEmpty(configFile)); - var initialConfig= System.IO.File.ReadAllText(configFile); + var initialConfig = System.IO.File.ReadAllText(configFile); var udpatedConfig = intialConfig.Replace("TRACE", "DEBUG"); var agentDetails = await _client.Agent.Self(); var agentLogLevel = agentDetails.Response["DebugConfig"]["Logging"]["LogLevel"]; From 69bf013755a910d86d73572a4b178e890fca5bc6 Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Fri, 3 Nov 2023 14:40:07 +0100 Subject: [PATCH 11/25] added changes --- Consul.Test/AgentTest.cs | 31 ++++++++++++++++++----------- Consul/Agent.cs | 11 ++++++++++ Consul/Interfaces/IAgentEndpoint.cs | 2 ++ 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Consul.Test/AgentTest.cs b/Consul.Test/AgentTest.cs index d048ccb70..280edd034 100644 --- a/Consul.Test/AgentTest.cs +++ b/Consul.Test/AgentTest.cs @@ -1008,19 +1008,26 @@ public async Task Agent_Metrics() public async Task Agent_Reload() { string configFile = Environment.GetEnvironmentVariable("CONSUL_AGENT_CONFIG_PATH"); - Skip.If(string.IsNullOrEmpty(configFile)); + Skip.If(string.IsNullOrEmpty(configFile), "The CONSUL_AGENT_CONFIG_PATH environment variable was not set"); var initialConfig = System.IO.File.ReadAllText(configFile); - var udpatedConfig = intialConfig.Replace("TRACE", "DEBUG"); - var agentDetails = await _client.Agent.Self(); - var agentLogLevel = agentDetails.Response["DebugConfig"]["Logging"]["LogLevel"]; - Assert.Equal("TRACE", agentLogLevel.Value); - System.IO.File.WriteAllText(configFile, udpatedConfig); - await _client.Agent.Reload(); - agentDetails = await _client.Agent.Self(); - agentLogLevel = agentDetails.Response["DebugConfig"]["Logging"]["LogLevel"]; - Assert.Equal("DEBUG", agentLogLevel.Value); - System.IO.File.WriteAllText(configFile, intialConfig); - await _client.Agent.Reload(); + var udpatedConfig = initialConfig.Replace("TRACE", "DEBUG"); + try + { + var agentDetails = await _client.Agent.Self(); + var agentLogLevel = agentDetails.Response["DebugConfig"]["Logging"]["LogLevel"]; + Assert.Equal("TRACE", agentLogLevel.Value); + System.IO.File.WriteAllText(configFile, udpatedConfig); + await _client.Agent.Reload(); + agentDetails = await _client.Agent.Self(); + agentLogLevel = agentDetails.Response["DebugConfig"]["Logging"]["LogLevel"]; + Assert.Equal("DEBUG", agentLogLevel.Value); + System.IO.File.WriteAllText(configFile, initialConfig); + await _client.Agent.Reload(); + } + finally + { + System.IO.File.WriteAllText(configFile, initialConfig); + } } } } diff --git a/Consul/Agent.cs b/Consul/Agent.cs index fed0b8793..be6412dc8 100644 --- a/Consul/Agent.cs +++ b/Consul/Agent.cs @@ -762,6 +762,17 @@ public Task Reload(CancellationToken ct = default) return _client.PutNothing("/v1/agent/reload").Execute(ct); } + /// + /// Reload triggers a configuration reload for the agent we are connected to. + /// + /// The node name to reload + /// An empty write result + [Obsolete] + public Task Reload(string node, CancellationToken ct = default) + { + return _client.PutNothing("/v1/agent/reload").Execute(ct); + } + /// /// EnableServiceMaintenance toggles service maintenance mode on for the given service ID /// diff --git a/Consul/Interfaces/IAgentEndpoint.cs b/Consul/Interfaces/IAgentEndpoint.cs index a357b9c15..dce6184e2 100644 --- a/Consul/Interfaces/IAgentEndpoint.cs +++ b/Consul/Interfaces/IAgentEndpoint.cs @@ -64,6 +64,8 @@ public interface IAgentEndpoint Task> GetLocalServiceHealthByID(string serviceID, CancellationToken ct = default); Task> GetAgentMetrics(CancellationToken ct = default); Task Reload(CancellationToken ct = default); + [Obsolete] + Task Reload(string node, CancellationToken ct = default); Task Leave(string node, CancellationToken ct = default); } } From 10d55cdd2b57b002a119b89068b5c7b4c818c28d Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Mon, 6 Nov 2023 13:28:25 +0100 Subject: [PATCH 12/25] testing env --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0acbba8c0..83156d487 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,7 +126,7 @@ jobs: - name: Run tests shell: bash run: | - export CONSUL_AGENT_CONFIG_PATH=Consul.Test/test_config.json + export CONSUL_AGENT_CONFIG_PATH=/Consul.Test/test_config.json ./Consul.Test/consul agent -dev -config-file Consul.Test/test_config.json -log-file consul.log >consul-stdout.log 2>consul-stderr.log & dotnet test Consul.Test --configuration=Release --logger "GitHubActions;report-warnings=false" --no-build -v=Normal --framework=${{ matrix.framework }} env: From 7d3bbf9e02bd3144542a9c4299c3df06492da730 Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Mon, 6 Nov 2023 13:34:18 +0100 Subject: [PATCH 13/25] testing env --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83156d487..621cb527e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,7 +126,7 @@ jobs: - name: Run tests shell: bash run: | - export CONSUL_AGENT_CONFIG_PATH=/Consul.Test/test_config.json + export CONSUL_AGENT_CONFIG_PATH=$GITHUB_WORKSPACE/Consul.Test/test_config.json ./Consul.Test/consul agent -dev -config-file Consul.Test/test_config.json -log-file consul.log >consul-stdout.log 2>consul-stderr.log & dotnet test Consul.Test --configuration=Release --logger "GitHubActions;report-warnings=false" --no-build -v=Normal --framework=${{ matrix.framework }} env: From 98ccbad7ca5f2293030b5d0ad67ff57fafab6303 Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Mon, 6 Nov 2023 13:42:48 +0100 Subject: [PATCH 14/25] test env --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 621cb527e..467cedf1c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: env: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_CLI_TELEMETRY_OPTOUT: true + CONSUL_AGENT_CONFIG_PATH: $GITHUB_WORKSPACE/Consul.Test/test_config.json jobs: # Enforces the consistency of code formatting using `.editorconfig` and the `dotnet format`. @@ -126,7 +127,6 @@ jobs: - name: Run tests shell: bash run: | - export CONSUL_AGENT_CONFIG_PATH=$GITHUB_WORKSPACE/Consul.Test/test_config.json ./Consul.Test/consul agent -dev -config-file Consul.Test/test_config.json -log-file consul.log >consul-stdout.log 2>consul-stderr.log & dotnet test Consul.Test --configuration=Release --logger "GitHubActions;report-warnings=false" --no-build -v=Normal --framework=${{ matrix.framework }} env: From 55d7e57d296e267ba1798ea9c2541b8c4f89811d Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Mon, 6 Nov 2023 13:46:51 +0100 Subject: [PATCH 15/25] test env --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 467cedf1c..556965ccf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,6 @@ on: env: DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_CLI_TELEMETRY_OPTOUT: true - CONSUL_AGENT_CONFIG_PATH: $GITHUB_WORKSPACE/Consul.Test/test_config.json jobs: # Enforces the consistency of code formatting using `.editorconfig` and the `dotnet format`. @@ -132,6 +131,7 @@ jobs: env: RUN_CONSUL_ENTERPRISE_TESTS: ${{env.RUN_CONSUL_ENTERPRISE_TESTS }} CONSUL_LICENSE: ${{ secrets.CONSUL_LICENSE }} + CONSUL_AGENT_CONFIG_PATH: $GITHUB_WORKSPACE/Consul.Test/test_config.json - name: Upload Consul logs if: failure() uses: actions/upload-artifact@v3 From 37246808816701f0951a7199317eb374293531c6 Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Mon, 6 Nov 2023 13:48:37 +0100 Subject: [PATCH 16/25] test env --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 556965ccf..27f0b34d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,7 +131,7 @@ jobs: env: RUN_CONSUL_ENTERPRISE_TESTS: ${{env.RUN_CONSUL_ENTERPRISE_TESTS }} CONSUL_LICENSE: ${{ secrets.CONSUL_LICENSE }} - CONSUL_AGENT_CONFIG_PATH: $GITHUB_WORKSPACE/Consul.Test/test_config.json + CONSUL_AGENT_CONFIG_PATH: ${{GITHUB_WORKSPACE}}/Consul.Test/test_config.json - name: Upload Consul logs if: failure() uses: actions/upload-artifact@v3 From 0d0ce5f50205505a182d503d307eea26a40dc547 Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Mon, 6 Nov 2023 13:58:50 +0100 Subject: [PATCH 17/25] test env --- Consul.Test/AgentTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Consul.Test/AgentTest.cs b/Consul.Test/AgentTest.cs index 356247299..68b261140 100644 --- a/Consul.Test/AgentTest.cs +++ b/Consul.Test/AgentTest.cs @@ -1019,6 +1019,7 @@ public async Task Agent_Metrics() public async Task Agent_Reload() { string configFile = Environment.GetEnvironmentVariable("CONSUL_AGENT_CONFIG_PATH"); + //Skip.If(string.IsNullOrEmpty(configFile), "The CONSUL_AGENT_CONFIG_PATH environment variable was not set"); var initialConfig = System.IO.File.ReadAllText(configFile); var udpatedConfig = initialConfig.Replace("TRACE", "DEBUG"); From a6a5f05f1b1d68fb014c5269128f68bdb35085af Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Mon, 6 Nov 2023 14:06:23 +0100 Subject: [PATCH 18/25] test env --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27f0b34d2..958841f4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,7 +131,7 @@ jobs: env: RUN_CONSUL_ENTERPRISE_TESTS: ${{env.RUN_CONSUL_ENTERPRISE_TESTS }} CONSUL_LICENSE: ${{ secrets.CONSUL_LICENSE }} - CONSUL_AGENT_CONFIG_PATH: ${{GITHUB_WORKSPACE}}/Consul.Test/test_config.json + CONSUL_AGENT_CONFIG_PATH: ${{vars.GITHUB_WORKSPACE}}/Consul.Test/test_config.json - name: Upload Consul logs if: failure() uses: actions/upload-artifact@v3 From 27a5f2924990af55fde708a98330ecf686db49bb Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Mon, 6 Nov 2023 14:15:50 +0100 Subject: [PATCH 19/25] testing env --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 958841f4b..0a25f8fb8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,7 +131,7 @@ jobs: env: RUN_CONSUL_ENTERPRISE_TESTS: ${{env.RUN_CONSUL_ENTERPRISE_TESTS }} CONSUL_LICENSE: ${{ secrets.CONSUL_LICENSE }} - CONSUL_AGENT_CONFIG_PATH: ${{vars.GITHUB_WORKSPACE}}/Consul.Test/test_config.json + CONSUL_AGENT_CONFIG_PATH: ${{vars.GITHUB_WORKSPACE}}/consuldotnet/Consul.Test/test_config.json - name: Upload Consul logs if: failure() uses: actions/upload-artifact@v3 From ec545b7fa579fe2aae5201ee2b0878957fcfdfb1 Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Mon, 6 Nov 2023 14:34:17 +0100 Subject: [PATCH 20/25] testing env --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a25f8fb8..27f0b34d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,7 +131,7 @@ jobs: env: RUN_CONSUL_ENTERPRISE_TESTS: ${{env.RUN_CONSUL_ENTERPRISE_TESTS }} CONSUL_LICENSE: ${{ secrets.CONSUL_LICENSE }} - CONSUL_AGENT_CONFIG_PATH: ${{vars.GITHUB_WORKSPACE}}/consuldotnet/Consul.Test/test_config.json + CONSUL_AGENT_CONFIG_PATH: ${{GITHUB_WORKSPACE}}/Consul.Test/test_config.json - name: Upload Consul logs if: failure() uses: actions/upload-artifact@v3 From b1c600db9556407f1c5df9bc72129434d9a02b4a Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Mon, 6 Nov 2023 14:36:10 +0100 Subject: [PATCH 21/25] testing env --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27f0b34d2..4a73448d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,7 +131,7 @@ jobs: env: RUN_CONSUL_ENTERPRISE_TESTS: ${{env.RUN_CONSUL_ENTERPRISE_TESTS }} CONSUL_LICENSE: ${{ secrets.CONSUL_LICENSE }} - CONSUL_AGENT_CONFIG_PATH: ${{GITHUB_WORKSPACE}}/Consul.Test/test_config.json + CONSUL_AGENT_CONFIG_PATH: ${GITHUB_WORKSPACE}/Consul.Test/test_config.json - name: Upload Consul logs if: failure() uses: actions/upload-artifact@v3 From 99148ba901fa4177df37c306599e267a9418d5b4 Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Mon, 6 Nov 2023 14:42:10 +0100 Subject: [PATCH 22/25] testing env --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a73448d2..8de499629 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -131,7 +131,7 @@ jobs: env: RUN_CONSUL_ENTERPRISE_TESTS: ${{env.RUN_CONSUL_ENTERPRISE_TESTS }} CONSUL_LICENSE: ${{ secrets.CONSUL_LICENSE }} - CONSUL_AGENT_CONFIG_PATH: ${GITHUB_WORKSPACE}/Consul.Test/test_config.json + CONSUL_AGENT_CONFIG_PATH: ${{ github.workspace }}/Consul.Test/test_config.json - name: Upload Consul logs if: failure() uses: actions/upload-artifact@v3 From aa0e3e9aa82951130189067f58646a32fd35311b Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Mon, 6 Nov 2023 14:46:38 +0100 Subject: [PATCH 23/25] changed github workflow --- Consul.Test/AgentTest.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Consul.Test/AgentTest.cs b/Consul.Test/AgentTest.cs index 68b261140..7f9a534cb 100644 --- a/Consul.Test/AgentTest.cs +++ b/Consul.Test/AgentTest.cs @@ -1014,13 +1014,11 @@ public async Task Agent_Metrics() Assert.NotNull(agentMetrics.Response.Samples); } - //[SkippableFact] - [Fact] + [SkippableFact] public async Task Agent_Reload() { string configFile = Environment.GetEnvironmentVariable("CONSUL_AGENT_CONFIG_PATH"); - - //Skip.If(string.IsNullOrEmpty(configFile), "The CONSUL_AGENT_CONFIG_PATH environment variable was not set"); + Skip.If(string.IsNullOrEmpty(configFile), "The CONSUL_AGENT_CONFIG_PATH environment variable was not set"); var initialConfig = System.IO.File.ReadAllText(configFile); var udpatedConfig = initialConfig.Replace("TRACE", "DEBUG"); try From 38bb8b24d27e04f5576e9aea7eed975355a932fc Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Wed, 29 Nov 2023 12:44:14 +0100 Subject: [PATCH 24/25] added extra skippable --- Consul.Test/AgentTest.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Consul.Test/AgentTest.cs b/Consul.Test/AgentTest.cs index 7f9a534cb..e53a43dac 100644 --- a/Consul.Test/AgentTest.cs +++ b/Consul.Test/AgentTest.cs @@ -1017,6 +1017,8 @@ public async Task Agent_Metrics() [SkippableFact] public async Task Agent_Reload() { + var cutOffVersion = SemanticVersion.Parse("1.14.0"); + Skip.If(AgentVersion < cutOffVersion, $"Current version is {AgentVersion}, but `Agent_Reload` is only supported from Consul {cutOffVersion}"); string configFile = Environment.GetEnvironmentVariable("CONSUL_AGENT_CONFIG_PATH"); Skip.If(string.IsNullOrEmpty(configFile), "The CONSUL_AGENT_CONFIG_PATH environment variable was not set"); var initialConfig = System.IO.File.ReadAllText(configFile); From 3d98503aacd2b05ebdfa9c4c0f2dc90ac4d113f7 Mon Sep 17 00:00:00 2001 From: Samson Amaugo Date: Wed, 29 Nov 2023 12:56:49 +0100 Subject: [PATCH 25/25] edit --- Consul.Test/AgentTest.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Consul.Test/AgentTest.cs b/Consul.Test/AgentTest.cs index e53a43dac..786770b6b 100644 --- a/Consul.Test/AgentTest.cs +++ b/Consul.Test/AgentTest.cs @@ -1029,10 +1029,12 @@ public async Task Agent_Reload() var agentLogLevel = agentDetails.Response["DebugConfig"]["Logging"]["LogLevel"]; Assert.Equal("TRACE", agentLogLevel.Value); System.IO.File.WriteAllText(configFile, udpatedConfig); + await _client.Agent.Reload(); agentDetails = await _client.Agent.Self(); agentLogLevel = agentDetails.Response["DebugConfig"]["Logging"]["LogLevel"]; Assert.Equal("DEBUG", agentLogLevel.Value); + System.IO.File.WriteAllText(configFile, initialConfig); await _client.Agent.Reload(); }