Francesco Romani has uploaded a new change for review.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
tests: add HostStatsThread._getCpuCoreStats test
Next patch wants to refactor HostStatsThread._getCpuCoreStats into a free function, so this patch adds very basic test coverage.
This test needs to be refactored as well, and will be done alongside the method refactoring.
Change-Id: I6c6a82c77054e76d7d08322ad83d086302c2bbad Signed-off-by: Francesco Romani fromani@redhat.com --- M tests/samplingTests.py M tests/vmfakelib.py 2 files changed, 49 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/72/41372/1
diff --git a/tests/samplingTests.py b/tests/samplingTests.py index 9e3c3c3..74218e7 100644 --- a/tests/samplingTests.py +++ b/tests/samplingTests.py @@ -30,11 +30,14 @@ from vdsm.password import ProtectedPassword import virt.sampling as sampling
+import caps + from testValidation import brokentest, ValidateRunningAsRoot from testlib import permutations, expandPermutations from testlib import VdsmTestCase as TestCaseBase from monkeypatch import MonkeyPatchScope from functional import dummy +import vmfakelib as fake
class SamplingTests(TestCaseBase): @@ -269,6 +272,36 @@ } self.assertEquals(self._hs.get(), expected)
+ def testCpuCoreStats(self): + node_id, cpu_id = 0, 0 + self._hs = sampling.HostStatsThread(self.log) + cpu_sample = {'user': 1.0, 'sys': 2.0} + + for fake_ts in xrange(5): # FIXME + self._hs._samples.append( + fake.HostSample(fake_ts, {cpu_id: cpu_sample})) + + def fakeNumaTopology(): + return { + node_id: { + 'cpus': [cpu_id] + } + } + + expected = { + '0': { + 'cpuIdle': '100.00', + 'cpuSys': '0.00', + 'cpuUser': '0.00', + 'nodeIndex': 0 + } + } + + with MonkeyPatchScope([(caps, 'getNumaTopology', + fakeNumaTopology)]): + self.assertEqual(self._hs._getCpuCoresStats(), + expected) +
class StatsCacheTests(TestCaseBase):
diff --git a/tests/vmfakelib.py b/tests/vmfakelib.py index 995508c..61ac448 100644 --- a/tests/vmfakelib.py +++ b/tests/vmfakelib.py @@ -240,3 +240,19 @@
def last(self): return self._samples + + +class CpuCoreSample(object): + + def __init__(self, samples): + self._samples = samples + + def getCoreSample(self, key): + return self._samples[key] + + +class HostSample(object): + + def __init__(self, timestamp, samples): + self.timestamp = timestamp + self.cpuCores = CpuCoreSample(samples)
automation@ovirt.org has posted comments on this change.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
Patch Set 1:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Francesco Romani has posted comments on this change.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
Patch Set 1: Verified+1
verified using 'make check'
automation@ovirt.org has posted comments on this change.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
Patch Set 2:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Dan Kenigsberg has posted comments on this change.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
Patch Set 2:
(1 comment)
https://gerrit.ovirt.org/#/c/41372/2/tests/samplingTests.py File tests/samplingTests.py:
Line 276: node_id, cpu_id = 0, 0 Line 277: self._hs = sampling.HostStatsThread(self.log) Line 278: cpu_sample = {'user': 1.0, 'sys': 2.0} Line 279: Line 280: for fake_ts in xrange(5): # FIXME please use
six.range()
in new code.
Please put a comment that is meaningful to others; I understand that you mean
# "5" is the side of the SampleWindow Line 281: self._hs._samples.append( Line 282: fake.HostSample(fake_ts, {cpu_id: cpu_sample})) Line 283: Line 284: def fakeNumaTopology():
Francesco Romani has posted comments on this change.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
Patch Set 2:
(1 comment)
https://gerrit.ovirt.org/#/c/41372/2/tests/samplingTests.py File tests/samplingTests.py:
Line 276: node_id, cpu_id = 0, 0 Line 277: self._hs = sampling.HostStatsThread(self.log) Line 278: cpu_sample = {'user': 1.0, 'sys': 2.0} Line 279: Line 280: for fake_ts in xrange(5): # FIXME
please use
Done Line 281: self._hs._samples.append( Line 282: fake.HostSample(fake_ts, {cpu_id: cpu_sample})) Line 283: Line 284: def fakeNumaTopology():
automation@ovirt.org has posted comments on this change.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
Patch Set 3:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Francesco Romani has posted comments on this change.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
Patch Set 3:
00:08:34.285 Traceback (most recent call last): 00:08:34.285 File "/tmp/run/vdsm/tests/samplingTests.py", line 285, in testCpuCoreStats 00:08:34.285 for fake_ts in six.range(5): 00:08:34.285 AttributeError: 'module' object has no attribute 'range'
automation@ovirt.org has posted comments on this change.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
Patch Set 4:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
Patch Set 5:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Francesco Romani has posted comments on this change.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
Patch Set 5: Verified+1
add new tests, so verified running the tests with 'make check'
automation@ovirt.org has posted comments on this change.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
Patch Set 6:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
Patch Set 7:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
Patch Set 8:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Dan Kenigsberg has posted comments on this change.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
Patch Set 8: Code-Review+2
automation@ovirt.org has posted comments on this change.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
Patch Set 9:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Francesco Romani has posted comments on this change.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
Patch Set 9: Verified+1
new tests. verified running make check
Dan Kenigsberg has submitted this change and it was merged.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
tests: add HostStatsThread._getCpuCoreStats test
Next patch wants to refactor HostStatsThread._getCpuCoreStats into a free function, so this patch adds very basic test coverage.
This test needs to be refactored as well, and will be done alongside the method refactoring.
Change-Id: I6c6a82c77054e76d7d08322ad83d086302c2bbad Signed-off-by: Francesco Romani fromani@redhat.com Reviewed-on: https://gerrit.ovirt.org/41372 Reviewed-by: Dan Kenigsberg danken@redhat.com Continuous-Integration: Jenkins CI --- M tests/samplingTests.py M tests/vmfakelib.py 2 files changed, 54 insertions(+), 0 deletions(-)
Approvals: Jenkins CI: Passed CI tests Dan Kenigsberg: Looks good to me, approved Francesco Romani: Verified
automation@ovirt.org has posted comments on this change.
Change subject: tests: add HostStatsThread._getCpuCoreStats test ......................................................................
Patch Set 10:
* Update tracker::IGNORE, no Bug-Url found * Set MODIFIED::IGNORE, no Bug-Url found.
vdsm-patches@lists.fedorahosted.org