Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set PARALLEL_TEST environment variable. #172

Merged
merged 5 commits into from
Jan 4, 2013

Conversation

jshraibman-mdsol
Copy link
Contributor

This will allow me to fix SimpleCov issue 64

Setting this environment variable will let tools know they are being run inside parallel_tests and adjust accordingly.

@grosser
Copy link
Owner

grosser commented Jan 2, 2013

Why not rely on TEST_ENV_NUMBER -> more generic -> if something needs multiple test envs it's something parallel -> use different command names

@jshraibman-mdsol
Copy link
Contributor Author

I often set TEST_ENV_NUMBER to run different tests in different terminals manually. TEST_ENV_NUMBER is used to determine which test database to connect to. I personally can't rely on it to mean that the test is being run inside parallel_tests and I imagine I'm not the only one.

@grosser
Copy link
Owner

grosser commented Jan 2, 2013

You are the 1% :D
Ok,

  • so make sure it is set in all places that TEST_ENV_NUMBER is used
  • add a test so I don't break it later
  • maybe set it so something like "1" or "yes" or "true"

@jshraibman-mdsol
Copy link
Contributor Author

How do you runs specs? I'm getting a failure when I try. Am I not running them properly or is there a bug in HEAD?

[jshraibman@Joseph-Shraibmans-MacBook-Pro master ~/work/parallel_tests]$ time spec spec
Example disabled: should not log examples without location
Example disabled: prints failing examples
/Users/jshraibman/work/parallel_tests/spec/parallel_tests/tasks_spec.rb:28:in `block (2 levels) in <top (required)>': undefined method `around' for Spec::Example::ExampleGroup::Subclass_10::Subclass_2:Class (NoMethodError)
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:183:in `module_eval'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:183:in `subclass'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:55:in `describe'
    from /Users/jshraibman/work/parallel_tests/spec/parallel_tests/tasks_spec.rb:27:in `block in <top (required)>'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:183:in `module_eval'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:183:in `subclass'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:55:in `describe'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/example/example_group_factory.rb:31:in `create_example_group'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/dsl/main.rb:28:in `describe'
    from /Users/jshraibman/work/parallel_tests/spec/parallel_tests/tasks_spec.rb:4:in `<top (required)>'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in `load'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in `block in load_files'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in `each'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in `load_files'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/runner/options.rb:133:in `run_examples'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in `run'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/bin/spec:5:in `<top (required)>'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/bin/spec:19:in `load'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/bin/spec:19:in `<main>'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:in `eval'
    from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:in `<main>'

real    0m0.851s
user    0m0.775s
sys 0m0.071s

@grosser
Copy link
Owner

grosser commented Jan 2, 2013

try rake ;)

On Wed, Jan 2, 2013 at 10:37 AM, Joseph Shraibman
notifications@git.luolix.topwrote:

How do you runs specs? I'm getting a failure when I try. Am I not running
them properly or is there a bug in HEAD?

[jshraibman@Joseph-Shraibmans-MacBook-Pro master ~/work/parallel_tests]$ time spec spec
Example disabled: should not log examples without location
Example disabled: prints failing examples
/Users/jshraibman/work/parallel_tests/spec/parallel_tests/tasks_spec.rb:28:in block (2 levels) in <top (required)>': undefined methodaround' for Spec::Example::ExampleGroup::Subclass_10::Subclass_2:Class (NoMethodError)
from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:183:in module_eval' from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:183:insubclass'
from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:55:in describe' from /Users/jshraibman/work/parallel_tests/spec/parallel_tests/tasks_spec.rb:27:inblock in <top (required)>'
from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:183:in module_eval' from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:183:insubclass'
from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:55:in describe' from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/example/example_group_factory.rb:31:increate_example_group'
from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/dsl/main.rb:28:in describe' from /Users/jshraibman/work/parallel_tests/spec/parallel_tests/tasks_spec.rb:4:in<top (required)>'
from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:in load' from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:15:inblock in load_files'
from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:in each' from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/runner/example_group_runner.rb:14:inload_files'
from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/runner/options.rb:133:in run_examples' from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:inrun'
from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rspec-1.3.0/bin/spec:5:in <top (required)>' from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/bin/spec:19:inload'
from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/bin/spec:19:in <main>' from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:ineval'
from /Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/bin/ruby_noexec_wrapper:14:in `

'

real 0m0.851s
user 0m0.775s
sys 0m0.071s


Reply to this email directly or view it on GitHubhttps://github.com//pull/172#issuecomment-11818720.

Try to set PARALLEL_TESTS to number of processes.
Add specs.
@jshraibman-mdsol
Copy link
Contributor Author

Updated. Test results:

[jshraibman@Joseph-Shraibmans-MacBook-Pro feature/env_var ~/work/parallel_tests]$ time rake
/Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.8.7/lib/rake/alt_system.rb:32: Use RbConfig instead of obsolete and deprecated Config.
(in /Users/jshraibman/work/parallel_tests)
rspec spec/
/Users/jshraibman/.rvm/gems/ruby-1.9.3-p125/gems/rake-0.8.7/lib/rake/alt_system.rb:32: Use RbConfig instead of obsolete and deprecated Config.
........................................................................................................................................................................................

Pending:
ParallelTests::RSpec::FailuresLogger should not log examples without location
# Not Yet Implemented
# ./spec/parallel_tests/rspec/failure_logger_spec.rb:75
ParallelTests::RSpec::SummaryLogger prints failing examples
# Not Yet Implemented
# ./spec/parallel_tests/rspec/summary_logger_spec.rb:12

Finished in 68.45 seconds
186 examples, 0 failures, 2 pending

real 1m9.833s
user 1m25.996s
sys 0m8.117s

@@ -24,6 +24,13 @@ def call(*args)
call(['xxx'],1,{})
end

# The PARALLEL_TESTS environment variable being set lets child processes know they are being run
# inside parallel_tests. The actual value doesn't matter.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say kill the comment and put it into the it
it "sets PARALLEL_TESTS to something so child processes know that parallel_tests is used"

@jshraibman-mdsol
Copy link
Contributor Author

Updated.

@grosser
Copy link
Owner

grosser commented Jan 3, 2013

how about making it more meaningful, for example PARALLEL_TEST_GROUPS=4 ?

On Wed, Jan 2, 2013 at 1:14 PM, Joseph Shraibman
notifications@git.luolix.topwrote:

Updated.


Reply to this email directly or view it on GitHubhttps://github.com//pull/172#issuecomment-11824534.

@grosser
Copy link
Owner

grosser commented Jan 3, 2013

I can do the change myself, just curious about your opinion / if you still need it

@jshraibman-mdsol
Copy link
Contributor Author

Changing the name still fulfills the original purpose of having programs know they are being run inside parallel_tests. I would have made the change myself but I got caught up with other things.

grosser added a commit that referenced this pull request Jan 4, 2013
Set PARALLEL_TEST environment variable.
@grosser grosser merged commit 7198afd into grosser:master Jan 4, 2013
@@ -28,7 +28,7 @@ def self.run_tests_in_parallel(num_processes, options)
report_number_of_tests runner, groups

test_results = Parallel.map(groups, :in_processes => groups.size) do |group|
run_tests(runner, group, groups.index(group), options)
run_tests(runner, group, groups.index(group), num_processes, options)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about groups.size instead of num_processes, since that's the real number of processes used (vs requested) ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just do it myself, also fits better with the env variable name :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize there was a difference or I would have used groups.size.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

99% the same, just in weird edge-cases...

On Thu, Jan 3, 2013 at 8:44 PM, Joseph Shraibman
notifications@git.luolix.topwrote:

In lib/parallel_tests/cli.rb:

@@ -28,7 +28,7 @@ def self.run_tests_in_parallel(num_processes, options)
report_number_of_tests runner, groups

     test_results = Parallel.map(groups, :in_processes => groups.size) do |group|
  •      run_tests(runner, group, groups.index(group), options)
    
  •      run_tests(runner, group, groups.index(group), num_processes, options)
    

I didn't realize there was a difference or I would have used groups.size.


Reply to this email directly or view it on GitHubhttps://github.com//pull/172/files#r2547499.

@grosser
Copy link
Owner

grosser commented Jan 4, 2013

-> 0.9.2, thanks for the pull :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatically detect the usage of parallel tests and modify setup
2 participants