Esempio n. 1
0
    def test_sample_host_perfdata_invlidStatus(self):
        self.createInvCache(True)
        old_stats = self.createfake_oldStats()
        new_stats = self.createfake_newStats(True, True)
        new_stats_forhost = self.createfake_newStats_forhost(False)
        LibvirtPerfMonitor.update_perfdata_InCache(
            self.vmhost_id,
            None, new_stats_forhost)
        LibvirtPerfMonitor.update_perfdata_InCache(
            self.vm_id,
            old_stats, new_stats)

        resource_util = self.sample_perfdata.sample_host_perfdata(
            self.vmhost_id,
            5)

        self.assertNotEquals(self.libvirtPerf_monitor.get_perfdata_fromCache(
            self.vm_id, Constants.NEW_STATS), None)
        self.assertNotEquals(self.libvirtPerf_monitor.get_perfdata_fromCache(
            self.vm_id, Constants.OLD_STATS), None)

        self.assertNotEquals(self.sample_perfdata.resource_utilization,
                             None)
        self.assertEquals(resource_util.get_status(), 0)
        self.assertEquals(resource_util.get_totalMemory(), 0)
        self.assertEquals(resource_util.get_freeMemory(), 0)
Esempio n. 2
0
    def test_sample_host_perfdata_Disconnected(self):
        self.createInvCache(True, hostconnection='Disconnected')
        new_stats = self.createfake_newStats(False, True)
        LibvirtPerfMonitor.update_perfdata_InCache(self.vm_id, None, new_stats)

        resource_util = self.sample_perfdata.sample_host_perfdata(
            self.vmhost_id, 5)

        self.assertEquals(resource_util.get_status(), -1)
Esempio n. 3
0
    def test_sample_vm_perfdata_notsampled(self):
        self.createInvCache(True)
        new_stats = self.createfake_newStats(False, True)
        LibvirtPerfMonitor.update_perfdata_InCache(self.vm_id, None, new_stats)

        resource_util = \
            self.sample_perfdata.sample_vm_perfdata(
                self.vm_id,
                5)

        self.assertEquals(resource_util.get_status(), -1)
Esempio n. 4
0
    def test_sample_host_perfdata_Disconnected(self):
        self.createInvCache(True, hostconnection='Disconnected')
        new_stats = self.createfake_newStats(False, True)
        LibvirtPerfMonitor.update_perfdata_InCache(
            self.vm_id,
            None, new_stats)

        resource_util = self.sample_perfdata.sample_host_perfdata(
            self.vmhost_id,
            5)

        self.assertEquals(resource_util.get_status(), -1)
Esempio n. 5
0
    def test_sample_vm_perfdata_notsampled(self):
        self.createInvCache(True)
        new_stats = self.createfake_newStats(False, True)
        LibvirtPerfMonitor.update_perfdata_InCache(
            self.vm_id,
            None, new_stats)

        resource_util = \
            self.sample_perfdata.sample_vm_perfdata(
                self.vm_id,
                5)

        self.assertEquals(resource_util.get_status(), -1)
    def test_sample_hostcpu_perfdata_notsampled(self):
        self.createInvCache(True)
        new_stats_forhost = self.createfake_newStats_forhost()
        LibvirtPerfMonitor.update_perfdata_InCache(
            self.vmhost_id,
            None, new_stats_forhost)

        resource_util = \
            self.sample_perfdata.sample_host_perfdata(
                self.vmhost_id,
                5)

        self.assertEquals(resource_util.get_status(), -1)
Esempio n. 7
0
    def test_sample_host_perfdata_vmnotRunning(self):
        self.createInvCache(False)
        new_stats = self.createfake_newStats(False, True)
        new_stats_forhost = self.createfake_newStats_forhost()
        LibvirtPerfMonitor.update_perfdata_InCache(self.vmhost_id, None,
                                                   new_stats_forhost)

        LibvirtPerfMonitor.update_perfdata_InCache(self.vm_id, None, new_stats)

        resource_util = self.sample_perfdata.sample_host_perfdata(
            self.vmhost_id, 5)

        self.assertEquals(resource_util.get_status(), 0)
Esempio n. 8
0
    def test_sample_vm_perfdata_negativeStats(self):
        self.createInvCache(True)
        old_stats = self.createfake_oldStats()
        new_stats = self.createfake_newStats_nochange(False, True)
        LibvirtPerfMonitor.update_perfdata_InCache(self.vm_id, old_stats,
                                                   new_stats)

        resource_util = \
            self.sample_perfdata.sample_vm_perfdata(
                self.vm_id,
                5)

        self.assertEquals(resource_util.get_status(), 0)
Esempio n. 9
0
    def test_sample_vm_perfdata_negativeStats(self):
        self.createInvCache(True)
        old_stats = self.createfake_oldStats()
        new_stats = self.createfake_newStats_nochange(False, True)
        LibvirtPerfMonitor.update_perfdata_InCache(
            self.vm_id,
            old_stats, new_stats)

        resource_util = \
            self.sample_perfdata.sample_vm_perfdata(
                self.vm_id,
                5)

        self.assertEquals(resource_util.get_status(), 0)
Esempio n. 10
0
    def test_sample_vm_perfdata_notRunning(self):
        self.createInvCache(False)
        old_stats = self.createfake_oldStats()
        new_stats = self.createfake_newStats(False, False)
        LibvirtPerfMonitor.update_perfdata_InCache(self.vm_id, old_stats,
                                                   new_stats)

        resource_util = \
            self.sample_perfdata.sample_vm_perfdata(
                self.vm_id,
                5)

        self.assertEquals(resource_util.get_status(), -1)

        self.assertEquals(len(self.libvirtPerf_monitor.perfDataCache), 1)
Esempio n. 11
0
    def test_sample_host_perfdata_vmnotRunning(self):
        self.createInvCache(False)
        new_stats = self.createfake_newStats(False, True)
        new_stats_forhost = self.createfake_newStats_forhost()
        LibvirtPerfMonitor.update_perfdata_InCache(
            self.vmhost_id,
            None, new_stats_forhost)

        LibvirtPerfMonitor.update_perfdata_InCache(
            self.vm_id,
            None, new_stats)

        resource_util = self.sample_perfdata.sample_host_perfdata(
            self.vmhost_id,
            5)

        self.assertEquals(resource_util.get_status(), 0)
Esempio n. 12
0
    def test_sample_vm_perfdata_notRunning(self):
        self.createInvCache(False)
        old_stats = self.createfake_oldStats()
        new_stats = self.createfake_newStats(False, False)
        LibvirtPerfMonitor.update_perfdata_InCache(
            self.vm_id,
            old_stats, new_stats)

        resource_util = \
            self.sample_perfdata.sample_vm_perfdata(
                self.vm_id,
                5)

        self.assertEquals(resource_util.get_status(), -1)

        self.assertEquals(len(self.libvirtPerf_monitor.perfDataCache),
                          1)
    def test_sample_vm_perfdata(self):
        self.createInvCache(True)
        old_stats = self.createfake_oldStats()
        new_stats = self.createfake_newStats()
        LibvirtPerfMonitor.update_perfdata_InCache(
            self.vm_id,
            old_stats, new_stats)

        resource_util = \
            self.sample_perfdata.sample_vm_perfdata(
                self.vm_id,
                5)

        self.assertNotEquals(self.sample_perfdata.resource_utilization,
                             None)
        self.assertEquals(resource_util.get_status(), 0)
        self._assert(resource_util)
Esempio n. 14
0
    def test_sample_host_perfdata(self):
        self.createInvCache(True)
        old_stats = self.createfake_oldStats()
        new_stats = self.createfake_newStats(True, True)
        new_stats_forhost = self.createfake_newStats_forhost()
        LibvirtPerfMonitor.update_perfdata_InCache(self.vmhost_id, None,
                                                   new_stats_forhost)
        LibvirtPerfMonitor.update_perfdata_InCache(self.vm_id, old_stats,
                                                   new_stats)

        resource_util = self.sample_perfdata.sample_host_perfdata(
            self.vmhost_id, 5)

        self.assertNotEquals(
            self.libvirtPerf_monitor.get_perfdata_fromCache(
                self.vm_id, Constants.NEW_STATS), None)
        self.assertNotEquals(
            self.libvirtPerf_monitor.get_perfdata_fromCache(
                self.vm_id, Constants.OLD_STATS), None)

        self.assertNotEquals(self.sample_perfdata.resource_utilization, None)
        self.assertEquals(resource_util.get_status(), 0)
        self._assert(resource_util)