Change in vdsm[master]: utils: add CommandStream class
nsoffer at redhat.com
nsoffer at redhat.com
Tue Apr 28 10:39:09 UTC 2015
Nir Soffer has posted comments on this change.
Change subject: utils: add CommandStream class
......................................................................
Patch Set 7:
(4 comments)
https://gerrit.ovirt.org/#/c/33909/7/tests/utilsTests.py
File tests/utilsTests.py:
Line 754: @expandPermutations
Line 755: class CommandStreamTests(TestCaseBase):
Line 756:
Line 757: @contextlib.contextmanager
Line 758: def assertElapsed(self, expected, tolerance=0.5):
This seems like a general utility that should be in testlib.
Line 759: start = utils.monotonic_time()
Line 760:
Line 761: yield
Line 762:
Line 773:
Line 774: @permutations((('stdout',), ('stderr',)))
Line 775: def test_receive(self, output):
Line 776: text = bytes("Hello World")
Line 777: received = bytearray()
We can use
received = [bytearray()]
or
self.received = bytearray()
Line 778:
Line 779: def recv_stdout(buffer):
Line 780: # cannot use received += buffer with a variable
Line 781: # defined in the parent function.
Line 775: def test_receive(self, output):
Line 776: text = bytes("Hello World")
Line 777: received = bytearray()
Line 778:
Line 779: def recv_stdout(buffer):
This should be now recv_data - can come from stderr in the stderr permutation.
Line 780: # cannot use received += buffer with a variable
Line 781: # defined in the parent function.
Line 782: operator.iadd(received, buffer)
Line 783:
Line 778:
Line 779: def recv_stdout(buffer):
Line 780: # cannot use received += buffer with a variable
Line 781: # defined in the parent function.
Line 782: operator.iadd(received, buffer)
But we can use received[0] += buffer, or self.received += bufffer
Line 783:
Line 784: if output == 'stdout':
Line 785: c = self._startCommand(["echo", "-n", text])
Line 786: p = utils.CommandStream(c, recv_stdout, self.assertUnexpectedCall)
--
To view, visit https://gerrit.ovirt.org/33909
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie015368bb9c5992e5c73a149277c59fc4ffbd570
Gerrit-PatchSet: 7
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Adam Litke <alitke at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi at redhat.com>
Gerrit-Reviewer: Shahar Havivi <shavivi at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
More information about the vdsm-patches
mailing list