Run rspecs in parallel WITHOUT several processes - ruby

How can I run several rspecs in parallel without launching several processes? More precisely, my requirement is that the RSpec.configure blocks should be run only once for the whole test suite. However, solutions such as parallel_tests seem to launch several processes and each process runs the Rspec.configure blocks.
The tests are not CPU intensive. Basically, an RSpec.configure block launches a bunch of machines on Amazon and then each tests runs commands on a subset of these machines and checks the output.

Related

Is there a way to determine / specify what core an M1 MacOS program is running on?

Scenario: I'm logging in remotely to my M1 Mini, and trying to run a Perl script which launches a long stream of instances of my (compiled for arm64 C++) program, one at a time, for testing purposes. Because it will surely take hours to run the full sequence, I nohup the Perl script.
I launched the first test run about 36 hours ago, and it is about one-third completed thus far. This is much slower than I'd expected -- in general my individual tests of the program have shown this machine to be faster than any other machine I have, and this isn't living up to that at all.
I got to thinking about this, and wondered if my code is getting treated as a "background" task, and run on one of the power-efficient "Icestorm" cores rather than one of the fast "Firestorm" cores. Does anyone know how to detect which core a process is running on and/or control which core a process is run on?

Scheduling Cucumber test features to run repeatedly

I have a Cucumber test (feature files) in the RubyMine IDE and lately I have a need to execute one of the feature repeatedly on a scheduled time.
I haven't found a way to do so. Any idea or thoughts on scheduling that feature file?
You can create a cron job which will execute a rake.
The software utility Cron is a time-based job scheduler in Unix-like
computer operating systems. People who set up and maintain software
environments use cron to schedule jobs (commands or shell scripts) to
run periodically at fixed times, dates, or intervals.
These links might help
How to create a cron job using Bash
how to create a cron job to run a ruby script?
http://rake.rubyforge.org/
I solved the problem by simply installing Jenkins on my machine from its official site,https://jenkins-ci.org/. I configured master and slave nodes on my own machine because I just needed to run one feature file(it has the script I want to run on daily basis).
Although, it is recommended to configure slave on a different machine if we have multiple jobs to run and our jobs are resource intensive.
There is a very good illustration on installing, configuring and running jobs in this link http://yakiloo.com/setup-jenkins-and-windows/

Running same Cucumber Features on different machines concurrently using parallel_tests gem

Running same Cucumber Features on different machines concurrently using parallel_tests gem
I'm trying to figure out how to use the parallel_tests gem to run the EXACT SAME Cucumber Features on a variety of different machines concurrently.
Currently I have them running on different machines but the SAME features do not execute, it just splits up the features and runs different features on different machines.
More clarification on what I want to do:
MACHINE 1 (Win 7) - EXECUTE SAME FEATURES CONCURRENTLY
MACHINE 2 (Win 8) - EXECUTE SAME FEATURES CONCURRENTLY
MACHINE 3 (Mac OS X) - EXECUTE SAME FEATURES CONCURRENTLY
...
Also my architecture is:
Cucumber -> Capybara -> Selenium Webdriver -> Selenium Grid
parallel_tests gem: https://github.com/grosser/parallel_tests
The parallel_tests gem is really purposed to parallellism, not executing multiple platforms.
You may find the following useful:
Sauce Gem 30 rake tasks
"The Sauce integration is currently targeted at RSpec and Cucumber, running on a local server you can spin up multiple copies of. It runs a copy of each test for each platform, and divides them up across all the concurrency available to your Sauce Labs account by default"
Hope it helps, I haven't used it myself yet.
Thanks for the clarification. To accomplish testing your app for all the supported environments (OSs/browsers) you can use something as Selenium Grid here is an example Selenium RC: Run tests in multiple browsers automatically.
TestingBot is a service that use this: http://blog.testingbot.com/2012/02/19/selenium-cucumber-capybara
Other approach is described here: http://altoros.github.io/2013/running-capybara-tests-in-remote-browsers/
http://paauspaani.blogspot.mx/2013/05/running-tests-remotely-using-selenium.html
There is also a presentation: http://www.slideshare.net/martinkleppmann/crossbrowser-testing-in-the-real-world
Also this could help you Has anyone figured out a way to run the same cucumber scenario on multiple browsers/web drivers?
Hopefully this will give you some clues.
I am confused by this statement of yours:
Currently I have them running on different machines but the SAME
features do not execute, it just splits up the features and runs
different features on different machines.
parallel_tests is used for splitting up tests and running them on multiple cores, not on a distributed environment of multiple machines. It can group tests to be run on a distributed environment using the --only-group flag, but it doesn't actually run tests on a distributed environment. So you have to do some lifting yourself to get the tests running on a distributed environment. You could run all of your tests on multiple machines like so:
Use net-ssh to ssh into each one of your boxes.
Use each ssh session to run your parallel_tests script (which should break the tests up and run them in parallel on the current box -- just don't use the --only-group option as described here)

Starting multiple tools like grunt and http-server in one terminal

I'm using git-bash on windows and I find it annoying to open up two terminal windows (and navigating to the right path in both) to:
start a http-server to server static files (node tool)
start grunt (default grunt task is grunt-watch which watches the file system and runs tasks when things change)
What I want is to be able to execute a bash script or something to
start the http-server
start other things if relevant
run the grunt command to start it watching
My questions are:
is it possible?
is it practical? (i.e. console feedback might not be possible or would be confusing if multiple things were able to be shown as they would be interwoven.. if that is even possible)
is there a better way? -- other than multiple terminals :o)
If your using Grunt already, you should be able to utilize Grunt's task queues to run multiple tasks in one go. Typically, for each project you have some default task that orchestrates a running development environment like so:
grunt.registerTask(
'default',
'Starts the server in development mode and watches for changes',
['build', 'server', 'watch']);
Sometimes, though, merely queuing tasks isn't enough. You can drop into writing ad-hoc tasks and utilize Grunt's extensive API, such as grunt.task.run and the rich context inside of tasks.
I am not going to bombard you with examples, but things you can do here can range from fetching data from remote sources, spawning different child processes, piping their stdin to the Grunt process and starting arbitrary tasks using grunt.task.run.

Rspec process hangs at different places, process cannot be killed. How to diagnose?

In a rails application I'm developing (on OS-X), I'm finding running the test suite via rspec locking up increasingly frequently. It does not happen every time. I've tried adding --format documentation when running the suite to see if it happens at the same place every time, and it does not.
I've tried killing the process with kill -9. It then changes the name to (ruby) with a process status of ?E. This link suggests that the process is blocked waiting for a system call to finish. I have to restart my machine every time this happens in order to kill this process.
I've tried re-installing rvm, ruby, mysql, and imagemagick. This project is using imagemagick (via the mini_magick) gem, and I suspected that it may be one of these commands that is causing rspec to block. I tried adding puts statements around each of the mini_magick commands to ensure they finish executing, and all looks fine.
I'm looking for suggestions on how to diagnose this issue.
It's possible your problem is an order-dependency bug, you can pass the seed along and the order will remain consistent.
RSpec prints out the random number it used to seed the randomizer.
Use this number to run rspec with the same order
--order rand:3455

Resources