Best Testsigma code snippet using com.testsigma.schedulers.scheduleTestPlanTask.getCurrentUTCTime
Source:scheduleTestPlanTask.java
...53 log.error(e.getMessage(), e);54 }55 }56 public ResponseEntity<Object> runSchedules() throws TestsigmaException, SQLException {57 Timestamp currentTime = getCurrentUTCTime();58 String message = null;59 Set<Long> runningExecutionIds = new HashSet<Long>();60 try {61 List<ScheduleTestPlan> scheduleTestPlanList = this.scheduleTestPlanService.findAllActiveSchedules(currentTime);62 log.info("Found " + scheduleTestPlanList.size() + " scheduled test plans");63 for (ScheduleTestPlan schedule : scheduleTestPlanList) {64 schedule.setQueueStatus(ScheduleQueueStatus.IN_PROGRESS);65 this.scheduleTestPlanService.update(schedule);66 }67 for (ScheduleTestPlan schedule : scheduleTestPlanList) {68 if (runningExecutionIds.contains(schedule.getTestPlanId())) {69 log.info("Scheduled test plan - " + schedule.getName() + " already running. Skipping it....");70 continue;71 }72 try {73 log.info("Triggering scheduled test plan - " + schedule.getName() + "....");74 TestPlan testPlan = this.testPlanService.find(schedule.getTestPlanId());75 AgentExecutionService agentExecutionService = agentExecutionServiceObjectFactory.getObject();76 agentExecutionService.setTestPlan(testPlan);77 String uuid = UUID.randomUUID().toString().toUpperCase().replace("-", "");78 ThreadContext.put("X-Request-Id", uuid);79 ThreadContext.put("NewRelic:X-Request-Id", uuid);80 agentExecutionService.setTriggeredType(ExecutionTriggeredType.SCHEDULED);81 agentExecutionService.setScheduleId(schedule.getId());82 agentExecutionService.start();83 } catch (Exception e) {84 log.error(e.getMessage(), e);85 }86 runningExecutionIds.add(schedule.getTestPlanId());87 if (!schedule.getScheduleType().equals(ScheduleType.ONCE)) {88 schedule.setStatus(ScheduleStatus.ACTIVE);89 populateNextInterval(schedule);90 } else {91 schedule.setStatus(ScheduleStatus.IN_ACTIVE);92 }93 schedule.setUpdatedDate(new Timestamp(System.currentTimeMillis()));94 schedule.setQueueStatus(ScheduleQueueStatus.COMPLETED);95 this.scheduleTestPlanService.update(schedule);96 }97 return new ResponseEntity<>(message, HttpStatus.OK);98 } catch (Exception e) {99 log.error(e, e);100 Thread.currentThread().interrupt();101 return new ResponseEntity<>(e.getLocalizedMessage(), HttpStatus.INTERNAL_SERVER_ERROR);102 }103 }104 private Timestamp getCurrentUTCTime() {105 ZonedDateTime zdt = ZonedDateTime.of(LocalDateTime.now(), ZoneId.systemDefault());106 ZonedDateTime utc = zdt.withZoneSameInstant(ZoneId.of("UTC"));107 return Timestamp.valueOf(utc.toLocalDateTime());108 }109 private void populateNextInterval(ScheduleTestPlan scheduleTestPlan) throws TestsigmaException {110 //[TODO] [Pratheepv] Bad way to handle Need to revisit this one111 try {112 Timestamp scheduleTime = schedulerService.getScheduleTime(scheduleTestPlan.getScheduleType(), scheduleTestPlan.getScheduleTime());113 scheduleTestPlan.setScheduleTime(scheduleTime);114 } catch (ParseException e) {115 e.printStackTrace();116 throw new TestsigmaException("Problem while calculating next interval");117 }118 }...
getCurrentUTCTime
Using AI Code Generation
1schedule = new com.testsigma.schedulers.scheduleTestPlanTask();2currentUTCTime = schedule.getCurrentUTCTime();3startTime = currentUTCTime + 600000;4schedule.scheduleTestPlan("TestPlan1",startTime,1800000)5schedule = new com.testsigma.schedulers.scheduleTestPlanTask();6currentUTCTime = schedule.getCurrentUTCTime();7startTime = currentUTCTime + 600000;8schedule.scheduleTestPlan("TestPlan1",startTime,1800000)
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!