Merge "Functional test improvements"
This commit is contained in:
commit
13a79650b9
@ -11,61 +11,3 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import time # for sleep
|
|
||||||
import util as func_utils
|
|
||||||
from glance import client as glance_client
|
|
||||||
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
if os.geteuid() != 0:
|
|
||||||
print 'test must be run as root'
|
|
||||||
assert False
|
|
||||||
|
|
||||||
if os.environ['OS_AUTH_STRATEGY'] != 'keystone':
|
|
||||||
print 'keystone authentication required'
|
|
||||||
assert False
|
|
||||||
|
|
||||||
prepare_jeos()
|
|
||||||
|
|
||||||
|
|
||||||
def prepare_jeos():
|
|
||||||
# verify JEOS and cloud init
|
|
||||||
args = ('F17', 'x86_64', 'cfntools')
|
|
||||||
imagename = '-'.join(str(i) for i in args)
|
|
||||||
creds = dict(username=os.environ['OS_USERNAME'],
|
|
||||||
password=os.environ['OS_PASSWORD'],
|
|
||||||
tenant=os.environ['OS_TENANT_NAME'],
|
|
||||||
auth_url=os.environ['OS_AUTH_URL'],
|
|
||||||
strategy=os.environ['OS_AUTH_STRATEGY'])
|
|
||||||
|
|
||||||
# -d: debug, -G: register with glance
|
|
||||||
subprocess.call(['heat-jeos', '-d', '-G', 'create', imagename])
|
|
||||||
|
|
||||||
gclient = glance_client.Client(host="0.0.0.0", port=9292,
|
|
||||||
use_ssl=False, auth_tok=None, creds=creds)
|
|
||||||
|
|
||||||
# Nose seems to change the behavior of the subprocess call to be
|
|
||||||
# asynchronous. So poll glance until image is registered.
|
|
||||||
imagelistname = None
|
|
||||||
tries = 0
|
|
||||||
while imagelistname != imagename:
|
|
||||||
tries += 1
|
|
||||||
assert tries < 50
|
|
||||||
time.sleep(15)
|
|
||||||
print "Checking glance for image registration"
|
|
||||||
imageslist = gclient.get_images()
|
|
||||||
for x in imageslist:
|
|
||||||
imagelistname = x['name']
|
|
||||||
if imagelistname == imagename:
|
|
||||||
print "Found image registration for %s" % imagename
|
|
||||||
break
|
|
||||||
|
|
||||||
# technically not necessary, but glance registers image before
|
|
||||||
# completely through with its operations
|
|
||||||
time.sleep(10)
|
|
||||||
|
|
||||||
# TODO: could do teardown and delete jeos
|
|
||||||
|
@ -25,6 +25,7 @@ def test_template():
|
|||||||
|
|
||||||
func_utils = util.FuncUtils()
|
func_utils = util.FuncUtils()
|
||||||
|
|
||||||
|
func_utils.prepare_jeos('F17', 'x86_64', 'cfntools')
|
||||||
func_utils.create_stack(template, 'F17')
|
func_utils.create_stack(template, 'F17')
|
||||||
func_utils.check_cfntools()
|
func_utils.check_cfntools()
|
||||||
func_utils.wait_for_provisioning()
|
func_utils.wait_for_provisioning()
|
||||||
|
@ -30,6 +30,7 @@ from nose.plugins.attrib import attr
|
|||||||
from nose import with_setup
|
from nose import with_setup
|
||||||
from nose.exc import SkipTest
|
from nose.exc import SkipTest
|
||||||
|
|
||||||
|
from glance import client as glance_client
|
||||||
from novaclient.v1_1 import client
|
from novaclient.v1_1 import client
|
||||||
from heat import utils
|
from heat import utils
|
||||||
from heat.engine import parser
|
from heat.engine import parser
|
||||||
@ -44,6 +45,10 @@ class FuncUtils:
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
raise SkipTest('OS_AUTH_STRATEGY not set, skipping functional test')
|
raise SkipTest('OS_AUTH_STRATEGY not set, skipping functional test')
|
||||||
|
|
||||||
|
if os.environ['OS_AUTH_STRATEGY'] != 'keystone':
|
||||||
|
print 'keystone authentication required'
|
||||||
|
assert False
|
||||||
|
|
||||||
creds = dict(username=os.environ['OS_USERNAME'],
|
creds = dict(username=os.environ['OS_USERNAME'],
|
||||||
password=os.environ['OS_PASSWORD'],
|
password=os.environ['OS_PASSWORD'],
|
||||||
tenant=os.environ['OS_TENANT_NAME'],
|
tenant=os.environ['OS_TENANT_NAME'],
|
||||||
@ -70,6 +75,52 @@ class FuncUtils:
|
|||||||
return self.sftp
|
return self.sftp
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def prepare_jeos(self, p_os, arch, type):
|
||||||
|
imagename = p_os + '-' + arch + '-' + type
|
||||||
|
creds = dict(username=os.environ['OS_USERNAME'],
|
||||||
|
password=os.environ['OS_PASSWORD'],
|
||||||
|
tenant=os.environ['OS_TENANT_NAME'],
|
||||||
|
auth_url=os.environ['OS_AUTH_URL'],
|
||||||
|
strategy=os.environ['OS_AUTH_STRATEGY'])
|
||||||
|
|
||||||
|
gclient = glance_client.Client(host="0.0.0.0", port=9292,
|
||||||
|
use_ssl=False, auth_tok=None, creds=creds)
|
||||||
|
|
||||||
|
# skip creating jeos if image already available
|
||||||
|
if not self.poll_glance(gclient, imagename, False):
|
||||||
|
if os.geteuid() != 0:
|
||||||
|
print 'test must be run as root to create jeos'
|
||||||
|
assert False
|
||||||
|
|
||||||
|
# -d: debug, -G: register with glance
|
||||||
|
subprocess.call(['heat-jeos', '-d', '-G', 'create', imagename])
|
||||||
|
|
||||||
|
# Nose seems to change the behavior of the subprocess call to be
|
||||||
|
# asynchronous. So poll glance until image is registered.
|
||||||
|
self.poll_glance(gclient, imagename, True)
|
||||||
|
|
||||||
|
def poll_glance(self, gclient, imagename, block):
|
||||||
|
imagelistname = None
|
||||||
|
tries = 0
|
||||||
|
while imagelistname != imagename:
|
||||||
|
tries += 1
|
||||||
|
assert tries < 50
|
||||||
|
if block:
|
||||||
|
time.sleep(15)
|
||||||
|
print "Checking glance for image registration"
|
||||||
|
imageslist = gclient.get_images()
|
||||||
|
for x in imageslist:
|
||||||
|
imagelistname = x['name']
|
||||||
|
if imagelistname == imagename:
|
||||||
|
print "Found image registration for %s" % imagename
|
||||||
|
# technically not necessary, but glance registers image
|
||||||
|
# before completely through with its operations
|
||||||
|
time.sleep(10)
|
||||||
|
return True
|
||||||
|
if not block:
|
||||||
|
break
|
||||||
|
return False
|
||||||
|
|
||||||
def create_stack(self, template_file, distribution):
|
def create_stack(self, template_file, distribution):
|
||||||
nt = client.Client(os.environ['OS_USERNAME'],
|
nt = client.Client(os.environ['OS_USERNAME'],
|
||||||
os.environ['OS_PASSWORD'], os.environ['OS_TENANT_NAME'],
|
os.environ['OS_PASSWORD'], os.environ['OS_TENANT_NAME'],
|
||||||
|
Loading…
Reference in New Issue
Block a user