pytest-randomly sets random.seed to a consistent value for all the workers/processes

pull/30653/head
Shane Smiskol 2 years ago
parent 61416a372b
commit 25241bcde2
  1. 4
      Jenkinsfile
  2. 1
      pyproject.toml
  3. 4
      selfdrive/car/tests/test_models.py

4
Jenkinsfile vendored

@ -234,8 +234,8 @@ node {
'car tests': {
pcStage("car tests") {
sh label: "build", script: "selfdrive/manager/build.py"
sh label: "test_models.py", script: "FILEREADER_CACHE=1 RANDOM_SEED=$RANDOM INTERNAL_SEG_CNT=250 \
INTERNAL_SEG_LIST=selfdrive/car/tests/test_models_segs.txt pytest selfdrive/car/tests/test_models.py"
sh label: "test_models.py", script: "INTERNAL_SEG_CNT=250 INTERNAL_SEG_LIST=selfdrive/car/tests/test_models_segs.txt FILEREADER_CACHE=1 \
pytest selfdrive/car/tests/test_models.py"
sh label: "test_car_interfaces.py", script: "MAX_EXAMPLES=100 pytest selfdrive/car/tests/test_car_interfaces.py"
}
},

@ -152,6 +152,7 @@ pytest-xdist = "*"
pytest-timeout = "*"
pytest-timeouts = "*"
pytest-random-order = "*"
pytest-randomly = "*"
ruff = "*"
scipy = "*"
sphinx = "*"

@ -32,7 +32,6 @@ NUM_JOBS = int(os.environ.get("NUM_JOBS", "1"))
JOB_ID = int(os.environ.get("JOB_ID", "0"))
INTERNAL_SEG_LIST = os.environ.get("INTERNAL_SEG_LIST", "")
INTERNAL_SEG_CNT = int(os.environ.get("INTERNAL_SEG_CNT", "0"))
RANDOM_SEED = int(os.environ.get("RANDOM_SEED", "0"))
def get_test_cases() -> List[Tuple[str, Optional[CarTestRoute]]]:
@ -51,9 +50,6 @@ def get_test_cases() -> List[Tuple[str, Optional[CarTestRoute]]]:
with open(os.path.join(BASEDIR, INTERNAL_SEG_LIST), "r") as f:
seg_list = f.read().splitlines()
if RANDOM_SEED:
random.seed(RANDOM_SEED)
seg_list_grouped = [(platform[2:], segment) for platform, segment in zip(seg_list[::2], seg_list[1::2])]
seg_list_grouped = random.sample(seg_list_grouped, INTERNAL_SEG_CNT or len(seg_list_grouped))
for platform, segment in seg_list_grouped:

Loading…
Cancel
Save