@Test(timeOut = AbstractTestSupport.DEFAULT_TEST_TIMEOUT * 4, enabled = true) public void testXAP9xRecipe() throws Exception { InvocationResult result; InvokeServiceCommandResponse response; // Install and verify xap-management String installationLog = installApplicationAndWait( XAP9X_PATH, APP_NAME); // installAndVerify(XAP9X_MANAGEMENT_PATH,XAP9X_MANAGEMENT); verifyPUInstallation(APP_NAME); Pattern pattern = Pattern.compile( "/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}] - xap-management-1 START invoked"); // Regex for ip to match in the log of xap-management installation Matcher matcher = pattern.matcher(installationLog); if (!matcher.find()) { throw new Exception("Unable to find lookuplocator's ip in the log: " + installationLog); } String managementPrivateIP = matcher.group(0); String lookuplocators = managementPrivateIP.substring( managementPrivateIP.indexOf("/") + 1, managementPrivateIP.indexOf("]")) + ":4242"; log("Using lookuplocators: " + lookuplocators); // Install and verify sgvalidator installAndVerify(SG_VALIDATOR_PATH, SG_VALIDATOR); // First validate and undeploy myDataGrid that the container-service deploy validateInstance(lookuplocators, DEPLOYGRID_MYDATAGRID_COMMAND); // undeploy-grid response = customCommand(UNDEPLOYGRID_MYDATAGRID_COMMAND, XAP9X_MANAGEMENT, APP_NAME); result = getCustomCommandResult(response); Assert.assertEquals(result.getInvocationStatus(), CloudifyConstants.InvocationStatus.SUCCESS); // deploy-pu response = customCommand(DEPLOYPU_COMMAND, XAP9X_MANAGEMENT, APP_NAME); result = getCustomCommandResult(response); Assert.assertEquals(result.getInvocationStatus(), CloudifyConstants.InvocationStatus.SUCCESS); validateInstance(lookuplocators, DEPLOYPU_COMMAND); // undeploy-grid response = customCommand(UNDEPLOYGRID_DEPLOYPU_COMMAND, XAP9X_MANAGEMENT, APP_NAME); result = getCustomCommandResult(response); Assert.assertEquals(result.getInvocationStatus(), CloudifyConstants.InvocationStatus.SUCCESS); // deploy-pu-basic response = customCommand(DEPLOYPUBASIC_COMMAND, XAP9X_MANAGEMENT, APP_NAME); result = getCustomCommandResult(response); Assert.assertEquals(result.getInvocationStatus(), CloudifyConstants.InvocationStatus.SUCCESS); validateInstance(lookuplocators, DEPLOYPUBASIC_COMMAND); // undeploy-grid response = customCommand(UNDEPLOYGRID_DEPLOYPUBASIC_COMMAND, XAP9X_MANAGEMENT, APP_NAME); result = getCustomCommandResult(response); Assert.assertEquals(result.getInvocationStatus(), CloudifyConstants.InvocationStatus.SUCCESS); // deploy-grid response = customCommand(DEPLOYGRID_COMMAND, XAP9X_MANAGEMENT, APP_NAME); result = getCustomCommandResult(response); Assert.assertEquals(result.getInvocationStatus(), CloudifyConstants.InvocationStatus.SUCCESS); validateInstance(lookuplocators, DEPLOYGRID_COMMAND); // undeploy-grid response = customCommand(UNDEPLOYGRID_DEPLOYGRID_COMMAND, XAP9X_MANAGEMENT, APP_NAME); result = getCustomCommandResult(response); Assert.assertEquals(result.getInvocationStatus(), CloudifyConstants.InvocationStatus.SUCCESS); // deploy-grid response = customCommand(DEPLOYGRIDBASIC_COMMAND, XAP9X_MANAGEMENT, APP_NAME); result = getCustomCommandResult(response); Assert.assertEquals(result.getInvocationStatus(), CloudifyConstants.InvocationStatus.SUCCESS); validateInstance(lookuplocators, DEPLOYGRIDBASIC_COMMAND); // undeploy-grid response = customCommand(UNDEPLOYGRID_DEPLOYGRIDBASIC_COMMAND, XAP9X_MANAGEMENT, APP_NAME); result = getCustomCommandResult(response); Assert.assertEquals(result.getInvocationStatus(), CloudifyConstants.InvocationStatus.SUCCESS); String uninstallOutput = uninstallAndVerify(); }
private void validateInstance(String lookuplocators, String deploypuCommand) throws Exception { String gridname; String partitions, backups, maxPerVM, maxPerMachine; String[] deployCmdArr = deploypuCommand.split(" "); if (deployCmdArr[0].equals("deploy-pu")) { gridname = deployCmdArr[1]; partitions = deployCmdArr[4]; backups = deployCmdArr[5]; maxPerVM = deployCmdArr[6]; maxPerMachine = deployCmdArr[7]; } else if (deployCmdArr[0].equals("deploy-grid")) { gridname = deployCmdArr[1]; partitions = deployCmdArr[3]; backups = deployCmdArr[4]; maxPerVM = deployCmdArr[5]; maxPerMachine = deployCmdArr[6]; } else if (deployCmdArr[0].equals("deploy-pu-basic")) { File file = new File(PUURL); gridname = file.getName(); partitions = "1"; backups = "0"; maxPerVM = "1"; maxPerMachine = "1"; } else if (deployCmdArr[0].equals("deploy-grid-basic")) { gridname = deployCmdArr[1]; partitions = "1"; backups = "1"; maxPerVM = "0"; maxPerMachine = "0"; } else { throw new Exception( "Unknown command. Please recheck the command or add it to validateInstance function."); } InvokeServiceCommandResponse response; InvocationResult result; String appName = "default"; String numOfInstances = String.valueOf(Integer.valueOf(partitions) * (1 + Integer.valueOf(backups))); response = customCommand( "get-datagrid-instances " + gridname + " " + lookuplocators + " " + numOfInstances, SG_VALIDATOR, appName); result = getCustomCommandResult(response); Assert.assertEquals(result.getInvocationStatus(), CloudifyConstants.InvocationStatus.SUCCESS); Assert.assertEquals(result.getResult(), numOfInstances); response = customCommand( "get-datagrid-deploymentstatus " + gridname + " " + lookuplocators + " " + numOfInstances, SG_VALIDATOR, appName); result = getCustomCommandResult(response); Assert.assertEquals(result.getInvocationStatus(), CloudifyConstants.InvocationStatus.SUCCESS); Assert.assertEquals(result.getResult(), String.valueOf(DeploymentStatus.INTACT)); response = customCommand( "get-datagrid-partitions " + gridname + " " + lookuplocators + " " + numOfInstances, SG_VALIDATOR, appName); result = getCustomCommandResult(response); Assert.assertEquals(result.getInvocationStatus(), CloudifyConstants.InvocationStatus.SUCCESS); Assert.assertEquals(result.getResult(), partitions); response = customCommand( "get-datagrid-backups " + gridname + " " + lookuplocators + " " + numOfInstances, SG_VALIDATOR, appName); result = getCustomCommandResult(response); Assert.assertEquals(result.getInvocationStatus(), CloudifyConstants.InvocationStatus.SUCCESS); Assert.assertEquals(result.getResult(), backups); response = customCommand( "get-datagrid-maxinstancespermachine " + gridname + " " + lookuplocators + " " + numOfInstances, SG_VALIDATOR, appName); result = getCustomCommandResult(response); Assert.assertEquals(result.getInvocationStatus(), CloudifyConstants.InvocationStatus.SUCCESS); Assert.assertEquals(result.getResult(), maxPerMachine); response = customCommand( "get-datagrid-maxinstancespervm " + gridname + " " + lookuplocators + " " + numOfInstances, SG_VALIDATOR, appName); result = getCustomCommandResult(response); Assert.assertEquals(result.getInvocationStatus(), CloudifyConstants.InvocationStatus.SUCCESS); Assert.assertEquals(result.getResult(), maxPerVM); }