Search in this blog

Tuesday, February 7, 2017

Create a dummy file of specified size

If you need to create a big file of specified size for testing purposes (for testing Glance or Cinder for example), you can follow next few steps:

  • Install fallocate tool from util-linux
    $ sudo apt-get install util-linux
  • Create your dummy file of specified size. Let's do a file of 1Gb size
    $ fallocate -l 1G dummy.iso
Then you can use it, for example upload to Glance:
$ glance image-create --name dummy.iso --disk-format iso --container-format bare --file dummy.iso

Friday, January 20, 2017

Create SSH tunnel to the virtual server running on hypervisor

To create SSH tunnel to the virtual server running on hypervisor:
ssh -f -N -L 5001:10.100.15.5:5000 us1234.hypervisor.lab.net
Where:
5001 - source port number (port on local machine)
5000 - destination port (port on virtual server)
us1234.hypervisor.lab.net - hypervisor domain address

Opening http://localhost:5001/ in browser actually will open 10.100.15.5:5000 via ssh tunnel for you.

Friday, January 6, 2017

How to create and manage python virtualenv?

Create, activate and deactivate virtualenv
cd my_project_folder

virtualenv .venv
. .venv/bin/activate

deactivate

Tuesday, December 27, 2016

Run a single python test with tox

This is the hint how to run a single or several specific functional and unit tests in python projects with tox.

Tox environment `functional`:

Run tests by the template of their name:
tox -e functional test_node_list

Run single test specifying full path:
tox -e ironicclient.tests.functional.osc.v1.test_baremetal_node_basic.BaremetalNodeTests.test_list

Run class of tests:
tox -e functional BaremetalNodeTests

Run specific test from class (including those under @ddt):
tox -e functional BaremetalNodeTests.test_delete

Unit tests (py27 for example):

Run several matching tests:
tox -e py27 do_port_show

Run single specific test from specified class:
tox -e py27 PortShellTest.test_do_port_show_invalid_fields

How to resolve a merge conflict?

How to resolve Git merge conflict in workflow using Gerrit?

Example

1. Clone the project Git repository
git clone https://github.com/openstack/python-ironicclient.git
cd python-ironicclient/

2. Create a new local branch for the issue you are working on
git checkout -b bug/1566329

3. Cherry-pick your patch set from Gerrit
git fetch https://git.openstack.org/openstack/python-ironicclient refs/changes/92/365692/11 && git cherry-pick FETCH_HEAD

4. Check git status to see where conflict is
git status

5. Resolve merge conflict using merge tool, IDE or text editor

6. Add changes to the next commit
git add ironicclient/tests/functional/osc/v1/base.py

7. Continue cherry-pick operation
git cherry-pick --continue

8. Push it back to Gerrit
git review