import tempfile import time # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), os.pardir, os.pardir)) if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): sys.path.insert(0, possible_topdir) from smoketests import base from smoketests import flags FLAGS = flags.FLAGS flags.DEFINE_string('bundle_kernel', 'random.kernel', 'Local kernel file to use for bundling tests') flags.DEFINE_string('bundle_image', 'random.image', 'Local image file to use for bundling tests') TEST_PREFIX = 'test%s' % int(random.random() * 1000000) TEST_BUCKET = '%s_bucket' % TEST_PREFIX TEST_KEY = '%s_key' % TEST_PREFIX TEST_GROUP = '%s_group' % TEST_PREFIX class ImageTests(base.UserSmokeTestCase): def test_001_can_bundle_image(self): self.data['tempdir'] = tempfile.mkdtemp() self.assertTrue(self.bundle_image(FLAGS.bundle_image, self.data['tempdir']))
import tempfile import shutil # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), os.pardir, os.pardir)) if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): sys.path.insert(0, possible_topdir) from smoketests import flags from smoketests import base FLAGS = flags.FLAGS flags.DEFINE_string('bundle_kernel', 'openwrt-x86-vmlinuz', 'Local kernel file to use for bundling tests') flags.DEFINE_string('bundle_image', 'openwrt-x86-ext2.image', 'Local image file to use for bundling tests') TEST_PREFIX = 'test%s' % int(random.random() * 1000000) TEST_BUCKET = '%s_bucket' % TEST_PREFIX TEST_KEY = '%s_key' % TEST_PREFIX TEST_GROUP = '%s_group' % TEST_PREFIX class ImageTests(base.UserSmokeTestCase): def test_001_can_bundle_image(self): self.data['tempdir'] = tempfile.mkdtemp() self.assertTrue(self.bundle_image(FLAGS.bundle_image, self.data['tempdir']))
import boto import commands import httplib import os import paramiko import sys import time import unittest from boto.ec2.regioninfo import RegionInfo from smoketests import flags SUITE_NAMES = '[image, instance, volume]' FLAGS = flags.FLAGS flags.DEFINE_string('suite', None, 'Specific test suite to run ' + SUITE_NAMES) flags.DEFINE_integer('ssh_tries', 3, 'Numer of times to try ssh') class SmokeTestCase(unittest.TestCase): def connect_ssh(self, ip, key_name): key = paramiko.RSAKey.from_private_key_file('/tmp/%s.pem' % key_name) tries = 0 while(True): try: client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.WarningPolicy()) client.connect(ip, username='******', pkey=key, timeout=5) return client except (paramiko.AuthenticationException, paramiko.SSHException): tries += 1