/** * Responsible for stopping multiple servers after test execution. * * <p>Add the @AfterSuite TestNG annotation in the method overriding this method * * @param serverList server list required to run test scenario * @throws Exception if an error occurs while in server stop process */ protected void stopMultipleServers(String serverList) throws Exception { EnvironmentBuilder environmentBuilder = new EnvironmentBuilder(); if (environmentBuilder.getFrameworkSettings().getEnvironmentSettings().isEnableDipFramework() && !environmentBuilder .getFrameworkSettings() .getEnvironmentSettings() .is_runningOnStratos()) { List<String> productList = Arrays.asList(serverList.split(",")); log.info("Stopping all server"); ServerGroupManager.shutdownServers(productList); } }
/** This method is invoked before the SuiteRunner starts. */ public synchronized void onStart(ISuite suite) { currentSuite = suite; PlatformUtil.setKeyStoreProperties(); int exeCount = RunnerSetter.getCount(); boolean isFirstExecution = RunnerSetter.getIsFirstRun(); RunnerSetter.setRunner(suite.getName(), exeCount + 1); environmentBuilder = new EnvironmentBuilder(); environmentBuilder = new EnvironmentBuilder(); boolean deploymentEnabled = environmentBuilder.getFrameworkSettings().getEnvironmentSettings().isEnableDipFramework(); boolean startosEnabled = environmentBuilder.getFrameworkSettings().getEnvironmentSettings().is_runningOnStratos(); boolean builderEnabled = environmentBuilder.getFrameworkSettings().getEnvironmentSettings().is_builderEnabled(); defaultProductList = environmentBuilder.getFrameworkSettings().getEnvironmentVariables().getProductList(); environmet = environmentBuilder.getFrameworkSettings().getEnvironmentSettings().executionEnvironment(); executionMode = environmentBuilder.getFrameworkSettings().getEnvironmentSettings().executionMode(); log.info( "**********Starting executing test Suite " + suite.getName() + " on " + executionMode.toString() + "***********"); try { /* If Execution mode is tenant executes main execution as tenant*/ if (executionMode.equals(ExecutionMode.tenant.name()) && !environmet.equalsIgnoreCase(ExecutionEnvironment.stratos.name())) { setEnvoronmentSettingsForTenant(true); } serverGroupManager = new ServerGroupManager(0); if (startosEnabled) { UserPopulator populator = new UserPopulator(); if (!environmet.equals(ExecutionEnvironment.stratos)) { if (executionMode.equals(ExecutionMode.tenant.name()) || executionMode.equals(ExecutionMode.all.name())) { populator.populateUsers(defaultProductList); } else { log.error( "\n......................................................" + "Invalid Environment Settings.......\n " + "Please Check The automation.properties file \n" + "......................................................"); } } else { populator.populateUsers(null); } } else if (deploymentEnabled) { if (suite.getParameter("server.list") != null) { List<String> productList = Arrays.asList(suite.getParameter("server.list").split(",")); log.info("Starting servers..."); serverGroupManager.startServers(productList); UserPopulator populator = new UserPopulator(); populator.populateUsers(defaultProductList); } else { log.info("Starting servers with default product list..."); serverGroupManager.startServers(defaultProductList); if (executionMode.equals(ExecutionMode.user.name()) || executionMode.equals(ExecutionMode.all.name())) { UserPopulator populator = new UserPopulator(); populator.populateUsers(defaultProductList); } } } else { UserPopulator populator = new UserPopulator(); if (populator.framework.getEnvironmentSettings().isUserManagementEnable()) { populator.populateUsers(defaultProductList); } } } catch (Exception e) { /*cannot throw the exception */ log.error(e); CustomTestNgReportSetter reportSetter = new CustomTestNgReportSetter(); reportSetter.createReport(suite, e); } }