use of org.eclipse.che.api.agent.shared.model.Agent in project che by eclipse.
the class AbstractAgentLauncherTest method shouldStartMachineProcessWithAgentScriptExecution.
@Test
public void shouldStartMachineProcessWithAgentScriptExecution() throws Exception {
// given
String agentId = "testAgentId";
String agentScript = "testAgentScript";
when(agent.getId()).thenReturn(agentId);
when(agent.getScript()).thenReturn(agentScript);
when(launcher.start(any(Instance.class), any(Agent.class), any(LineConsumer.class))).thenCallRealMethod();
// when
launcher.launch(machine, agent);
// then
verify(machine).createProcess(eq(new CommandImpl(agentId, agentScript, "agent")), eq(null));
}
use of org.eclipse.che.api.agent.shared.model.Agent in project che by eclipse.
the class AbstractAgentLauncherTest method shouldLogAgentStartLogsIfMachineExceptionOccurs.
@Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "An error on agent start")
public void shouldLogAgentStartLogsIfMachineExceptionOccurs() throws Exception {
// given
doThrow(new MachineException("An error on agent start")).when(launcher).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
// when
launcher.launch(machine, agent);
// then
verify(launcher).logAsErrorAgentStartLogs(anyString(), anyString());
}
use of org.eclipse.che.api.agent.shared.model.Agent in project che by eclipse.
the class AbstractAgentLauncherTest method shouldLogAgentStartLogsIfMachineExceptionOccursAfterAgentStartTimeoutHadReached.
@Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "An error on process kill")
public void shouldLogAgentStartLogsIfMachineExceptionOccursAfterAgentStartTimeoutHadReached() throws Exception {
// given
launcher = spy(new TestAgentLauncher(-1, 100, agentChecker));
when(agentChecker.isLaunched(any(Agent.class), any(InstanceProcess.class), any(Instance.class))).thenReturn(false);
doReturn(process).when(launcher).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
doThrow(new MachineException("An error on process kill")).when(process).kill();
// when
launcher.launch(machine, agent);
// then
verify(launcher).logAsErrorAgentStartLogs(anyString(), anyString());
}
use of org.eclipse.che.api.agent.shared.model.Agent in project che by eclipse.
the class AgentConfigApplier method apply.
/**
* Applies docker specific properties to a machine.
*
* @param machineConf
* machine config with the list of agents that should be injected into machine
* @param machine
* affected machine
* @throws AgentException
* if any error occurs
*/
public void apply(@Nullable ExtendedMachine machineConf, CheServiceImpl machine) throws AgentException {
if (machineConf != null) {
for (AgentKey agentKey : sorter.sort(machineConf.getAgents())) {
Agent agent = agentRegistry.getAgent(agentKey);
addEnv(machine, agent.getProperties());
addExposedPorts(machine, agent.getServers());
addLabels(machine, agent.getServers());
}
}
}
Aggregations