|
1 | 1 | // -----------------------------------------------------------------------
|
2 |
| -// <copyright file="AgentTest.cs" company="PlayFab Inc"> |
3 |
| -// Copyright 2015 PlayFab Inc. |
| 2 | +// <copyright file="AgentTest.cs" company="G-Research Limited"> |
4 | 3 | // Copyright 2020 G-Research Limited
|
5 | 4 | //
|
6 |
| -// Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +// Licensed under the Apache License, Version 2.0 (the "License"), |
7 | 6 | // you may not use this file except in compliance with the License.
|
8 | 7 | // You may obtain a copy of the License at
|
9 | 8 | //
|
10 |
| -// http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
11 | 10 | //
|
12 | 11 | // Unless required by applicable law or agreed to in writing, software
|
13 | 12 | // distributed under the License is distributed on an "AS IS" BASIS,
|
@@ -1014,5 +1013,35 @@ public async Task Agent_Metrics()
|
1014 | 1013 | Assert.NotNull(agentMetrics.Response.Points);
|
1015 | 1014 | Assert.NotNull(agentMetrics.Response.Samples);
|
1016 | 1015 | }
|
| 1016 | + |
| 1017 | + [SkippableFact] |
| 1018 | + public async Task Agent_Reload() |
| 1019 | + { |
| 1020 | + var cutOffVersion = SemanticVersion.Parse("1.14.0"); |
| 1021 | + Skip.If(AgentVersion < cutOffVersion, $"Current version is {AgentVersion}, but `Agent_Reload` is only supported from Consul {cutOffVersion}"); |
| 1022 | + string configFile = Environment.GetEnvironmentVariable("CONSUL_AGENT_CONFIG_PATH"); |
| 1023 | + Skip.If(string.IsNullOrEmpty(configFile), "The CONSUL_AGENT_CONFIG_PATH environment variable was not set"); |
| 1024 | + var initialConfig = System.IO.File.ReadAllText(configFile); |
| 1025 | + var udpatedConfig = initialConfig.Replace("TRACE", "DEBUG"); |
| 1026 | + try |
| 1027 | + { |
| 1028 | + var agentDetails = await _client.Agent.Self(); |
| 1029 | + var agentLogLevel = agentDetails.Response["DebugConfig"]["Logging"]["LogLevel"]; |
| 1030 | + Assert.Equal("TRACE", agentLogLevel.Value); |
| 1031 | + System.IO.File.WriteAllText(configFile, udpatedConfig); |
| 1032 | + |
| 1033 | + await _client.Agent.Reload(); |
| 1034 | + agentDetails = await _client.Agent.Self(); |
| 1035 | + agentLogLevel = agentDetails.Response["DebugConfig"]["Logging"]["LogLevel"]; |
| 1036 | + Assert.Equal("DEBUG", agentLogLevel.Value); |
| 1037 | + |
| 1038 | + System.IO.File.WriteAllText(configFile, initialConfig); |
| 1039 | + await _client.Agent.Reload(); |
| 1040 | + } |
| 1041 | + finally |
| 1042 | + { |
| 1043 | + System.IO.File.WriteAllText(configFile, initialConfig); |
| 1044 | + } |
| 1045 | + } |
1017 | 1046 | }
|
1018 | 1047 | }
|
0 commit comments