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);
}
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));
}
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));
}
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"));
}
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()));
}
Aggregations