Author: gnichols
Date: 2011-04-18 13:23:53 +0000 (Mon, 18 Apr 2011)
New Revision: 877
Modified:
trunk/tests/reboot/reboot.py
Log:
626970 - FEAT: kdump test needs to verify kdump
Modified: trunk/tests/reboot/reboot.py
===================================================================
--- trunk/tests/reboot/reboot.py 2011-04-18 13:23:33 UTC (rev 876)
+++ trunk/tests/reboot/reboot.py 2011-04-18 13:23:53 UTC (rev 877)
@@ -43,6 +43,22 @@
rpms = ["kernel-debug", "kernel-debuginfo", "kexec-tools"]
return rpms
+ def plan(self, devices):
+ tests = list()
+ # plan reboot twice: once on storage (local disk) and once over network
+ for dumpMethod in [Constants.nfs, Constants.local]:
+ test = self.makeCopy()
+ test.setLogicalDeviceName(dumpMethod)
+ tests.append(test)
+ return tests
+
+ def verify(self):
+ if self.getLogicalDevice == Constants.nfs and (self.getTestServer() == None or self.getTestServer() == "unknown"):
+ print "Reboot test for %s failed verification: No test server was set." % self.getLogicalDevice()
+ return False
+ return True
+
+
def tags(self):
return [TestTag.noninteractive, TestTag.certification]
@@ -90,13 +106,39 @@
try:
configFile = ConfigFile(self.kdumpConfigPath)
coreCollector = configFile.getParameter("core_collector")
+ net = configFile.getParameter("net")
except IOError, exception:
print "Error: %s" % exception
return False
+ restart = False
if not coreCollector:
- print "Adding core_collector = %s to /etc/kdump.conf" % self.coreCollector
+ print "Adding core_collector = %s to %s" % (self.coreCollector, self.kdumpConfigPath)
configFile.addParameter("core_collector", self.coreCollector)
+ restart = True
+ else:
+ print "core_collector currently set to \"" + coreCollector + "\""
+
+ if net:
+ if self.getLogicalDeviceName() == Constants.local:
+ print "removing net setting for local disk dump"
+ configFile.removeParameter("net")
+ restart = True
+ else:
+ print "Network Dump set to %s" % net
+ elif self.getLogicalDeviceName() == Constants.nfs:
+ if self.getTestServer():
+ net = "%s:/var/v7/export" % self.getTestServer()
+ print "Adding net %s to %s" % (net, self.kdumpConfigPath)
+ configFile.addParameter("net", net)
+ restart = True
+ else:
+ print "Error: v7 test server not set for network dump"
+ return False
+
+
+ if restart:
+ configFile.save()
print "restarting kdump with new configuration..."
try:
Command("service kdump stop").echo()
@@ -105,12 +147,9 @@
print "Error: kdump restart failed"
print exception
exception.command.printErrors()
- verified = False
- else:
- print "core_collector currently set to \"" + coreCollector + "\""
+ verified = False
-
print "Checking kdump service"
try:
kdump = Command("service kdump status")
@@ -170,12 +209,10 @@
return False
def verifyKDumpImage(self):
- # parse /etc/kdump.conf to find the location of the image file
- configFile = ConfigFile(self.kdumpConfigPath)
- imageDirectory = configFile.getParameter("path")
- if not imageDirectory:
- imageDirectory = "/var/crash"
-
+ imageDirectory = self.getImageDirectory()
+ if not imageDirectory():
+ return False
+
# find the vmcore image file matching the timestamp
# vmcore directories are like this: 127.0.0.1-2011-03-10-13:18:27
vmcoreDirectoryPattern = re.compile("(?P<ipaddr>[0-9]+\.[0-9]+\.[0-9]+)-(?P<date>[0-9]+-[0-9]+-[0-9]+)-(?P<time>[0-9]+:[0-9]+:[0-9]+)")
@@ -217,7 +254,32 @@
crash.printErrors()
return False
+
+ def getImageDirectory(self):
+ # parse /etc/kdump.conf to find the location of the image file
+ configFile = ConfigFile(self.kdumpConfigPath)
+ imageDirectory = configFile.getParameter("path")
+ if not imageDirectory:
+ imageDirectory = "/var/crash"
+
+ # if nfs network dump, mount the filesystem
+ net = configFile.getParameter("net")
+ if net:
+ print "Attempting to mount net setting %s as nfs."
+ try:
+ localPath = "v7-net"
+ Command("mkdir %s" % localPath).echo()
+ Command("mount %s %s" % (net, localPath).echo())
+ imageDirectory = os.path.join(localPath, imageDirectory)
+ except V7CommandException, exception:
+ print "Error: could not mount nfs image directory"
+ print exception
+ print exception.command.printErrors()
+ return None
+ print "Looking for vmcore image directories under " + imageDirectory
+ return imageDirectory
+
def run(self):
PASSED = 0