use of org.cerberus.crud.entity.CountryEnvParam in project cerberus-source by cerberustesting.
the class FactoryCountryEnvParam method create.
@Override
public CountryEnvParam create(String system, String country, String env) {
countryEnvParam = new CountryEnvParam();
countryEnvParam.setSystem(system);
countryEnvParam.setCountry(country);
countryEnvParam.setEnvironment(env);
return countryEnvParam;
}
use of org.cerberus.crud.entity.CountryEnvParam in project cerberus-source by cerberustesting.
the class FactoryCountryEnvParam method create.
@Override
public CountryEnvParam create(String system, String country, String environment, String description, String build, String revision, String chain, String distribList, String eMailBodyRevision, String type, String eMailBodyChain, String eMailBodyDisableEnvironment, boolean active, boolean maintenanceAct, String maintenanceStr, String maintenanceEnd) {
countryEnvParam = new CountryEnvParam();
countryEnvParam.setSystem(system);
countryEnvParam.setCountry(country);
countryEnvParam.setEnvironment(environment);
countryEnvParam.setDescription(description);
countryEnvParam.setBuild(build);
countryEnvParam.setRevision(revision);
countryEnvParam.setChain(chain);
countryEnvParam.setDistribList(distribList);
countryEnvParam.seteMailBodyRevision(eMailBodyRevision);
countryEnvParam.setType(type);
countryEnvParam.seteMailBodyChain(eMailBodyChain);
countryEnvParam.seteMailBodyDisableEnvironment(eMailBodyDisableEnvironment);
countryEnvParam.setActive(active);
countryEnvParam.setMaintenanceAct(maintenanceAct);
countryEnvParam.setMaintenanceStr(maintenanceStr);
countryEnvParam.setMaintenanceEnd(maintenanceEnd);
return countryEnvParam;
}
use of org.cerberus.crud.entity.CountryEnvParam in project cerberus-source by cerberustesting.
the class ExecutionCheckService method checkTargetBuildRevision.
private boolean checkTargetBuildRevision(TestCaseExecution tCExecution) {
if (LOG.isDebugEnabled()) {
LOG.debug("Checking target build");
}
TestCase tc = tCExecution.getTestCaseObj();
CountryEnvParam env = tCExecution.getCountryEnvParam();
String tcSprint = ParameterParserUtil.parseStringParam(tc.getTargetBuild(), "");
String tcRevision = ParameterParserUtil.parseStringParam(tc.getTargetRev(), "");
String sprint = ParameterParserUtil.parseStringParam(env.getBuild(), "");
String revision = ParameterParserUtil.parseStringParam(env.getRevision(), "");
int dif = -1;
if (!tcSprint.isEmpty() && sprint != null) {
try {
if (sprint.isEmpty()) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_NOTDEFINED);
return false;
} else {
dif = this.compareBuild(sprint, tcSprint, env.getSystem());
}
if (dif == 0) {
if (!tcRevision.isEmpty() && revision != null) {
if (revision.isEmpty()) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_NOTDEFINED);
return false;
} else if (this.compareRevision(revision, tcRevision, env.getSystem()) < 0) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TARGET_DIFFERENT);
return false;
}
}
} else if (dif < 0) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TARGET_DIFFERENT);
return false;
}
} catch (NumberFormatException exception) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TARGET_WRONGFORMAT);
return false;
} catch (CerberusException ex) {
message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_BADLYDEFINED);
return false;
}
}
return true;
}
use of org.cerberus.crud.entity.CountryEnvParam in project cerberus-source by cerberustesting.
the class ExecutionRunService method executeTestCase.
@Override
public TestCaseExecution executeTestCase(TestCaseExecution tCExecution) throws CerberusException {
long runID = tCExecution.getId();
String logPrefix = runID + " - ";
/**
* Feeding Build Rev of main Application system to
* testcaseexecutionsysver table. Only if execution is not manual.
*/
try {
if (!(tCExecution.isManualURL())) {
/**
* Insert SystemVersion in Database
*/
TestCaseExecutionSysVer myExeSysVer = null;
try {
LOG.debug(logPrefix + "Registering Main System Version.");
myExeSysVer = factoryTestCaseExecutionSysVer.create(runID, tCExecution.getApplicationObj().getSystem(), tCExecution.getBuild(), tCExecution.getRevision());
testCaseExecutionSysVerService.insertTestCaseExecutionSysVer(myExeSysVer);
} catch (CerberusException ex) {
LOG.error(logPrefix + ex.getMessage());
}
LOG.debug(logPrefix + "Main System Version Registered.");
/**
* For all Linked environment, we also keep track on the
* build/rev information inside testcaseexecutionsysver table.
*/
LOG.debug(logPrefix + "Registering Linked System Version.");
try {
List<CountryEnvLink> ceLink = null;
ceLink = countryEnvLinkService.convert(countryEnvLinkService.readByVarious(tCExecution.getApplicationObj().getSystem(), tCExecution.getCountry(), tCExecution.getEnvironment()));
for (CountryEnvLink myCeLink : ceLink) {
LOG.debug(logPrefix + "Linked environment found : " + myCeLink.getSystemLink() + myCeLink.getCountryLink() + myCeLink.getEnvironmentLink());
CountryEnvParam mycountEnvParam;
try {
mycountEnvParam = this.countryEnvParamService.convert(this.countryEnvParamService.readByKey(myCeLink.getSystemLink(), myCeLink.getCountryLink(), myCeLink.getEnvironmentLink()));
myExeSysVer = factoryTestCaseExecutionSysVer.create(runID, myCeLink.getSystemLink(), mycountEnvParam.getBuild(), mycountEnvParam.getRevision());
testCaseExecutionSysVerService.insertTestCaseExecutionSysVer(myExeSysVer);
} catch (CerberusException ex) {
// Referencial Integrity link between countryEnvLink and CountryEnvParam table should secure that exception to never happen.
LOG.error(logPrefix + ex.getMessage());
throw new CerberusException(ex.getMessageError());
}
}
} catch (CerberusException ex) {
LOG.debug(logPrefix + "No Linked environment found.");
}
LOG.debug(logPrefix + "Linked System Version Registered.");
}
/**
* Get used SeleniumCapabilities (empty if application is not GUI)
*/
LOG.debug(logPrefix + "Getting Selenium capabitities for GUI applications.");
if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {
try {
Capabilities caps = this.seleniumServerService.getUsedCapabilities(tCExecution.getSession());
tCExecution.setBrowserFullVersion(caps.getBrowserName() + " " + caps.getVersion() + " " + caps.getPlatform().toString());
tCExecution.setVersion(caps.getVersion());
tCExecution.setPlatform(caps.getPlatform().toString());
} catch (Exception ex) {
LOG.error(logPrefix + "Exception on selenium getting Used Capabilities :" + ex.toString());
}
LOG.debug(logPrefix + "Selenium capabitities loaded.");
} else {
// If Selenium is not needed, the selenium and browser info is set to empty.
tCExecution.setSeleniumIP("");
tCExecution.setSeleniumPort("");
tCExecution.setBrowser("");
tCExecution.setVersion("");
tCExecution.setPlatform("");
tCExecution.setRobotDecli("");
LOG.debug(logPrefix + "No Selenium capabitities loaded because application not GUI : " + tCExecution.getApplicationObj().getType());
}
tCExecution.setRobotDecli(tCExecution.getRobotDecli().replace("%BROWSER%", tCExecution.getBrowser()));
tCExecution.setRobotDecli(tCExecution.getRobotDecli().replace("%BROWSERVERSION%", tCExecution.getVersion()));
tCExecution.setRobotDecli(tCExecution.getRobotDecli().replace("%PLATFORM%", tCExecution.getPlatform()));
/**
* Load PreTestCase information and set PreTCase to the
* TestCaseExecution object
*/
tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_LOADINGDETAILEDDATA));
LOG.debug(logPrefix + "Loading Pre-testcases.");
List<TestCase> preTests = testCaseService.findTestCaseActiveByCriteria("Pre Testing", tCExecution.getTestCaseObj().getApplication(), tCExecution.getCountry());
tCExecution.setPreTestCaseList(preTests);
if (!(preTests == null)) {
LOG.debug(logPrefix + "Loaded PreTest List. " + tCExecution.getPreTestCaseList().size() + " found.");
}
LOG.debug(logPrefix + "Pre-testcases Loaded.");
/**
* Load Main TestCase with Step dependencies (Actions/Control)
*/
LOG.debug(logPrefix + "Loading all Steps information of Main testcase.");
List<TestCaseStep> testCaseStepList;
testCaseStepList = this.loadTestCaseService.loadTestCaseStep(tCExecution.getTestCaseObj());
tCExecution.getTestCaseObj().setTestCaseStep(testCaseStepList);
LOG.debug(logPrefix + "Steps information of Main testcase Loaded : " + tCExecution.getTestCaseObj().getTestCaseStep().size() + " Step(s) found.");
/**
* Load Pre TestCase with Step dependencies (Actions/Control)
*/
LOG.debug(logPrefix + "Loading all Steps information (Actions & Controls) of all Pre-testcase.");
List<TestCaseStep> preTestCaseStepList = new ArrayList<TestCaseStep>();
List<TestCase> preTestCase = new ArrayList<TestCase>();
for (TestCase myTCase : tCExecution.getPreTestCaseList()) {
myTCase.setTestCaseStep(this.loadTestCaseService.loadTestCaseStep(myTCase));
preTestCaseStepList.addAll(myTCase.getTestCaseStep());
preTestCase.add(myTCase);
LOG.debug(logPrefix + "Pre testcase : " + myTCase.getTest() + "-" + myTCase.getTestCase() + " Loaded With " + myTCase.getTestCaseStep().size() + " Step(s) found.");
}
tCExecution.setPreTestCaseList(preTestCase);
LOG.debug(logPrefix + "All Steps information (Actions & Controls) of all Pre-testcase Loaded.");
/**
* Load All properties of the testcase
*/
LOG.debug(logPrefix + "Loading all Properties.");
List<TestCaseCountryProperties> tcProperties = new ArrayList();
try {
tcProperties = testCaseCountryPropertiesService.findAllWithDependencies(tCExecution.getTest(), tCExecution.getTestCase(), tCExecution.getCountry());
tCExecution.setTestCaseCountryPropertyList(tcProperties);
} catch (CerberusException ex) {
LOG.warn("Exception getting all the properties : " + ex);
}
if (LOG.isDebugEnabled()) {
LOG.debug(logPrefix + "All Properties Loaded. " + tcProperties.size() + " property(ies) found : " + tcProperties);
}
/**
* Start Execution of the steps/Actions/controls Iterate Steps.
* mainExecutionTestCaseStepList will contain the list of steps to
* execute for both pretest and test. This is where we schedule the
* execution of the steps using mainExecutionTestCaseStepList
* object.
*/
LOG.debug(logPrefix + "Starting the execution with step iteration.");
List<TestCaseStep> mainExecutionTestCaseStepList;
mainExecutionTestCaseStepList = new ArrayList<TestCaseStep>();
mainExecutionTestCaseStepList.addAll(preTestCaseStepList);
mainExecutionTestCaseStepList.addAll(testCaseStepList);
/**
* Initialize the global TestCaseExecution Data List.
*/
//
tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_TESTEXECUTING));
try {
testCaseExecutionService.updateTCExecution(tCExecution);
} catch (CerberusException ex) {
LOG.warn(ex);
}
// Websocket --> we refresh the corresponding Detail Execution pages attached to this execution.
if (tCExecution.isCerberus_featureflipping_activatewebsocketpush()) {
TestCaseExecutionEndPoint.getInstance().send(tCExecution, true);
}
// Evaluate the condition at the step level.
AnswerItem<Boolean> conditionAnswerTc;
AnswerItem<String> answerDecode = new AnswerItem();
boolean conditionDecodeError = false;
/**
* If execution is not manual, evaluate the condition at the step
* level
*/
if (!tCExecution.getManualExecution().equals("Y")) {
try {
answerDecode = variableService.decodeStringCompletly(tCExecution.getConditionVal1(), tCExecution, null, false);
tCExecution.setConditionVal1((String) answerDecode.getItem());
if (!(answerDecode.isCodeStringEquals("OK"))) {
// If anything wrong with the decode --> we stop here with decode message in the action result.
tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_CONDITIONDECODE).resolveDescription("MES", answerDecode.getMessageDescription()).resolveDescription("FIELD", "TestCase Condition Value1"));
tCExecution.setEnd(new Date().getTime());
LOG.debug("TestCase interupted due to decode 'TestCase Condition Value1' Error.");
conditionDecodeError = true;
}
} catch (CerberusEventException cex) {
LOG.warn(cex);
}
try {
answerDecode = variableService.decodeStringCompletly(tCExecution.getConditionVal2(), tCExecution, null, false);
tCExecution.setConditionVal2((String) answerDecode.getItem());
if (!(answerDecode.isCodeStringEquals("OK"))) {
// If anything wrong with the decode --> we stop here with decode message in the action result.
tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_CONDITIONDECODE).resolveDescription("MES", answerDecode.getMessageDescription()).resolveDescription("FIELD", "TestCase Condition Value2"));
tCExecution.setEnd(new Date().getTime());
LOG.debug("TestCase interupted due to decode 'TestCase Condition Value2' Error.");
conditionDecodeError = true;
}
} catch (CerberusEventException cex) {
LOG.warn(cex);
}
}
if (!conditionDecodeError) {
conditionAnswerTc = this.conditionService.evaluateCondition(tCExecution.getConditionOper(), tCExecution.getConditionVal1(), tCExecution.getConditionVal2(), tCExecution);
boolean execute_TestCase = (boolean) conditionAnswerTc.getItem();
if (execute_TestCase || tCExecution.getManualExecution().equals("Y")) {
for (TestCaseStep testCaseStep : mainExecutionTestCaseStepList) {
// init the index of the step in case we loop.
int step_index = 1;
boolean execute_Next_Step = false;
TestCaseStepExecution testCaseStepExecution;
int maxloop = parameterService.getParameterIntegerByKey("cerberus_loopstep_max", tCExecution.getApplicationObj().getSystem(), 20);
do {
/**
* Start Execution of TestCaseStep
*/
LOG.debug("Start execution of testcasestep");
long startStep = new Date().getTime();
/**
* Create and Register TestCaseStepExecution
*/
MessageEvent stepMess = new MessageEvent(MessageEventEnum.STEP_PENDING).resolveDescription("STEP", String.valueOf(testCaseStep.getSort())).resolveDescription("STEPINDEX", String.valueOf(step_index));
testCaseStepExecution = factoryTestCaseStepExecution.create(runID, testCaseStep.getTest(), testCaseStep.getTestCase(), testCaseStep.getStep(), step_index, testCaseStep.getSort(), testCaseStep.getLoop(), testCaseStep.getConditionOper(), testCaseStep.getConditionVal1(), testCaseStep.getConditionVal2(), testCaseStep.getConditionVal1(), testCaseStep.getConditionVal2(), null, startStep, 0, startStep, 0, new BigDecimal("0"), null, stepMess, testCaseStep, tCExecution, testCaseStep.getUseStep(), testCaseStep.getUseStepTest(), testCaseStep.getUseStepTestCase(), testCaseStep.getUseStepStep(), testCaseStep.getDescription());
testCaseStepExecution.setLoop(testCaseStep.getLoop());
testCaseStepExecutionService.insertTestCaseStepExecution(testCaseStepExecution);
testCaseStepExecution.setExecutionResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_TESTSTARTED));
/**
* We populate the TestCaseStep inside the execution
* List
*/
tCExecution.addTestCaseStepExecutionList(testCaseStepExecution);
// determine if step is executed (execute_Step) and if we trigger a new step execution after (execute_Next_Step)
boolean execute_Step = true;
boolean conditionStepDecodeError = false;
boolean conditionStepError = false;
AnswerItem<Boolean> conditionAnswer = new AnswerItem<>(new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_UNKNOWNCONDITION));
if (testCaseStepExecution.getLoop().equals(TestCaseStep.LOOP_ONCEIFCONDITIONFALSE) || testCaseStepExecution.getLoop().equals(TestCaseStep.LOOP_ONCEIFCONDITIONTRUE) || testCaseStepExecution.getLoop().equals(TestCaseStep.LOOP_WHILECONDITIONFALSEDO) || testCaseStepExecution.getLoop().equals(TestCaseStep.LOOP_WHILECONDITIONTRUEDO) || testCaseStepExecution.getLoop().equals("") || step_index > 1) {
// Decode Conditionvalue1 and Conditionvalue2 and Evaluate the condition at the Step level.
try {
answerDecode = variableService.decodeStringCompletly(testCaseStepExecution.getConditionVal1(), tCExecution, null, false);
testCaseStepExecution.setConditionVal1((String) answerDecode.getItem());
if (!(answerDecode.isCodeStringEquals("OK"))) {
testCaseStepExecution.setExecutionResultMessage(new MessageGeneral(answerDecode.getResultMessage().getMessage()));
testCaseStepExecution.setStepResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "Step Condition Value1"));
testCaseStepExecution.setReturnMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "Step Condition Value1").getDescription());
testCaseStepExecution.setReturnCode(answerDecode.getResultMessage().getCodeString());
testCaseStepExecution.setStopExecution(answerDecode.getResultMessage().isStopTest());
testCaseStepExecution.setEnd(new Date().getTime());
LOG.debug("Step interupted due to decode 'Step Condition Value1' Error.");
conditionStepDecodeError = true;
}
} catch (CerberusEventException cex) {
LOG.warn(cex);
}
if (!conditionStepDecodeError) {
try {
answerDecode = variableService.decodeStringCompletly(testCaseStepExecution.getConditionVal2(), tCExecution, null, false);
testCaseStepExecution.setConditionVal2((String) answerDecode.getItem());
if (!(answerDecode.isCodeStringEquals("OK"))) {
testCaseStepExecution.setExecutionResultMessage(new MessageGeneral(answerDecode.getResultMessage().getMessage()));
testCaseStepExecution.setStepResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "Step Condition Value2"));
testCaseStepExecution.setReturnMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "Step Condition Value2").getDescription());
testCaseStepExecution.setReturnCode(answerDecode.getResultMessage().getCodeString());
testCaseStepExecution.setStopExecution(answerDecode.getResultMessage().isStopTest());
testCaseStepExecution.setEnd(new Date().getTime());
LOG.debug("Step interupted due to decode 'Step Condition Value2' Error.");
conditionStepDecodeError = true;
}
} catch (CerberusEventException cex) {
LOG.warn(cex);
}
}
if (!(conditionStepDecodeError)) {
conditionAnswer = this.conditionService.evaluateCondition(testCaseStepExecution.getConditionOper(), testCaseStepExecution.getConditionVal1(), testCaseStepExecution.getConditionVal2(), tCExecution);
execute_Step = (boolean) conditionAnswer.getItem();
if (conditionAnswer.getResultMessage().getMessage().getCodeString().equals("PE")) {
// There were no error when performing the condition evaluation.
switch(testCaseStepExecution.getLoop()) {
case TestCaseStep.LOOP_ONCEIFCONDITIONFALSE:
execute_Step = !execute_Step;
execute_Next_Step = false;
break;
case TestCaseStep.LOOP_ONCEIFCONDITIONTRUE:
case "":
execute_Next_Step = false;
break;
case TestCaseStep.LOOP_WHILECONDITIONFALSEDO:
case TestCaseStep.LOOP_DOWHILECONDITIONFALSE:
execute_Step = !execute_Step;
execute_Next_Step = execute_Step;
break;
case TestCaseStep.LOOP_WHILECONDITIONTRUEDO:
case TestCaseStep.LOOP_DOWHILECONDITIONTRUE:
execute_Next_Step = execute_Step;
break;
default:
execute_Next_Step = false;
}
} else {
// Error when performing the condition evaluation. We force no execution (false)
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_CONDITION);
mes.setDescription(mes.getDescription().replace("%AREA%", "step ").replace("%COND%", testCaseStepExecution.getConditionOper()).replace("%MES%", conditionAnswer.getResultMessage().getDescription()));
tCExecution.setResultMessage(mes);
testCaseStepExecution.setExecutionResultMessage(mes);
testCaseStepExecution.setStepResultMessage(new MessageEvent(MessageEventEnum.CONDITION_TESTCASESTEP_FAILED).resolveDescription("AREA", "").resolveDescription("COND", testCaseStepExecution.getConditionOper()).resolveDescription("MESSAGE", conditionAnswer.getResultMessage().getDescription()));
testCaseStepExecution.setEnd(new Date().getTime());
LOG.debug("Step interupted due to condition error.");
conditionStepError = true;
execute_Next_Step = false;
execute_Step = false;
}
} else {
// If anything wrong with the decode --> we stop here with decode message in the action result.
tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_CONDITIONDECODE).resolveDescription("AREA", "Step ").resolveDescription("MES", answerDecode.getMessageDescription()));
tCExecution.setEnd(new Date().getTime());
LOG.debug("TestCase interupted due to decode Condition Error.");
// There was an error on decode so we stop everything.
execute_Next_Step = false;
execute_Step = false;
}
} else if (testCaseStepExecution.getLoop().equals(TestCaseStep.LOOP_DOWHILECONDITIONFALSE) || testCaseStepExecution.getLoop().equals(TestCaseStep.LOOP_DOWHILECONDITIONTRUE)) {
// First Step execution for LOOP_DOWHILECONDITIONTRUE and LOOP_DOWHILECONDITIONFALSE --> We force the step execution and activate the next step execution.
execute_Step = true;
execute_Next_Step = true;
} else {
// First Step execution for Unknown Loop --> We force the step execution only once (default behaviour).
execute_Step = true;
execute_Next_Step = false;
conditionAnswer.setResultMessage(new MessageEvent(MessageEventEnum.CONDITIONEVAL_FAILED_UNKNOWNCONDITION));
}
/**
* Execute Step
*/
LOG.debug(logPrefix + "Executing step : " + testCaseStepExecution.getTest() + " - " + testCaseStepExecution.getTestCase() + " - Step " + testCaseStepExecution.getStep() + " - Index " + testCaseStepExecution.getStep());
if (execute_Step) {
/**
* We execute the step
*/
testCaseStepExecution = this.executeStep(testCaseStepExecution, tCExecution);
/**
* Updating Execution Result Message only if
* execution result message of the step is not
* PE or OK.
*/
if ((!(testCaseStepExecution.getExecutionResultMessage().equals(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_TESTSTARTED)))) && (!(testCaseStepExecution.getExecutionResultMessage().equals(new MessageGeneral(MessageGeneralEnum.EXECUTION_OK))))) {
tCExecution.setResultMessage(testCaseStepExecution.getExecutionResultMessage());
}
if (testCaseStepExecution.getStepResultMessage().equals(new MessageEvent(MessageEventEnum.STEP_PENDING))) {
testCaseStepExecution.setStepResultMessage(new MessageEvent(MessageEventEnum.STEP_SUCCESS));
}
testCaseStepExecutionService.updateTestCaseStepExecution(testCaseStepExecution);
if (testCaseStepExecution.isStopExecution()) {
break;
}
} else // We don't execute the step and record a generic execution.
if ((!conditionStepDecodeError) && (!conditionStepError)) {
/**
* Register Step in database
*/
LOG.debug("Registering Step : " + testCaseStepExecution.getStep());
// We change the Step message only if the Step is not executed due to condition.
MessageEvent stepMes = new MessageEvent(MessageEventEnum.CONDITION_TESTCASESTEP_NOTEXECUTED);
testCaseStepExecution.setStepResultMessage(stepMes);
testCaseStepExecution.setReturnMessage(testCaseStepExecution.getReturnMessage().replace("%COND%", testCaseStepExecution.getConditionOper()).replace("%LOOP%", testCaseStepExecution.getLoop()).replace("%MESSAGE%", conditionAnswer.getResultMessage().getDescription()));
testCaseStepExecution.setEnd(new Date().getTime());
this.testCaseStepExecutionService.updateTestCaseStepExecution(testCaseStepExecution);
LOG.debug("Registered Step");
} else {
// Not executed because decode error or failed condition.
testCaseStepExecution.setEnd(new Date().getTime());
testCaseStepExecution.setStopExecution(true);
this.testCaseStepExecutionService.updateTestCaseStepExecution(testCaseStepExecution);
LOG.debug("Registered Step");
}
/**
* Log TestCaseStepExecution
*/
if (tCExecution.getVerbose() > 0) {
LOG.info(testCaseStepExecution.toJson(false, true));
}
// Websocket --> we refresh the corresponding Detail Execution pages attached to this execution.
if (tCExecution.isCerberus_featureflipping_activatewebsocketpush()) {
TestCaseExecutionEndPoint.getInstance().send(tCExecution, false);
}
step_index++;
} while (execute_Next_Step && step_index <= maxloop);
if (testCaseStepExecution.isStopExecution()) {
break;
}
}
/**
* If at that time the execution is still PE, we move it to
* OK. It means that no issue were met.
*/
if ((tCExecution.getResultMessage() == null) || (tCExecution.getResultMessage().equals(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_TESTSTARTED)))) {
tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_OK));
}
/**
* We record Selenium log at the end of the execution.
*/
try {
tCExecution.addFileList(recorderService.recordSeleniumLog(tCExecution));
} catch (Exception ex) {
LOG.error(logPrefix + "Exception Getting Selenium Logs " + tCExecution.getId() + " Exception :" + ex.toString());
}
} else {
// We don't execute the testcase linked with condition.
MessageGeneral mes;
/**
* Update Execution status from condition
*/
if (conditionAnswerTc.getResultMessage().getMessage().getCodeString().equals("PE")) {
mes = new MessageGeneral(MessageGeneralEnum.EXECUTION_NA_CONDITION);
} else {
mes = new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_CONDITION);
}
mes.setDescription(mes.getDescription().replace("%COND%", tCExecution.getConditionOper()).replace("%MES%", conditionAnswerTc.getResultMessage().getDescription()));
tCExecution.setResultMessage(mes);
}
}
} catch (Exception ex) {
/**
* If an exception is found, set the execution to FA and print the
* exception
*/
tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_FA));
tCExecution.setControlMessage(tCExecution.getControlMessage() + " Exception: " + ex);
LOG.error(logPrefix + "Exception found Executing Test " + tCExecution.getId() + " Exception :" + ex.toString());
} finally {
/**
* We stop the server session here (selenium for ex.).
*/
try {
tCExecution = this.stopTestCase(tCExecution);
} catch (Exception ex) {
LOG.error(logPrefix + "Exception Stopping Test " + tCExecution.getId() + " Exception :" + ex.toString());
}
/**
* Log Execution
*/
LOG.info(tCExecution.toJson(false));
/**
* Clean memory
*/
try {
executionUUID.removeExecutionUUID(tCExecution.getExecutionUUID());
LOG.debug("Clean ExecutionUUID");
} catch (Exception ex) {
LOG.error("Exception cleaning Memory: " + ex.toString());
}
/**
* Log execution is finished
*/
LOG.info("Execution Finished : UUID=" + tCExecution.getExecutionUUID() + "__ID=" + tCExecution.getId() + "__RC=" + tCExecution.getControlStatus() + "__" + "TestName=" + tCExecution.getEnvironment() + "." + tCExecution.getCountry() + "." + tCExecution.getBuild() + "." + tCExecution.getRevision() + "." + tCExecution.getTest() + "_" + tCExecution.getTestCase() + "_" + tCExecution.getTestCaseObj().getDescription().replace(".", ""));
/**
* Updating queue to done status only for execution from queue
*/
if (tCExecution.getQueueID() != 0) {
executionQueueService.updateToDone(tCExecution.getQueueID(), "", runID);
}
/**
* Retry management, in case the result is not (OK or NE), we
* execute the job again reducing the retry to 1.
*/
if (tCExecution.getNumberOfRetries() > 0 && !tCExecution.getResultMessage().getCodeString().equals("OK") && !tCExecution.getResultMessage().getCodeString().equals("NE")) {
TestCaseExecutionQueue newExeQueue = new TestCaseExecutionQueue();
if (tCExecution.getQueueID() > 0) {
// If QueueId exist, we try to get the original execution queue.
try {
newExeQueue = executionQueueService.convert(executionQueueService.readByKey(tCExecution.getQueueID()));
} catch (Exception e) {
// Unfortunatly the execution no longuer exist so we pick initial value.
newExeQueue = tCExecution.getTestCaseExecutionQueue();
}
} else {
// Initial Execution does not come from the queue so we pick the value created at the beginning of the execution.
newExeQueue = tCExecution.getTestCaseExecutionQueue();
}
// Forcing init value for that new queue execution : exeid=0, no debugflag and State = QUEUED
int newRetry = tCExecution.getNumberOfRetries() - 1;
newExeQueue.setId(0);
newExeQueue.setDebugFlag("N");
if (newRetry <= 0) {
newExeQueue.setComment("Added from Retry. Last attempt to go.");
} else {
newExeQueue.setComment("Added from Retry. Still " + newRetry + " attempt(s) to go.");
}
newExeQueue.setState(TestCaseExecutionQueue.State.QUEUED);
newExeQueue.setRetries(newRetry);
// Insert execution to the Queue.
executionQueueService.create(newExeQueue);
}
/**
* After every execution finished, <br>
* if the execution has a tag that has a campaign associated <br>
* and no more executions are in the queue, <br>
* we trigger : <br>
* 1/ The update of the EndExeQueue of the tag <br>
* 2/ We notify the Distribution List with execution report status
*/
try {
if (!StringUtil.isNullOrEmpty(tCExecution.getTag())) {
Tag currentTag = tagService.convert(tagService.readByKey(tCExecution.getTag()));
if ((currentTag != null)) {
if (currentTag.getDateEndQueue().before(Timestamp.valueOf("1980-01-01 01:01:01.000000001"))) {
AnswerList answerListQueue = new AnswerList();
answerListQueue = executionQueueService.readQueueOpen(tCExecution.getTag());
if (answerListQueue.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && (answerListQueue.getDataList().isEmpty())) {
LOG.debug("No More executions in (queue) on tag : " + tCExecution.getTag() + " - " + answerListQueue.getDataList().size() + " " + answerListQueue.getMessageCodeString() + " - ");
tagService.updateDateEndQueue(tCExecution.getTag(), new Timestamp(new Date().getTime()));
if (!StringUtil.isNullOrEmpty(currentTag.getCampaign())) {
// We get the campaig here and potencially send the notification.
emailService.generateAndSendNotifyEndTagExecution(tCExecution.getTag(), currentTag.getCampaign());
}
} else {
LOG.debug("Still executions in queue on tag : " + tCExecution.getTag() + " - " + answerListQueue.getDataList().size() + " " + answerListQueue.getMessageCodeString());
}
} else {
LOG.debug("Tag is already flaged with recent timstamp. " + currentTag.getDateEndQueue());
}
}
}
} catch (Exception e) {
LOG.error(e);
}
//
// After every execution finished we try to trigger more from the queue;-).
executionThreadPoolService.executeNextInQueueAsynchroneously(false);
}
return tCExecution;
}
use of org.cerberus.crud.entity.CountryEnvParam in project cerberus-source by cerberustesting.
the class ExecutionStartService method startExecution.
@Override
public TestCaseExecution startExecution(TestCaseExecution tCExecution) throws CerberusException {
/**
* Start timestamp.
*/
long executionStart = new Date().getTime();
LOG.debug("Initializing Start Timestamp : " + executionStart);
tCExecution.setStart(executionStart);
/**
* Checking the parameters.
*/
LOG.debug("Checking the parameters.");
Invariant myInvariant;
try {
myInvariant = invariantService.convert(invariantService.readByKey("OUTPUTFORMAT", tCExecution.getOutputFormat()));
} catch (CerberusException ex) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_OUTPUTFORMAT_INVALID);
mes.setDescription(mes.getDescription().replace("%PARAM%", tCExecution.getOutputFormat()));
LOG.debug(mes.getDescription());
throw new CerberusException(mes);
}
try {
myInvariant = invariantService.convert(invariantService.readByKey("VERBOSE", String.valueOf(tCExecution.getVerbose())));
} catch (CerberusException ex) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_VERBOSE_INVALID);
mes.setDescription(mes.getDescription().replace("%PARAM%", String.valueOf(tCExecution.getVerbose())));
LOG.debug(mes.getDescription());
throw new CerberusException(mes);
}
try {
myInvariant = invariantService.convert(invariantService.readByKey("SCREENSHOT", String.valueOf(tCExecution.getScreenshot())));
} catch (CerberusException ex) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_SCREENSHOT_INVALID);
mes.setDescription(mes.getDescription().replace("%PARAM%", String.valueOf(tCExecution.getScreenshot())));
LOG.debug(mes.getDescription());
throw new CerberusException(mes);
}
LOG.debug("Parameters checked.");
/**
* Load TestCase information and set TCase to the TestCaseExecution
* object.
*/
tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_LOADINGDATA));
LOG.debug("Loading Test Case Information. " + tCExecution.getTest() + "-" + tCExecution.getTestCase());
// Integrate this.loadTestCaseService.loadTestCase(tCExecution); inside with Dependency.
try {
// TestCase tCase = testCaseService.findTestCaseByKey(tCExecution.getTest(), tCExecution.getTestCase());
TestCase tCase = testCaseService.convert(testCaseService.readByKey(tCExecution.getTest(), tCExecution.getTestCase()));
if (tCase != null) {
tCExecution.setTestCaseObj(tCase);
tCExecution.setDescription(tCase.getDescription());
tCExecution.setConditionOper(tCase.getConditionOper());
tCExecution.setConditionVal1(tCase.getConditionVal1());
tCExecution.setConditionVal1Init(tCase.getConditionVal1());
tCExecution.setConditionVal2(tCase.getConditionVal2());
tCExecution.setConditionVal2Init(tCase.getConditionVal2());
tCExecution.setTestCaseVersion(tCase.getTestCaseVersion());
} else {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.NO_DATA_FOUND));
}
/**
* Copy the status of the testcase to the status column of the
* Execution. This is done to know how stable was the testcase at
* the time of the execution.
*/
tCExecution.setStatus(tCase.getStatus());
} catch (CerberusException ex) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TESTCASE_NOT_FOUND);
mes.setDescription(mes.getDescription().replace("%TEST%", tCExecution.getTest()));
mes.setDescription(mes.getDescription().replace("%TESTCASE%", tCExecution.getTestCase()));
LOG.debug(mes.getDescription());
throw new CerberusException(mes);
}
LOG.debug("Test Case Information Loaded - " + tCExecution.getTest() + "-" + tCExecution.getTestCase());
/**
* Load Test information and Set TestObject to the TestCaseExecution
* object.
*/
LOG.debug("Loading Test Information");
try {
tCExecution.setTestObj(this.testService.convert(this.testService.readByKey(tCExecution.getTest())));
} catch (CerberusException ex) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TEST_NOT_FOUND);
mes.setDescription(mes.getDescription().replace("%TEST%", tCExecution.getTest()));
LOG.debug(mes.getDescription());
throw new CerberusException(mes);
}
LOG.debug("Test Information Loaded - " + tCExecution.getTest());
/**
* Load Application information and Set Application to the
* TestCaseExecution object.
*/
LOG.debug("Loading Application Information");
try {
tCExecution.setApplication(tCExecution.getTestCaseObj().getApplication());
tCExecution.setApplicationObj(applicationService.convert(this.applicationService.readByKey(tCExecution.getTestCaseObj().getApplication())));
} catch (CerberusException ex) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_APPLICATION_NOT_FOUND);
mes.setDescription(mes.getDescription().replace("%APPLI%", tCExecution.getTestCaseObj().getApplication()));
LOG.debug(mes.getDescription());
throw new CerberusException(mes);
}
LOG.debug("Application Information Loaded - " + tCExecution.getApplicationObj().getApplication() + " - " + tCExecution.getApplicationObj().getDescription());
/**
* Init System from Application.
*/
tCExecution.setSystem(tCExecution.getApplicationObj().getSystem());
/**
* Load Country information and Set it to the TestCaseExecution object.
*/
LOG.debug("Loading Country Information");
try {
tCExecution.setCountryObj(invariantService.convert(invariantService.readByKey("COUNTRY", tCExecution.getCountry())));
} catch (CerberusException ex) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_COUNTRY_NOT_FOUND);
mes.setDescription(mes.getDescription().replace("%COUNTRY%", tCExecution.getCountry()));
LOG.debug(mes.getDescription());
throw new CerberusException(mes);
}
LOG.debug("Country Information Loaded - " + tCExecution.getCountryObj().getValue() + " - " + tCExecution.getCountryObj().getDescription());
/**
* Checking if execution is manual or automaticaly configured. If
* Manual, CountryEnvironmentParameters object is manually created with
* the servlet parameters. If automatic, parameters are build from the
* CountryEnvironmentParameters. table in the database. Environmentdata
* will always be filled with the environment. Environment will be
* forced to MANUAL if execution is manual.
*/
LOG.debug("Checking if connectivity parameters are manual or automatic from the database. '" + tCExecution.isManualURL() + "'");
if (tCExecution.isManualURL()) {
LOG.debug("Execution will be done with manual application connectivity setting.");
if (StringUtil.isNullOrEmpty(tCExecution.getMyHost())) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_MANUALURL_INVALID);
LOG.debug(mes.getDescription());
throw new CerberusException(mes);
} else {
CountryEnvironmentParameters cea;
cea = this.factorycountryEnvironmentParameters.create(tCExecution.getApplicationObj().getSystem(), tCExecution.getCountry(), tCExecution.getEnvironment(), tCExecution.getApplicationObj().getApplication(), tCExecution.getMyHost(), "", tCExecution.getMyContextRoot(), tCExecution.getMyLoginRelativeURL(), "", "", "", "", CountryEnvironmentParameters.DEFAULT_POOLSIZE);
cea.setIp(tCExecution.getMyHost());
cea.setUrl(tCExecution.getMyContextRoot());
tCExecution.setUrl(StringUtil.getURLFromString(cea.getIp(), cea.getUrl(), "", ""));
cea.setUrlLogin(tCExecution.getMyLoginRelativeURL());
tCExecution.setCountryEnvironmentParameters(cea);
LOG.debug(" -> Execution will be done with manual application connectivity setting. IP/URL/LOGIN : " + cea.getIp() + "-" + cea.getUrl() + "-" + cea.getUrlLogin());
}
/**
* If execution is manual, we force the env at 'MANUAL-ENVDATA'
* string. We keep envData information in order to trace the env
* data that has been used.
*/
tCExecution.setEnvironment("MANUAL-" + tCExecution.getEnvironmentData());
} else {
/**
* Automatic application configuration execution.
*/
LOG.debug("Execution will be done with automatic application connectivity setting.");
/**
* Load Country/Environment/Application information and set them to
* the TestCaseExecution object
*/
LOG.debug("Loading Country/Environment/Application Information. " + tCExecution.getCountry() + "-" + tCExecution.getEnvironment() + "-" + tCExecution.getApplicationObj().getApplication());
CountryEnvironmentParameters cea;
try {
cea = this.countryEnvironmentParametersService.convert(this.countryEnvironmentParametersService.readByKey(tCExecution.getApplicationObj().getSystem(), tCExecution.getCountry(), tCExecution.getEnvironment(), tCExecution.getApplicationObj().getApplication()));
if (cea != null) {
tCExecution.setCountryEnvironmentParameters(cea);
// tCExecution.setUrl(cea.getIp()+ cea.getUrl());
tCExecution.setUrl(StringUtil.getURLFromString(cea.getIp(), cea.getUrl(), "", ""));
} else {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_COUNTRYENVAPP_NOT_FOUND);
mes.setDescription(mes.getDescription().replace("%COUNTRY%", tCExecution.getCountry()));
mes.setDescription(mes.getDescription().replace("%ENV%", tCExecution.getEnvironment()));
mes.setDescription(mes.getDescription().replace("%APPLI%", tCExecution.getTestCaseObj().getApplication()));
LOG.error(mes.getDescription());
throw new CerberusException(mes);
}
/**
* Forcing the IP URL and Login config from DevIP, DevURL and
* DevLogin parameter only if DevURL is defined.
*/
} catch (CerberusException ex) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_COUNTRYENVAPP_NOT_FOUND);
mes.setDescription(mes.getDescription().replace("%COUNTRY%", tCExecution.getCountry()));
mes.setDescription(mes.getDescription().replace("%ENV%", tCExecution.getEnvironment()));
mes.setDescription(mes.getDescription().replace("%APPLI%", tCExecution.getTestCaseObj().getApplication()));
LOG.error(mes.getDescription());
throw new CerberusException(mes);
}
LOG.debug("Country/Environment/Application Information Loaded. " + tCExecution.getCountry() + " - " + tCExecution.getEnvironment() + " - " + tCExecution.getApplicationObj().getApplication());
LOG.debug(" -> Execution will be done with automatic application connectivity setting. IP/URL/LOGIN : " + cea.getIp() + "-" + cea.getUrl() + "-" + cea.getUrlLogin());
tCExecution.setEnvironmentData(tCExecution.getEnvironment());
}
/**
* Load Environment object from invariant table.
*/
LOG.debug("Loading Environment Information. " + tCExecution.getEnvironmentData());
try {
tCExecution.setEnvironmentDataObj(invariantService.convert(invariantService.readByKey("ENVIRONMENT", tCExecution.getEnvironmentData())));
} catch (CerberusException ex) {
if (tCExecution.isManualURL()) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_ENVIRONMENT_DOESNOTEXIST_MAN);
mes.setDescription(mes.getDescription().replace("%ENV%", tCExecution.getEnvironmentData()));
LOG.debug(mes.getDescription());
throw new CerberusException(mes);
} else {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_ENVIRONMENT_DOESNOTEXIST);
mes.setDescription(mes.getDescription().replace("%ENV%", tCExecution.getEnvironmentData()));
LOG.debug(mes.getDescription());
throw new CerberusException(mes);
}
}
LOG.debug("Environment Information Loaded");
/**
* Load Country/Environment information and set them to the
* TestCaseExecution object. Environment considered here is the data
* environment.
*/
LOG.debug("Loading Country/Environment Information. " + tCExecution.getCountry() + " - " + tCExecution.getEnvironmentData());
CountryEnvParam countEnvParam;
try {
countEnvParam = this.countryEnvParamService.convert(this.countryEnvParamService.readByKey(tCExecution.getApplicationObj().getSystem(), tCExecution.getCountry(), tCExecution.getEnvironmentData()));
tCExecution.setCountryEnvParam(countEnvParam);
/**
* Copy the Build/Revision of the environment to the Execution. This
* is done to keep track of all execution done on a specific version
* of system
*/
tCExecution.setBuild(countEnvParam.getBuild());
tCExecution.setRevision(countEnvParam.getRevision());
} catch (CerberusException ex) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_COUNTRYENV_NOT_FOUND);
mes.setDescription(mes.getDescription().replace("%SYSTEM%", tCExecution.getApplicationObj().getSystem()));
mes.setDescription(mes.getDescription().replace("%COUNTRY%", tCExecution.getCountry()));
mes.setDescription(mes.getDescription().replace("%ENV%", tCExecution.getEnvironmentData()));
LOG.debug(mes.getDescription());
throw new CerberusException(mes);
}
LOG.debug("Country/Environment Information Loaded. " + tCExecution.getCountry() + " - " + tCExecution.getEnvironmentData());
/**
* If Timeout is defined at the execution level, set action wait default
* to this value, else Get the cerberus_action_wait_default parameter.
* This parameter will be used by tha wait action if no timeout/event is
* defined.
*/
try {
if (!tCExecution.getTimeout().isEmpty()) {
tCExecution.setCerberus_action_wait_default(Integer.valueOf(tCExecution.getTimeout()));
} else {
tCExecution.setCerberus_action_wait_default(parameterService.getParameterIntegerByKey("cerberus_action_wait_default", tCExecution.getApplicationObj().getSystem(), 90000));
}
} catch (NumberFormatException ex) {
LOG.warn("Parameter cerberus_action_wait_default must be an integer, default value set to 90000 milliseconds. " + ex.toString());
tCExecution.setCerberus_action_wait_default(90000);
}
/**
* Check if test can be executed TODO : Replace Message with try/catch
* cerberus exception
*/
tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_VALIDATIONSTARTING));
LOG.debug("Performing the Checks before starting the execution");
MessageGeneral canExecuteTestCase = this.executionCheckService.checkTestCaseExecution(tCExecution);
tCExecution.setResultMessage(canExecuteTestCase);
/**
* We stop if the result is not OK
*/
if (!(tCExecution.getResultMessage().equals(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_CHECKINGPARAMETERS)))) {
return tCExecution;
}
LOG.debug("Checks performed -- > OK to continue.");
/**
* For GUI application, check if Browser is supported.
*/
if (!tCExecution.getManualExecution().equals("Y") && tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI)) {
try {
myInvariant = invariantService.convert(invariantService.readByKey("BROWSER", tCExecution.getBrowser()));
} catch (CerberusException ex) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_BROWSER_NOT_SUPPORTED);
mes.setDescription(mes.getDescription().replace("%BROWSER%", tCExecution.getBrowser()));
LOG.debug(mes.getDescription());
throw new CerberusException(mes);
}
}
/**
* Start server if execution is not manual
*/
if (!tCExecution.getManualExecution().equals("Y")) {
tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_STARTINGROBOTSERVER));
if (tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_GUI) || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_APK) || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_IPA) || tCExecution.getApplicationObj().getType().equalsIgnoreCase(Application.TYPE_FAT)) {
if (tCExecution.getIp().equalsIgnoreCase("")) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_SELENIUM_EMPTYORBADIP);
mes.setDescription(mes.getDescription().replace("%IP%", tCExecution.getIp()));
LOG.debug(mes.getDescription());
throw new CerberusException(mes);
}
/**
* Start Selenium server
*/
LOG.debug("Starting Server.");
tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_CREATINGRUNID));
try {
this.serverService.startServer(tCExecution);
} catch (CerberusException ex) {
LOG.debug(ex.getMessageError().getDescription());
throw new CerberusException(ex.getMessageError());
}
LOG.debug("Server Started.");
}
}
/**
* Register RunID inside database.
*/
tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_CREATINGRUNID));
LOG.debug("Registering Execution ID on database");
long runID = 0;
try {
runID = this.testCaseExecutionService.registerRunID(tCExecution);
if (runID != 0) {
tCExecution.setId(runID);
executionUUIDObject.setExecutionUUID(tCExecution.getExecutionUUID(), tCExecution);
// Update Queue Execution here if QueueID =! 0.
if (tCExecution.getQueueID() != 0) {
inQueueService.updateToExecuting(tCExecution.getQueueID(), "", runID);
}
} else {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_COULDNOTCREATE_RUNID);
tCExecution.setResultMessage(mes);
LOG.fatal("Could not create RunID, or cannot retreive the generated Key");
throw new CerberusException(mes);
}
} catch (CerberusException ex) {
tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_COULDNOTCREATE_RUNID));
LOG.warn(ex.getMessageError().getDescription());
throw new CerberusException(ex.getMessageError());
}
LOG.debug("Execution ID registered on database : " + tCExecution.getId());
/**
* Stop the browser if executionID is equal to zero (to prevent database
* instabilities)
*/
if (!tCExecution.getManualExecution().equals("Y")) {
try {
if (tCExecution.getId() == 0) {
LOG.debug("Starting to Stop the Selenium Server.");
this.serverService.stopServer(tCExecution.getSession());
LOG.debug("Selenium Server stopped.");
}
} catch (Exception ex) {
LOG.warn(ex.toString());
}
}
/**
* Feature Flipping. Should be removed when websocket push is fully
* working
*/
tCExecution.setCerberus_featureflipping_activatewebsocketpush(parameterService.getParameterBooleanByKey("cerberus_featureflipping_activatewebsocketpush", "", false));
tCExecution.setCerberus_featureflipping_websocketpushperiod(parameterService.getParameterLongByKey("cerberus_featureflipping_websocketpushperiod", "", 5000));
return tCExecution;
}
Aggregations