Search in sources :

Example 1 with ExecutionDTO

use of com.testsigma.agent.dto.ExecutionDTO in project testsigma by testsigmahq.

the class RunScheduler method run.

@Scheduled(cron = "${agent.jobs.runSchedule:-}")
public void run() {
    try {
        Thread.currentThread().setName("RunScheduler");
        if (skipScheduleRun()) {
            log.info("Skipping agent RunScheduler run...");
            return;
        }
        String authHeader = HttpClient.BEARER + " " + agentConfig.getJwtApiKey();
        HttpResponse<ExecutionDTO> response = httpClient.get(ServerURLBuilder.executionURL(agentConfig.getUUID()), new TypeReference<>() {
        }, authHeader);
        if (response.getStatusCode() == HttpStatus.OK.value()) {
            ExecutionDTO executionDTO = response.getResponseEntity();
            setRequestId(response);
            startExecutions(executionDTO.getEnvironment());
        } else {
            log.error("Unable To Fetch Executions From Testsigma Servers. Request Failed With Response Code - " + response.getStatusCode());
        }
    } catch (AgentDeletedException e) {
        deRegisterAgent(e);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : ExecutionDTO(com.testsigma.agent.dto.ExecutionDTO) AgentDeletedException(com.testsigma.automator.exceptions.AgentDeletedException) AgentDeletedException(com.testsigma.automator.exceptions.AgentDeletedException) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Aggregations

ExecutionDTO (com.testsigma.agent.dto.ExecutionDTO)1 AgentDeletedException (com.testsigma.automator.exceptions.AgentDeletedException)1 Scheduled (org.springframework.scheduling.annotation.Scheduled)1