Revision b773795c kamaki/clients/livetest/cyclades.py

b/kamaki/clients/livetest/cyclades.py
160 160

  
161 161
    def _has_status(self, servid, status):
162 162
        r = self.client.get_server_details(servid)
163
        #print 'MY STATUS IS ', r['status']
163
        #print 'MY ', servid, ' STATUS IS ', r['status']
164 164
        return r['status'] == status
165 165

  
166 166
    def _wait_for_status(self, servid, status):
167 167
        (wait_bar, wait_cb) = self._safe_progress_bar(
168 168
            'Server %s in %s' % (servid, status))
169
        self.client.wait_server(servid, status, wait_cb=wait_cb)
169
        self.client.wait_server(servid, status, wait_cb=wait_cb, delay=5)
170 170
        self._safe_progress_bar_finish(wait_bar)
171 171

  
172 172
    def test_parallel_creation(self):
......
174 174
        Do not use this in regular livetest
175 175
        """
176 176
        from kamaki.clients import SilentEvent
177
        c1 = SilentEvent(
178
            self._create_server,
179
            self.servname1,
180
            self.flavorid,
181
            self.img)
182
        c2 = SilentEvent(
183
            self._create_server,
184
            self.servname2,
185
            self.flavorid,
186
            self.img)
187
        c3 = SilentEvent(
188
            self._create_server,
189
            self.servname1,
190
            self.flavorid,
191
            self.img)
192
        c4 = SilentEvent(
193
            self._create_server,
194
            self.servname2,
195
            self.flavorid,
196
            self.img)
197
        c5 = SilentEvent(
198
            self._create_server,
199
            self.servname1,
200
            self.flavorid,
201
            self.img)
202
        c6 = SilentEvent(
203
            self._create_server,
204
            self.servname2,
205
            self.flavorid,
206
            self.img)
207
        c7 = SilentEvent(
208
            self._create_server,
209
            self.servname1,
210
            self.flavorid,
211
            self.img)
212
        c8 = SilentEvent(
213
            self._create_server,
214
            self.servname2,
215
            self.flavorid,
216
            self.img)
217
        c1.start()
218
        c2.start()
219
        c3.start()
220
        c4.start()
221
        c5.start()
222
        c6.start()
223
        c7.start()
224
        c8.start()
177
        c = []
178
        for i in range(8):
179
            sname = '%s_%s' % (self.servname1, i)
180
            c.append(SilentEvent(
181
                self._create_server, sname, self.flavorid, self.img))
182
        for i in range(8):
183
            c[i].start()
225 184

  
226 185
    def test_create_server(self):
227 186
        """Test create_server"""
228 187
        self.server1 = self._create_server(
229
            self.servname1,
230
            self.flavorid,
231
            self.img)
188
            self.servname1, self.flavorid, self.img)
232 189
        self._wait_for_status(self.server1['id'], 'BUILD')
233 190
        self._test_0010_create_server()
234 191

  
......
241 198
    def test_list_servers(self):
242 199
        """Test list servers"""
243 200
        self.server1 = self._create_server(
244
            self.servname1,
245
            self.flavorid,
246
            self.img)
201
            self.servname1, self.flavorid, self.img)
247 202
        self.server2 = self._create_server(
248
            self.servname2,
249
            self.flavorid,
250
            self.img)
203
            self.servname2, self.flavorid, self.img)
251 204
        self._test_0020_list_servers()
252 205

  
253 206
    def _test_0020_list_servers(self):
......
256 209

  
257 210
        """detailed and simple are same size"""
258 211
        self.assertEqual(len(dservers), len(servers))
259
        for i in range(len(servers)):
260
            for field in (
261
                    'created',
262
                    'flavor',
263
                    'hostId',
264
                    'image',
265
                    'progress',
266
                    'status',
267
                    'updated'):
268
                self.assertFalse(field in servers[i])
269
                self.assertTrue(field in dservers[i])
212
        fields = set([
213
            'created', 'flavor', 'hostId', 'image', 'progress', 'status',
214
            'updated'])
215
        for i, srv in enumerate(servers):
216
            self.assertTrue(fields.isdisjoint(srv))
217
            self.assertTrue(fields.issubset(dservers[i]))
270 218

  
271 219
        """detailed and simple contain same names"""
272 220
        names = sorted(map(lambda x: x["name"], servers))
......
282 230
    def test_get_server_details(self):
283 231
        """Test get_server_details"""
284 232
        self.server1 = self._create_server(
285
            self.servname1,
286
            self.flavorid,
287
            self.img)
233
            self.servname1, self.flavorid, self.img)
288 234
        self._wait_for_status(self.server1['id'], 'BUILD')
289 235
        self._test_0040_get_server_details()
290 236

  
......
298 244
    def test_update_server_name(self):
299 245
        """Test update_server_name"""
300 246
        self.server1 = self._create_server(
301
            self.servname1,
302
            self.flavorid,
303
            self.img)
247
            self.servname1, self.flavorid, self.img)
304 248
        self._test_0050_update_server_name()
305 249

  
306 250
    def _test_0050_update_server_name(self):
307 251
        new_name = self.servname1 + '_new_name'
308 252
        self.client.update_server_name(self.server1['id'], new_name)
309 253
        r = self.client.get_server_details(
310
            self.server1['id'],
311
            success=(200, 400))
254
            self.server1['id'], success=(200, 400))
312 255
        self.assertEqual(r['name'], new_name)
313 256
        changed = self.servers.pop(self.servname1)
314 257
        changed['name'] = new_name
......
317 260
    def test_reboot_server(self):
318 261
        """Test reboot server"""
319 262
        self.server1 = self._create_server(
320
            self.servname1,
321
            self.flavorid,
322
            self.img)
263
            self.servname1, self.flavorid, self.img)
323 264
        self._wait_for_status(self.server1['id'], 'BUILD')
324 265
        self.server2 = self._create_server(
325
            self.servname2,
326
            self.flavorid + 1,
327
            self.img)
266
            self.servname2, self.flavorid + 2, self.img)
328 267
        self._wait_for_status(self.server2['id'], 'BUILD')
329 268
        self._test_0060_reboot_server()
330 269
        self._wait_for_status(self.server1['id'], 'REBOOT')
......
345 284
        self.server1 = self._create_server(
346 285
            self.servname1, self.flavorid, self.img)
347 286

  
348
    def test_0065_resize_server(self):
349
        self.client.resize_server(self.servname1, self.flavorid + 1, self.img)
287
    def _test_0065_resize_server(self):
288
        self.client.resize_server(self.servname1, self.flavorid + 2)
350 289
        srv = self.client.get_flavor_details(self.server1['id'])
351
        self.assertEqual(srv['flavor']['id'], self.flavorid + 1)
290
        self.assertEqual(srv['flavor']['id'], self.flavorid + 2)
352 291

  
353 292
    def _test_0070_wait_test_servers_to_reboot(self):
354 293
        """Pseudo-test to wait for VMs to load"""
......
359 298
    def test_create_server_metadata(self):
360 299
        """Test create_server_metadata"""
361 300
        self.server1 = self._create_server(
362
            self.servname1,
363
            self.flavorid,
364
            self.img)
301
            self.servname1, self.flavorid, self.img)
365 302
        self._test_0080_create_server_metadata()
366 303

  
367 304
    def _test_0080_create_server_metadata(self):
368 305
        r1 = self.client.create_server_metadata(
369
            self.server1['id'],
370
            'mymeta',
371
            'mymeta val')
306
            self.server1['id'], 'mymeta', 'mymeta val')
372 307
        self.assertTrue('mymeta' in r1)
373 308
        r2 = self.client.get_server_metadata(self.server1['id'], 'mymeta')
374 309
        self.assert_dicts_are_equal(r1, r2)
......
376 311
    def test_get_server_metadata(self):
377 312
        """Test get server_metadata"""
378 313
        self.server1 = self._create_server(
379
            self.servname1,
380
            self.flavorid,
381
            self.img)
314
            self.servname1, self.flavorid, self.img)
382 315
        self._test_0090_get_server_metadata()
383 316

  
384 317
    def _test_0090_get_server_metadata(self):
......
390 323
    def test_update_server_metadata(self):
391 324
        """Test update_server_metadata"""
392 325
        self.server1 = self._create_server(
393
            self.servname1,
394
            self.flavorid,
395
            self.img)
326
            self.servname1, self.flavorid, self.img)
396 327
        self._test_0100_update_server_metadata()
397 328

  
398 329
    def _test_0100_update_server_metadata(self):
......
474 405
    def test_shutdown_server(self):
475 406
        """Test shutdown_server"""
476 407
        self.server1 = self._create_server(
477
            self.servname1,
478
            self.flavorid,
479
            self.img)
408
            self.servname1, self.flavorid, self.img)
480 409
        self._wait_for_status(self.server1['id'], 'BUILD')
481 410
        self._test_0170_shutdown_server()
482 411

  
......
489 418
    def test_start_server(self):
490 419
        """Test start_server"""
491 420
        self.server1 = self._create_server(
492
            self.servname1,
493
            self.flavorid,
494
            self.img)
421
            self.servname1, self.flavorid, self.img)
495 422
        self._wait_for_status(self.server1['id'], 'BUILD')
496 423
        self.client.shutdown_server(self.server1['id'])
497 424
        self._wait_for_status(self.server1['id'], 'ACTIVE')
......
506 433
    def test_get_server_console(self):
507 434
        """Test get_server_console"""
508 435
        self.server2 = self._create_server(
509
            self.servname2,
510
            self.flavorid,
511
            self.img)
436
            self.servname2, self.flavorid, self.img)
512 437
        self._wait_for_status(self.server2['id'], 'BUILD')
513 438
        self._test_0190_get_server_console()
514 439

  
......
522 447
    def test_get_firewall_profile(self):
523 448
        """Test get_firewall_profile"""
524 449
        self.server1 = self._create_server(
525
            self.servname1,
526
            self.flavorid,
527
            self.img)
450
            self.servname1, self.flavorid, self.img)
528 451
        self._test_0200_get_firewall_profile()
529 452

  
530 453
    def _test_0200_get_firewall_profile(self):
......
535 458
    def test_set_firewall_profile(self):
536 459
        """Test set_firewall_profile"""
537 460
        self.server1 = self._create_server(
538
            self.servname1,
539
            self.flavorid,
540
            self.img)
461
            self.servname1, self.flavorid, self.img)
541 462
        self._test_0210_set_firewall_profile()
542 463

  
543 464
    def _test_0210_set_firewall_profile(self):
......
573 494

  
574 495
    def test_get_server_stats(self):
575 496
        self.server1 = self._create_server(
576
            self.servname1,
577
            self.flavorid,
578
            self.img)
497
            self.servname1, self.flavorid, self.img)
579 498
        self._test_0220_get_server_stats()
580 499

  
581 500
    def _test_0220_get_server_stats(self):
......
625 544
    def test_connect_server(self):
626 545
        """Test connect_server"""
627 546
        self.server1 = self._create_server(
628
            self.servname1,
629
            self.flavorid,
630
            self.img)
547
            self.servname1, self.flavorid, self.img)
631 548
        self.network1 = self._create_network(self.netname1)
632 549
        self._wait_for_status(self.server1['id'], 'BUILD')
633 550
        self._wait_for_network(self.network1['id'], 'ACTIVE')
......
635 552

  
636 553
    def _test_0250_connect_server(self):
637 554
        self.client.connect_server(self.server1['id'], self.network1['id'])
638
        self.assertTrue(self._wait_for_nic(
639
            self.network1['id'],
640
            self.server1['id']))
555
        self.assertTrue(
556
            self._wait_for_nic(self.network1['id'], self.server1['id']))
641 557

  
642 558
    def test_disconnect_server(self):
643 559
        """Test disconnect_server"""
......
647 563
    def _test_0250_disconnect_server(self):
648 564
        self.client.disconnect_server(self.server1['id'], self.network1['id'])
649 565
        self.assertTrue(self._wait_for_nic(
650
            self.network1['id'],
651
            self.server1['id'],
652
            in_creation=False))
566
            self.network1['id'], self.server1['id'], in_creation=False))
653 567

  
654 568
    def _test_0260_wait_for_second_network(self):
655 569
        self.network2 = self._create_network(self.netname2)
......
658 572
    def test_list_server_nics(self):
659 573
        """Test list_server_nics"""
660 574
        self.server1 = self._create_server(
661
            self.servname1,
662
            self.flavorid,
663
            self.img)
575
            self.servname1, self.flavorid, self.img)
664 576
        self.network2 = self._create_network(self.netname2)
665 577
        self._wait_for_status(self.server1['id'], 'BUILD')
666 578
        self._wait_for_network(self.network2['id'], 'ACTIVE')
......
670 582
        r = self.client.list_server_nics(self.server1['id'])
671 583
        len0 = len(r)
672 584
        self.client.connect_server(self.server1['id'], self.network2['id'])
673
        self.assertTrue(self._wait_for_nic(
674
            self.network2['id'],
675
            self.server1['id']))
585
        self.assertTrue(
586
            self._wait_for_nic(self.network2['id'], self.server1['id']))
676 587
        r = self.client.list_server_nics(self.server1['id'])
677 588
        self.assertTrue(len(r) > len0)
678 589

  
......
704 615
    def test_list_network_nics(self):
705 616
        """Test list_server_nics"""
706 617
        self.server1 = self._create_server(
707
            self.servname1,
708
            self.flavorid,
709
            self.img)
618
            self.servname1, self.flavorid, self.img)
710 619
        self.network1 = self._create_network(self.netname1)
711 620
        self.network2 = self._create_network(self.netname2)
712 621
        self._wait_for_status(self.server1['id'], 'BUILD')
......
719 628
        self._test_0293_list_network_nics()
720 629

  
721 630
    def _test_0293_list_network_nics(self):
722
        netid1 = self.network1['id']
723
        netid2 = self.network2['id']
631
        netid1, netid2 = self.network1['id'], self.network2['id']
724 632
        r = self.client.list_network_nics(netid1)
725 633
        expected = ['nic-%s-1' % self.server1['id']]
726 634
        self.assertEqual(r, expected)

Also available in: Unified diff