Start & Stop Jenkins daemon on Mac OS X

I was looking for a way to restart jenkins on Mac when it hung when installing some plugin.  The following worked 🙂

Start Jenkins:

sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist

Stop Jenkins:

sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
Posted in Uncategorized | Leave a comment

Installing Ruby 1.9.3 with brew on Mac if rvm install errors with “rsync timed out”

$ brew update
$ brew install rbenv
$ brew install ruby-build
rbenv install 1.9.3-p392

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
#To use 1.9.3-p392 as default rbenv global 1.9.3-p392 
 gem update --system # Update the latest ruby gems version
Posted in Uncategorized | Leave a comment

Rake taks for cucumber tests

#Sample rake file

require ‘cucumber/rake/task’

require ‘rdoc/task’

desc ‘generate API documentation to doc/rdocs/index.html’ do |rd|

    rd.rdoc_dir = ‘doc/rdocs’

    rd.options << “–all”

    rd.options << ‘–inline-source’

    rd.options << ‘–line-numbers’

    rd.options << ‘–all’

    rd.options << ‘–fileboxes’

    rd.options << ‘–diagram’

end :features do |t|

    t.cucumber_opts = [


#                       ‘–tags’, ‘~@smoke’, # Exclude tests with @smoke tag

                      ‘–tags’, ‘@smoke,@wip’,

                      “–format progress -o log/features.log”,

                      “–format junit -o log/”,

                      “–format html -o log/features.html”,

                      “–format pretty” ]



To run the Rakefile:

rake features # This will execute the feature files

rake rdoc # This will execute the documentation

Posted in Uncategorized | Leave a comment – Automated Acceptance test for mobile apps


Windows Installation:

  • Install from (Gherkin is not supported in 2.0 yet so install 1.9.x)
  • Also install devkit that corresponds to the ruby version that you install
    • Download DevKit-xx-32-4.7.2-20130224-1151-sfx.exe

    • unzip to Downloads\rubydevkit\ directory

    • run “devkitvars.bat”

  • gem install rspec

  • gem env # lists the sources etc…

  • gem install cucumber
  • gem install calabash-android
  • gem install bundler
  • bundle install
  • Install Android sdk & Platform-tools –

Linux Installation:

  • sudo apt-get install curl
  • curl -L | bash -s stable –ruby – installing rvm //Do not use apt-get install.  It installs Ruby 1.8.7
  • sudo apt-get install irb1.9

  • sudo apt-get install git

  • sudo ln -s /usr/bin/ruby1.9.x /usr/bin/ruby

  • rvm install rubygems latest

  • gem install cucumber

  • gem install calabash-android
  • gem install bundler
  • bundle install
  • rvm gemset use global && gem install bundler

  • gem install rspec

  • gem env # lists the sources etc…

  • Install Android sdk & Platform-tools –

Setting up the environment:

  • Set JAVA_HOME (eg.,C:\Program Files\java\jdkx.x.x)
  • ANDROID_HOME (location of android.jar)
  • Download your *.apk file
  • Setup path to android-sdk, platform-tools

Get Started with Calabash:

  • calabash-android gen (refer to
    • It will create a Cucumber skeleton in the current folder In this skeleton you find all the predefined steps that comes with calabash. Try to take a look my_first.feature and change it to fit your app.  Also, there will be sample step_definitions created for you

Signing the App:

  • jarsigner.exe -sigalg MD5withRSA -digestalg SHA1 -keystore debug.keystore <myapp.apk> androiddebugkey

When it asks for password enter “android”


  • jarsigner.exe” -sigalg MD5withRSA -digestalg SHA1 -signedjar <myapp>.apk -storepass android -keystore debug.keystore mytest.apk androiddebugkey
  • Sample “Gemfile”:
source ''
gem 'calabash-android', "~> 0.4.4"
gem 'json', "~> 1.7.7"
gem 'rspec'
  • Sample .feature file
Feature: Adding Cameras
  As a user able to connect a camera

   Given I am on the Welcome Screen
   When I press Add button
    And I press Connect to a camera
    And I enter IP, Camera name, username and password
    And I press Connect button
   Then I should see rotate for fullscreen view
  • Sample step_definitions file:
# features/step_definitions/addcamera_steps.rb

require 'rspec/expectations'
require 'calabash-android/operations'
extend Calabash::Android::Operations

Given(/^I am on the Welcome Screen$/) do
    wait_for(25) do 

When(/^I press Add button$/) do 
   touch("webView css:'#ext-gen1084'")

When(/^I press Connect to a camera$/) do
   # To find the id of the button to touch, check the Running test
   # from Console below
   touch("webView css: '#ext-gen1160'")


When(/^I enter IP, Camera name, username and password$/) do
   touch("webView css:'#ext-gen1197'")
   set_text("webView css:'#ext-gen1197'", '10.220.x.x')

Running test with cucumber and calabash-android:

> bundle exec calabash-android run mytest.apk

Running test from console:

To test with an emulator:

# start the emulator on a command window:
> android
# Make sure Android SDK Tools, Platform Tools and Build Tools 
# are installed
# Create an emulator and start the emulator
   # Tools > Manage AVDs
   # Create New and select the profile that you need.
# If you want verbose on add -v at the end of the foll. command
> calabash-android console mytest.apk

To test with an actual android device:

* Connect the device with usb  
* In the AndroidManifest.xml file, add android:debuggable="true" to the 
<application> element.  
* Enable USB debugging on your device.  
    * On most devices running Android 3.2 or older, you can find the 
    option under Settings > Applications > Development.  
    * On Android 4.0 and newer, it's in Settings > Developer options.  
* You might have to do “adb kill-server” and “adb start-server” to see 
the device in “adb devices”

# calabash-android console <myapp.apk>
# This starts the test server and you should be able to see your app
# running on the emulator or the device whichever is connected 
# and online
irb(main):001:0> start_test_server_in_background
# The following commands work for application developed with 
# PhoneGap (webview) and not with native code
>  query("webView css:'div'").find{|x| x["textContent"] == "Add"}
             "id" => "ext-comp-1297",
    "textContent" => "Add",
       "nodeName" => "DIV",
          "class" => "x-button x-button-plain x-iconalign-left",
           "html" => "<div id=\"ext-comp-1297\" class=\"x-button x-button-plain
x-iconalign-left\" style=\"padding-top: 13px; padding-right: 13px; padding-botto
m: 13px; padding-left: 13px; margin-top: 0px; margin-right: 0px; margin-bottom:
0px; margin-left: 0px; height: 44px; \"><span class=\"x-button-label\" id=\"ext-
gen1084\">Add</span><img src=\"data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH
5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\" class=\"toolbar_add x-icon-mask\" id=\"ext-g
           "rect" => {
        "center_y" => 1134.0,
        "center_x" => 84.0,
          "height" => 44,
           "width" => 74,
          "bottom" => 564,
            "left" => 5,
           "right" => 79,
               "y" => 1040.0,
               "x" => 10.0,
             "top" => 520
       "nodeType" => "ELEMENT_NODE",
        "webView" => nil

# The above gives you the id for "Add" button which is "ext-gen1084"
# Now you can click the "Add" button with the id
> touch("webView css: '#ext-gen1084'")
# Note: This id changes from emulator to emulator.  Dev has to provide
 an id for each element to make it easier I think

Possible issues and fixes:

  1. To get rid of warning about ansicolor (windows):

  • open cmd and navigate to the unzipped folder
  • Navigate to x64 (if you have a 64 bit machine) otherwise navigate to x86
  • Execute ‘ansicon.exe -i’ to install and add ansicon to your Windows
  • Run your cucumber test and you should
  • get the colored output result on Windows
  1. Warning about gem json ~>1.7.7 (Windows):

  • If the above, doesn’t fix it,
    • uninstall Ruby.
    • Install Ruby 1.9.x again
    • Make sure you also install the corresponding Devkit
    • gem install json -v 1.7.7
    • bundle update json

3. Jarsigner: unable to sign jar

  • Rename the .apk file to .zip
  • Unpack the .zip file and remove the META-INF folder

  • Zip the folder again and rename it to .apk (zip -r <xxx.apk> *)

  • Sign the apk:

4. No MD5 fingerprint found: (RuntimeError)

  • Copy your “Calabash” folder having “feature” file.
  • Paste it into your android workspace having gen, res, src folder. eg., ~/.android

  • Navigate to new path and again run apk file.

  • Now, Test server will create inside your calabash folder.

5. If the AndroidManifest.xml is missing:

To create AndroidManifest.xml file:  where should this be?

calabash-android extract-manifest Downloads\mytest.apk

6. If adb device not showing up in “adb devices”:

adb kill-server
adb start-server
adb devices

7.Cannot load such file rspec/expectations:

  • Make sure you add the foll. line in your Gemfile

gem ‘rspec’

List of useful commands:

1. You can see what is available for instrumentation

adb shell pm list instrumentation

2. List packages:

adb shell pm list packages

3. To get reports with the run:

calabash-android run mytest.apk --format html --out reports.html

4.To see logcat:

adb logcat


Calabash-Android: – Intro

Calabash-iOS: -intro – Test execution Service

Things not working:

1. When running the test fails when touching the “Add” button with the foll. error “An existing connection was forcibly closed by the remote host. (Errno::ECONNRESET)”

2. wake_up doesn’t unlock the emulator

Posted in Uncategorized | Tagged | Leave a comment

RBAC, keystone and openstack

Setting up roles (based on Diablo/Essex release):

1. create roles with keystone

keystone-manage -c <keystone.conf> role add <role>

2. Assign role to a user

keystone-manage -c <keystone.conf> role grant <role> <user> <tenant>

3. If not using default policy.json file:

nova.conf file should be set with “–policy_file=FILENAME”

4. If using the default /opt/stack/nova/etc/nova/policy.json file:

1. Sample policy.json file
Line #1 {
Line #2 “admin_or_owner”:  [[“role:admin”], [“project_id:%(project_id)s”]],
Line #3 “sysadmin_or_owner”: [[“role:sysadmin”], [“project_id:%(project_id)s”]],

Line #4 “compute:create”: [[“rule:admin_or_owner”]],
Line #5 “compute:create:attach_network”: [[“rule:admin_or_owner”]],
Line #6 “compute:create:attach_volume”: [[“rule:admin_or_owner”]],

Line #7 “compute:get”: [[“rule:admin_or_owner”]],
Line #8 “compute:get_all” :[],
“compute:pause”: [[“rule:admin_or_owner”], [“rule:sysadmin_or_owner”]],

Line #40    “network:get_dns_entries_by_name”: []
Line #41 }


The contents of the file are a JSON-encoded hash in the from of:

The MATCH_LIST can be:


RULE will be in the form of the following for specific checks.


When a MATCH_LIST for a rule:* is found, it acts as a link to the other rule
to perform checking.

When a MATCH_LIST for a role:* is found, the auth context of the request is
checked and made sure it contains the named role.

When a KEY:%(CONTEXT_KEY)s check is found, the KEY for the checked object
(an instnace model, a network address, a volume, etc) is compared to the
CONTEXT_KEY from the checked context.  The admin_or_owner uses this type
of check for project_id matching between the context and the checked object.

Line #1:

RULE can be a custom name that is referenced by a MATCH_LIST.

“admin_or_owner”:  [[“role:admin”], [“project_id:%(project_id)s”]]

“admin_or_owner” is just a RULE name
The rule defines that if the user has admin role OR he is the owner of the project
Note the box separating the role admin and the project id, that shows that it’s OR”

If you want to set a rule saying if the user is a member AND owner of the project
“admin_and_owner”:  [[“role:admin”, “project_id:%(project_id)s”]],    “admin_and_owner” is the rule name
Note there is no box separation between role member and project id that shows that it’s AND”

Line #4:

“compute:create”: [[“rule:admin_or_owner”]],
“compute:create:attach_network”: [[“rule:admin_or_owner”]],

This implies that an admin or owner can attach network.

“compute:get_all” :[],    

All users can list instances

5. When users are created through dashboard, they default to a tenant.  So, always a user would be a member of a project.

6. mysql > keystone> users table:

a. If users table has the tenant_id set to “NULL” and if the user has roles set in the keystone, then still would be able to do whatever that role is allowed to do
b. If users table has the tenant_id set to a tenant for eg., 1 or 2…, and if no role or object is set, still the user would be able to do the actions which are set as []
c. There is no concept of project manager by default as we had in bexar.  Owner doesn’t mean that the user is the project manager of the project, it just means that the user is a member of the project.

Posted in Uncategorized | 6 Comments

config_drive for openstack server

config_drive for server is a Nova (Openstack) API extension (from Piston Cloud).  It can be issued as a parameter when creating a server.  It builds a separate partition/volume on the local disk.

Note: As of Jan 20th 2012, there is no nova client support for this.

config_drive takes 2 values. “true” or “image UUID”.

If the value is set to “true”, it builds a 64MB vfat volume and attaches it to the server.
If the value is set to “image-UUID”, it builds a volume from the image and attaches it.

JSON request – config_drive with imageref:

curl -i -X POST -d ‘{“server” : {“config_drive”:”<image_UUID>”, “name” : “<name>”, “imageRef” : “<image_ref>”,”flavorRef”: “<flavor_id>”,”key_name”:”<keypair_name>”}}’ http://<ip&gt;:8774/v2/1/servers -H “Content-Type:application/json” -H “X-Auth-Token: <token>”

JSON request – config_drive with “true”:

curl -i -X POST -d ‘{“server” : {“config_drive”:true, “name” : “<name>”, “imageRef” : “<image_ref>”,”flavorRef”: “<flavor_id>”,”key_name”:”<keypair_name>”}}’ http://<ip&gt;:8774/v2/1/servers -H “Content-Type:application/json” -H “X-Auth-Token: <token>”

To verify from host:

If instance gets launched successfully, on the host, instances directory, you should see a file called “disk.config” created.

“libvirt.xml” under the instances directory (/opt/stack/nova/instances/instance-xxxxx) should contain the following:

<disk type=’file’>
<driver type=’raw’ />
<source file=’/opt/stack/nova/nova/..//instances/instance-xxxxxx/disk.config’ />
<target dev=’vdz’ bus=’virtio’ />

To verify from the instance:

drive created eg., /dev/vdx
The drive is not mounted automatically.

Now, it can me mounted.

Posted in Uncategorized | Leave a comment