Search in sources :

Example 66 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class JobRunnerTest method setUp.

@Before
public void setUp() throws Exception {
    runner = new JobRunner();
    work = new FakeWork();
    consoleOut = new ArrayList<>();
    statesAndResult = new ArrayList<>();
    properties = new ArrayList<>();
    agentIdentifier = new AgentIdentifier("localhost", "127.0.0.1", "uuid");
    new SystemEnvironment().setProperty("serviceUrl", SERVER_URL);
    resolver = mock(UpstreamPipelineResolver.class);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) UpstreamPipelineResolver(com.thoughtworks.go.server.service.UpstreamPipelineResolver) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) FakeWork(com.thoughtworks.go.work.FakeWork) Before(org.junit.Before)

Example 67 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class BuildAssignmentServiceIntegrationTest method shouldNotAssignCancelledJob.

@Test
public void shouldNotAssignCancelledJob() throws Exception {
    AgentIdentifier instance = agent(AgentMother.localAgent());
    Pipeline pipeline = instanceFactory.createPipelineInstance(evolveConfig, modifyNoFiles(evolveConfig), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    dbHelper.savePipelineWithStagesAndMaterials(pipeline);
    buildAssignmentService.onConfigChange(goConfigService.getCurrentConfig());
    JobInstance job = buildOf(pipeline);
    job.cancel();
    jobInstanceDao.updateStateAndResult(job);
    assertThat(buildAssignmentService.assignWorkToAgent(instance), is(BuildAssignmentService.NO_WORK));
}
Also used : AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier)

Example 68 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class BuildAssignmentServiceIntegrationTest method shouldNotAssignWorkWhenPipelineScheduledWithStaleMaterials.

@Test
public void shouldNotAssignWorkWhenPipelineScheduledWithStaleMaterials() {
    AgentIdentifier instance = agent(AgentMother.localAgent());
    Pipeline pipeline = instanceFactory.createPipelineInstance(evolveConfig, modifyNoFiles(evolveConfig), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    dbHelper.savePipelineWithStagesAndMaterials(pipeline);
    evolveConfig.setMaterialConfigs(new MaterialConfigs(new HgMaterialConfig("foo", null)));
    configHelper.removePipeline(CaseInsensitiveString.str(evolveConfig.name()));
    configHelper.addPipeline(evolveConfig);
    buildAssignmentService.onConfigChange(goConfigService.getCurrentConfig());
    JobInstance job = buildOf(pipeline);
    jobInstanceDao.updateStateAndResult(job);
    assertThat(buildAssignmentService.assignWorkToAgent(instance), is(BuildAssignmentService.NO_WORK));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) HgMaterialConfig(com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier)

Example 69 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class AgentDaoTest method shouldCacheCookieForAgent.

@Test
public void shouldCacheCookieForAgent() throws Exception {
    AgentIdentifier agentIdentifier = new AgentIdentifier("host", "127.0.0.1", "uuid");
    agentDao.associateCookie(agentIdentifier, "cookie");
    assertThat(agentDao.cookieFor(agentIdentifier), is("cookie"));
    hibernateTemplate.execute(new HibernateCallback() {

        public Object doInHibernate(Session session) throws HibernateException, SQLException {
            Agent agent = (Agent) session.createQuery("from Agent where uuid = 'uuid'").uniqueResult();
            agent.update("updated_cookie", agentIdentifier.getHostName(), agentIdentifier.getIpAddress());
            session.update(agent);
            return null;
        }
    });
    Agent agent = getAgentByUuid(agentIdentifier);
    assertThat(agent.getCookie(), is("updated_cookie"));
    assertThat(agentDao.cookieFor(agentIdentifier), is("cookie"));
    goCache.clear();
    assertThat(agentDao.cookieFor(agentIdentifier), is("updated_cookie"));
}
Also used : Agent(com.thoughtworks.go.server.domain.Agent) HibernateException(org.hibernate.HibernateException) SQLException(java.sql.SQLException) AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) HibernateCallback(org.springframework.orm.hibernate3.HibernateCallback) Session(org.hibernate.Session) Test(org.junit.Test)

Example 70 with AgentIdentifier

use of com.thoughtworks.go.remote.AgentIdentifier in project gocd by gocd.

the class AgentDaoTest method shouldReturnNullIfNoCookie.

@Test
public void shouldReturnNullIfNoCookie() throws Exception {
    AgentIdentifier agentIdentifier = new AgentIdentifier("host", "127.0.0.1", "uuid");
    assertThat(agentDao.cookieFor(agentIdentifier), is(nullValue()));
}
Also used : AgentIdentifier(com.thoughtworks.go.remote.AgentIdentifier) Test(org.junit.Test)

Aggregations

AgentIdentifier (com.thoughtworks.go.remote.AgentIdentifier)81 Test (org.junit.Test)57 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)34 FakeBuildRepositoryRemote (com.thoughtworks.go.agent.testhelpers.FakeBuildRepositoryRemote)12 Before (org.junit.Before)11 UploadEntry (com.thoughtworks.go.matchers.UploadEntry)10 ArrayList (java.util.ArrayList)10 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)9 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)9 File (java.io.File)9 AgentConfig (com.thoughtworks.go.config.AgentConfig)5 AgentInstance (com.thoughtworks.go.domain.AgentInstance)5 AgentStatusChangeListener (com.thoughtworks.go.listener.AgentStatusChangeListener)5 AgentInstruction (com.thoughtworks.go.remote.AgentInstruction)4 NoWork (com.thoughtworks.go.remote.work.NoWork)4 Work (com.thoughtworks.go.remote.work.Work)4 Agent (com.thoughtworks.go.server.domain.Agent)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)3 GoConfigDao (com.thoughtworks.go.config.GoConfigDao)2