예제 #1
0
    def test_networks_have_all_keys(self):
        nics = (FakeNic(name='vnet0',
                        model='virtio',
                        mac_addr='00:1a:4a:16:01:51'), )
        vm = FakeVM(nics=nics)

        stats = {}
        vmstats.networks(vm, stats, self.bulk_stats, self.bulk_stats,
                         self.interval)
        self.assertRepeatedStatsHaveKeys(nics, stats['network'])
예제 #2
0
    def test_networks_have_all_keys(self):
        nics = (
            FakeNic(name='vnet0', model='virtio',
                    mac_addr='00:1a:4a:16:01:51'),
        )
        vm = FakeVM(nics=nics)

        stats = {}
        vmstats.networks(vm, stats,
                         self.bulk_stats, self.bulk_stats,
                         self.interval)
        self.assertRepeatedStatsHaveKeys(nics, stats['network'])
예제 #3
0
    def test_networks_good_interval(self):
        nics = (FakeNic(name='vnet0',
                        model='virtio',
                        mac_addr='00:1a:4a:16:01:51'), )
        vm = FakeVM(nics=nics)

        stats = {}
        self.assertTrue(
            vmstats.networks(vm, stats, self.bulk_stats, self.bulk_stats, 1))
예제 #4
0
    def test_networks_bad_interval(self, interval):
        nics = (
            FakeNic(name='vnet0', model='virtio',
                    mac_addr='00:1a:4a:16:01:51'),
        )
        vm = FakeVM(nics=nics)

        stats = {}
        self.assertTrue(
            vmstats.networks(vm, stats,
                             self.bulk_stats, self.bulk_stats,
                             0) is None
        )
예제 #5
0
    def test_networks_missing_key(self, key):
        nics = (
            FakeNic(name='vnet0', model='virtio',
                    mac_addr='00:1a:4a:16:01:51'),
        )
        vm = FakeVM(nics=nics)
        vm.migrationPending = True

        faulty_bulk_stats = {}
        faulty_bulk_stats.update(self.bulk_stats)
        del faulty_bulk_stats[key]

        stats = {}
        self.assertTrue(
            vmstats.networks(vm, stats,
                             self.bulk_stats, faulty_bulk_stats,
                             1)
        )