freezer-tempest-plugin/freezer_tempest_plugin/README.rst
Cai Hui 3590b5e7d6 Update README.rst
1.Update 'Run the freezer test' command
2.Update 'Troubleshooting'

Change-Id: If38c69d70cb01d85a2080a8e0be5f4ad813f5bc4
2018-11-09 02:52:40 -05:00

9.0 KiB
Raw Blame History

Freezer Tempest Tests

Integration tests in Freezer are implemented using tempest. This document describes different approaches to run these tests.

Where to start?

Setting up a devstack VM

Install devstack with swift and the freezer1 as well as the freezer-api2 plugins by adding the following lines to you `local.conf`:

enable_plugin freezer https://git.openstack.org/openstack/freezer master
enable_plugin freezer-api https://git.openstack.org/openstack/freezer-api master
enable_service s-proxy s-object s-container s-account

Run tests inside a devstack VM

  1. Create a devstack VM as described in Setting up a devstack VM
  2. Inside your devstack VM, navigate to /opt/stack/tempest.
  3. Run ostestr -r freezer

Debugging tests inside a devstack VM

Often a devstack VM is used via SSH without graphical interface. Python has multiple command line debuggers. The out-of-the-box pdb works fine but I recommend pudb3 which looks a bit like the old Turbo-Pascal/C IDE. The following steps are necessary to get it running:

  1. Follow the steps in Run tests inside a devstack VM.

  2. Log into the devstack VM

  3. Install pudb:

    pip install pudb
  4. Open the test file were you want to set the first breakpoint (more breakpoints can be set interactively later) and add the following line

    import pudb;pu.db
  5. Navigate to /opt/stack/tempest.

  6. ostestr runs tests in parallel which causes issues with debuggers. To work around that you need to run the relevant test directly. E.g.:

    python -m unittest freezer_tempest_plugin.tests.scenario.test_backups.TestFreezerScenario
  7. It should drop you into the debugger!

Run tests outside a devstack VM

This section describes how to run the tests outside of a devstack VM (e.g. in PyCharm) while using services (keystone, swift, ...) inside a VM.

  1. Create a devstack VM as described in Setting up a devstack VM.

  2. Create and activate a virtual environment for Tempest: :

    virtualenv --no-site-packages tempest-venv
    . tempest-venv/bin/activate
  3. Clone and install the Tempest project into the virtual environment: :

    git clone https://github.com/openstack/tempest
    pip install tempest/
  4. Clone and install the Freezer project into the virtual environment: :

    git clone https://github.com/openstack/freezer
    pip install -e freezer/
  5. Clone and install the Freezer API project into the virtual environment: :

    git clone https://github.com/openstack/freezer-api
    pip install -e freezer-api/
  6. Initialise a Tempest working directory: :

    mkdir tempest-working
    cd tempest-working
    tempest init .
  7. Configure tempest-working/etc/tempest.conf. The easiest way to do this is to just copy the config from /opt/stack/tempest/etc/tempest.conf inside the devstack VM.

  8. Run the freezer test inside the tempest working directory: :

    cd tempest-working
    tempest run  -r  freezer_tempest_plug

Run tests outside a devstack VM (alternative instructions using nose)

  1. Need to make sure that there is a Devstack or other environment for running Keystone and Swift.

  2. Clone the Tempest Repo:

    run 'git clone https://github.com/openstack/tempest.git'
  3. Create a virtual environment for Tempest. In these instructions, the Tempest virtual environment is ~/virtualenvs/tempest-freezer.

  4. Activate the Tempest virtual environment:

    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 environment:

    run 'pip install -r requirements.txt -r test-requirements.txt'
  7. Install Tempest project into the virtual environment in develop mode:

    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

    To fix this, edit logging.conf

    Change /dev/log/ to '/var/run/syslog in logging.conf

    see: https://github.com/baremetal/python-backoff/issues/1 for details

  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 and modify uri and uri_v3 to point to the host where Keystone is running::
    
    [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
  10. Clone freezer Repo:

    run 'git clone https://github.com/openstack/freezer.git'
  11. Set the virtual environment to the Tempest virtual environment:

    run 'source ~/virtualenvs/tempest-freezer/bin/activate'
  12. pip install freezer requirements.txt and test-requirements.txt in Tempest virtual environment:

    run 'pip install -r requirements.txt -r test-requirements.txt'
  13. Install nose in the Temptest virtual environment:

    run 'pip install nose'
  14. Install freezer project into the Tempest virtual environment in develop mode:

    run python setup.py develop
  15. Set project interpreter (pycharm) to Tempest virtual environment.

  16. Create test config (pycharm) using the Tempest virtual environment as python interpreter:

    Set the environment variable OS_AUTH_URL to the URI where Keystone is running.  For example, OS_AUTH_URL=http://10.10.10.6:5000/v2.0.
    Set the Working Directory to the Tempest home dir. This will allow Tempest to find the etc/tempest.conf file.
  17. Run the tests in the api directory in the freezer_tempest_plugin directory.

Mac OS X Instructions

For Mac OS X users you will need to install gnu-tar in /usr/local/bin and make sure that /usr/local/bin is in the PATH environment variable before any other directories where a different version of tar can be found. Gnu-tar can be installed as gtar or tar, either name works.

Also, currently for Mac OS X users, the latest version of gnu-tar (1.29) will not allow --unlink-first and --overwrite options to be used together. Also, gnu-tar will complain about the --unlink-first argument. To get around these limitations, you will need to modify tar_builders.py and remove the --unlink-first option from the UNIX_TEMPLATE variable.

Run tests in PyCharm

  1. Set up the test environment as described in Run tests outside a devstack VM.
  2. Start PyCharm and open a new project pointing to the cloned freezer directory.
  3. Click File > Settings > Project: freezer > Project Interpreter.
  4. Click the gear-wheel icon next to Project Interpreter and choose Add Local.
  5. Navigate to your virtual environment and select the Python interpreter under bin/python and confirm with OK
  6. In the left pane, navigate to one of the test scripts in freezer_tempest_plugin/tests/[api or scenario]/*.py.
  7. Right-click the file and choose Run 'Unittests in [..]'
  8. This test run will most likely fail because it is started from the wrong directory. To fix this, open the dropdown box next to the run button in the top-right corner. Choose Edit Configurations ..
  9. Point Working directory: to your tempest working directory.
  10. Run the test again, this time it should work!

Troubleshooting

If tests fail these are good places to check:

  • freezer-api log: $HOME/log/freezer-api.log' /var/log/apache2/freezer-api.log`
  • freezer-agent log: $HOME/.freezer/freezer.log
  • freezer-scheduler log:/var/log/freezer/scheduler.log

  1. https://github.com/openstack/freezer/blob/master/devstack/README.rst↩︎

  2. https://github.com/openstack/freezer-api/blob/master/devstack/README.rst↩︎

  3. https://pypi.org/project/pudb↩︎