Skip to content

Commit 48f7f0f

Browse files
committed
Automate flavors, networks, and image get
Functional tests rely on some sort of configuration and rather than configure something right now, how about it pulls something from the middle of the available list. Change-Id: I8147e40e5ee7393d8a8dcf1b0beb48856f28af7e
1 parent 3751dbf commit 48f7f0f

1 file changed

Lines changed: 29 additions & 9 deletions

File tree

functional/tests/compute/v2/test_server.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import testtools
1717

18+
from functional.common import exceptions
1819
from functional.common import test
1920

2021

@@ -27,19 +28,38 @@ class ServerTests(test.TestCase):
2728
FIELDS = ['name']
2829
IP_POOL = 'public'
2930

31+
@classmethod
32+
def get_flavor(cls):
33+
raw_output = cls.openstack('flavor list -f value -c ID')
34+
ray = raw_output.split('\n')
35+
idx = len(ray)/2
36+
return ray[idx]
37+
38+
@classmethod
39+
def get_image(cls):
40+
raw_output = cls.openstack('image list -f value -c ID')
41+
ray = raw_output.split('\n')
42+
idx = len(ray)/2
43+
return ray[idx]
44+
45+
@classmethod
46+
def get_network(cls):
47+
try:
48+
raw_output = cls.openstack('network list -f value -c ID')
49+
except exceptions.CommandFailed:
50+
return ''
51+
ray = raw_output.split('\n')
52+
idx = len(ray)/2
53+
return ' --nic net-id=' + ray[idx]
54+
3055
@classmethod
3156
def setUpClass(cls):
3257
opts = cls.get_show_opts(cls.FIELDS)
33-
# TODO(thowe): pull these values from clouds.yaml
34-
flavor = '4'
35-
image = 'cirros-0.3.4-x86_64-uec'
36-
netid = ''
37-
if netid:
38-
nicargs = ' --nic net-id=' + netid
39-
else:
40-
nicargs = ''
58+
flavor = cls.get_flavor()
59+
image = cls.get_image()
60+
network = cls.get_network()
4161
raw_output = cls.openstack('server create --flavor ' + flavor +
42-
' --image ' + image + nicargs + ' ' +
62+
' --image ' + image + network + ' ' +
4363
cls.NAME + opts)
4464
expected = cls.NAME + '\n'
4565
cls.assertOutput(expected, raw_output)

0 commit comments

Comments
 (0)