forked from StackOps/stackops-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installTest.py
157 lines (120 loc) · 4.25 KB
/
installTest.py
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
# Copyright 2011 STACKOPS TECHNOLOGIES S.L.
#
# 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.
'''
Created on Feb 21, 2011
@author: Diego Parrilla
'''
import unittest
import sys
import os
import install
class PopulateTest(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def testPopulateXML(self):
f = install.Filler()
f.createNode(None)
pass
def testPopulateController(self):
f = install.Filler()
node = f.populateController('verbose',
'nodaemon',
'root',
'nova',
'mysql_host',
'3306',
'nova',
'nova.auth.dbdriver.DbDriver',
'/var/log/nova',
'/var/lib/nova',
's3_host',
's3_host_dmz',
'rabbitmq_host',
'ec2_host',
'ec2_dmz_host',
'nova.network.manager.VlanManager',
'192.168.0.0/12',
'5000',
'true')
node.export(sys.stdout,0)
pass
def testImportNode(self):
f = install.Filler()
node = f.importNode('test/test_conf.xml')
pass
class MachineTest(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def testCPUType(self):
c = install.Machine()
self.assertTrue(len(c.getCPUType())>0)
def testCPUCount(self):
c = install.Machine()
self.assertEqual(2,c.getCPUCount())
def testMachineType(self):
c = install.Machine()
self.assertEqual("x86_64",c.getMachine())
def testCPUSpeed(self):
c = install.Machine()
self.assertTrue(len(c.getCPUSpeed())>0)
def testMemoryAvailable(self):
c = install.Machine()
self.assertTrue(c.getMemoryAvailable()>0)
def testInterfacesList(self):
# now, use the function to get the 'up' interfaces array
c = install.Machine()
ifaces = c.getIfaceList()
# well, what to do? print it out maybe...
for iface in ifaces:
print iface
self.assertTrue(len(ifaces)>0)
def testBlockDevicesList(self):
c = install.Machine()
self.assertTrue(len(c.getBlockDeviceList())>0)
def testVirtualization(self):
iface = os.popen2("egrep '(vmx|svm)' /proc/cpuinfo")[1].read()
v = "False"
if len(iface)>0:
v = "True"
c = install.Machine()
self.assertTrue(v == c.getVirtualization())
class OperatingSystemTest(unittest.TestCase):
def setUp(self):
pass
def tearDown(self):
pass
def testGetUname(self):
c = install.OperatingSystem()
uname = c.getUname()
print uname[3]
self.assertNotEqual(0,len(uname[3]))
def testGetHostname(self):
c = install.OperatingSystem()
hostname = c.getHostname()
print hostname
self.assertNotEqual(0,len(hostname))
def testNameserver(self):
c = install.OperatingSystem()
nameservers = c.getNameservers()
print nameservers
self.assertNotEqual(0,nameservers)
def testNetworkConfiguration(self):
c = install.OperatingSystem()
nameservers = c.getNetworkConfiguration()
print nameservers
self.assertNotEqual(0,nameservers)