r791 - trunk/tests/network
by gnichols@fedoraproject.org
Author: gnichols
Date: 2011-03-08 13:05:26 +0000 (Tue, 08 Mar 2011)
New Revision: 791
Modified:
trunk/tests/network/network.py
Log:
680225 - network test should use HTTP for file transfer tests rather than NFS
Modified: trunk/tests/network/network.py
===================================================================
--- trunk/tests/network/network.py 2011-03-08 12:57:20 UTC (rev 790)
+++ trunk/tests/network/network.py 2011-03-08 13:05:26 UTC (rev 791)
@@ -21,6 +21,7 @@
import sys
import re
import time
+import urllib2
# sys.path.append("/home/gnichols/devel/v7")
from v7.tags import Constants, DeviceClass
@@ -29,6 +30,8 @@
from v7.v7kudzu import Kudzu
from v7.command import Command, V7CommandException
from v7.environment import Environment
+from v7.hash import hashModule
+from v7.http import V7Http
FAILED = 1
PASSED = 0
@@ -301,10 +304,6 @@
return None
def createTestFile(self):
- try:
- os.remove(self.testFile)
- except OSError:
- pass
if not self.getInterfaceSpeed():
print "Warning: Unable to determine interface speed"
@@ -312,9 +311,24 @@
else:
print "interface speed is %u Mb/s" % self.interfaceSpeed
- returnValue = os.system("dd if=/dev/urandom of=%s bs=128k count=%s" % (self.testFile, self.interfaceSpeed))
- return returnValue == 0
+ return self.regenerateTestFile()
+ def regenerateTestFile(self):
+ try:
+ os.remove(self.testFile)
+ except OSError:
+ pass
+
+ dd = Command("dd if=/dev/urandom of=%s bs=128k count=%s" % (self.testFile, self.interfaceSpeed))
+ try:
+ dd.run()
+ except V7CommandException, exception:
+ # dd shows output on stderr, ignore this
+ pass
+
+ return True
+
+
def getInterfaceSpeed(self):
# default to 100 Mb/s
self.interfaceSpeed = 0
@@ -337,15 +351,24 @@
# icmpTest uses ping with various packet sizes
def icmpTest(self):
- packetSizes = [0, 1, 240, 256, 1024, 2000, 10000, 40000, 65507]
- for size in packetSizes:
- sizeParam = ""
- if size > 0:
- sizeParam = "-s %s" % size
- (input, pingPipe) = os.popen4("/bin/ping -f -c 1000 %s %s" % (sizeParam, self.getTestServer()))
- returnValue = self.printPipe(pingPipe)
- if returnValue:
- return False
+ # (<bytes in packet>, <percent lost for warning>)
+ packetSizes = [(0, 0), (1, 0), (240, 10), (256, 15), (1024, 20), (2000, 30), (10000, 40), (40000, 60), (65507, 80)]
+ try:
+ for (size, warnLoss) in packetSizes:
+ sizeParam = ""
+ if size > 0:
+ sizeParam = "-s %s" % size
+ ping = Command("/bin/ping -i 0 -q -c 1000 %s %s" % (sizeParam, self.getTestServer()))
+ print ping.command
+ packetLoss = ping.getString(regex="^.*, (?P<packetLoss>[0-9]+)% packet loss.*$", regexGroup="packetLoss", singleLine=False)
+ ping.printOutput()
+ if int(packetLoss) > warnLoss:
+ print "Warning: packet loss of %s%% is greater than %s%% expected" % (packetLoss, warnLoss)
+ except V7CommandException, exception:
+ print "Error:"
+ print exception
+ ping.printErrors()
+ return False
# otherwise
return True
@@ -574,6 +597,76 @@
print "%u mbit received in %u sec ( %.2f mbit/s)" % (mbit, rxtime, mbit/rxtime)
return True # success
+ def httpTransferTest(self):
+ """ transfer a file to the server via POST, then pull it back via GET and compare the files """
+ errorCount = 0
+ for count in range(1,5):
+ self.regenerateTestFile()
+ (sentFileCheckSum, uploadIPAddress) = self.httpUpload()
+ if not uploadIPAddress:
+ errorCount += 1
+ continue
+ receivedFileCheckSum = self.httpDownload(uploadIPAddress)
+ if sentFileCheckSum == receivedFileCheckSum:
+ print "Checksums Match"
+ else:
+ print "Error: checksum %s does not match the file that was sent" % receivedFileCheckSum
+ errorCount += 1
+ if errorCount > 0:
+ print "Http test had %u errors" % errorCount
+ return (errorCount is 0)
+
+ def httpUpload(self):
+ # getMD5 checksum
+ m=hashModule.md5()
+ sentFile = open(self.testFile, "rb")
+ m.update(sentFile.read())
+ sentFile.close()
+ sentCheckSum=m.hexdigest()
+ request = V7Http(self.getTestServer(), "/v7/cgi/networkTest.py")
+ if not request.addFile(self.testFile):
+ eturn (None, None)
+ # otherwise
+ print "sending file %s hash: %s" % (self.testFile, sentCheckSum)
+ startTime = time.time()
+ (size, response) = request.send()
+ stopTime = time.time()
+ if not response:
+ # send failed
+ return (None, None)
+ print "response: "
+ print response
+ print "Upload took %.2f seconds, %.2f MB/sec" % (stopTime-startTime, size/((stopTime-startTime)*1000000))
+
+ #get the requests' IP address as seen by the server
+ pattern = re.compile("[0-9]+\.[0-9]+\.[0-9]+\.[0-9]")
+ match = pattern.search(response)
+ if match:
+ uploadIPAddress = match.group()
+ else:
+ "Warning: could not read upload IP address from response, assuming device IP address"
+ uploadIPAddress = self.ipAddress
+
+ return (sentCheckSum, uploadIPAddress)
+
+ def httpDownload(self, uploadIPAddress):
+ # GET the file back
+ fileURL = 'http://%s/v7/store/%s/%s' % (self.getTestServer(), uploadIPAddress, os.path.basename(self.testFile))
+ print "getting file %s " % fileURL
+ sys.stdout.flush()
+ request = urllib2.Request(fileURL)
+ opener = urllib2.build_opener()
+
+ startTime = time.time()
+ response = opener.open(request).read()
+ stopTime = time.time()
+ print "Download took %.2f seconds, %.2f MB/sec" % (stopTime-startTime, len(response)/((stopTime-startTime)*1000000))
+
+ m=hashModule.md5()
+ m.update(response)
+ return m.hexdigest()
+
+
def printInfo(self):
# YK: grab NIC info and running status
sys.stdout.flush()
@@ -642,7 +735,7 @@
success = True
if not self.runSubTest(self.tcpTest, "TCP", "tcp latency and bandwidth test via lmbench"):
success = False
- if not self.runSubTest(self.nfsTest, "NFS", "NFS file transfer test"):
+ if not self.runSubTest(self.nfsTest, "HTTP", "HTTP file transfer test"):
success = False
if not self.runSubTest(self.icmpTest, "ICMP"):
success = False
13 years, 2 months
r790 - trunk/v7
by gnichols@fedoraproject.org
Author: gnichols
Date: 2011-03-08 12:57:20 +0000 (Tue, 08 Mar 2011)
New Revision: 790
Added:
trunk/v7/http.py
Modified:
trunk/v7/Makefile
trunk/v7/command.py
trunk/v7/commandLineUI.py
trunk/v7/deviceDetector.py
trunk/v7/reporthtml.py
trunk/v7/resultsengine.py
trunk/v7/test.py
Log:
678984 - can't find tape device on RHEL6.1
Modified: trunk/v7/Makefile
===================================================================
--- trunk/v7/Makefile 2011-03-08 12:50:45 UTC (rev 789)
+++ trunk/v7/Makefile 2011-03-08 12:57:20 UTC (rev 790)
@@ -24,7 +24,9 @@
COMMAND_PY := command.py
endif
+UNITS := redhatrelease.py
+
install:
rm -rf $(DESTDIR)$(V7_CLASS_LIB)/v7
mkdir -p $(DESTDIR)$(V7_CLASS_LIB)/v7
@@ -34,3 +36,8 @@
clean:
rm -rf $(DESTDIR)$(V7_CLASS_LIB)/v7
+
+
+unit-test: install
+ for unit in $(UNITS); do python $(DESTDIR)$(V7_CLASS_LIB)/v7/$$unit > unit-test.log; done
+
Modified: trunk/v7/command.py
===================================================================
--- trunk/v7/command.py 2011-03-08 12:50:45 UTC (rev 789)
+++ trunk/v7/command.py 2011-03-08 12:57:20 UTC (rev 790)
@@ -72,7 +72,8 @@
if self.output:
for line in self.output:
sys.stdout.write( line )
- sys.stdout.flush()
+ sys.stdout.write("\n")
+ sys.stdout.flush()
if self.returnValue != 0:
raise V7CommandException(self, "returned %d" % self.returnValue)
if self.signal != 0:
@@ -230,7 +231,7 @@
def poll(self):
if self.pipe:
return self.pipe.poll()
- # otherwise, commmand never started
+ # otherwise, command never started
raise V7CommandException(self.command, "call to poll() before start()")
Modified: trunk/v7/commandLineUI.py
===================================================================
--- trunk/v7/commandLineUI.py 2011-03-08 12:50:45 UTC (rev 789)
+++ trunk/v7/commandLineUI.py 2011-03-08 12:57:20 UTC (rev 790)
@@ -16,7 +16,7 @@
import string, os, sys, copy, re
-from v7.tags import Constants
+from tags import Constants
class CommandLineUI:
# utilities
Modified: trunk/v7/deviceDetector.py
===================================================================
--- trunk/v7/deviceDetector.py 2011-03-08 12:50:45 UTC (rev 789)
+++ trunk/v7/deviceDetector.py 2011-03-08 12:57:20 UTC (rev 790)
@@ -18,8 +18,8 @@
import string, os, sys, copy
-from v7.tags import Constants
-from v7.commandLineUI import CommandLineUI
+from tags import Constants
+from commandLineUI import CommandLineUI
class DeviceDetector:
Added: trunk/v7/http.py
===================================================================
--- trunk/v7/http.py (rev 0)
+++ trunk/v7/http.py 2011-03-08 12:57:20 UTC (rev 790)
@@ -0,0 +1,87 @@
+#!/usr/bin/python
+# Copyright (c) 2011 Red Hat, Inc. All rights reserved. This copyrighted material
+# is made available to anyone wishing to use, modify, copy, or
+# redistribute it subject to the terms and conditions of the GNU General
+# Public License v.2.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Author: Greg Nichols <gnichols(a)redhat.com>
+#
+# HTTP library for v7's tests
+
+import os, urllib2, httplib
+
+class V7Http:
+
+ def __init__(self, host, url):
+ self.host = host
+ self.url = url
+ self.fields = list()
+ self.files = list()
+
+ def __encode(self):
+ boundary = 'v7v7v7v7v7v7v7'
+ lines = list()
+ for (name, value) in self.fields:
+ lines.append('--' + boundary)
+ lines.append('Content-Disposition: form-data; name="%s"' % name)
+ lines.append('')
+ lines.append(value)
+ for (name, filename, contents) in self.files:
+ lines.append('--' + boundary)
+ lines.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (name, filename))
+ lines.append('Content-Type: application/octet-stream')
+ lines.append('')
+ lines.append(contents)
+ lines.append('--' + boundary + '--')
+ lines.append('')
+ self.body = '\r\n'.join(lines)
+ self.contentType = 'multipart/form-data; boundary=%s' % boundary
+ encoded = True
+
+ def addFile(self, filepath):
+ try:
+ contents = open(filepath, "rb").read().encode("base64")
+ except IOError, exception:
+ print "Error: could not add file " + filepath
+ print exception
+ return False
+
+ self.files.append(("file", os.path.basename(filepath), contents))
+ return True
+
+ def addField(self, name, value):
+ self.fields.append((name, value))
+
+ def send(self):
+ self.__encode()
+ request = httplib.HTTP(self.host)
+ request.putrequest('POST', self.url)
+ request.putheader('content-type', self.contentType)
+ request.putheader('content-length', str(len(self.body)))
+ request.endheaders()
+ request.send(self.body)
+ responseCode, responseMessage, headers = request.getreply()
+ if responseCode != 200:
+ print "Error: could not send message (response code %s)" % responseCode
+ print "Message: %s" % responseMessage
+ return (0, None)
+
+ return (len(self.body), request.file.read())
+
+
+if __name__ == "__main__":
+
+ request = V7Http("localhost", "/v7/cgi/networkTest.py")
+ request.addFile("/var/v7/images/logo_rh_home.png")
+ result = request.send()
+ print result
+
+
\ No newline at end of file
Modified: trunk/v7/reporthtml.py
===================================================================
--- trunk/v7/reporthtml.py 2011-03-08 12:50:45 UTC (rev 789)
+++ trunk/v7/reporthtml.py 2011-03-08 12:57:20 UTC (rev 790)
@@ -158,7 +158,7 @@
result = run.getSummary()
if result == Constants.PASS and run.getMode() == Constants.auto and test.isInteractive():
result = "auto"
- print "<td class=\"%s\"><a href=\"v7web.py?test=%s&udi=%s&device=%s&run=%u\">%s</a></td>" % (result.lower(), test.getName(), test.getUDI(), test.getLogicalDeviceName(), runNumber, result.lower())
+ print "<td class=\"%s\"><a href=\"v7xml.py?test=%s&udi=%s&device=%s&run=%u\">%s</a></td>" % (result.lower(), test.getName(), test.getUDI(), test.getLogicalDeviceName(), runNumber, result.lower())
else:
print "<td> </td>"
print "</tr>"
@@ -262,7 +262,8 @@
print "<strong>run:</strong> %s<br/>" % self.options.run
print "<strong>start:</strong> %s<br/>" % run.getRunTime()
print "<strong>end:</strong> %s<br/>" % run.getEndTime()
- print "<strong>duration:</strong> %s<br/>" % run.duration(run.getRunTime(), run.getEndTime())
+ if len(run.getRunTime()) > 0 and len(run.getEndTime()):
+ print "<strong>duration:</strong> %s<br/>" % run.duration(run.getRunTime(), run.getEndTime())
print "<strong>mode:</strong> %s<br/>" % run.getMode().lower()
if run.getSummary().lower() == "fail":
print "<strong>result:</strong> <font class=\"error\">fail</font><br/>"
Modified: trunk/v7/resultsengine.py
===================================================================
--- trunk/v7/resultsengine.py 2011-03-08 12:50:45 UTC (rev 789)
+++ trunk/v7/resultsengine.py 2011-03-08 12:57:20 UTC (rev 790)
@@ -48,12 +48,12 @@
if test.getRun(runNumber).passed():
print test.getRun(runNumber).passed()
print "added %s to passed tests" % test.getName()
- passedTests[test.getName()] = test
+ passedTests[test.getKey()] = test
remainingTests = list()
for test in self.certification.getTests():
try:
- check = passedTests[test.getName()]
+ check = passedTests[test.getKey()]
except:
if not test.isDeleted():
remainingTests.append(test)
Modified: trunk/v7/test.py
===================================================================
--- trunk/v7/test.py 2011-03-08 12:50:45 UTC (rev 789)
+++ trunk/v7/test.py 2011-03-08 12:57:20 UTC (rev 790)
@@ -13,7 +13,7 @@
#
# Author: Greg Nichols
#
-import string, os, sys, copy, commands, time
+import string, os, sys, copy, commands, time, datetime
from v7.tags import Constants, TestTag
@@ -424,12 +424,12 @@
self.markOutput(name, description)
sys.stdout.flush()
sys.stderr.flush()
- try:
- result = subtestFunction()
- except Exception, exception:
- print "Error: Subtest raised unhandled exception:"
- print exception
- result = False
+ #try:
+ result = subtestFunction()
+ #except Exception, exception:
+ # print "Error: Subtest raised unhandled exception:"
+ # print exception
+ # result = False
sys.stdout.flush()
sys.stderr.flush()
self.markSummary(result)
@@ -558,7 +558,7 @@
# 2) try and get them from the testDocument
self.testDocument = testDocument
- map = [(Constants.DEVICE, testDocument.getLogicalDeviceName)]
+ map = [(Constants.DEVICE, testDocument.getLogicalDeviceName), (Constants.UDI, testDocument.getUDI)]
for (name, function) in map:
self.parameters[name] = function()
@@ -577,6 +577,8 @@
def set(self, name, value):
self.parameters[name] = value
+
+
13 years, 2 months
r789 - trunk/v7
by gnichols@fedoraproject.org
Author: gnichols
Date: 2011-03-08 12:50:45 +0000 (Tue, 08 Mar 2011)
New Revision: 789
Modified:
trunk/v7/controller.py
Log:
681470 - v7 submit fail on ppc64
Modified: trunk/v7/controller.py
===================================================================
--- trunk/v7/controller.py 2011-03-08 12:48:26 UTC (rev 788)
+++ trunk/v7/controller.py 2011-03-08 12:50:45 UTC (rev 789)
@@ -54,7 +54,7 @@
def removeBadCharactersInName(self, value):
"""Remove bad characters []()\/&@in generated names"""
- pattern = re.compile("[^\[\]\(\)\\\/&@]")
+ pattern = re.compile("[^\[\]\(\)\\\/&@,]")
goodList = pattern.findall(value)
return "".join(goodList)
13 years, 2 months
r788 - trunk/v7
by gnichols@fedoraproject.org
Author: gnichols
Date: 2011-03-08 12:48:26 +0000 (Tue, 08 Mar 2011)
New Revision: 788
Modified:
trunk/v7/hardwaretest.py
Log:
682672 - reboot testing abort on RHEL6.1
Modified: trunk/v7/hardwaretest.py
===================================================================
--- trunk/v7/hardwaretest.py 2011-03-08 12:45:14 UTC (rev 787)
+++ trunk/v7/hardwaretest.py 2011-03-08 12:48:26 UTC (rev 788)
@@ -61,6 +61,7 @@
self.certification = None
self.runMode = self.options.mode
self.command = None
+ self.virtualization = None
self.commands = {'plan': self.doPlan,
'verify': self.doVerify,
@@ -599,6 +600,8 @@
print "All tests in the last test run are complete"
return False
tests = self.addMandatoryTests(tests)
+ self.planner = Planner(self.options, virtualization=self.getVirtualization())
+ self.planner.analyse(self.environment.getSourceDirectory())
return self._doRun(tests, continueRun=True)
def _doRun(self, tests, continueRun=False):
13 years, 2 months
r787 - trunk
by gnichols@fedoraproject.org
Author: gnichols
Date: 2011-03-08 12:45:14 +0000 (Tue, 08 Mar 2011)
New Revision: 787
Modified:
trunk/Makefile
Log:
R14
Modified: trunk/Makefile
===================================================================
--- trunk/Makefile 2011-02-15 16:15:26 UTC (rev 786)
+++ trunk/Makefile 2011-03-08 12:45:14 UTC (rev 787)
@@ -14,7 +14,7 @@
# Author: Greg Nichols
V7_VERSION := 1.3
-V7_RELEASE := 13
+V7_RELEASE := 14
V7_VERSION_RELEASE := $(V7_VERSION)-$(V7_RELEASE)
V7_VERSION_PY := v7/version.py
V7_SVN_MODULE := svn+ssh://svn.fedorahosted.org/svn/v7
13 years, 2 months