Change in vdsm[master]: test: add ddWatchCopy append tests

2013-10-11 Thread danken
Dan Kenigsberg has submitted this change and it was merged.

Change subject: test: add ddWatchCopy append tests
..


test: add ddWatchCopy append tests

Change-Id: Ib3a8cc6b59b356b333f4338103e7b665af584cdc
Signed-off-by: Federico Simoncelli fsimo...@redhat.com
Reviewed-on: http://gerrit.ovirt.org/20075
Reviewed-by: Sergey Gotliv sgot...@redhat.com
Reviewed-by: Dan Kenigsberg dan...@redhat.com
---
M tests/miscTests.py
1 file changed, 68 insertions(+), 9 deletions(-)

Approvals:
  Federico Simoncelli: Verified
  Sergey Gotliv: Looks good to me, but someone else must approve
  Dan Kenigsberg: Looks good to me, approved



-- 
To view, visit http://gerrit.ovirt.org/20075
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib3a8cc6b59b356b333f4338103e7b665af584cdc
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli fsimo...@redhat.com
Gerrit-Reviewer: Ayal Baron aba...@redhat.com
Gerrit-Reviewer: Dan Kenigsberg dan...@redhat.com
Gerrit-Reviewer: Federico Simoncelli fsimo...@redhat.com
Gerrit-Reviewer: Sergey Gotliv sgot...@redhat.com
Gerrit-Reviewer: oVirt Jenkins CI Server
___
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches


Change in vdsm[master]: test: add ddWatchCopy append tests

2013-10-11 Thread danken
Dan Kenigsberg has posted comments on this change.

Change subject: test: add ddWatchCopy append tests
..


Patch Set 1: Code-Review+2

-- 
To view, visit http://gerrit.ovirt.org/20075
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib3a8cc6b59b356b333f4338103e7b665af584cdc
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli fsimo...@redhat.com
Gerrit-Reviewer: Ayal Baron aba...@redhat.com
Gerrit-Reviewer: Dan Kenigsberg dan...@redhat.com
Gerrit-Reviewer: Federico Simoncelli fsimo...@redhat.com
Gerrit-Reviewer: Sergey Gotliv sgot...@redhat.com
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: No
___
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches


Change in vdsm[master]: test: add ddWatchCopy append tests

2013-10-10 Thread fsimonce
Federico Simoncelli has uploaded a new change for review.

Change subject: test: add ddWatchCopy append tests
..

test: add ddWatchCopy append tests

Change-Id: Ib3a8cc6b59b356b333f4338103e7b665af584cdc
Signed-off-by: Federico Simoncelli fsimo...@redhat.com
---
M tests/miscTests.py
1 file changed, 68 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/75/20075/1

diff --git a/tests/miscTests.py b/tests/miscTests.py
index d8b188a..b22ef64 100644
--- a/tests/miscTests.py
+++ b/tests/miscTests.py
@@ -50,11 +50,6 @@
 SUDO_GROUP = root
 
 
-def ddWatchCopy(srcPath, dstPath, callback, dataLen):
-rc, out, err = misc.ddWatchCopy(srcPath, dstPath, callback, dataLen)
-return rc, out, err
-
-
 def watchCmd(cmd, stop, cwd=None, data=None, recoveryCallback=None):
 ret, out, err = utils.watchCmd(cmd, stop, cwd=cwd, data=data,
recoveryCallback=recoveryCallback)
@@ -437,7 +432,7 @@
 os.chmod(dstPath, 0666)
 
 #Copy
-rc, out, err = ddWatchCopy(srcPath, dstPath, None, len(data))
+rc, out, err = misc.ddWatchCopy(srcPath, dstPath, None, len(data))
 
 #Get copied data
 readData = open(dstPath).read()
@@ -448,6 +443,70 @@
 
 # Compare
 self.assertEquals(readData, data)
+
+def _createDataFile(self, data, repetitions):
+fd, path = tempfile.mkstemp()
+
+try:
+for i in xrange(repetitions):
+os.write(fd, data)
+self.assertEquals(os.stat(path).st_size, misc.MEGA)
+except:
+os.unlink(path)
+raise
+finally:
+os.close(fd)
+
+return path
+
+def testAlignedAppend(self):
+data = ABCD * 256  # 1Kb
+repetitions = misc.MEGA / len(data)
+
+path = self._createDataFile(data, repetitions)
+try:
+# Using os.stat(path).st_size is part of the test, please do not
+# remove or change.
+rc, out, err = misc.ddWatchCopy(
+/dev/zero, path, None, misc.MEGA, os.stat(path).st_size)
+
+self.assertEquals(rc, 0)
+self.assertEquals(os.stat(path).st_size, misc.MEGA * 2)
+
+with open(path, r) as f:
+for i in xrange(repetitions):
+self.assertEquals(f.read(len(data)), data)
+finally:
+os.unlink(path)
+
+def testNonAlignedAppend(self):
+data = ABCD * 256  # 1Kb
+add_data = E
+repetitions = misc.MEGA / len(data)
+
+path = self._createDataFile(data, repetitions)
+try:
+with open(path, a) as f:  # Appending additional data
+f.write(add_data)
+
+self.assertEquals(os.stat(path).st_size, misc.MEGA + len(add_data))
+
+# Using os.stat(path).st_size is part of the test, please do not
+# remove or change.
+rc, out, err = misc.ddWatchCopy(
+/dev/zero, path, None, misc.MEGA, os.stat(path).st_size)
+
+self.assertEquals(rc, 0)
+self.assertEquals(os.stat(path).st_size,
+  misc.MEGA * 2 + len(add_data))
+
+with open(path, r) as f:
+for i in xrange(repetitions):
+self.assertEquals(f.read(len(data)), data)
+# Checking the additional data
+self.assertEquals(f.read(len(add_data)), add_data)
+finally:
+os.unlink(path)
 
 def testCopy(self):
 
@@ -476,7 +535,7 @@
 os.chmod(dstPath, 0666)
 
 #Copy
-rc, out, err = ddWatchCopy(srcPath, dstPath, None, len(data))
+rc, out, err = misc.ddWatchCopy(srcPath, dstPath, None, len(data))
 
 #Get copied data
 readData = open(dstPath).read()
@@ -498,7 +557,7 @@
 os.unlink(srcPath)
 
 #Copy
-self.assertRaises(misc.se.MiscBlockWriteException, ddWatchCopy,
+self.assertRaises(misc.se.MiscBlockWriteException, misc.ddWatchCopy,
   srcPath, /tmp/tmp, None, 100)
 
 def testStop(self):
@@ -510,7 +569,7 @@
 os.unlink(src.name)
 os.mkfifo(src.name)
 with tempfile.NamedTemporaryFile() as dst:
-ddWatchCopy(src.name, dst.name, lambda: True, 100)
+misc.ddWatchCopy(src.name, dst.name, lambda: True, 100)
 except utils.ActionStopped:
 self.log.info(Looks like it stopped!)
 else:


-- 
To view, visit http://gerrit.ovirt.org/20075
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib3a8cc6b59b356b333f4338103e7b665af584cdc
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli fsimo...@redhat.com
___
vdsm-patches 

Change in vdsm[master]: test: add ddWatchCopy append tests

2013-10-10 Thread oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.

Change subject: test: add ddWatchCopy append tests
..


Patch Set 1:

Build Successful 

http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/4897/ : SUCCESS

http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/4012/ : SUCCESS

http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/4822/ : SUCCESS

-- 
To view, visit http://gerrit.ovirt.org/20075
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib3a8cc6b59b356b333f4338103e7b665af584cdc
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli fsimo...@redhat.com
Gerrit-Reviewer: Ayal Baron aba...@redhat.com
Gerrit-Reviewer: Dan Kenigsberg dan...@redhat.com
Gerrit-Reviewer: Sergey Gotliv sgot...@redhat.com
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: No
___
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches


Change in vdsm[master]: test: add ddWatchCopy append tests

2013-10-10 Thread fsimonce
Federico Simoncelli has posted comments on this change.

Change subject: test: add ddWatchCopy append tests
..


Patch Set 1: Verified+1

Verified running unit tests.

-- 
To view, visit http://gerrit.ovirt.org/20075
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib3a8cc6b59b356b333f4338103e7b665af584cdc
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli fsimo...@redhat.com
Gerrit-Reviewer: Ayal Baron aba...@redhat.com
Gerrit-Reviewer: Dan Kenigsberg dan...@redhat.com
Gerrit-Reviewer: Federico Simoncelli fsimo...@redhat.com
Gerrit-Reviewer: Sergey Gotliv sgot...@redhat.com
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: No
___
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches


Change in vdsm[master]: test: add ddWatchCopy append tests

2013-10-10 Thread sgotliv
Sergey Gotliv has posted comments on this change.

Change subject: test: add ddWatchCopy append tests
..


Patch Set 1: Code-Review+1

-- 
To view, visit http://gerrit.ovirt.org/20075
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib3a8cc6b59b356b333f4338103e7b665af584cdc
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli fsimo...@redhat.com
Gerrit-Reviewer: Ayal Baron aba...@redhat.com
Gerrit-Reviewer: Dan Kenigsberg dan...@redhat.com
Gerrit-Reviewer: Federico Simoncelli fsimo...@redhat.com
Gerrit-Reviewer: Sergey Gotliv sgot...@redhat.com
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: No
___
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches