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

access process.env.PARTITION in application config #46

Closed
Sinled opened this issue Jul 21, 2016 · 6 comments
Closed

access process.env.PARTITION in application config #46

Sinled opened this issue Jul 21, 2016 · 6 comments
Labels

Comments

@Sinled
Copy link

Sinled commented Jul 21, 2016

Hi, thanks for great tool.

I have a small question.
Is there any ways to access PARTITION number in ember config/environment.js file?
I need it badly in my acceptance tests.

@trentmwillis
Copy link
Member

So a couple things:

  1. process.env.PARTITION is not provided or controller by this addon. It would be set as an environment variable for the process if you do something like: PARTITION=2 ember exam. (I might need to clarify that in the README).
  2. I'd be very wary of why you need this in your acceptance tests (or any test for that matter) as one of the major benefits of splitting/randomizing tests is that your tests don't know the order/context in which they are running so that you have better guarantees of their autonomy.

@Sinled
Copy link
Author

Sinled commented Jul 22, 2016

I'd be very wary of why you need this in your acceptance tests

i know it sounds strange, but our acceptance tests works with real backend, and at the beginning of every acceptance test we need to 'login' test user, but login works in such way - when you login in one place, backend terminates other session, and parallel tests fail because of that.

so if there would be information about partitions it would be possible to use different test logins for different partitions.

Maybe i am doing something wrong and there is better solution for my problem?

@trentmwillis
Copy link
Member

Seems reasonable. As long as you're not directly supplying the tests with the partition number, then I think it makes sense. I would likely do something like:

// config/environment.js

var USERS = [
  // user login information
];

module.exports = function() {
  var partition = process.env.PARTITION;
  return {
    testUser: USERS[partition]
  };
};

@Sinled
Copy link
Author

Sinled commented Jul 25, 2016

@trentmwillis thanks for reply
i tried almost exact solution, but it is not working out of the box,
if i don't pass manually PARTITION variable, process.env.PARTITION is undefined in config file

But to manually specify PARTITION i need to run separate processes, with ugly looking command

PARTITION=1 ember exam --split 4 --partition 1 --server --query="hidepassed=true&nojscs=true&nolint=true" &
 PARTITION=2 ember exam --split 4 --partition 2 --server --query="hidepassed=true&nojscs=true&nolint=true" &
 PARTITION=3 ember exam --split 4 --partition 3 --server --query="hidepassed=true&nojscs=true&nolint=true" &
 PARTITION=4 ember exam --split 4 --partition 4 --server --query="hidepassed=true&nojscs=true&nolint=true"

am i right?

@trentmwillis
Copy link
Member

Again:

process.env.PARTITION is not provided or controller by this addon. It would be set as an environment variable for the process

This means that yes, you must set it in your environment.

If you're hoping to use this with the --parallel option then it won't work properly since the config/environment is only generated once per build, meaning that partition numbers will not be available within that module. Splitting is done at run time, so unless you're only running a single partition (as in the example you gave above), it isn't possible to know the partition at build time.

Your only real option for doing this at run time is to check the query parameters.

@Sinled
Copy link
Author

Sinled commented Jul 26, 2016

Your only real option for doing this at run time is to check the query parameters.

Thanks, i'll try this way.

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

No branches or pull requests

2 participants