@Override protected void fillMandatoryOption(TestCommandInstance instance, String name) { if (CliStrings.EXPORT_LOGS__MEMBER.equals(name)) { instance.addOption(name, getMemberId()); } else if (CliStrings.EXPORT_LOGS__GROUP.equals(name)) { instance.addOption(name, getGroup()); } else if (CliStrings.EXPORT_LOGS__LOGLEVEL.equals(name)) { instance.addOption(name, getLogLevel()); } else if (CliStrings.EXPORT_LOGS__UPTO_LOGLEVEL.equals(name)) { instance.addOption(name, String.valueOf(HydraUtil.getRandomBoolean())); } else if (CliStrings.EXPORT_LOGS__MERGELOG.equals(name)) { instance.addOption(name, "true"); } else if (CliStrings.EXPORT_LOGS__STARTTIME.equals(name)) { String startTime = getStartTime(); HydraUtil.logInfo("Adding start-time=" + startTime); instance.addOption(name, startTime); } else if (CliStrings.EXPORT_LOGS__ENDTIME.equals(name)) { String endTime = getEndTime(); HydraUtil.logInfo("Adding end-time=" + endTime); instance.addOption(name, endTime); } else if (name.equals(CliStrings.EXPORT_LOGS__DIR)) { directory = getDirectory(instance.getMode()); instance.addOption(name, directory); } }
private String getStartTime() { calendar = Calendar.getInstance(); int rollback = -1 * HydraUtil.getnextRandomInt(60); // in minutes fair towards distant past calendar.add(Calendar.MINUTE, rollback); Date date = calendar.getTime(); HydraUtil.logFine("Final Start Time " + date); return formatter.format(date); }
private String getEndTime() { Date date = null; if (calendar == null) { // only end-time calendar = Calendar.getInstance(); int rollback = 1 + HydraUtil.getnextRandomInt(10); // in minutes fair towards near past HydraUtil.logFine("Adding diff=" + rollback + " minutes to " + calendar.getTime()); calendar.add(Calendar.MINUTE, (-1) * rollback); date = calendar.getTime(); } else { int rollback = 1 + HydraUtil.getnextRandomInt(10); // in minutes fair towards near past HydraUtil.logFine("Adding diff=" + rollback + " minutes to " + calendar.getTime()); calendar.add(Calendar.MINUTE, rollback); date = calendar.getTime(); } HydraUtil.logFine("Final End Time " + date); return formatter.format(date); }
private Object getLogLevel() { String logLevels[] = { "ALL", "FINEST", "FINER", "FINE", "INFO", "CONFIG", "WARNING", "ERROR", "SEVERE" }; return HydraUtil.getRandomElement(logLevels); }