use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class JobAssignmentIntegrationTest method setupLocalAgent.
private AgentInstance setupLocalAgent() throws UnknownHostException {
Agent agent = AgentMother.localAgent();
agentService.saveOrUpdate(agent);
return AgentInstance.createFromAgent(agent, systemEnvironment, agentStatusChangeListener());
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class ScheduleServiceRescheduleHungJobsIntegrationTest method shouldRescheduleHungBuildWhenAgentTryToGetWorkWithSameUuid.
@Test
public void shouldRescheduleHungBuildWhenAgentTryToGetWorkWithSameUuid() throws Exception {
Agent agent = AgentMother.localAgent();
AgentInstance instance = agent(agent);
BuildCause buildCause = modifySomeFiles(evolveConfig);
dbHelper.saveMaterials(buildCause.getMaterialRevisions());
Pipeline pipeline = instanceFactory.createPipelineInstance(evolveConfig, buildCause, new DefaultSchedulingContext(DEFAULT_APPROVED_BY), "md5-test", new TimeProvider());
buildAssignmentService.onTimer();
Stage stage = pipeline.getFirstStage();
JobInstance jobInstance = stage.getJobInstances().get(0);
jobInstance.setAgentUuid(agent.getUuid());
jobInstance.changeState(JobState.Building);
pipelineDao.saveWithStages(pipeline);
buildAssignmentService.onTimer();
buildAssignmentService.assignWorkToAgent(instance);
buildAssignmentService.onTimer();
buildAssignmentService.assignWorkToAgent(instance);
final Stage reloadedStage = stageDao.stageById(stage.getId());
final JobInstance rescheduledJob = reloadedStage.getJobInstances().getByName(jobInstance.getName());
assertThat(rescheduledJob.getState(), is(JobState.Assigned));
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class ScheduleServiceRescheduleHungJobsIntegrationTest method shouldNotRescheduleCancelledBuilds.
@Test
public void shouldNotRescheduleCancelledBuilds() throws SQLException {
String agentId = "uuid";
final Pipeline pipeline = instanceFactory.createPipelineInstance(evolveConfig, modifySomeFiles(evolveConfig), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), "md5-test", new TimeProvider());
dbHelper.savePipelineWithStagesAndMaterials(pipeline);
buildAssignmentService.assignWorkToAgent(agent(new Agent(agentId)));
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
stageService.cancelStage(stageOf(pipeline), null);
}
});
scheduleService.rescheduleHungJobs();
JobInstance reloaded = jobInstanceDao.buildByIdWithTransitions(buildOf(pipeline).getId());
assertThat(reloaded.getState(), is(JobState.Completed));
assertThat(reloaded.getResult(), is(JobResult.Cancelled));
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class UpdateAgentStatusTest method setUp.
@BeforeEach
public void setUp(@TempDir Path tempDir) throws Exception {
dbHelper.onSetUp();
configHelper.onSetUp();
configHelper.usingCruiseConfigDao(goConfigDao);
preCondition = new PipelineWithTwoStages(materialRepository, transactionTemplate, tempDir);
preCondition.usingConfigHelper(configHelper).usingDbHelper(dbHelper).onSetUp();
agentService.clearAll();
agentService.saveOrUpdate(new Agent(agentId, "CCEDev01", "10.81.2.1", "cookie"));
}
use of com.thoughtworks.go.config.Agent in project gocd by gocd.
the class AgentPerformanceVerifier method doAssertAgentAndItsAssociationInDBAndCache.
private void doAssertAgentAndItsAssociationInDBAndCache() {
stream(agentService.getAgentInstances()).filter(agentInstance -> agentInstance.getUuid().startsWith("Perf-Test-Agent-")).forEach(agentInstance -> {
Agent agentInCache = agentInstance.getAgent();
Agent agentInDB = agentDao.fetchAgentFromDBByUUID(agentInCache.getUuid());
if (agentInDB == null && !agentInstance.isPending()) {
LOG.debug("Agent {} is not pending but not present in DB", agentInCache.getUuid());
bombIfAgentInDBAndCacheAreDifferent(agentInCache, agentInDB);
}
Set<String> agentEnvsInEnvCache = environmentConfigService.getAgentEnvironmentNames(agentInCache.getUuid());
HashSet<String> agentEnvsInDB = new HashSet<>(agentInDB.getEnvironmentsAsList());
bombIfAgentEnvAssociationInDBAndEnvCacheAreDifferent(agentInCache, agentEnvsInDB, agentEnvsInEnvCache);
bombIfMissingAgentKnownEnvAssociationInEnvCache(agentInCache, agentEnvsInEnvCache, agentEnvsInDB);
});
LOG.debug("\n\n*************** Hurray! Verification of performance tests succeeded and there are no threading issues reported! ***************\n\n");
}
Aggregations