Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Expose taskId (or some way of uniquely identifying test runners) #2392

Open
pmowrer opened this issue Jul 31, 2015 · 15 comments
Open

Expose taskId (or some way of uniquely identifying test runners) #2392

pmowrer opened this issue Jul 31, 2015 · 15 comments

Comments

@pmowrer
Copy link
Contributor

pmowrer commented Jul 31, 2015

When using test file sharding, I can't seem to find a way of uniquely identifying each runner. Being able to do so is helpful when synchronizing shared resources between the runners.

By taskId, I'm referring to chrome #1-1, etc.

var taskId = rotatedIndex + 1;

@sjelin
Copy link
Contributor

sjelin commented Sep 21, 2015

The taskId is an arbitrary number. Just generate a UUID if you need a unique number.

@sjelin sjelin closed this as completed Sep 21, 2015
@pmowrer
Copy link
Contributor Author

pmowrer commented Sep 21, 2015

@sjelin I'm not looking for a unique number, just a way to identify a task from another, period. If you know of a way to do this, please share.

@sjelin
Copy link
Contributor

sjelin commented Sep 21, 2015

I don't understand. Surely giving each task a UUID is a way to identify one from another?

@pmowrer
Copy link
Contributor Author

pmowrer commented Sep 21, 2015

As an example, when test file sharding with maxInstances at 2, I'm looking for a way to know whether the currently running Protractor instance is #1 or #2.

@sjelin
Copy link
Contributor

sjelin commented Sep 25, 2015

Why do you need to know if a task is 1 or 2? Why won't a UUID work? Again the taskId is arbitrary and exposing it would force us to have to keep it consistent over new version releases.

@pmowrer
Copy link
Contributor Author

pmowrer commented Sep 25, 2015

Probably easiest if I explain the use case:

Our tests use random subdomains as part of our test scenario. To facilitate on CI, we generate a file of X random subdomains that are written to the hosts file. When we run the test, Y test instances get an equal share, X/Y, subdomains that are read from the aforementioned file. Since none of the instances are aware of one another and they cannot communicate, they use an index to grab their X/Y chunk of the subdomains available. E.g. the instance 1 is index 1 and reads from the beginning until X/Y, instance 2 reads from X/Y until (X/Y) * 2, etc.

Since Protractor doesn't (to my knowledge) expose any way for us to identify a test runner, we use getMultiCapabilities() to assign an index to each capability. The test instance can then identify itself via browser.getProcessedConfig(). However, in the test sharding scenario, we've not been able to find a way of assigning indexes to the shard runners.

Hope that explains sufficiently.

@sjelin
Copy link
Contributor

sjelin commented Sep 25, 2015

@juliemr thoughts?

@sricc
Copy link

sricc commented Jun 6, 2016

Any update / info on this?

@juliemr
Copy link
Member

juliemr commented Jul 14, 2016

I think it wouldn't be unreasonable to add this to the processed config, but we need to make sure we're doing it in a sane and simple way so we don't break it going forward.

@fcin
Copy link

fcin commented Oct 25, 2016

I would love to have this feature soon, because I want customize my reporter with separate page for every file. Any progress?

@lovedota
Copy link

@sjelin How to the UUID approach works in the cases, I have 3 users, I config 3 instances to run at the same time and it would be very easy to get unique user with the currentInstance for example

login() {
    let user = browser.params.users[browser.getInstance()]; 
}

@csymeonides
Copy link

I have the same problem. Can anyone explain how I can set a UUID per shard instance? The code from @lovedota above doesn't work (browser.getInstance() doesn't seem to exist).

@korobochka
Copy link

+1 to this.
Use case: when running parallel test cases we want to show different "threads" separately. Currently I attach process.pid to the report, but this results in tenths of threads instead of maxInstances ones.

@zwingliernst
Copy link

+1 to this.
Use case. The same user can login in x parallel sessions of the application. If the user does not exist yet, the onPrepare-Section creates it. Because of sharding, y instances try to create the same username, which of course doesn't work.
Goal: for each opened browser have a unique username-extension like runner-id.

@idem7x
Copy link

idem7x commented Feb 9, 2021

+1
As a use case I have array[] with 2 test accounts and I want to use them in parallel run. Every run should take 1 from 2 accounts in time.
Would be cool to have something like browser.getInstanceNumber() from [chrome #1-0] and [chrome #1-1], so I can take credentials for users like const user = array[browser.getInstanceNumber()].

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

No branches or pull requests