On Thu, Aug 22, 2013 at 12:16 PM, Thomas Thrainer <[email protected]>wrote:
> > > > On Thu, Aug 22, 2013 at 10:55 AM, Michele Tartara <[email protected]>wrote: > >> The function was not unit tested previously. >> >> Signed-off-by: Michele Tartara <[email protected]> >> --- >> Makefile.am | 2 + >> test/data/proc_cpuinfo.txt | 104 >> +++++++++++++++++++++++++++++++++ >> test/data/proc_meminfo.txt | 42 +++++++++++++ >> test/py/ganeti.hypervisor_unittest.py | 12 ++++ >> 4 files changed, 160 insertions(+) >> create mode 100644 test/data/proc_cpuinfo.txt >> create mode 100644 test/data/proc_meminfo.txt >> >> diff --git a/Makefile.am b/Makefile.am >> index 531197c..7aef305 100644 >> --- a/Makefile.am >> +++ b/Makefile.am >> @@ -1144,6 +1144,8 @@ TEST_FILES = \ >> test/data/proc_drbd83_sync.txt \ >> test/data/proc_drbd83_sync_want.txt \ >> test/data/proc_drbd83_sync_krnl2.6.39.txt \ >> + test/data/proc_meminfo.txt \ >> + test/data/proc_cpuinfo.txt \ >> test/data/qa-minimal-nodes-instances-only.json \ >> test/data/sys_drbd_usermode_helper.txt \ >> test/data/vgreduce-removemissing-2.02.02.txt \ >> diff --git a/test/data/proc_cpuinfo.txt b/test/data/proc_cpuinfo.txt >> new file mode 100644 >> index 0000000..4637a5a >> --- /dev/null >> +++ b/test/data/proc_cpuinfo.txt >> @@ -0,0 +1,104 @@ >> +processor : 0 >> +vendor_id : GenuineIntel >> +cpu family : 6 >> +model : 58 >> +model name : Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz >> +stepping : 9 >> +microcode : 0x13 >> +cpu MHz : 1200.000 >> +cache size : 3072 KB >> +physical id : 0 >> +siblings : 4 >> +core id : 0 >> +cpu cores : 2 >> +apicid : 0 >> +initial apicid : 0 >> +fpu : yes >> +fpu_exception : yes >> +cpuid level : 13 >> +wp : yes >> +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge >> mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall >> nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology >> nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 >> ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer >> aes xsave avx f16c rdrand lahf_lm ida arat epb xsaveopt pln pts dtherm >> tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms >> +bogomips : 5188.22 >> +clflush size : 64 >> +cache_alignment : 64 >> +address sizes : 36 bits physical, 48 bits virtual >> +power management: >> + >> +processor : 1 >> +vendor_id : GenuineIntel >> +cpu family : 6 >> +model : 58 >> +model name : Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz >> +stepping : 9 >> +microcode : 0x13 >> +cpu MHz : 1200.000 >> +cache size : 3072 KB >> +physical id : 0 >> +siblings : 4 >> +core id : 0 >> +cpu cores : 2 >> +apicid : 1 >> +initial apicid : 1 >> +fpu : yes >> +fpu_exception : yes >> +cpuid level : 13 >> +wp : yes >> +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge >> mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall >> nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology >> nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 >> ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer >> aes xsave avx f16c rdrand lahf_lm ida arat epb xsaveopt pln pts dtherm >> tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms >> +bogomips : 5188.22 >> +clflush size : 64 >> +cache_alignment : 64 >> +address sizes : 36 bits physical, 48 bits virtual >> +power management: >> + >> +processor : 2 >> +vendor_id : GenuineIntel >> +cpu family : 6 >> +model : 58 >> +model name : Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz >> +stepping : 9 >> +microcode : 0x13 >> +cpu MHz : 1200.000 >> +cache size : 3072 KB >> +physical id : 0 >> +siblings : 4 >> +core id : 1 >> +cpu cores : 2 >> +apicid : 2 >> +initial apicid : 2 >> +fpu : yes >> +fpu_exception : yes >> +cpuid level : 13 >> +wp : yes >> +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge >> mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall >> nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology >> nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 >> ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer >> aes xsave avx f16c rdrand lahf_lm ida arat epb xsaveopt pln pts dtherm >> tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms >> +bogomips : 5188.22 >> +clflush size : 64 >> +cache_alignment : 64 >> +address sizes : 36 bits physical, 48 bits virtual >> +power management: >> + >> +processor : 3 >> +vendor_id : GenuineIntel >> +cpu family : 6 >> +model : 58 >> +model name : Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz >> +stepping : 9 >> +microcode : 0x13 >> +cpu MHz : 1200.000 >> +cache size : 3072 KB >> +physical id : 0 >> +siblings : 4 >> +core id : 1 >> +cpu cores : 2 >> +apicid : 3 >> +initial apicid : 3 >> +fpu : yes >> +fpu_exception : yes >> +cpuid level : 13 >> +wp : yes >> +flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge >> mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall >> nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology >> nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 >> ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer >> aes xsave avx f16c rdrand lahf_lm ida arat epb xsaveopt pln pts dtherm >> tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms >> +bogomips : 5188.22 >> +clflush size : 64 >> +cache_alignment : 64 >> +address sizes : 36 bits physical, 48 bits virtual >> +power management: >> + >> diff --git a/test/data/proc_meminfo.txt b/test/data/proc_meminfo.txt >> new file mode 100644 >> index 0000000..c3a80fb >> --- /dev/null >> +++ b/test/data/proc_meminfo.txt >> @@ -0,0 +1,42 @@ >> +MemTotal: 7870584 kB >> +MemFree: 1549012 kB >> +Buffers: 227328 kB >> +Cached: 4647780 kB >> +SwapCached: 2988 kB >> +Active: 2787880 kB >> +Inactive: 3160328 kB >> +Active(anon): 1951852 kB >> +Inactive(anon): 2007648 kB >> +Active(file): 836028 kB >> +Inactive(file): 1152680 kB >> +Unevictable: 36 kB >> +Mlocked: 32 kB >> +SwapTotal: 8077308 kB >> +SwapFree: 8029968 kB >> +Dirty: 84 kB >> +Writeback: 0 kB >> +AnonPages: 1070164 kB >> +Mapped: 194876 kB >> +Shmem: 2886396 kB >> +Slab: 226092 kB >> +SReclaimable: 169140 kB >> +SUnreclaim: 56952 kB >> +KernelStack: 4232 kB >> +PageTables: 40184 kB >> +NFS_Unstable: 0 kB >> +Bounce: 0 kB >> +WritebackTmp: 0 kB >> +CommitLimit: 12012600 kB >> +Committed_AS: 7618508 kB >> +VmallocTotal: 34359738367 kB >> +VmallocUsed: 374800 kB >> +VmallocChunk: 34359352560 kB >> +HardwareCorrupted: 0 kB >> +AnonHugePages: 0 kB >> +HugePages_Total: 0 >> +HugePages_Free: 0 >> +HugePages_Rsvd: 0 >> +HugePages_Surp: 0 >> +Hugepagesize: 2048 kB >> +DirectMap4k: 96448 kB >> +DirectMap2M: 7983104 kB >> diff --git a/test/py/ganeti.hypervisor_unittest.py b/test/py/ >> ganeti.hypervisor_unittest.py >> index 1d3e524..88b82bc 100755 >> --- a/test/py/ganeti.hypervisor_unittest.py >> +++ b/test/py/ganeti.hypervisor_unittest.py >> @@ -57,6 +57,18 @@ class TestBase(unittest.TestCase): >> self.assertEqual(fn(["a"]), "a") >> self.assertEqual(fn(["a", "b"]), "a; b") >> >> + def testGetLinuxNodeInfo(self): >> + meminfo = testutils.TestDataFilename("proc_meminfo.txt") >> + cpuinfo = testutils.TestDataFilename("proc_cpuinfo.txt") >> + result = hv_base.BaseHypervisor.GetLinuxNodeInfo(meminfo, cpuinfo) >> + print result >> > > Is this for debugging or actually required? > Uh, good spot! Of course it was only for debugging. I'll remove it before submitting. > > >> + self.assertEqual(result["memory_total"], 7686) >> + self.assertEqual(result["memory_free"], 6272) >> + self.assertEqual(result["memory_dom0"], 2722) >> + self.assertEqual(result["cpu_total"], 4) >> + self.assertEqual(result["cpu_nodes"], 1) >> + self.assertEqual(result["cpu_sockets"], 1) >> + >> >> if __name__ == "__main__": >> testutils.GanetiTestProgram() >> -- >> 1.7.10.4 >> >> > > > -- > Thomas Thrainer | Software Engineer | [email protected] | > > Google Germany GmbH > Dienerstr. 12 > 80331 München > > Registergericht und -nummer: Hamburg, HRB 86891 > Sitz der Gesellschaft: Hamburg > Geschäftsführer: Graham Law, Christine Elizabeth Flores > Thanks, Michele -- Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores
