File: test_vios.py

package info (click to toggle)
python-pypowervm 1.1.16%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 7,356 kB
  • sloc: python: 29,449; xml: 174; makefile: 21; sh: 14
file content (167 lines) | stat: -rw-r--r-- 6,302 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# Copyright 2015 IBM Corp.
#
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

"""Tests for the raw VIOS long term metrics."""

import testtools

from pypowervm.tests.test_utils import pvmhttp
from pypowervm.wrappers.pcm import vios as pcm_vios

VIOS_DATA = 'vios_pcm_data.txt'
VIOS_DATA_SPARSE = 'vios_pcm_data_sparse.txt'


class TestViosLTM(testtools.TestCase):

    def setUp(self):
        super(TestViosLTM, self).setUp()

        self.raw_json = pvmhttp.PVMFile(VIOS_DATA).body

    def test_parse(self):
        info = pcm_vios.ViosInfo(self.raw_json)
        self.assertIsNotNone(info)

        # Validate the info
        self.assertEqual('1.0.0', info.info.version)
        self.assertEqual('Raw', info.info.metric_type)
        self.assertEqual('LTM', info.info.monitoring_type)
        self.assertEqual('8247-22L*2125D4A', info.info.mtms)

        # Validate some samples
        sample = info.sample
        self.assertEqual(u'2015-05-27T00:22:00+0000', sample.time_stamp)
        self.assertEqual(1, sample.id)
        self.assertEqual('IOServer - SN2125D4A', sample.name)

        # Validate Memory
        self.assertEqual(1715, sample.mem.utilized_mem)

        # Validate the Network
        self.assertEqual(6, len(sample.network.adpts))
        self.assertEqual(1, len(sample.network.seas))

        phys_dev = sample.network.adpts[1]
        self.assertEqual('ent0', phys_dev.name)
        self.assertEqual('physical', phys_dev.type)
        self.assertEqual('U78CB.001.WZS007Y-P1-C10-T1',
                         phys_dev.physical_location)
        self.assertEqual(1703083, phys_dev.received_packets)
        self.assertEqual(65801, phys_dev.sent_packets)
        self.assertEqual(0, phys_dev.dropped_packets)
        self.assertEqual(187004823, phys_dev.received_bytes)
        self.assertEqual(71198950, phys_dev.sent_bytes)

        # SEA validation
        sea = sample.network.seas[0]
        self.assertEqual('ent6', sea.name)
        self.assertEqual('sea', sea.type)
        self.assertEqual('U8247.22L.2125D4A-V1-C12-T1', sea.physical_location)
        self.assertEqual(0, sea.received_packets)
        self.assertEqual(0, sea.sent_packets)
        self.assertEqual(0, sea.dropped_packets)
        self.assertEqual(0, sea.received_bytes)
        self.assertEqual(0, sea.sent_bytes)
        self.assertEqual(['ent3', 'ent5'], sea.bridged_adpts)

        # Storage - FC Validation
        fc = sample.storage.fc_adpts[0]
        self.assertEqual('fcs0', fc.name)
        self.assertEqual('21000024ff649104', fc.wwpn)
        self.assertEqual('U78CB.001.WZS007Y-P1-C3-T1', fc.physical_location)
        self.assertEqual(0, fc.num_reads)
        self.assertEqual(0, fc.num_writes)
        self.assertEqual(0, fc.read_bytes)
        self.assertEqual(0, fc.write_bytes)
        self.assertEqual(8, fc.running_speed)

        # VFC Validation
        vfc = sample.storage.fc_adpts[1].ports[0]
        self.assertEqual("vfc1", vfc.name)
        self.assertEqual("21000024ff649159", vfc.wwpn)
        self.assertEqual(1234, vfc.num_reads)
        self.assertEqual(1235, vfc.num_writes)
        self.assertEqual(184184, vfc.read_bytes)
        self.assertEqual(138523, vfc.write_bytes)
        self.assertEqual(8, vfc.running_speed)
        self.assertEqual("U78CB.001.WZS007Y-P1-C3-T2000",
                         vfc.physical_location)

        # Physical Adpt Validation
        padpt = sample.storage.phys_adpts[0]
        self.assertEqual('sissas0', padpt.name)
        self.assertEqual('U78CB.001.WZS007Y-P1-C14-T1',
                         padpt.physical_location)
        self.assertEqual(1089692, padpt.num_reads)
        self.assertEqual(1288936, padpt.num_writes)
        self.assertEqual(557922304, padpt.read_bytes)
        self.assertEqual(659935232, padpt.write_bytes)
        self.assertEqual('sas', padpt.type)

        # Storage Virtual Adapter Validation
        vadpt = sample.storage.virt_adpts[0]
        self.assertEqual('vhost5', vadpt.name)
        self.assertEqual('U8247.22L.2125D4A-V1-C7', vadpt.physical_location)
        self.assertEqual(0, vadpt.num_reads)
        self.assertEqual(1, vadpt.num_writes)
        self.assertEqual(0, vadpt.read_bytes)
        self.assertEqual(512, vadpt.write_bytes)
        self.assertEqual('virtual', vadpt.type)

        # SSP Validation
        ssp = sample.storage.ssps[0]
        self.assertEqual('ssp1', ssp.name)
        self.assertEqual(["sissas0"], ssp.pool_disks)
        self.assertEqual(12346, ssp.num_reads)
        self.assertEqual(17542, ssp.num_writes)
        self.assertEqual(18352435, ssp.total_space)
        self.assertEqual(123452, ssp.used_space)
        self.assertEqual(123825, ssp.read_bytes)
        self.assertEqual(375322, ssp.write_bytes)


class TestViosLTMSparse(testtools.TestCase):

    def setUp(self):
        super(TestViosLTMSparse, self).setUp()

        self.raw_json = pvmhttp.PVMFile(VIOS_DATA_SPARSE).body

    def test_parse(self):
        info = pcm_vios.ViosInfo(self.raw_json)
        self.assertIsNotNone(info)

        # Validate the info
        self.assertEqual('1.0.0', info.info.version)
        self.assertEqual('Raw', info.info.metric_type)
        self.assertEqual('LTM', info.info.monitoring_type)
        self.assertEqual('8247-22L*2125D4A', info.info.mtms)

        # Validate some samples
        sample = info.sample
        self.assertEqual(u'2015-05-27T00:22:00+0000', sample.time_stamp)
        self.assertEqual(1, sample.id)
        self.assertEqual('IOServer - SN2125D4A', sample.name)

        # Validate Memory
        self.assertIsNone(sample.mem)

        # Validate the Network
        self.assertIsNone(sample.network)

        # Validate the Storage
        self.assertIsNone(sample.storage)