[SERVER-25401] Add Random.choice() method to the shell Created: 02/Aug/16 Updated: 06/Dec/22 Resolved: 19/Nov/21 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Charlie Swanson | Assignee: | Backlog - Server Tooling and Methods (STM) (Inactive) |
| Resolution: | Won't Fix | Votes: | 1 |
| Labels: | move-stm | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Server Tooling & Methods
|
||||||||
| Sprint: | Platforms 2016-08-26 | ||||||||
| Participants: | |||||||||
| Description |
|
There are many tests that do random selections from arrays, or write helper functions to do so for them. We should add a Random.choice() to remove the need for all these custom helpers. Name chosen to match python's random.choice, but I don't really care what the name is. Examples of places that could benefit from such functionality:
|
| Comments |
| Comment by Brooke Miller [ 19/Nov/21 ] |
|
STM doesn't have bandwidth to pick this up, so we're closing as won't fix. However, if other teams have capacity and would like to pursue this, please feel free to pick this up. |
| Comment by Charlie Swanson [ 29/Aug/16 ] |
|
Ok, that sounds reasonable. Will do if it comes up, thanks. |
| Comment by Mira Carey [ 29/Aug/16 ] |
|
Ah, sorry, didn't mean to say that you marked it required, but rather that it's behind a bunch of actually 3.3. required work in line. I'm suggesting that if you want it now, or before we get to it (after our 3.3. requireds), that you drop it into a util lib. We can clean it up, or use it in other use cases, after 3.4 |
| Comment by Charlie Swanson [ 29/Aug/16 ] |
|
Ok. I don't recall marking it 3.3 Required? That seems optimistic... Could we add it quickly to the shell in the short term and schedule the larger refactor separately? Or, could I do that later the next time I write a test that needs a choice()? |
| Comment by Mira Carey [ 29/Aug/16 ] |
|
charlie.swanson - Also, this isn't really 3.3 required, so I'm going to push this out to planning bucket a. If you need it in the short run you're welcome to it. Otherwise we'll tackle it after 3.4 |
| Comment by Mira Carey [ 29/Aug/16 ] |
|
I think the angle I want to take is to add new things like this to a utility library, but also to make that generally available for jstests (probably via resmoke). That way it won't be an unnecessary load on developers writing the tests, but also won't increase the amount of code we have to externally support in the shell. So let's do jstests/libs/random.js and I'll link in another ticket for the resmoke changes to make it generally available. |
| Comment by Charlie Swanson [ 29/Aug/16 ] |
|
I don't really have strong opinions on where it gets defined. It could be in a utility, but then shouldn't most/all of the random utility? It seems weird that you get most of the methods on Random by default, but need to load something else to get this other one. It would be easier to just always load jstests/libs/random.js or something whenever I reference Random. But really I just want to avoid typing the same code over and over again, so a utility would be fine. |
| Comment by Mira Carey [ 29/Aug/16 ] |
|
I'm not in favor of adding more random helpers to the shell that exist entirely for tests. Is there a reason to have this in the shell, instead of in a utility library loaded in by jstests? (like the other files in jstests/libs) |