root / snf-tools / synnefo_tools / burnin / stale_tests.py @ 43ce827c
History | View | Annotate | Download (4.9 kB)
1 |
# Copyright 2013 GRNET S.A. All rights reserved.
|
---|---|
2 |
#
|
3 |
# Redistribution and use in source and binary forms, with or
|
4 |
# without modification, are permitted provided that the following
|
5 |
# conditions are met:
|
6 |
#
|
7 |
# 1. Redistributions of source code must retain the above
|
8 |
# copyright notice, this list of conditions and the following
|
9 |
# disclaimer.
|
10 |
#
|
11 |
# 2. Redistributions in binary form must reproduce the above
|
12 |
# copyright notice, this list of conditions and the following
|
13 |
# disclaimer in the documentation and/or other materials
|
14 |
# provided with the distribution.
|
15 |
#
|
16 |
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 |
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 |
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 |
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 |
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 |
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 |
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 |
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 |
# POSSIBILITY OF SUCH DAMAGE.
|
28 |
#
|
29 |
# The views and conclusions contained in the software and
|
30 |
# documentation are those of the authors and should not be
|
31 |
# interpreted as representing official policies, either expressed
|
32 |
# or implied, of GRNET S.A.
|
33 |
|
34 |
"""
|
35 |
This is the burnin class that handles stale resources (Servers/Networks)
|
36 |
|
37 |
"""
|
38 |
|
39 |
from synnefo_tools.burnin.common import Proper, SNF_TEST_PREFIX |
40 |
from synnefo_tools.burnin.cyclades_common import CycladesTests |
41 |
|
42 |
|
43 |
# Too many public methods. pylint: disable-msg=R0904
|
44 |
class StaleServersTestSuite(CycladesTests): |
45 |
"""Handle stale Servers"""
|
46 |
stale_servers = Proper(value=None)
|
47 |
|
48 |
def test_001_show_stale_servers(self): |
49 |
"""Show staled servers (servers left from previous runs)"""
|
50 |
servers = self._get_list_of_servers()
|
51 |
self.stale_servers = [s for s in servers |
52 |
if s['name'].startswith(SNF_TEST_PREFIX)] |
53 |
|
54 |
len_stale = len(self.stale_servers) |
55 |
if len_stale == 0: |
56 |
self.info("No stale servers found") |
57 |
return
|
58 |
|
59 |
self.info("Found %s stale servers:", len_stale) |
60 |
for stl in self.stale_servers: |
61 |
self.info(" Server \"%s\" with id %s", stl['name'], stl['id']) |
62 |
|
63 |
def test_002_delete_stale_servers(self): |
64 |
"""Delete staled servers (servers left from previous runs)"""
|
65 |
len_stale = len(self.stale_servers) |
66 |
if not self.delete_stale and len_stale != 0: |
67 |
msg = "Use --delete-stale flag to delete stale servers"
|
68 |
self.error(msg)
|
69 |
self.fail(msg)
|
70 |
elif len_stale == 0: |
71 |
self.info("No stale servers found") |
72 |
else:
|
73 |
self.info("Deleting %s stale servers:", len_stale) |
74 |
for stl in self.stale_servers: |
75 |
self.info(" Deleting server \"%s\" with id %s", |
76 |
stl['name'], stl['id']) |
77 |
self.clients.cyclades.delete_server(stl['id']) |
78 |
|
79 |
for stl in self.stale_servers: |
80 |
self._insist_on_server_transition(
|
81 |
stl, ["ACTIVE", "ERROR", "STOPPED"], "DELETED") |
82 |
|
83 |
|
84 |
# Too many public methods. pylint: disable-msg=R0904
|
85 |
class StaleNetworksTestSuite(CycladesTests): |
86 |
"""Handle stale Networks"""
|
87 |
stale_networks = Proper(value=None)
|
88 |
|
89 |
def test_001_show_stale_networks(self): |
90 |
"""Show staled networks (networks left from previous runs)"""
|
91 |
networks = self._get_list_of_networks()
|
92 |
self.stale_networks = [n for n in networks |
93 |
if n['name'].startswith(SNF_TEST_PREFIX)] |
94 |
|
95 |
len_stale = len(self.stale_networks) |
96 |
if len_stale == 0: |
97 |
self.info("No stale networks found") |
98 |
return
|
99 |
|
100 |
self.info("Found %s stale networks:", len_stale) |
101 |
for stl in self.stale_networks: |
102 |
self.info(" Network \"%s\" with id %s", stl['name'], stl['id']) |
103 |
|
104 |
def test_002_delete_stale_networks(self): |
105 |
"""Delete staled networks (networks left from previous runs)"""
|
106 |
len_stale = len(self.stale_networks) |
107 |
if not self.delete_stale and len_stale != 0: |
108 |
msg = "Use --delete-stale flag to delete stale networks"
|
109 |
self.error(msg)
|
110 |
self.fail(msg)
|
111 |
elif len_stale == 0: |
112 |
self.info("No stale networks found") |
113 |
else:
|
114 |
self.info("Deleting %s stale networks:", len_stale) |
115 |
for stl in self.stale_networks: |
116 |
self.info(" Deleting network \"%s\" with id %s", |
117 |
stl['name'], stl['id']) |
118 |
self.clients.cyclades.delete_network(stl['id']) |
119 |
|
120 |
for stl in self.stale_networks: |
121 |
self._insist_on_network_transition(
|
122 |
stl, ["ACTIVE", "ERROR"], "DELETED") |