use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class AgentPoolMutationTest method testRemoveProjectFromPoolRecursive.
@Test
public void testRemoveProjectFromPoolRecursive() throws AgentPoolCannotBeRenamedException, NoSuchAgentPoolException {
final String poolName = "testPool";
final String projectName = "testProject";
final String childProjectName = "testProjectChild";
AgentPool pool = myFixture.getAgentPoolManager().createNewAgentPool(poolName);
ProjectEx project = createProject(projectName, projectName);
ProjectEx childProject = project.createProject(childProjectName, childProjectName);
Set<String> associateList = new HashSet<>();
associateList.add(project.getProjectId());
associateList.add(childProject.getProjectId());
myFixture.getAgentPoolManager().associateProjectsWithPool(pool.getAgentPoolId(), associateList);
UnassignProjectFromAgentPoolInput input = new UnassignProjectFromAgentPoolInput();
input.setAgentPoolRawId(pool.getAgentPoolId());
input.setProjectRawId(project.getExternalId());
input.setRecursive(true);
DataFetcherResult<UnassignProjectFromAgentPoolPayload> result = myMutation.unassignProjectFromAgentPool(input);
assertNotNull(result);
assertFalse(result.hasErrors());
assertNotNull(result.getData());
UnassignProjectFromAgentPoolPayload payload = result.getData();
assertEquals(poolName, payload.getAgentPool().getName());
assertEquals(projectName, payload.getProject().getName());
assertNotContains(myFixture.getAgentPoolManager().getPoolProjects(pool.getAgentPoolId()), project.getProjectId(), childProject.getProjectId());
}
use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class AgentPoolMutationTest method testRemoveProjectFromPool.
@Test
public void testRemoveProjectFromPool() throws AgentPoolCannotBeRenamedException, NoSuchAgentPoolException {
final String poolName = "testPool";
final String projectName = "testProject";
AgentPool pool = myFixture.getAgentPoolManager().createNewAgentPool(poolName);
ProjectEx project = createProject(projectName);
myFixture.getAgentPoolManager().associateProjectsWithPool(pool.getAgentPoolId(), Collections.singleton(project.getProjectId()));
UnassignProjectFromAgentPoolInput input = new UnassignProjectFromAgentPoolInput();
input.setAgentPoolRawId(pool.getAgentPoolId());
input.setProjectRawId(project.getExternalId());
DataFetcherResult<UnassignProjectFromAgentPoolPayload> result = myMutation.unassignProjectFromAgentPool(input);
assertNotNull(result);
assertFalse(result.hasErrors());
assertNotNull(result.getData());
UnassignProjectFromAgentPoolPayload payload = result.getData();
assertEquals(poolName, payload.getAgentPool().getName());
assertEquals(projectName, payload.getProject().getName());
assertNotContains(myFixture.getAgentPoolManager().getPoolProjects(pool.getAgentPoolId()), project.getProjectId());
}
use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class AgentPoolMutationTest method testAddProjectToPoolExclusively.
@Test
public void testAddProjectToPoolExclusively() throws AgentPoolCannotBeRenamedException {
final String poolName = "testPool";
final String projectName = "testProject";
AgentPool pool = myFixture.getAgentPoolManager().createNewAgentPool(poolName);
ProjectEx project = createProject(projectName);
AssignProjectWithAgentPoolInput input = new AssignProjectWithAgentPoolInput();
input.setAgentPoolRawId(pool.getAgentPoolId());
input.setProjectRawId(project.getExternalId());
input.setExclusively(true);
DataFetcherResult<AssignProjectWithAgentPoolPayload> result = myMutation.assignProjectWithAgentPool(input);
assertNotNull(result);
assertFalse(result.hasErrors());
assertNotNull(result.getData());
AssignProjectWithAgentPoolPayload payload = result.getData();
assertEquals(poolName, payload.getAgentPool().getName());
assertEquals(projectName, payload.getProject().getName());
assertContains(myFixture.getAgentPoolManager().getPoolProjects(pool.getAgentPoolId()), project.getProjectId());
assertEquals("Only one pool should contain project after exclusive assignment.", 1, myFixture.getAgentPoolManager().getAgentPoolsWithProject(project.getProjectId()).size());
}
use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class AgentFinderTest method testLocatorCompatible.
@Test
public void testLocatorCompatible() throws Exception {
ProjectEx project10 = createProject("project10", "project 10");
BuildTypeEx bt10 = project10.createBuildType("bt10", "bt 10");
bt10.addRequirement(myFixture.findSingletonService(RequirementFactory.class).createRequirement("a", null, RequirementType.EXISTS));
BuildTypeEx bt20 = project10.createBuildType("bt20", "bt 20");
BuildTypeEx bt30 = project10.createBuildType("bt30", "bt 30");
bt30.addRequirement(myFixture.findSingletonService(RequirementFactory.class).createRequirement("x", "1", RequirementType.EQUALS));
myAgent1.addConfigParameter("x", "1");
myAgent1.pushAgentTypeData();
MockBuildAgent agent10 = myFixture.createEnabledAgent("agent10", "Ant");
agent10.addConfigParameter("a", "b");
agent10.addConfigParameter("x", "1");
agent10.pushAgentTypeData();
if (myServer.getLicensingPolicy().getMaxNumberOfAuthorizedAgents() < 4) {
throw new SkipException("Cannot execute test logic when there is not enough agent licenses (only works in internal dev environment tests)");
}
MockBuildAgent agent15 = myFixture.createEnabledAgent("agent15", "Ant");
agent15.addConfigParameter("a", "b");
agent15.pushAgentTypeData();
MockBuildAgent agent20 = myFixture.createEnabledAgent("agent20", "Ant");
agent20.addConfigParameter("a", "b");
agent20.pushAgentTypeData();
final int poolId1 = myFixture.getAgentPoolManager().createNewAgentPool("pool1").getAgentPoolId();
myFixture.getAgentPoolManager().moveAgentTypesToPool(poolId1, createSet(agent20.getId()));
MockBuildAgent agent30 = myFixture.createEnabledAgent("agent30", "Ant");
agent30.addConfigParameter("a", "b");
agent30.pushAgentTypeData();
myFixture.getAgentTypeManager().setRunConfigurationPolicy(agent30.getAgentTypeId(), BuildAgentManager.RunConfigurationPolicy.SELECTED_COMPATIBLE_CONFIGURATIONS);
myFixture.getAgentTypeManager().excludeRunConfigurationsFromAllowed(agent30.getAgentTypeId(), new String[] { bt10.getInternalId(), bt20.getInternalId() });
MockBuildAgent agent40 = myFixture.createEnabledAgent("agent40", "Ant");
MockBuildAgent agent50 = myFixture.createEnabledAgent("agent50", "Ant");
agent50.addConfigParameter("a", "b");
agent50.pushAgentTypeData();
agent50.setEnabled(false, null, "");
checkAgents("defaultFilter:false", myAgent1, myAgent2, myAgent3, myAgent4, agent10, agent15, agent20, agent30, agent40, agent50);
checkAgents(null, myAgent1, myAgent2, agent10, agent15, agent20, agent30, agent40, agent50);
checkAgents("compatible:(buildType:(id:" + bt10.getExternalId() + "))", agent10, agent15);
checkAgents("enabled:any,compatible:(buildType:(id:" + bt10.getExternalId() + "))", agent10, agent15, agent50);
checkAgents("compatible:(buildType:(id:" + bt30.getExternalId() + "))", myAgent1, agent10);
checkAgents("compatible:(buildType:(item:(id:" + bt10.getExternalId() + "),item:(id:" + bt30.getExternalId() + ")))", myAgent1, agent10, agent15);
checkAgents("enabled:any,compatible:(buildType:(item:(id:" + bt10.getExternalId() + "),item:(id:" + bt30.getExternalId() + ")))", myAgent1, agent10, agent15, agent50);
// checkAgents("compatible:(buildType:(id:" + bt10.getExternalId() + ")),compatible:(buildType:(id:" + bt30.getExternalId() + "))", agent10);
checkAgents("incompatible:(buildType:(id:" + bt10.getExternalId() + "))", myAgent1, myAgent2, agent20, agent30, agent40);
checkAgents("incompatible:(buildType:(item:(id:" + bt10.getExternalId() + "),item:(id:" + bt30.getExternalId() + ")))", myAgent1, myAgent2, agent15, agent20, agent30, agent40, agent50);
checkAgents("compatible:(buildType:(id:" + bt30.getExternalId() + ")),incompatible:(buildType:(id:" + bt10.getExternalId() + "))", myAgent1);
}
use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.
the class AgentFinderTest method testLocatorCompatible3AgentLimit.
@Test
public void testLocatorCompatible3AgentLimit() throws Exception {
ProjectEx project10 = createProject("project10", "project 10");
BuildTypeEx bt10 = project10.createBuildType("bt10", "bt 10");
bt10.addRequirement(myFixture.findSingletonService(RequirementFactory.class).createRequirement("a", null, RequirementType.EXISTS));
BuildTypeEx bt20 = project10.createBuildType("bt20", "bt 20");
BuildTypeEx bt30 = project10.createBuildType("bt30", "bt 30");
bt30.addRequirement(myFixture.findSingletonService(RequirementFactory.class).createRequirement("x", "1", RequirementType.EQUALS));
myAgent1.addConfigParameter("x", "1");
myAgent1.pushAgentTypeData();
myAgent1.setAuthorized(false, null, "");
myAgent2.setAuthorized(false, null, "");
MockBuildAgent agent10 = myFixture.createEnabledAgent("agent10", "Ant");
agent10.addConfigParameter("a", "b");
agent10.addConfigParameter("x", "1");
agent10.pushAgentTypeData();
MockBuildAgent agent15 = myFixture.createEnabledAgent("agent15", "Ant");
agent15.addConfigParameter("a", "b");
agent15.pushAgentTypeData();
MockBuildAgent agent20 = myFixture.createEnabledAgent("agent20", "Ant");
agent20.addConfigParameter("a", "b");
agent20.pushAgentTypeData();
agent20.setAuthorized(false, null, "");
final int poolId1 = myFixture.getAgentPoolManager().createNewAgentPool("pool1").getAgentPoolId();
myFixture.getAgentPoolManager().moveAgentTypesToPool(poolId1, createSet(agent20.getId()));
MockBuildAgent agent30 = myFixture.createEnabledAgent("agent30", "Ant");
agent30.addConfigParameter("a", "b");
agent30.pushAgentTypeData();
agent30.setAuthorized(false, null, "");
myFixture.getAgentTypeManager().setRunConfigurationPolicy(agent30.getAgentTypeId(), BuildAgentManager.RunConfigurationPolicy.SELECTED_COMPATIBLE_CONFIGURATIONS);
myFixture.getAgentTypeManager().excludeRunConfigurationsFromAllowed(agent30.getAgentTypeId(), new String[] { bt10.getInternalId(), bt20.getInternalId() });
MockBuildAgent agent40 = myFixture.createEnabledAgent("agent40", "Ant");
agent40.setAuthorized(false, null, "");
checkAgents("defaultFilter:false", myAgent1, myAgent2, myAgent3, myAgent4, agent10, agent15, agent20, agent30, agent40);
checkAgents(null, agent10, agent15);
checkAgents("authorized:any", myAgent1, myAgent2, myAgent3, myAgent4, agent10, agent15, agent20, agent30, agent40);
checkAgents("compatible:(buildType:(id:" + bt10.getExternalId() + ")),authorized:any", agent10, agent15);
checkAgents("compatible:(buildType:(id:" + bt30.getExternalId() + ")),authorized:any", myAgent1, agent10);
checkAgents("compatible:(buildType:(item:(id:" + bt10.getExternalId() + "),item:(id:" + bt30.getExternalId() + "))),authorized:any", myAgent1, agent10, agent15);
checkAgents("incompatible:(buildType:(id:" + bt10.getExternalId() + ")),authorized:any", myAgent1, myAgent2, myAgent3, myAgent4, agent20, agent30, agent40);
checkAgents("incompatible:(buildType:(item:(id:" + bt10.getExternalId() + "),item:(id:" + bt30.getExternalId() + "))),authorized:any", myAgent1, myAgent2, myAgent3, myAgent4, agent15, agent20, agent30, agent40);
checkAgents("compatible:(buildType:(id:" + bt30.getExternalId() + ")),incompatible:(buildType:(id:" + bt10.getExternalId() + ")),authorized:any", myAgent1);
}
Aggregations