Tuesday, May 19, 2015

Testing OpenStack REST API using JMeter

OpenStack provides numerous REST APIs for managing various tasks and fetching information. Project website provides a well written API document which can be found here.
APIs are classified based on components and version numbers.


While creating API end points, we need to give  three different URLs namely public, internal and admin and level of access for these endpoints are defined in keystone-paste.ini file.

1. Download JMeter from http://jmeter.apache.org/ and extract the archive.

2. Download JMeter plugins from http://jmeter-plugins.org/ and extract the content into JMeter directory.

3. Create a new JMeter test plan and add "Thread Group" controller with single thread.



4. Add "HTTP Header Manager" Config Element.



5.  In HTTP Request sampler, configure server ip, port  and REST request(In Body Data field).




6.  Configure JSON Path to extract the toke id.



7. Now configure another HTTP Request control to send the API request to the Nova node. Here HTTP request type is GET.



Save the configuration and click on run button. First JMeter will fire a request to Keystone endpoint and token id is obtained. Later token id is extracted using JSon Path and passed to the second API. You can view the results in Result tree.

Monday, May 11, 2015

Run OpenStack on your laptop using DevStack

DevStack requires Ubuntu 14.04 (Trusty Tahr) to run. First create a sudo user in you Linux box.

If you are using any higher version of Ubuntu then you can forcefully run DevStack by setting FORCE environment variable to yes. However you may face issue due to python library mismatch.

export FORCE=yes

Add a new user to run DevStack. This step is optional and DevStack can be run from any sudo user.
Sudo is required since DevStack downloads various  packages and also mounts disk partitions.

groupadd stack
useradd -g stack -s /bin/bash -d /opt/stack -m stack

user@ubuntuvm:~$ id
uid=1001(stack) gid=1001(stack) groups=1001(stack),27(sudo),130(libvirtd)


apt-get install sudo -y
echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers


DevStack project is hosted on GIT and therefore install git client if not installed.

sudo apt-get install git -y

git clone https://git.openstack.org/openstack-dev/devstack

To download a specific branch

git clone https://github.com/openstack-dev/devstack.git -b stable/juno devstack/

cd devstack

./stack.sh
First this script will checkout DevStack source code from DevStack repository and it will download and install dependency packages from Ubuntu package repository.

stack.sh uses screen command. Once it is started you can close the terminal. To reconnect to the screen just ./rejoin.sh

To stop DevStack, run

./unstack.sh

This will stop all the processes and close screens.

Configuration file

In DevStack features can be enabled or disabled through local.conf file. I have created a sample local.conf file in which almost all OpenStack components
are enabled.


git clone https://github.com/uttamhoode/devstack

cp local.conf /opt/devstack


Stop DevStack instance and restart it.