Revision 60a80953 snf-tools/synnefo_tools/burnin/network_tests.py

b/snf-tools/synnefo_tools/burnin/network_tests.py
79 79
        """Submit create server request for server A"""
80 80
        use_image = random.choice(self.avail_images)
81 81
        use_flavor = random.choice(self.avail_flavors)
82
        server = self._create_server(use_image, use_flavor)
82
        server = self._create_server(use_image, use_flavor, network=True)
83 83

  
84 84
        self.server_a = {}
85 85
        self.server_a['server'] = server
......
92 92
        """Submit create server request for server B"""
93 93
        use_image = random.choice(self.avail_images)
94 94
        use_flavor = random.choice(self.avail_flavors)
95
        server = self._create_server(use_image, use_flavor)
95
        server = self._create_server(use_image, use_flavor, network=True)
96 96

  
97 97
        self.server_b = {}
98 98
        self.server_b['server'] = server
......
113 113

  
114 114
    def test_006_create_network(self):
115 115
        """Submit a create network request"""
116
        name = self.run_id
117
        self.network = self._create_network(name)
116
        self.network = self._create_network()
118 117

  
119 118
        self._insist_on_network_transition(
120 119
            self.network, ["BUILD"], "ACTIVE")
121 120

  
122 121
    def test_007_connect_to_network(self):
123 122
        """Connect the two VMs to the newly created network"""
124
        self.clients.cyclades.connect_server(
125
            self.server_a['server']['id'], self.network['id'])
126
        self.clients.cyclades.connect_server(
127
            self.server_b['server']['id'], self.network['id'])
128

  
129
        self._insist_on_network_connection(
130
            self.server_a['server'], self.network)
131
        self._insist_on_network_connection(
132
            self.server_b['server'], self.network)
123
        self._create_port(self.network['id'], self.server_a['server']['id'])
124
        self._create_port(self.network['id'], self.server_b['server']['id'])
133 125

  
134 126
        # Update servers
135 127
        self.server_a['server'] = self._get_server_details(
......
138 130
            self.server_b['server'])
139 131

  
140 132
        # Check that servers got private IPs
141
        self.server_a['pr_ipv4'] = self._get_ip(
142
            self.server_a['server'], network=self.network)
143
        self.server_b['pr_ipv4'] = self._get_ip(
144
            self.server_b['server'], network=self.network)
133
        ipv4 = self._get_ips(self.server_a['server'], network=self.network)
134
        self.assertEqual(len(ipv4), 1)
135
        self.server_a['pr_ipv4'] = ipv4[0]
136
        ipv4 = self._get_ips(self.server_b['server'], network=self.network)
137
        self.assertEqual(len(ipv4), 1)
138
        self.server_b['pr_ipv4'] = ipv4
145 139

  
146 140
    def test_008_reboot_server_a(self):
147 141
        """Rebooting server A"""
......
155 149

  
156 150
    def test_009_ping_server_a(self):
157 151
        """Test if server A responds to IPv4 pings"""
158
        self._insist_on_ping(self._get_ip(self.server_a['server']))
152
        self._insist_on_ping(self._get_ips(self.server_a['server'])[0])
159 153

  
160 154
    def test_010_reboot_server_b(self):
161 155
        """Rebooting server B"""
......
169 163

  
170 164
    def test_011_ping_server_b(self):
171 165
        """Test that server B responds to IPv4 pings"""
172
        self._insist_on_ping(self._get_ip(self.server_b['server']))
166
        self._insist_on_ping(self._get_ips(self.server_b['server'])[0])
173 167

  
174 168
    def test_012_test_connection_exists(self):
175 169
        """Ping server B from server A to test if connection exists"""
......
178 172
        self._skip_if(not self._image_is(self.server_b['image'], "linux"),
179 173
                      "only valid for Linux servers")
180 174

  
181
        server_a_public_ip = self._get_ip(self.server_a['server'])
182
        server_b_private_ip = self._get_ip(
183
            self.server_b['server'], network=self.network)
175
        server_a_public_ip = self._get_ips(self.server_a['server'])[0]
176
        server_b_private_ip = self._get_ips(
177
            self.server_b['server'], network=self.network)[0]
184 178
        msg = "Will try to connect to server A (%s) and ping to server B (%s)"
185 179
        self.info(msg, server_a_public_ip, server_b_private_ip)
186 180

  
......
198 192
        self._disconnect_from_network(self.server_a['server'], self.network)
199 193
        self._disconnect_from_network(self.server_b['server'], self.network)
200 194

  
201
        self._insist_on_network_connection(
202
            self.server_a['server'], self.network, disconnect=True)
203
        self._insist_on_network_connection(
204
            self.server_b['server'], self.network, disconnect=True)
205

  
206 195
    def test_014_destroy_network(self):
207 196
        """Submit delete network request"""
208
        self.clients.cyclades.delete_network(self.network['id'])
209
        self._insist_on_network_transition(
210
            self.network, ["ACTIVE"], "DELETED")
211

  
212
        networks = [net['id'] for net in self._get_list_of_networks()]
213
        self.assertNotIn(self.network['id'], networks)
214

  
215
        # Verify quotas
216
        self._check_quotas(network=-1)
197
        self._delete_networks([self.network])
217 198

  
218 199
    def test_015_cleanup_servers(self):
219 200
        """Cleanup servers created for this test"""
220
        self.clients.cyclades.delete_server(self.server_a['server']['id'])
221
        self.clients.cyclades.delete_server(self.server_b['server']['id'])
222

  
223
        self._insist_on_server_transition(
224
            self.server_a['server'], ["ACTIVE"], "DELETED")
225
        self._insist_on_server_transition(
226
            self.server_b['server'], ["ACTIVE"], "DELETED")
227

  
228
        # Verify quotas
229
        self._verify_quotas_deleted([self.server_a['flavor'],
230
                                     self.server_b['flavor']])
201
        self._delete_servers([self.server_a['server'],
202
                              self.server_b['server']])

Also available in: Unified diff