Show me the code! – By Davanum Srinivas

January 13, 2015

Quickly running a single OpenStack Nova test

Filed under: Nova, openstack — Davanum Srinivas @ 10:41 am

Here’s how we usually run a single test

dims@dims-mac:~/openstack/nova$ time tox -e py27 nova.tests.unit.test_versions
py27 develop-inst-noop: /Users/dims/openstack/nova
py27 runtests: PYTHONHASHSEED='0'
py27 runtests: commands[0] | find . -type f -name *.pyc -delete
py27 runtests: commands[1] | bash tools/pretty_tox.sh nova.tests.unit.test_versions
{1} nova.tests.unit.test_versions.VersionTestCase.test_version_string_with_package_is_good [0.180036s] ... ok
{0} nova.tests.unit.test_versions.VersionTestCase.test_release_file [0.184115s] ... ok

======
Totals
======
Ran: 2 tests in 13.0000 sec.
 - Passed: 2
 - Skipped: 0
 - Failed: 0
Sum of execute time for each test: 0.3642 sec.

==============
Worker Balance
==============
 - Worker 0 (1 tests) => 0:00:00.184115s
 - Worker 1 (1 tests) => 0:00:00.180036s
________________________________________________________________________________________________________________________ summary _________________________________________________________________________________________________________________________
  py27: commands succeeded
  congratulations 🙂

real	0m14.452s
user	0m16.392s
sys	0m2.354s

Sometimes the usual way is not very helpful, especially when you are working on some new code and say running into issues importing code. Then, here’s what you do.

First, activate the py27 virtualenv

dims@dims-mac:~/openstack/nova$ . .tox/py27/bin/activate

Then use testtools

(py27)dims@dims-mac:~/openstack/nova$ python -m testtools.run nova.tests.unit.test_versions
Tests running...

Ran 2 tests in 0.090s
OK

Or you can install pytest

(py27)dims@dims-mac:~/openstack/nova$ pip install pytest
Collecting pytest
  Downloading pytest-2.6.4.tar.gz (512kB)
    100% |################################| 516kB 877kB/s
Collecting py>=1.4.25 (from pytest)
  Downloading py-1.4.26.tar.gz (190kB)
    100% |################################| 192kB 4.3MB/s
Installing collected packages: py, pytest
  Running setup.py install for py
  Running setup.py install for pytest
    Installing py.test-2.7 script to /Users/dims/openstack/nova/.tox/py27/bin
    Installing py.test script to /Users/dims/openstack/nova/.tox/py27/bin
Successfully installed py-1.4.26 pytest-2.6.4

And then run the same test using py.test

(py27)dims@dims-mac:~/openstack/nova$ find . -name py.test
./.tox/py27/bin/py.test

(py27)dims@dims-mac:~/openstack/nova$ .tox/py27/bin/py.test -svx nova/tests/unit/test_versions.py
================================================================================================================== test session starts ===================================================================================================================
platform darwin -- Python 2.7.8 -- py-1.4.26 -- pytest-2.6.4 -- /Users/dims/openstack/nova/.tox/py27/bin/python2.7
collected 2 items

nova/tests/unit/test_versions.py::VersionTestCase::test_release_file PASSED
nova/tests/unit/test_versions.py::VersionTestCase::test_version_string_with_package_is_good PASSED

================================================================================================================ 2 passed in 1.69 seconds ================================================================================================================

These tips are based on the openstack-dev mailing list discussion:
http://openstack.markmail.org/thread/wetxcnhuq6b7auhn

Advertisements

June 24, 2014

Running Cloud Foundry’s Micro BOSH on latest DevStack

Filed under: cloud foundry, openstack — Tags: , , , — Davanum Srinivas @ 7:45 am

The Cloud Foundry docs are excellent. Here’s where i started from:
http://docs.cloudfoundry.org/deploying/openstack/

I provisioned a big beefy bare metal box with Ubuntu 14.04 LTS on SoftLayer and installed DevStack on it as usual. Here’s the super simple local.conf that i used. Note the 100GB volume needed later for Micro BOSH deployment.

[[local|localrc]]
FLAT_INTERFACE=eth0
PUBLIC_INTERFACE=eth1
ADMIN_PASSWORD=passw0rd
MYSQL_PASSWORD=passw0rd
RABBIT_PASSWORD=passw0rd
SERVICE_PASSWORD=passw0rd
VOLUME_BACKING_FILE_SIZE=100GB

Once you deploy DevStack, follow the steps in the CF docs url above, Here’s the ~/.fog file that i used in step #2. Note that i am just using the “admin” credentials and the “admin” tenant for all openstack operations

:openstack:
  :openstack_auth_url:  http://9.193.231.50:5000/v2.0/tokens
  :openstack_api_key:   passw0rd
  :openstack_username:  admin
  :openstack_tenant: admin
  :openstack_region:

Here’s a script to create all the security groups and floating ips needed in step #3.

nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0 
nova secgroup-add-rule default tcp 22 22 0.0.0.0/0

nova secgroup-create ssh ssh
nova secgroup-add-rule ssh udp 68 68 0.0.0.0/0
nova secgroup-add-rule ssh tcp 22 22 0.0.0.0/0
nova secgroup-add-rule ssh icmp -1 -1 0.0.0.0/0

nova secgroup-create bosh bosh
nova secgroup-add-group-rule bosh bosh tcp 1 65535
nova secgroup-add-rule bosh tcp 4222 4222 0.0.0.0/0
nova secgroup-add-rule bosh tcp 6868 6868 0.0.0.0/0
nova secgroup-add-rule bosh tcp 25250 25250 0.0.0.0/0
nova secgroup-add-rule bosh tcp 25555 25555 0.0.0.0/0
nova secgroup-add-rule bosh tcp 25777 25777 0.0.0.0/0
nova secgroup-add-rule bosh tcp 53 53 0.0.0.0/0
nova secgroup-add-rule bosh udp 68 68 0.0.0.0/0
nova secgroup-add-rule bosh udp 53 53 0.0.0.0/0

nova secgroup-create cf-public cf-public
nova secgroup-add-rule cf-public udp 68 68 0.0.0.0/0
nova secgroup-add-rule cf-public tcp 80 80 0.0.0.0/0
nova secgroup-add-rule cf-public tcp 443 443 0.0.0.0/0

nova secgroup-create cf-private cf-private
nova secgroup-add-rule cf-private udp 68 68 0.0.0.0/0
nova secgroup-add-group-rule cf-private cf-private tcp 1 65535

nova floating-ip-create

For Step #4, i used this stem cell – bosh-stemcell-2611-openstack-kvm-ubuntu-lucid.tgz and the following microbosh.yml

---
name: microbosh-openstack

logging:
  level: DEBUG

network:
  type: dynamic
  vip: 172.24.4.1

resources:
  persistent_disk: 16384
  cloud_properties:
    instance_type: m1.small

cloud:
  plugin: openstack
  properties:
    openstack:
      auth_url: http://9.193.231.50:5000/v2.0
      username: admin
      api_key: passw0rd
      tenant: admin
      default_security_groups: ["ssh", "bosh"]
      default_key_name: microbosh
      private_key: /opt/stack/bosh-workspace/microbosh.pem

apply_spec:
  properties:
    director:
      max_threads: 3
    hm:
      resurrector_enabled: true
    ntp:
      - 0.north-america.pool.ntp.org
      - 1.north-america.pool.ntp.org

That was it! Final check on status.

stack@bigblue:~/bosh-workspace/deployments$ bosh micro status
Stemcell CID   6203baa8-d64f-4701-952e-a33ea0aabdb0
Stemcell name  bosh-stemcell-2611-openstack-kvm-ubuntu-lucid
VM CID         55fc5d01-e56a-4120-bd8c-6ec1c7d295ea
Disk CID       a9eb53a9-74a1-4210-8afe-d04ba68536ac
Micro BOSH CID bm-c84e8442-016a-499f-aa31-19a8a9c58a9e
Deployment     /opt/stack/bosh-workspace/deployments/microbosh-openstack/micro_bosh.yml
Target         https://172.24.4.1:25555

stack@bigblue:~/bosh-workspace/deployments$ bosh status
Config
             /opt/stack/.bosh_config

Director
  Name       microbosh-openstack
  URL        https://172.24.4.1:25555
  Version    1.2611.0 (00000000)
  User       admin
  UUID       46aa8b77-3f41-4268-952e-37c07f938b86
  CPI        openstack
  dns        enabled (domain_name: microbosh)
  compiled_package_cache disabled
  snapshots  disabled

Deployment
  not set

Next up, Will try steps #5, #6, #7 and report back here.

Create a free website or blog at WordPress.com.