Пример #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'],
                                         self._EXPECTED_KEYS)
Пример #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'],
                                         self._EXPECTED_KEYS)
Пример #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',
                        is_hostdevice=False), )
        vm = FakeVM(nics=nics)

        stats = {}
        assert vmstats.networks(vm, stats, self.bulk_stats, self.bulk_stats,
                                0) is None
Пример #5
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
        )
Пример #6
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))
Пример #7
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)
        )