GithubHelp home page GithubHelp logo

parallel_calabash's Introduction

PS: I am no longer maintaining this utility due to time constraints. Any pull requests or issues will not be attended

calabash parallel execution

Build Status

Watch a quick demo here:

https://www.youtube.com/watch?v=sK3s0txeJvc

Run calabash-android or calabash-ios tests in parallel on multiple connected devices. This is inspired by parallel_tests https://rubygems.org/gems/parallel_tests

eg. Android: bundle exec parallel_calabash --apk my.apk -o'--format pretty' features/ --serialize-stdout
eg. iOS: bundle exec parallel_calabash --app my.app -o'--format pretty' features/ --serialize-stdout

Installation

Add this line to your application's Gemfile:

gem 'parallel_calabash'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install parallel_calabash

Usage Android

Usage: parallel_calabash [options]

Example: parallel_calabash -a my.apk -o 'cucumber_opts_like_tags_profile_etc_here' features/

-h, --help                       Show this message
-v, --version                    Show version
-a, --apk apk_path               apk file path
-o, --cucumber_opts '[OPTIONS]'  execute with those cucumber options
-f, --filter                     Filter devices to run tests against using partial device id or model name matching. Multiple filters seperated by ','
--serialize-stdout               Serialize stdout output, nothing will be written until everything is done
--group-by-scenarios             Distribute equally as per scenarios. This uses cucumber dry run
--concurrent                     Run tests concurrently. Each test will run once on each device.

Usage iOS

Example: parallel_calabash --app my.app --ios_config ~/.parallel_calabash.iphoneos -o '-cucumber -opts' -r '-cucumber -reports>' features/

-h, --help                       Show this message
-v, --version                    Show version
    --app app_path               app file path
    --device_target target       ios target if no .parallel-calabash config
    --device_endpoint endpoint   ios endpoint if no .parallel-calabash config
    --simulator type             for simctl create, e.g. 'com.apple.CoreSimulator.SimDeviceType.iPhone-6 com.apple.CoreSimulator.SimRuntime.iOS-8-4'
    --ios_config file            for ios, configuration for devices and users
-d, --distribution-tag tag       divide features into groups as per occurrence of given tag
-f, --filter filter              Filter devices to run tests against keys or values in config. Multiple filters seperated by ','
    --skip_ios_ping_check        Skip the connectivity test for iOS devices
-o, --cucumber_opts '[OPTIONS]'  execute with those cucumber options
-r '[REPORTS]',                  generate these cucumber reports (not during filtering)
    --cucumber_reports
    --serialize-stdout           Serialize stdout output, nothing will be written until everything is done
    --concurrent                 Run tests concurrently. Each test will run once on each device
    --group-by-scenarios         Distribute equally as per scenarios. This uses cucumber dry run

iOS set-up

  • iOS testing is only supported on MacOS hosts.
  • Create as many (Administrator-privileged!) test accounts as you have devices or want simulators (Settings > Users & Groups)
  • As the main user, the one that runs parallel_calabash, create ~/.parallel_calabash.iphonesimulator and/or ~/.parallel_calabash.iphoneos

As follows:

{
  USERS: [ 'tester1', 'tester2', 'tester3' ],
  INIT: '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"',
  # You only need to specify the port if the default clashes for you. Simulators start sequentially from this.
  # CALABASH_SERVER_PORT: 3800,
  # You only need to give the test users' password if you want to run autostart_test_users
  # PASSWORD: 'testuserspassword',
  # You only need to set this if you want to run autostart_test_users and the default 6900 clashes with something.
  # VNC_FORWARD: 6900,
  # Omit 'DEVICES' entirely if you're only testing on simulators.
  DEVICES: [
    {
      NAME: 'ios-iphone5c-tinkywinkie (8.4.1)',
      DEVICE_TARGET: '23984729837401987239874987239',
      DEVICE_ENDPOINT: 'http://192.168.126.206:37265'
    },
    {
      NAME: 'ios-iphone6plus-lala (8.4)',
      DEVICE_TARGET: 'c987234987983458729375923485792345',
      DEVICE_ENDPOINT: 'http://192.168.126.205:37265',
    },
    {
      NAME: 'ios-iphone6plus-dipsy (8.4.1)',
      DEVICE_TARGET: '98723498792873459872398475982347589',
      DEVICE_ENDPOINT: 'http://192.168.126.207:37265',
    }
  ]
}
  • As the main account, run ssh-keygen
  • As each test account:
  1. Use Screen Sharing to log in to the user's desktop (particularly if you're using simulators) to let the computer set it up.
  2. Settings > Sharing > Remote Login > Allow access for main account (if not already permitted by Remote Management)
  3. Copy ~main_account/.ssh/id_rsa.pub into each test account's ~tester1/.ssh/authorized_keys
  4. Any other set-up, e.g. ln -s /Users/main_account/.rvm ~/.rvm
  • If you don't want to test on simulators, your set-up stops here.
  • If you want to test on simulators too...
  • ... for each test user, Settings > Sharing > Screen sharing > Allow access (if not already permitted by Remote Management)
  • ... (we were suprised that a mac mini can cheerfully run upwards of 7 simulators without much struggle)
  • ... and as your primary user:
  1. Run: sudo defaults write com.apple.ScreenSharing skipLocalAddressCheck -boolean YES
  2. Run: ln -s ~/.parallel_config.iphonesimulator ~/.parallel_config.autostart (or whatever your simulators' config is called).
  3. Add a PASSWORD: 'whatever', in your config - same password for all test users.
  4. Copy misc/autostart_test_users.app from the Git repository into the system /Applications/ directory
  5. Run /Applications/autostart_test_users, skip the countdown, and see it complain about accessibility; close the connection request dialog
  6. In Settings > Privacy & Security > Privacy > Accessibility, allow it - close Settings
  7. Re-run it, skip the countdown, and it should open a screen sharing session for each test user.
  8. Add it into Settings > User & Groups > Login Items, set BOOT_DELAY if you need to tune the post-login startup time.

FILTERING

Filters are partial matches on the device id, or model name.

adb devices -l List of devices attached 4100142545f271b5 device usb:14200000 product:sltexx model:SM_G850F device:slte 4366432135f271c6 device usb:14200000 product:sltexx model:SM_G9901 device:slte emulator-5554 device product:sdk_phone_x86_64 model:Android_SDK_built_for_x86_64 device:generic_x86_64

To run against just the emulator: -f emulator To run against a device id list: -f 4100142545f271b5,4366432135f271c6

REPORTING

use ENV['TEST_PROCESS_NUMBER'] environment variable in your ruby scripts to find out the process number. you can use this for reporting purpose OR process specific action.

To get device model info, use ENV['DEVICE_INFO'] env variable.

eg. modify default profile in cucumber.yml as below to get different report from different process

default: --format html --out reports/Report_<%=ENV['DEVICE_INFO']%>_<%= ENV['TEST_PROCESS_NUMBER']%>.html --format pretty

Contributing

  1. Fork it ( https://github.com/[my-github-username]/parallel_calabash/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

parallel_calabash's People

Contributors

rajdeepv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

parallel_calabash's Issues

Run test on specific devices

Hi Srs,

Is posssible run tests with parallel on specific devices connecteds on machine.

For example, i'm have 4 devices to one project A:

Device 1 - Android 4.1.1
Device 2 - Android 4.2.2
Device 3 - Android 4.4
Device 4 - Android 5.0

But to second project B, is necessary use only device 3 and device 4.

Is possible configure parallel calabash to run second project only on devices 3 and 4 ?

"PROCESS 0 COMPLETED" even though found "3 DEVICES"

Hi @rajdeepv

I'm a newbie in Calabash, I'm trying to run multiple simulators for my iOS project but found this issue, I have researched this but still not working, could you please advise me some reasons ?

Name:project_calabash Name$ bundle exec parallel_calabash --app prebuilt/app-staging-release_cal.app --ios_config ~/.parallel_calabash.iphonesimulator --cucumber_opts '-p ios' features/integration/login.feature

2016-10-07 18:21:07.831 instruments[10714:70215] WebKit Threading Violation - initial use of WebKit from a secondary thread.


3 DEVICES FOUND:
{:USER=>"tester1", :CALABASH_SERVER_PORT=>28000, :INIT=>"source "$HOME/.rvm/scripts/rvm""}
{:USER=>"tester2", :CALABASH_SERVER_PORT=>28001, :INIT=>"source "$HOME/.rvm/scripts/rvm""}
{:USER=>"tester3", :CALABASH_SERVER_PORT=>28002, :INIT=>"source "$HOME/.rvm/scripts/rvm""}


Running with 1 threads: [["features/integration/login.feature"]]
Delete: Entry, "CalabashServerPort", Does Not Exist
User app: prebuilt/tester1/app-staging-release_cal.app
Devices:
Double check...
Devices:
OK if none
Usage: simctl create
0>> Device: = PCal-tester1 = PCal-tester1 (0.0)
PING localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.097 ms

--- localhost ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.097/0.097/0.097/0.000 ms
0>> Command: ssh tester1@localhost bash -lc "AUTOTEST='1';export AUTOTEST;DEVICE_ENDPOINT='http://localhost:28000';export DEVICE_ENDPOINT;DEVICE_TARGET='PCal-tester1 (0.0)';export DEVICE_TARGET;DEVICE_INFO='';export DEVICE_INFO;TEST_USER='tester1';export TEST_USER;TEST_PROCESS_NUMBER='1';export TEST_PROCESS_NUMBER;SCREENSHOT_PATH='PCal_1_';export SCREENSHOT_PATH;source "$HOME/.rvm/scripts/rvm";cd /Users/Name/Documents/Projects/project_calabash;umask 002;bundle exec cucumber APP_BUNDLE_PATH=prebuilt/tester1/app-staging-release_cal.app -p ios features/integration/login.feature" 2>&1
0> bash: /Users/Name/.rvm/scripts/rvm: Too many levels of symbolic links
0> bash: line 0: cd: /Users/Name/Documents/Projects/project_calabash: Permission denied
0> bash: bundle: command not found

****** PROCESS 0 COMPLETED ******

Writing log /tmp/PCal-tester1.process_number
[0]
All threads complete

************ FINAL SUMMARY ************

Took 0 Minutes, 13.78 Seconds
Parallel run complete

Group by feature files

Hi @rajdeepv rajdeep,
Does this support running the tests group by feature files ? I am aware that this does not hold good if the feature file tests sizes are different. But in my case, i have relatively same number of scenarios in each feature file. I can't divide the scenarios in one feature file across more than one device and run(in few functional modules of our app only).

NO Devies found

I'm getting below when i run

parallel_calabash -app my.app --ios_config ~/.parallel_calabash.iphoneos

/Users//.rvm/gems/ruby-2.3.0/gems/parallel_calabash-0.2.7.pre/lib/parallel_calabash.rb:39:in number_of_processes_to_start': (RuntimeError) **** NO DEVICE FOUND **** from /Users/***/.rvm/gems/ruby-2.3.0/gems/parallel_calabash-0.2.7.pre/lib/parallel_calabash.rb:49:in run_tests_in_parallel'
from /Users/
/.rvm/gems/ruby-2.3.0/gems/parallel_calabash-0.2.7.pre/bin/parallel_calabash:99:in <top (required)>' from /Users/***/.rvm/gems/ruby-2.3.0/bin/parallel_calabash:23:in load'
from /Users//.rvm/gems/ruby-2.3.0/bin/parallel_calabash:23:in <main>' from /Users/***/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in eval'
from /Users/
/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `

'

error: more than one device and emulator

Hi @rajdeepv, Thanks for this wonderful solution. My test suites are running fine except that some times we get the error:

  • waiting for device -
    error: more than one device and emulator
    which causes the execution fail. Are aware of this case ?
    No change in the commands and it works on some machines without issues and fails some times on some machines.

Distribute the test between android phone and tablet

Is it possible to distribute the test run between phone and tablet?

For example: 3 phone and 3 tablet are connected to the same machine and i want my tests to run only on phone and not on tablet as the app flow and apk is different

Cannot get html reports for android device tests

Steps:

  1. Added cucumber.yml file in the config folder with the code below:

# config/cucumber.yml

default: --format html --out reports/Report_<%=ENV['DEVICE_INFO']%>_<%= ENV['TEST_PROCESS_NUMBER']%>.html --format pretty

  1. Executed tests with the following code:

bundle exec parallel_calabash --apk $APP_PATH -o'--format pretty' features/ --concurrent

Expected outcome: html files are generated

Actual outcome: following error is generated:

No such file or directory @ rb_sysopen - reports/Report_GT_I9195_1.html
Error creating formatter: html (Errno::ENOENT)

Complete command line output:

Starting tests on multiple android devices


2 DEVICES FOUND:
725920e1
GT_I9195
725920e1_
ce041604749c182804
SM_G935F
ce041604749c182804_


Running with 2 threads: [["features/check_bill.feature", "features/fix_problem_broadbandntalk.feature", "features/fix_problem_skyhd.feature", "features/sign_in.feature", "features/sign_up.feature"], ["features/check_bill.feature", "features/fix_problem_broadbandntalk.feature", "features/fix_problem_skyhd.feature", "features/sign_in.feature", "features/sign_up.feature"]]
0>> Command: AUTOTEST=1;export AUTOTEST;ADB_DEVICE_ARG=725920e1;export ADB_DEVICE_ARG;DEVICE_INFO=GT_I9195;export DEVICE_INFO;TEST_PROCESS_NUMBER=1;export TEST_PROCESS_NUMBER;SCREENSHOT_PATH=725920e1_;export SCREENSHOT_PATH;calabash-android run /Users/msi15/documents/workspace/sky-app-android/app/build/outputs/apk/app-integration-debug-0.4-1.apk --format pretty features/check_bill.feature features/fix_problem_broadbandntalk.feature features/fix_problem_skyhd.feature features/sign_in.feature features/sign_up.feature
1>> Command: AUTOTEST=1;export AUTOTEST;ADB_DEVICE_ARG=ce041604749c182804;export ADB_DEVICE_ARG;DEVICE_INFO=SM_G935F;export DEVICE_INFO;TEST_PROCESS_NUMBER=2;export TEST_PROCESS_NUMBER;SCREENSHOT_PATH=ce041604749c182804_;export SCREENSHOT_PATH;calabash-android run /Users/msi15/documents/workspace/sky-app-android/app/build/outputs/apk/app-integration-debug-0.4-1.apk --format pretty features/check_bill.feature features/fix_problem_broadbandntalk.feature features/fix_problem_skyhd.feature features/sign_in.feature features/sign_up.feature
No such file or directory @ rb_sysopen - reports/Report_SM_G935F_2.html
Error creating formatter: html (Errno::ENOENT)

****** PROCESS 1 COMPLETED ******

[1]
No such file or directory @ rb_sysopen - reports/Report_GT_I9195_1.html
Error creating formatter: html (Errno::ENOENT)

****** PROCESS 0 COMPLETED ******

[1, 0]
All threads complete

************ FINAL SUMMARY ************

Took 0 Minutes, 44.88 Seconds
Parallel run complete

iOS App execution error

Could not find a device with a UDID or name matching 'PCal- (0.0)' (ArgumentError)
1
2
3
4
parallel_calabash_error.zip

Not able to execute test in parallel for iOS device.
Followed the instruction given on README.

Thanks for the help

Device Info at Runtime

The statement ENV['DEVICE_INFO'] works fine in command line. But how can I get the device details at run time in my Ruby step definition?

Any tips on the usage will be helpful.

concerns on parallel run

Hi,

Does the test run in parallel with different devices or can we run different tests on different devices?

Permission denied while running ios parallel-calabash

Hi There,
Thanks for this awesome helpful gem. After setting up for Android, I am currently working on IOS. I have done the set up as mentioned here. It identifies devices but before executing the test, it throws Permission denied error on my scripts folder stating the directory <$Home>/.rvm/scripts/extras/bash_zsh_support/chpwd/function.sh: line 5.
Could you please assist me here. Your help is highly appreciated.

rerun is not working

I have run following command for rerun and I got rerun.txt file

parallel_calabash --apk <apk> -o '--tags @smoke --format pretty --format rerun --out features/support/rerun.txt' features/

Rerun.txt file output :
features/tests/golden_flow/smoke_android.feature:4:38:54:82:97:160:180

Then I ran following command for rerun, but its running all feature files instead failures.

parallel_calabash --apk <apk> -o '@features/support/rerun.txt --format pretty' features/

Thanks

Reports dont load screenshots when directory default is changed

When i'm change directory of reports on config.yml, screenshots are not loaded.

My config.yml
default: --format html --out reports\Automation_report_<%= ENV['TEST_PROCESS_NUMBER'] %>_<%= ENV['DEVICE_INFO'] %>.html --format pretty

The report is visible with layout brokened when link to open screenshot is tapped
1

ps: I'm think the problem occurs only on windows

Multiple devices - single report

I'm very excited to have found this project. I've noticed however that with the html results I am experiencing a few issues. With two devices and --group-by-scenarios I am only getting half of the results. Running without this option I am getting half of the results and the other half is not outputting properly (see the screenshot attached)
capture

-r command

Could you explain the -r command a little and give an example for that? I am having an issue now where my output report formats are defined in my cucumber YML and so when I run --group-by-scenario and it does the dry run its outputing a report in those formats. This throws off Teamcity. Is the -r command a workaround for this?

Tests distribution based on "feature" files

Hello @rajdeepv and @sleekweasel
First of all I want to thank you guys for your great work upon this project - nicely done ๐Ÿ‘
The only question that still confuses me is the tests distribution.
Can you explain how exactly --distribution-tag tag works ? How can we divide features using only 1 tag ? Can you add some info about this under Wiki section ? Thank you advance.
Or can you advise me how can I set distribution mode based on feature files ? For example I'd like to split all available feature files into 2 separate groups and run them using 2 iOS simulators (each simulator gets its own set of features) ?
Should I use some weighing_factor ?
If you have some manuals or tutorials can you pin them under Wiki section ? Thank you advance once again.

No Device Found

@rajdeepv when I try to configure and run this feature. I am getting error like this

Error Message

/Library/Ruby/Gems/2.0.0/gems/parallel_calabash-0.2.4/lib/parallel_calabash.rb:39:in number_of_processes_to_start': (RuntimeError) **** NO DEVICE FOUND **** from /Library/Ruby/Gems/2.0.0/gems/parallel_calabash-0.2.4/lib/parallel_calabash.rb:49:inrun_tests_in_parallel'
from /Library/Ruby/Gems/2.0.0/gems/parallel_calabash-0.2.4/bin/parallel_calabash:94:in <top (required)>' from /usr/bin/parallel_calabash:23:inload'
from /usr/bin/parallel_calabash:23:in `

parallel_calabash.iphoneos

{
USERS: [ 'tester1'],
INIT: '[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"',
DEVICES: [
{
NAME: 'iPod (8.4.1)',
DEVICE_TARGET: '97be62ebxxxxxb6e8swded66d841f7678898b33e',
DEVICE_ENDPOINT: 'http://10.1.4.109:37265',
}
]
}

'No such file or directory' while running android tests in parallel

I have some problems while running calabash-android tests in parallels.
I use

parallel_calabash -a android_apps/some.apk -o '-p android' --concurrent features/some.feature

where -p android is

'PLATFORM=android -r features/support -r features/android -r features/step_definitions -r features/android/pages' 

And next I have a following stacktrace

*******************************
 2 DEVICES FOUND
*******************************
No such file or directory - @smoke. Please create a @smoke directory to get started. (Errno::ENOENT)
No such file or directory - @smoke. Please create a @smoke directory to get started. (Errno::ENOENT)

Where @smoke is a tag in my feature file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.