private static String handleCommandResult(CommandResult object) { StringBuilder sb = new StringBuilder(); sb.append(" Status : " + object.getStatus()).append(NEW_LINE); try { sb.append(" Raw JSON : " + object.getContent().toIndentedString(5)); sb.append(NEW_LINE); } catch (GfJsonException e) { sb.append(" Error getting raw JSON : " + e.getMessage()); logError(" Error getting raw JSON : ", e); } return sb.toString(); }
public CommandOutputValidatorResult validate() { CommandOutputValidatorResult validationResult = new CommandOutputValidatorResult(); validationResult.command = this.command; validationResult.result = true; List<String> stringerrors = stringValidator.validate(presentationStr); if(stringerrors.size()>0){ validationResult.result = false; validationResult.errorStrings.addAll(stringerrors); } // checkStrings(errorStringPatterns, validationResult, false); // checkStrings(stringPatterns, validationResult, true); if(!result.getStatus().equals(Result.Status.OK)){ validationResult.result = false; validationResult.errorStrings.add("Result status is not OK : " + result.getStatus()); } return validationResult; }
private static void logOutput(String command, Object object[]){ Map map = (Map) object[0]; CommandResult result =null; Collection values = map.values(); for(Object r : values){ if(r instanceof CommandResult){ result = (CommandResult) r; if(!result.getStatus().equals(Result.Status.OK)) throw new TestException("Command return status is OK. Command execution has failed"); else HydraUtil.logInfo("Completed exeuction of <" + command + "> successfully"); } } }
public void testCommand() throws Throwable { disconnectAllFromDS(); CommandResult cmdResult = executeUpgradeDiskStore("dd", "dddd", "1"); assertTrue(Status.ERROR.equals(cmdResult.getStatus())); }
public void testEchoAllPropertyVariables() { Gfsh gfshInstance = Gfsh.getCurrentInstance(); if (gfshInstance == null) { fail("In testEcho command gfshInstance is null"); } String command = "echo --string=\"$*\""; CommandResult cmdResult = executeCommand(command); if (cmdResult != null) { assertEquals(Result.Status.OK, cmdResult.getStatus()); } else { fail("testEchoAllPropertyVariables failed"); } }
public void testStatusLocatorUsingMemberNameIDWhenGfshIsNotConnected() { final CommandResult result = executeCommand(CliStrings.STATUS_LOCATOR + " --name=" + testName); assertEquals(Result.Status.ERROR, result.getStatus()); assertEquals(CliStrings.format(CliStrings.STATUS_SERVICE__GFSH_NOT_CONNECTED_ERROR_MESSAGE, "Locator"), StringUtils.trim(toString(result))); }
public void testEchoForSingleVariable2() { Gfsh gfshInstance = Gfsh.getCurrentInstance(); if (gfshInstance == null) { fail("In testEcho command gfshInstance is null"); } gfshInstance.setEnvProperty("TESTSYS", "SYS_VALUE"); String command = "echo --string=\"${TESTSYS} ${TESTSYS}\""; CommandResult cmdResult = executeCommand(command); if (cmdResult != null) { assertEquals(Result.Status.OK, cmdResult.getStatus()); String stringResult = commandResultToString(cmdResult); assertTrue(stringResult.contains("SYS_VALUE")); } else { fail("testEchoForSingleVariable2 failed"); } }
public void testEchoWithVariableAtStart() { Gfsh gfshInstance = Gfsh.getCurrentInstance(); if (gfshInstance == null) { fail("In testEcho command gfshInstance is null"); } gfshInstance.setEnvProperty("TESTSYS", "SYS_VALUE"); String command = "echo --string=\"${TESTSYS} Hello World! This is VMWARE\""; CommandResult cmdResult = executeCommand(command); if (cmdResult != null) { assertEquals(Result.Status.OK, cmdResult.getStatus()); String stringResult = commandResultToString(cmdResult); assertTrue(stringResult.contains("SYS_VALUE Hello World! This is VMWARE")); } else { fail("testEchoWithVariableAtStart failed"); } }
public void testEchoForSingleVariable() { Gfsh gfshInstance = Gfsh.getCurrentInstance(); if (gfshInstance == null) { fail("In testEcho command gfshInstance is null"); } gfshInstance.setEnvProperty("TESTSYS", "SYS_VALUE"); String command = "echo --string=${TESTSYS}"; CommandResult cmdResult = executeCommand(command); if (cmdResult != null) { assertEquals(Result.Status.OK, cmdResult.getStatus()); String stringResult = commandResultToString(cmdResult); assertTrue(stringResult.contains("SYS_VALUE")); } else { fail("testEchoForSingleVariable failed"); } }
public void testHistory() { Gfsh gfshInstance = Gfsh.getCurrentInstance(); if (gfshInstance == null) { fail("In testHistory command gfshInstance is null"); } gfshInstance.setDebug(false); String command = "history"; CommandResult cmdResult = executeCommand(command); if (cmdResult != null) { assertEquals(Result.Status.OK, cmdResult.getStatus()); } else { fail("testHistory failed"); } } public void testHistoryWithFileName() {
public void testEchoWithNoVariable() { Gfsh gfshInstance = Gfsh.getCurrentInstance(); if (gfshInstance == null) { fail("In testEcho command gfshInstance is null"); } gfshInstance.setEnvProperty("TESTSYS", "SYS_VALUE"); String command = "echo --string=\"Hello World! This is VMWARE\""; CommandResult cmdResult = executeCommand(command); if (cmdResult != null) { assertEquals(Result.Status.OK, cmdResult.getStatus()); String stringResult = commandResultToString(cmdResult); assertTrue(stringResult.contains("Hello World! This is VMWARE")); } else { fail("testEchoWithNoVariable failed"); } }
public void testStopLocatorUsingMemberNameIDWhenGfshIsNotConnected() { final CommandResult result = executeCommand(CliStrings.STOP_LOCATOR + " --name=" + testName); assertNotNull(result); assertEquals(Result.Status.ERROR, result.getStatus()); assertEquals(CliStrings.format(CliStrings.STOP_SERVICE__GFSH_NOT_CONNECTED_ERROR_MESSAGE, "Locator"), StringUtils.trim(toString(result))); }
@Test public void testCommandLineProperty() { System.setProperty(CommandManager.USER_CMD_PACKAGES_PROPERTY, "junit.ucdunit"); ClassPathLoader.setLatestToDefault(); CommandManager.clearInstance(); Host.getHost(0).getVM(0).invoke(new SerializableRunnable() { private static final long serialVersionUID = 1L; @Override public void run() { System.setProperty(CommandManager.USER_CMD_PACKAGES_PROPERTY, "junit.ucdunit"); ClassPathLoader.setLatestToDefault(); CommandManager.clearInstance(); } }); createDefaultSetup(null); CommandResult cmdResult = executeCommand("ucdunitcmd"); assertEquals(Result.Status.OK, cmdResult.getStatus()); }
public void testDebug() { Gfsh gfshInstance = Gfsh.getCurrentInstance(); if (gfshInstance == null) { fail("In testDebug command gfshInstance is null"); } gfshInstance.setDebug(false); String command = "debug --state=ON"; CommandResult cmdResult = executeCommand(command); if (cmdResult != null) { assertEquals(Result.Status.OK, cmdResult.getStatus()); } else { fail("testDebug failed"); } assertEquals(gfshInstance.getDebug(), true); } public void testHistory() {
public void testEchoWithVariableAtEnd() { Gfsh gfshInstance = Gfsh.getCurrentInstance(); if (gfshInstance == null) { fail("In testEcho command gfshInstance is null"); } gfshInstance.setEnvProperty("TESTSYS", "SYS_VALUE"); String command = "echo --string=\"Hello World! This is ${TESTSYS}\""; CommandResult cmdResult = executeCommand(command); if (cmdResult != null) { assertEquals(Result.Status.OK, cmdResult.getStatus()); String stringResult = commandResultToString(cmdResult); assertEquals("Hello World! This is SYS_VALUE", StringUtils.trim(stringResult)); } else { fail("testEchoWithVariableAtEnd failed"); } }
public void testShowLogDefault() { createDefaultSetup(null); final VM vm1 = Host.getHost(0).getVM(0); final String vm1MemberId = (String) vm1.invoke( MiscellaneousCommandsDUnitTest.class, "getMemberId"); String command = "show log --member=" + vm1MemberId; CommandResult cmdResult = executeCommand(command); if (cmdResult != null) { String log = commandResultToString(cmdResult); assertNotNull(log); getLogWriter().info("Show Log is" + log); assertEquals(Result.Status.OK, cmdResult.getStatus()); } else { fail("testShowLog failed as did not get CommandResult"); } }
public void testShowLogNumLines() { createDefaultSetup(null); final VM vm1 = Host.getHost(0).getVM(0); final String vm1MemberId = (String) vm1.invoke( MiscellaneousCommandsDUnitTest.class, "getMemberId"); String command = "show log --member=" + vm1MemberId + " --lines=50"; CommandResult cmdResult = executeCommand(command); if (cmdResult != null) { String log = commandResultToString(cmdResult); assertNotNull(log); getLogWriter().info("Show Log is" + log); assertEquals(Result.Status.OK, cmdResult.getStatus()); } else { fail("testShowLog failed as did not get CommandResult"); } }
public void testDestroyOnMember() { createDefaultSetup(null); Function function = new TestFunction(true, TestFunction.TEST_FUNCTION1); FunctionService.registerFunction(function); final VM vm1 = Host.getHost(0).getVM(1); final String vm1MemberId = (String) vm1.invoke(FunctionCommandsDUnitTest.class,"getMemberId"); String command = "destroy function --id=" + function.getId()+ " --member="+ vm1MemberId; Log.getLogWriter().info("testDestroyOnMember command=" + command); CommandResult cmdResult = executeCommand(command); if (cmdResult != null) { String strCmdResult = commandResultToString(cmdResult); assertEquals(Result.Status.OK, cmdResult.getStatus()); Log.getLogWriter().info("testDestroyOnMember strCmdResult=" + strCmdResult); assertTrue(strCmdResult.contains("Destroyed TestFunction1 Successfully")); } else { fail("testDestroyOnMember failed as did not get CommandResult"); } }
public void testRebalanceCommandForTimeOut() { setupTestRebalanceForEntireDS(); //check if DistributedRegionMXBean is available so that command will not fail final VM manager = Host.getHost(0).getVM(0); manager.invoke(checkRegionMBeans); Log.getLogWriter().info("testRebalanceCommandForTimeOut verified Mbean and executin command"); String command = "rebalance --time-out=1"; CommandResult cmdResult = executeCommand(command); Log.getLogWriter().info("testRebalanceCommandForTimeOut just after executing " + cmdResult); if (cmdResult != null) { String stringResult = commandResultToString(cmdResult); Log.getLogWriter().info("testRebalanceCommandForTimeOut stringResult : " + stringResult); assertEquals(Result.Status.OK, cmdResult.getStatus()); } else { fail("testRebalanceCommandForTimeOut failed as did not get CommandResult"); } }
public void testRebalanceCommandForTimeOutForRegion() { setupTestRebalanceForEntireDS(); //check if DistributedRegionMXBean is available so that command will not fail final VM manager = Host.getHost(0).getVM(0); manager.invoke(checkRegionMBeans); Log.getLogWriter().info("testRebalanceCommandForTimeOutForRegion verified Mbean and executin command"); String command = "rebalance --time-out=1 --include-region=" + "/" +REBALANCE_REGION_NAME; CommandResult cmdResult = executeCommand(command); Log.getLogWriter().info("testRebalanceCommandForTimeOutForRegion just after executing " + cmdResult); if (cmdResult != null) { String stringResult = commandResultToString(cmdResult); Log.getLogWriter().info("testRebalanceCommandForTimeOutForRegion stringResult : " + stringResult); assertEquals(Result.Status.OK, cmdResult.getStatus()); } else { fail("testRebalanceCommandForTimeOut failed as did not get CommandResult"); } }