3030#Import System modules
3131import time
3232
33- #ENABLE THE QUOTA PLUGIN AND RESTART THE MANAGEMENT SERVER TO RUN QUOTA TESTS
34-
3533class TestQuota (cloudstackTestCase ):
3634
35+ @classmethod
36+ def setUpClass (cls ):
37+ # Create Account
38+ testClient = super (TestQuota , cls ).getClsTestClient ()
39+ cls .apiclient = testClient .getApiClient ()
40+ cls .services = testClient .getParsedTestDataConfig ()
41+
42+ # Get Zone, Domain
43+ cls .domain = get_domain (cls .apiclient )
44+ cls .zone = get_zone (cls .apiclient , cls .testClient .getZoneForTests ())
45+
46+ # Create Account
47+ cls .account = Account .create (
48+ cls .apiclient ,
49+ cls .services ["account" ],
50+ domainid = cls .domain .id
51+ )
52+ cls ._cleanup = [
53+ cls .account ,
54+ ]
55+ return
56+
3757 def setUp (self ):
3858 self .apiclient = self .testClient .getApiClient ()
3959 self .hypervisor = self .testClient .getHypervisorInfo ()
@@ -55,6 +75,12 @@ def tearDown(self):
5575 #Check quotaTariffList API returning 22 items
5676 @attr (tags = ["smoke" , "advanced" ], required_hardware = "false" )
5777 def test_01_quota (self ):
78+ if not is_config_suitable (
79+ apiclient = self .apiclient ,
80+ name = 'quota.enable.service' ,
81+ value = 'true' ):
82+ self .skipTest ('quota.enable.service should be true. skipping' )
83+
5884 cmd = quotaTariffList .quotaTariffListCmd ()
5985 response = self .apiclient .quotaTariffList (cmd )
6086
@@ -75,6 +101,12 @@ def test_01_quota(self):
75101 #Check quota tariff on a particualr day
76102 @attr (tags = ["smoke" , "advanced" ], required_hardware = "false" )
77103 def test_02_quota (self ):
104+ if not is_config_suitable (
105+ apiclient = self .apiclient ,
106+ name = 'quota.enable.service' ,
107+ value = 'true' ):
108+ self .skipTest ('quota.enable.service should be true. skipping' )
109+
78110 cmd = quotaTariffList .quotaTariffListCmd ()
79111 cmd .startdate = '2015-07-06'
80112 response = self .apiclient .quotaTariffList (cmd )
@@ -89,6 +121,12 @@ def test_02_quota(self):
89121 #check quota tariff of a particular item
90122 @attr (tags = ["smoke" , "advanced" ], required_hardware = "false" )
91123 def test_03_quota (self ):
124+ if not is_config_suitable (
125+ apiclient = self .apiclient ,
126+ name = 'quota.enable.service' ,
127+ value = 'true' ):
128+ self .skipTest ('quota.enable.service should be true. skipping' )
129+
92130 cmd = quotaTariffList .quotaTariffListCmd ()
93131 cmd .startdate = '2015-07-06'
94132 cmd .usagetype = '10'
@@ -107,6 +145,12 @@ def test_03_quota(self):
107145 #check the old tariff it should be same
108146 @attr (tags = ["smoke" , "advanced" ], required_hardware = "false" )
109147 def test_04_quota (self ):
148+ if not is_config_suitable (
149+ apiclient = self .apiclient ,
150+ name = 'quota.enable.service' ,
151+ value = 'true' ):
152+ self .skipTest ('quota.enable.service should be true. skipping' )
153+
110154 cmd = quotaTariffList .quotaTariffListCmd ()
111155 cmd .startdate = '2015-07-06'
112156 cmd .usagetype = '10'
@@ -157,9 +201,15 @@ def test_04_quota(self):
157201 #Make credit deposit
158202 @attr (tags = ["smoke" , "advanced" ], required_hardware = "false" )
159203 def test_05_quota (self ):
204+ if not is_config_suitable (
205+ apiclient = self .apiclient ,
206+ name = 'quota.enable.service' ,
207+ value = 'true' ):
208+ self .skipTest ('quota.enable.service should be true. skipping' )
209+
160210 cmd = quotaCredits .quotaCreditsCmd ()
161- cmd .domainid = '1'
162- cmd .account = 'admin'
211+ cmd .domainid = self . account . domainid
212+ cmd .account = self . account . name
163213 cmd .value = '10'
164214 cmd .quota_enforce = '1'
165215 cmd .min_balance = '9'
@@ -173,32 +223,45 @@ def test_05_quota(self):
173223 #Make credit deposit and check today balance
174224 @attr (tags = ["smoke" , "advanced" ], required_hardware = "false" )
175225 def test_06_quota (self ):
226+ if not is_config_suitable (
227+ apiclient = self .apiclient ,
228+ name = 'quota.enable.service' ,
229+ value = 'true' ):
230+ self .skipTest ('quota.enable.service should be true. skipping' )
231+
176232 cmd = quotaBalance .quotaBalanceCmd ()
177233 today = datetime .date .today ()
178- cmd .domainid = '1'
179- cmd .account = 'admin'
234+ cmd .domainid = self . account . domainid
235+ cmd .account = self . account . name
180236 cmd .startdate = today
181237 response = self .apiclient .quotaBalance (cmd )
182238
183239 self .debug ("Quota Balance on: %s" % response .startdate )
184240 self .debug ("is: %s" % response .startquota )
185241
186- self .assertGreater ( response .startquota , 9 )
242+ self .assertEqual ( response .startquota , 10 )
187243 return
188244
189245 #make credit deposit and check start and end date balances
190246 @attr (tags = ["smoke" , "advanced" ], required_hardware = "false" )
191247 def test_07_quota (self ):
248+ if not is_config_suitable (
249+ apiclient = self .apiclient ,
250+ name = 'quota.enable.service' ,
251+ value = 'true' ):
252+ self .skipTest ('quota.enable.service should be true. skipping' )
253+
192254 cmd = quotaBalance .quotaBalanceCmd ()
193255 today = datetime .date .today ()
194- cmd .domainid = '1'
195- cmd .account = 'admin'
256+ cmd .domainid = self . account . domainid
257+ cmd .account = self . account . name
196258 cmd .startdate = today - datetime .timedelta (days = 2 )
197- cmd .enddate = today
259+ cmd .enddate = today
198260 response = self .apiclient .quotaBalance (cmd )
199261
200262 self .debug ("Quota Balance on: %s" % response .startdate )
201263 self .debug ("is: %s" % response .startquota )
202264
203- self .assertGreater ( response .endquota , 9 )
265+ self .assertEqual ( response .startquota , 0 )
266+ self .assertEqual ( response .endquota , 10 )
204267 return
0 commit comments