private boolean setUpRemoteEngines(TestPlanEntity testPlan, Queue<Engine> engineQ) {
   List<EngineRole> engineRoles = testPlan.getTestTenant().getEngineList();
   Queue<EngineRole> engineRoleQ = new ArrayDeque<>();
   engineRoleQ.addAll(engineRoles);
   while (!engineRoleQ.isEmpty()) {
     EngineRole role = engineRoleQ.remove();
     if (engineQ.size() < engineRoles.size()) {
       _logger.error(
           String.format(
               "Testplan: %d can't init. Not enough available engines", testPlan.getId()));
       return true;
     }
     while (true) {
       Engine e = engineQ.remove();
       if (engineService.setRemoteEngineRole(e, role)) {
         break;
       }
       if (engineQ.isEmpty()) {
         _logger.error(
             String.format(
                 "Testplan: %d can't init. Not enough available engines", testPlan.getId()));
         return true;
       }
     }
   }
   return false;
 }
 @Deprecated
 private void initTestShortCut(TestPlanEntity tp) {
   List<Engine> totest = engineService.getAllEngines().subList(0, tp.getEngineNumber());
   List<EngineRole> engineRoles = tp.getTestTenant().getEngineList();
   Queue<Engine> engineQ = new ArrayDeque<>();
   engineQ.addAll(totest);
   setUpRemoteEngines(tp, engineQ);
 }
 private boolean initTest(TestPlanEntity testPlan) {
   List<EngineRole> engineRoles = testPlan.getTestTenant().getEngineList();
   Host tester = testPlan.getHost();
   List<Engine> idleEngines = engineService.getIdleEngines().stream().collect(Collectors.toList());
   List<Engine> engineOnTester =
       tester.getEngineList().stream().map(EngineRole::getEngine).collect(Collectors.toList());
   if (idleEngines.size() + tester.getEngineList().size() < engineRoles.size()) {
     _logger.error(
         String.format("Testplan: %d can't init. Not enough available engines", testPlan.getId()));
     return false;
   }
   tester
       .getEngineList()
       .stream()
       .filter(e -> e.getEngine() != null)
       .forEach(e -> e.getEngine().setStatus(EngineStatus.IDLE));
   if (roleSettingOperation(testPlan, tester, idleEngines, engineOnTester)) return false;
   tester
       .getEngineList()
       .stream()
       .filter(e -> e.getEngine() != null)
       .forEach(e -> e.getEngine().setStatus(EngineStatus.TESTING));
   return true;
 }