use of com.testsigma.automator.exceptions.AgentDeletedException in project testsigma by testsigmahq.
the class AgentBrowserService method sync.
public void sync() throws AgentDeletedException {
try {
if (!startSync()) {
return;
}
log.info("Syncing agent details");
String hostName = AgentService.getComputerName();
String uuid = agentConfig.getUUID();
AgentDTO agentDTO = new AgentDTO();
AgentOs osType = AgentOs.getLocalAgentOs();
agentDTO.setOsType(osType);
agentDTO.setOsVersion(AgentService.getOsVersion());
agentDTO.setHostName(hostName);
agentDTO.setIpAddress(NetworkUtil.getCurrentIpAddress());
agentDTO.setAgentVersion(this.agentConfig.getAgentVersion());
agentDTO.setBrowserList(this.getBrowserList());
String authHeader = WebAppHttpClient.BEARER + " " + this.agentConfig.getJwtApiKey();
HttpResponse<AgentDTO> response = httpClient.put(ServerURLBuilder.agentURL(uuid), agentDTO, new TypeReference<>() {
}, authHeader);
log.debug(response);
if (response.getStatusCode() == HttpStatus.OK.value()) {
log.info("Successfully updated latest agent details...");
} else {
log.info("Failed to sync latest hybrid agent details to application server");
log.info("Error code: " + response.getStatusCode() + " - " + response.getStatusMessage());
}
} catch (AgentDeletedException e) {
throw e;
} catch (Exception e) {
log.error(e.getMessage(), e);
}
log.debug("Finished syncing agent details");
}
use of com.testsigma.automator.exceptions.AgentDeletedException in project testsigma by testsigmahq.
the class ApplicationEventHandler method postAppContextReadyActions.
public void postAppContextReadyActions(ApplicationContext context) {
log.info("-------------- Post App Context Ready Actions Started --------------");
AgentConfig agentConfig = context.getBean(AgentConfig.class);
CloudAppBridge cloudAppBridge = context.getBean(CloudAppBridge.class);
ApplicationConfig applicationConfig = context.getBean(ApplicationConfig.class);
AgentWebServerService agentWebServerService = context.getBean(AgentWebServerService.class);
AutomatorConfig automatorConfig = AutomatorConfig.getInstance();
automatorConfig.setCloudServerUrl(agentConfig.getServerUrl());
automatorConfig.setTestCaseFetchWaitInterval(applicationConfig.getTestCaseFetchWaitInterval());
automatorConfig.setTestCaseDefaultMaxTries(applicationConfig.getTestCaseDefaultMaxTries());
automatorConfig.setAppBridge(cloudAppBridge);
automatorConfig.init();
AdbBridge adbBridge = context.getBean(AdbBridge.class);
MobileAutomationServer mobileAutomationServer = context.getBean(MobileAutomationServer.class);
AgentBrowserService agentBrowserService = context.getBean(AgentBrowserService.class);
AndroidDeviceListener androidDeviceListener = context.getBean(AndroidDeviceListener.class);
IosDeviceListener iosDeviceListener = context.getBean(IosDeviceListener.class);
AgentWebServer agentWebServer = context.getBean(AgentWebServer.class);
agentWebServer.startWebServerConnectors();
try {
agentBrowserService.sync();
} catch (AgentDeletedException e) {
log.info("-------------- Post App Context Failed Agent is deleted --------------");
}
androidDeviceListener.syncInitialDeviceStatus();
adbBridge.createBridge();
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.submit(androidDeviceListener);
ExecutorService executorService1 = Executors.newSingleThreadExecutor();
executorService1.submit(iosDeviceListener);
mobileAutomationServer.start();
agentWebServerService.registerLocalAgent();
log.info("-------------- Post App Context Ready Actions Finished --------------");
}
use of com.testsigma.automator.exceptions.AgentDeletedException 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);
}
}
Aggregations