Merge "Add Freezer Tempest Tests"
This commit is contained in:
commit
789353fc27
|
@ -4,3 +4,90 @@ Tempest Integration of Freezer
|
|||
|
||||
This directory contains Tempest tests to cover the freezer project.
|
||||
|
||||
|
||||
Instructions for Running/Developing Tempest Tests with Freezer Project
|
||||
|
||||
1. Need Devstack or other Environment for running Keystone
|
||||
|
||||
2. Clone the Tempest Repo
|
||||
|
||||
3. Create virtual env for Tempest
|
||||
|
||||
4. Activate the Tempest virtual env
|
||||
run 'source ~/virtualenvs/tempest-freezer/bin/activate'
|
||||
|
||||
5. Make sure you have latest pip installed
|
||||
run 'pip install --upgrade pip'
|
||||
|
||||
6. install Tempest requirements.txt and test-requirements.txt in the Tempest
|
||||
virtual env
|
||||
run 'pip install -r requirements.txt -r test-requirements.txt'
|
||||
|
||||
7. Install Tempest project into virtual env
|
||||
run ‘python setup.py develop’
|
||||
|
||||
8. Create logging.conf in Tempest Repo home dir/etc
|
||||
|
||||
Make a copy of logging.conf.sample as logging.conf
|
||||
|
||||
In logging configuration
|
||||
|
||||
You will see this error on Mac OS X
|
||||
|
||||
socket.error: [Errno 2] No such file or directory
|
||||
Edit logging.conf
|
||||
|
||||
Change ‘/dev/log/ to '/var/run/syslog’ in logging.conf
|
||||
|
||||
see: https://github.com/baremetal/python-backoff/issues/1
|
||||
|
||||
9. Create tempest.conf in Tempest Repo home dir/etc
|
||||
|
||||
run 'oslo-config-generator --config-file etc/config-generator.tempest.conf --output-file etc/tempest.conf'
|
||||
|
||||
Add the following sections to tempest.conf
|
||||
|
||||
[identity]
|
||||
|
||||
username = freezer
|
||||
password = secretservice
|
||||
tenant_name = service
|
||||
domain_name = default
|
||||
admin_username = admin
|
||||
admin_password = secretadmin
|
||||
admin_domain_name = default
|
||||
admin_tenant_name = admin
|
||||
alt_username = admin
|
||||
alt_password = secretadmin
|
||||
alt_tenant_name = admin
|
||||
use_ssl = False
|
||||
auth_version = v3
|
||||
uri = http://10.10.10.6:5000/v2.0/
|
||||
uri_v3 = http://10.10.10.6:35357/v3/
|
||||
|
||||
[auth]
|
||||
|
||||
allow_tenant_isolation = true
|
||||
tempest_roles = admin
|
||||
|
||||
Modify the uri and the uri_v3 to point to the host where Keystone is
|
||||
running
|
||||
|
||||
10. Clone freezer Repo
|
||||
|
||||
11. Set virtualenv to the Tempest virtual env
|
||||
run 'source ~/virtualenvs/tempest-freezer/bin/activate'
|
||||
|
||||
12. pip install freezer requirements.txt and test-requirements.txt in
|
||||
Tempest virtualenv
|
||||
run 'pip install -r requirements.txt -r test-requirements.txt'
|
||||
|
||||
13. Install nose in virtual env
|
||||
run 'pip install nose'
|
||||
|
||||
14. Install freezer project into virtual env
|
||||
run ‘python setup.py develop’ in Tempest virtual env
|
||||
|
||||
15. Set project interpreter (pycharm) to Tempest virtual env
|
||||
|
||||
16. Create test config using Tempest virtual env as python interpreter
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
# (C) Copyright 2016 Hewlett Packard Enterprise Development Company LP
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import os
|
||||
import shutil
|
||||
|
||||
import datetime
|
||||
import subprocess
|
||||
|
||||
from freezer.tests.freezer_tempest_plugin.tests.api import base
|
||||
from tempest import test
|
||||
|
||||
|
||||
class TestFreezerSwiftBackup(base.BaseFreezerTest):
|
||||
|
||||
@test.attr(type="gate")
|
||||
def test_freezer_swift_backup(self):
|
||||
|
||||
now_in_secs = datetime.datetime.now().strftime("%s")
|
||||
|
||||
backup_source_dir = ("/tmp/freezer-test-backup-source/"
|
||||
+ now_in_secs)
|
||||
backup_source_sub_dir = backup_source_dir + "/subdir"
|
||||
|
||||
restore_target_dir = (
|
||||
"/tmp/freezer-test-backup-restore/"
|
||||
+ now_in_secs)
|
||||
|
||||
freezer_container_name = 'freezer-test-container-0'
|
||||
freezer_backup_name = 'freezer-test-backup-0'
|
||||
|
||||
shutil.rmtree(backup_source_dir, True)
|
||||
os.makedirs(backup_source_dir)
|
||||
open(backup_source_dir + "/a", 'w').close()
|
||||
open(backup_source_dir + "/b", 'w').close()
|
||||
open(backup_source_dir + "/c", 'w').close()
|
||||
|
||||
os.makedirs(backup_source_sub_dir)
|
||||
open(backup_source_sub_dir + "/x", 'w').close()
|
||||
open(backup_source_sub_dir + "/y", 'w').close()
|
||||
open(backup_source_sub_dir + "/z", 'w').close()
|
||||
|
||||
shutil.rmtree(restore_target_dir, True)
|
||||
os.makedirs(restore_target_dir)
|
||||
|
||||
os.environ['OS_REGION_NAME'] = 'RegionOne'
|
||||
os.environ['OS_PASSWORD'] = 'secretadmin'
|
||||
os.environ['OS_IDENTITY_API_VERSION'] = '2.0'
|
||||
os.environ['OS_NO_CACHE'] = '1'
|
||||
os.environ['OS_USERNAME'] = 'demo'
|
||||
os.environ['OS_VOLUME_API_VERSION'] = '2'
|
||||
os.environ['OS_PROJECT_NAME'] = 'demo'
|
||||
os.environ['PYTHONUNBUFFERED'] = '1'
|
||||
os.environ['OS_TENANT_NAME'] = 'demo'
|
||||
os.environ['OS_TENANT_ID'] = ''
|
||||
os.environ['OS_AUTH_URL'] = 'http://localhost:5000/v2.0'
|
||||
# Mac OS X uses gtar located in /urs/local/bin
|
||||
os.environ['PATH'] = '/usr/local/bin:' + os.environ['PATH']
|
||||
|
||||
backup_args = ['freezer-agent',
|
||||
'--path-to-backup',
|
||||
backup_source_dir,
|
||||
'--container',
|
||||
freezer_container_name,
|
||||
'--backup-name',
|
||||
freezer_backup_name]
|
||||
|
||||
output = subprocess.check_output(backup_args,
|
||||
stderr=subprocess.STDOUT,
|
||||
env=os.environ, shell=False)
|
||||
|
||||
restore_args = ['freezer-agent',
|
||||
'--action',
|
||||
'restore',
|
||||
'--restore-abs-path',
|
||||
restore_target_dir,
|
||||
'--container',
|
||||
freezer_container_name,
|
||||
'--backup-name',
|
||||
freezer_backup_name,
|
||||
'--storage',
|
||||
'swift']
|
||||
|
||||
output = subprocess.check_output(restore_args,
|
||||
stderr=subprocess.STDOUT,
|
||||
env=os.environ, shell=False)
|
||||
|
||||
diff_args = ['diff',
|
||||
'-r',
|
||||
'-q',
|
||||
backup_source_dir,
|
||||
restore_target_dir]
|
||||
|
||||
diff_rc = subprocess.call(diff_args,
|
||||
shell=False)
|
||||
|
||||
self.assertEqual(0, diff_rc, "Test backup to swift and restore")
|
||||
|
||||
shutil.rmtree(backup_source_dir, True)
|
||||
shutil.rmtree(restore_target_dir, True)
|
|
@ -0,0 +1,23 @@
|
|||
# (C) Copyright 2016 Hewlett Packard Enterprise Development Company LP
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from freezer.tests.freezer_tempest_plugin.tests.api import base
|
||||
from tempest import test
|
||||
|
||||
class TestFreezerTestsRunning(base.BaseFreezerTest):
|
||||
|
||||
@test.attr(type="gate")
|
||||
def test_tests_running(self):
|
||||
# See if tempest plugin tests run.
|
||||
self.assertEqual(1, 1, 'Tests are running')
|
|
@ -12,12 +12,18 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import subprocess
|
||||
|
||||
from freezer.tests.freezer_tempest_plugin.tests.api import base
|
||||
from freezer import __version__ as FREEZER_VERSION
|
||||
from tempest import test
|
||||
|
||||
|
||||
class TestFreezerVersion(base.BaseFreezerTest):
|
||||
|
||||
@test.attr(type="gate")
|
||||
def test_api_version(self):
|
||||
# See if tempest plugin tests run.
|
||||
self.assertEqual(1, 1, 'First test case')
|
||||
def test_version(self):
|
||||
|
||||
version = subprocess.check_output(['freezer-agent', '--version'],
|
||||
stderr=subprocess.STDOUT)
|
||||
self.assertEqual(FREEZER_VERSION, version.strip())
|
||||
|
|
Loading…
Reference in New Issue