Search in sources :

Example 51 with ProjectEx

use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.

the class AgentFinderTest method testLocatorCompatibleBuildSpecific.

@Test
@TestFor(issues = { "TW-49934" })
public void testLocatorCompatibleBuildSpecific() throws Exception {
    ProjectEx project10 = createProject("project10", "project 10");
    BuildTypeEx bt10 = project10.createBuildType("bt10", "bt 10");
    bt10.addParameter(new SimpleParameter("a", "%b%"));
    checkAgents(null, myAgent1, myAgent2);
    checkAgents("compatible:(buildType:(id:" + bt10.getExternalId() + "))");
    {
        SQueuedBuild queuedBuild = build().in(bt10).addToQueue();
        checkAgents("compatible:(build:(id:" + queuedBuild.getItemId() + "))");
        queuedBuild.removeFromQueue(null, null);
    }
    {
        SQueuedBuild queuedBuild = build().in(bt10).parameter("b", "value").addToQueue();
        checkAgents("compatible:(build:(id:" + queuedBuild.getItemId() + "))", myAgent1);
    }
}
Also used : ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 52 with ProjectEx

use of jetbrains.buildServer.serverSide.impl.ProjectEx in project teamcity-rest by JetBrains.

the class AgentFinderTest method testLocatorCompatibleForBuild.

@Test
public void testLocatorCompatibleForBuild() 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");
    MockBuildAgent agent10 = myFixture.createEnabledAgent("agent10", "Ant");
    agent10.addConfigParameter("a", "b");
    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 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[] { 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,connected:true,authorized:true,enabled:true", myAgent1, agent10, agent20, agent30, agent40);
    SQueuedBuild build1 = build().in(bt10).addToQueue();
    checkAgents("compatible:(build:(id:" + build1.getBuildPromotion().getId() + "))", agent10);
    SQueuedBuild build2 = build().in(bt20).addToQueue();
    checkAgents("compatible:(build:(id:" + build2.getBuildPromotion().getId() + "))", myAgent1, agent10, agent40);
    checkAgents("compatible:(build:(item:(id:" + build2.getBuildPromotion().getId() + "),item:(id:" + build1.getBuildPromotion().getId() + ")))", myAgent1, agent10, agent40);
    SFinishedBuild build3 = build().in(bt10).finish();
    // agent50 should probably not be here
    checkAgents("compatible:(build:(id:" + build3.getBuildPromotion().getId() + "))", agent10, agent50);
    SFinishedBuild build4 = build().in(bt20).finish();
    // agent50 should probably not be here
    checkAgents("compatible:(build:(id:" + build4.getBuildPromotion().getId() + "))", myAgent1, agent10, agent40, agent50);
}
Also used : ProjectEx(jetbrains.buildServer.serverSide.impl.ProjectEx) MockBuildAgent(jetbrains.buildServer.serverSide.impl.MockBuildAgent) SkipException(org.testng.SkipException) Test(org.testng.annotations.Test)

Aggregations

ProjectEx (jetbrains.buildServer.serverSide.impl.ProjectEx)52 Test (org.testng.annotations.Test)42 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)16 SUser (jetbrains.buildServer.users.SUser)10 BuildTypeOrTemplate (jetbrains.buildServer.server.rest.util.BuildTypeOrTemplate)8 BuildTypeEx (jetbrains.buildServer.serverSide.BuildTypeEx)7 MockVcsSupport (jetbrains.buildServer.serverSide.impl.MockVcsSupport)7 BuildType (jetbrains.buildServer.server.rest.model.buildType.BuildType)6 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)6 BadRequestException (jetbrains.buildServer.server.rest.errors.BadRequestException)5 Fields (jetbrains.buildServer.server.rest.model.Fields)5 TestName (jetbrains.buildServer.tests.TestName)5 ApiOperation (io.swagger.annotations.ApiOperation)4 SUserGroup (jetbrains.buildServer.groups.SUserGroup)4 ProjectRequestTest (jetbrains.buildServer.server.rest.request.ProjectRequestTest)4 Mutes (jetbrains.buildServer.server.rest.model.problem.Mutes)3 SFinishedBuild (jetbrains.buildServer.serverSide.SFinishedBuild)3 SProject (jetbrains.buildServer.serverSide.SProject)3 STest (jetbrains.buildServer.serverSide.STest)3 Permissions (jetbrains.buildServer.serverSide.auth.Permissions)3