mirror of
https://github.com/actions/runner.git
synced 2025-12-19 08:50:41 +00:00
lint + tests
This commit is contained in:
@@ -240,21 +240,21 @@ namespace GitHub.Runner.Listener
|
|||||||
// Decrypt the message body if the session is using encryption
|
// Decrypt the message body if the session is using encryption
|
||||||
message = DecryptMessage(message);
|
message = DecryptMessage(message);
|
||||||
|
|
||||||
|
|
||||||
if (message != null && message.MessageType == BrokerMigrationMessage.MessageType)
|
if (message != null && message.MessageType == BrokerMigrationMessage.MessageType)
|
||||||
{
|
{
|
||||||
Trace.Info("BrokerMigration message received. Polling Broker for messages...");
|
Trace.Info("BrokerMigration message received. Polling Broker for messages...");
|
||||||
|
|
||||||
var migrationMessage = JsonUtility.FromString<BrokerMigrationMessage>(message.Body);
|
var migrationMessage = JsonUtility.FromString<BrokerMigrationMessage>(message.Body);
|
||||||
var brokerServer = HostContext.GetService<IBrokerServer>();
|
var brokerServer = HostContext.GetService<IBrokerServer>();
|
||||||
|
|
||||||
await brokerServer.ConnectAsync(migrationMessage.BrokerBaseUrl, _creds);
|
await brokerServer.ConnectAsync(migrationMessage.BrokerBaseUrl, _creds);
|
||||||
message = await brokerServer.GetRunnerMessageAsync(token,
|
message = await brokerServer.GetRunnerMessageAsync(token,
|
||||||
_session.SessionId,
|
_session.SessionId,
|
||||||
runnerStatus,
|
runnerStatus,
|
||||||
BuildConstants.RunnerPackage.Version,
|
BuildConstants.RunnerPackage.Version,
|
||||||
VarUtil.OS,
|
VarUtil.OS,
|
||||||
VarUtil.OSArchitecture,
|
VarUtil.OSArchitecture,
|
||||||
_settings.DisableUpdate);
|
_settings.DisableUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,9 +118,10 @@ namespace GitHub.Actions.RunService.WebApi
|
|||||||
throw new Exception($"Failed to get job message: {result.Error}");
|
throw new Exception($"Failed to get job message: {result.Error}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<TaskAgentSession> CreateSessionAsync(
|
public async Task<TaskAgentSession> CreateSessionAsync(
|
||||||
TaskAgentSession session,
|
|
||||||
CancellationToken cancellationToken = default)
|
TaskAgentSession session,
|
||||||
|
CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
|
|
||||||
var requestUri = new Uri(Client.BaseAddress, "session");
|
var requestUri = new Uri(Client.BaseAddress, "session");
|
||||||
@@ -137,7 +138,7 @@ namespace GitHub.Actions.RunService.WebApi
|
|||||||
return result.Value;
|
return result.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.StatusCode == HttpStatusCode.Forbidden)
|
if (result.StatusCode == HttpStatusCode.Forbidden)
|
||||||
{
|
{
|
||||||
throw new AccessDeniedException(result.Error);
|
throw new AccessDeniedException(result.Error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ namespace GitHub.Runner.Common.Tests.Listener
|
|||||||
private Mock<ICredentialManager> _credMgr;
|
private Mock<ICredentialManager> _credMgr;
|
||||||
private Mock<IConfigurationStore> _store;
|
private Mock<IConfigurationStore> _store;
|
||||||
|
|
||||||
|
private Mock<IBrokerServer> _brokerServer;
|
||||||
|
|
||||||
public MessageListenerL0()
|
public MessageListenerL0()
|
||||||
{
|
{
|
||||||
_settings = new RunnerSettings { AgentId = 1, AgentName = "myagent", PoolId = 123, PoolName = "default", ServerUrl = "http://myserver", WorkFolder = "_work" };
|
_settings = new RunnerSettings { AgentId = 1, AgentName = "myagent", PoolId = 123, PoolName = "default", ServerUrl = "http://myserver", WorkFolder = "_work" };
|
||||||
@@ -32,6 +34,7 @@ namespace GitHub.Runner.Common.Tests.Listener
|
|||||||
_runnerServer = new Mock<IRunnerServer>();
|
_runnerServer = new Mock<IRunnerServer>();
|
||||||
_credMgr = new Mock<ICredentialManager>();
|
_credMgr = new Mock<ICredentialManager>();
|
||||||
_store = new Mock<IConfigurationStore>();
|
_store = new Mock<IConfigurationStore>();
|
||||||
|
_brokerServer = new Mock<IBrokerServer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestHostContext CreateTestContext([CallerMemberName] String testName = "")
|
private TestHostContext CreateTestContext([CallerMemberName] String testName = "")
|
||||||
@@ -41,6 +44,7 @@ namespace GitHub.Runner.Common.Tests.Listener
|
|||||||
tc.SetSingleton<IRunnerServer>(_runnerServer.Object);
|
tc.SetSingleton<IRunnerServer>(_runnerServer.Object);
|
||||||
tc.SetSingleton<ICredentialManager>(_credMgr.Object);
|
tc.SetSingleton<ICredentialManager>(_credMgr.Object);
|
||||||
tc.SetSingleton<IConfigurationStore>(_store.Object);
|
tc.SetSingleton<IConfigurationStore>(_store.Object);
|
||||||
|
tc.SetSingleton<IBrokerServer>(_brokerServer.Object);
|
||||||
return tc;
|
return tc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user