Best Cerberus-source code snippet using org.cerberus.crud.entity.TestCaseExecution.getRobotExecutorObj
Source:ExecutionCheckService.java
...367 return true;368 }369 private boolean checkExecutorProxy(TestCaseExecution tce) {370 //if executor proxy active, check cerberus-executor is available371 if (tce.getRobotExecutorObj() != null && "Y".equals(tce.getRobotExecutorObj().getExecutorProxyActive())) {372 //If ExecutorExtensionHost is null or empty, use the Robot Host373 if (tce.getRobotExecutorObj().getExecutorExtensionHost() == null || tce.getRobotExecutorObj().getExecutorExtensionHost().isEmpty()) {374 tce.getRobotExecutorObj().setExecutorExtensionHost(tce.getRobotExecutorObj().getHost());375 }376 String url = "http://" + tce.getRobotExecutorObj().getExecutorExtensionHost() + ":" + tce.getRobotExecutorObj().getExecutorExtensionPort() + "/check";377 LOG.debug("Url to check Proxy Executor : " + url);378 try (InputStream is = new URL(url).openStream()) {379 BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8")));380 StringBuilder sb = new StringBuilder();381 int cp;382 while ((cp = rd.read()) != -1) {383 sb.append((char) cp);384 }385 String jsonText = sb.toString();386 JSONObject json = new JSONObject(jsonText);387 if ("OK".equals(json.getString("message"))) {388 return true;389 }390 } catch (ConnectException ex) {391 LOG.warn("Exception Reaching Cerberus Extension " + tce.getRobotExecutorObj().getExecutorExtensionHost() + ":" + tce.getRobotExecutorObj().getExecutorExtensionPort() + " Exception :" + ex.toString());392 } catch (Exception ex) {393 LOG.error("Exception Reaching Cerberus Extension " + tce.getRobotExecutorObj().getExecutorExtensionHost() + ":" + tce.getRobotExecutorObj().getExecutorExtensionPort() + " Exception :" + ex.toString(), ex);394 }395 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_CERBERUSEXECUTORNOTAVAILABLE);396 message.resolveDescription("HOST", tce.getRobotExecutorObj().getExecutorExtensionHost())397 .resolveDescription("PORT", String.valueOf(tce.getRobotExecutorObj().getExecutorExtensionPort()))398 .resolveDescription("ROBOT", String.valueOf(tce.getRobotExecutorObj().getRobot()))399 .resolveDescription("ROBOTEXE", String.valueOf(tce.getRobotExecutorObj().getExecutor()));400 return false;401 }402 return true;403 }404}...
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!!