use of jetbrains.buildServer.serverSide.BuildAgentEx in project teamcity-git by JetBrains.
the class GitAgentVersionHealthReport method report.
@Override
public void report(@NotNull final HealthStatusScope scope, @NotNull final HealthStatusItemConsumer consumer) {
final List<BuildAgentEx> unsupported = new ArrayList<>();
final List<BuildAgentEx> deprecated = new ArrayList<>();
for (BuildAgentEx a : myAgentManager.getRegisteredAgents()) {
final GitVersion version = getGitVersion(a);
if (version == null) {
LOG.debug("No git executable version reported for \"" + a.getName() + "\" agent via \"" + Constants.TEAMCITY_AGENT_GIT_VERSION + "\" environment property");
continue;
}
if (version.isLessThan(GitVersion.MIN)) {
unsupported.add(a);
} else if (version.isLessThan(myDeprecatedVersion)) {
deprecated.add(a);
}
}
if (!unsupported.isEmpty()) {
final Map<String, Object> model = new HashMap<>();
model.put("gitVersionUnsupported", true);
model.put("gitVersionAgentCount", unsupported.size());
model.put("gitVersionAgents", groupAgents(unsupported));
model.put("hasSeveralPools", myAgentPoolManager.hasSeveralPools());
consumer.consumeGlobal(new HealthStatusItem(UNSUPPORTED_CATEGORY, myUnsupportedCategory, model));
}
if (!deprecated.isEmpty()) {
final Map<String, Object> model = new HashMap<>();
model.put("gitVersionUnsupported", false);
model.put("gitVersionAgentCount", deprecated.size());
model.put("gitVersionAgents", groupAgents(deprecated));
model.put("hasSeveralPools", myAgentPoolManager.hasSeveralPools());
consumer.consumeGlobal(new HealthStatusItem(DEPRECATED_CATEGORY, myDeprecatedCategory, model));
}
}
use of jetbrains.buildServer.serverSide.BuildAgentEx in project teamcity-rest by JetBrains.
the class AgentPoolMutationTest method testMoveAgentToPool.
@Test
public void testMoveAgentToPool() throws AgentPoolCannotBeRenamedException {
final String poolName = "testPool";
AgentPool targetPool = myFixture.getAgentPoolManager().createNewAgentPool(poolName);
BuildAgentEx agent = myFixture.createEnabledAgent("test");
// Let's ensure that our mock agent is created in default pool
assertEquals(AgentPool.DEFAULT_POOL_ID, agent.getAgentPoolId());
MoveAgentToAgentPoolInput input = new MoveAgentToAgentPoolInput();
input.setAgentRawId(agent.getId());
input.setTargetAgentPoolRawId(targetPool.getAgentPoolId());
DataFetcherResult<MoveAgentToAgentPoolPayload> result = myMutation.moveAgentToAgentPool(input, new MockDataFetchingEnvironment());
assertNotNull(result);
assertFalse(result.hasErrors());
assertNotNull(result.getData());
MoveAgentToAgentPoolPayload payload = result.getData();
assertEquals(AgentPool.DEFAULT_POOL_ID, payload.getSourceAgentPool().getRealPool().getAgentPoolId());
assertEquals(targetPool.getAgentPoolId(), payload.getTargetAgentPool().getRealPool().getAgentPoolId());
assertEquals(agent.getId(), Integer.parseInt(payload.getAgent().getRawId()));
// Agent must be deleted from source pool
assertNotContains(myFixture.getAgentPoolManager().getAgentTypeIdsByPool(AgentPool.DEFAULT_POOL_ID), agent.getAgentTypeId());
// Agent must be moved to target pool
assertContains(myFixture.getAgentPoolManager().getAgentTypeIdsByPool(targetPool.getAgentPoolId()), agent.getAgentTypeId());
}
Aggregations