diff options
author | Endi S. Dewata <edewata@redhat.com> | 2016-01-05 01:39:06 +0100 |
---|---|---|
committer | Endi S. Dewata <edewata@redhat.com> | 2016-01-18 16:45:32 +0100 |
commit | 02b63c6f8200042175b482b9cc00a0bc950f2f06 (patch) | |
tree | 3903613cd1989d8621dc6dafcf7e12580a6fc65a /base/server/cmscore/src | |
parent | 2c88b5d9c15487a796f65beea6c102b1ef04016f (diff) | |
download | pki-02b63c6f8200042175b482b9cc00a0bc950f2f06.tar.gz pki-02b63c6f8200042175b482b9cc00a0bc950f2f06.tar.xz pki-02b63c6f8200042175b482b9cc00a0bc950f2f06.zip |
Updated CLI to run individual selftests.
The pki selftest-run command has been modified to execute the
specified selftests, or all selftests if nothing is specified.
The command will also display the status of each test and the
stack trace if it fails.
https://fedorahosted.org/pki/ticket/1502
Diffstat (limited to 'base/server/cmscore/src')
-rw-r--r-- | base/server/cmscore/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java | 75 |
1 files changed, 39 insertions, 36 deletions
diff --git a/base/server/cmscore/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java b/base/server/cmscore/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java index 14fab26e4..4b89aa49e 100644 --- a/base/server/cmscore/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java +++ b/base/server/cmscore/src/com/netscape/cmscore/selftests/SelfTestSubsystem.java @@ -501,16 +501,11 @@ public class SelfTestSubsystem Enumeration<SelfTestOrderedInstance> instances = mOnDemandOrder.elements(); while (instances.hasMoreElements()) { - SelfTestOrderedInstance instance = instances.nextElement(); - String instanceFullName = null; + SelfTestOrderedInstance instance = instances.nextElement(); String instanceName = instance.getSelfTestName(); - if (instanceName != null) { - instanceName = instanceName.trim(); - instanceFullName = getFullName(mPrefix, - instanceName); - } else { + if (instanceName == null) { log(mLogger, CMS.getLogMessage( "CMSCORE_SELFTESTS_PROPERTY_NAME_IS_NULL")); @@ -518,37 +513,11 @@ public class SelfTestSubsystem throw new EMissingSelfTestException(); } - if (mSelfTestInstances.containsKey(instanceName)) { - ISelfTest test = mSelfTestInstances.get(instanceName); - - try { - if (CMS.debugOn()) { - CMS.debug("SelfTestSubsystem::runSelfTestsOnDemand():" - + " running \"" - + test.getSelfTestName() - + "\""); - } - - test.runSelfTest(mLogger); - - } catch (Exception e) { - - CMS.debug(e); - - // Check to see if the self test was critical: - if (isSelfTestCriticalOnDemand(instanceName)) { - log(mLogger, - CMS.getLogMessage( - "CMSCORE_SELFTESTS_RUN_ON_DEMAND_FAILED", - instanceFullName)); + instanceName = instanceName.trim(); - // shutdown the system gracefully - CMS.shutdown(); + String instanceFullName = getFullName(mPrefix, instanceName); - return; - } - } - } else { + if (!mSelfTestInstances.containsKey(instanceName)) { // self test plugin instance property name is not present log(mLogger, CMS.getLogMessage( @@ -557,6 +526,27 @@ public class SelfTestSubsystem throw new EMissingSelfTestException(instanceFullName); } + + try { + runSelfTest(instanceName); + + } catch (Exception e) { + + CMS.debug(e); + + // Check to see if the self test was critical: + if (isSelfTestCriticalOnDemand(instanceName)) { + log(mLogger, + CMS.getLogMessage( + "CMSCORE_SELFTESTS_RUN_ON_DEMAND_FAILED", + instanceFullName)); + + // shutdown the system gracefully + CMS.shutdown(); + + return; + } + } } if (CMS.debugOn()) { @@ -565,6 +555,19 @@ public class SelfTestSubsystem } } + public void runSelfTest(String instanceName) throws Exception { + + CMS.debug("SelfTestSubsystem.runSelfTest(" + instanceName + ")"); + + ISelfTest test = mSelfTestInstances.get(instanceName); + + if (test == null) { + throw new EMissingSelfTestException(instanceName); + } + + test.runSelfTest(mLogger); + } + // // methods associated with the list of startup self tests // |