sts-sponsors team mailing list archive
-
sts-sponsors team
-
Mailing list archive
-
Message #03506
Re: [Merge] ~bjornt/maas:perf-test-no-custom-runner into maas:master
Review: Approve
+1 with a couple nits
Diff comments:
> diff --git a/Makefile b/Makefile
> index 6ddf017..6f826b7 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -62,7 +61,8 @@ build: \
> .run \
> $(VENV) \
> $(BIN_SCRIPTS) \
> - bin/py
> + bin/py \
> + bin/test.perf
I would drop this entirely, not to leave legacy stuff around.
> .PHONY: build
>
> all: build ui go-bins doc
> diff --git a/src/maastesting/pytest.py b/src/maastesting/pytest.py
> new file mode 100644
> index 0000000..60e01cc
> --- /dev/null
> +++ b/src/maastesting/pytest.py
> @@ -0,0 +1,30 @@
> +# Copyright 2022 Canonical Ltd. This software is licensed under the
> +# GNU Affero General Public License version 3 (see the file LICENSE).
> +import os
> +import random
> +import time
> +
> +import pytest
> +
> +
> +@pytest.fixture(scope="session")
> +def configure_seeds():
> + maas_rand_seed = os.environ.get("MAAS_RAND_SEED")
> + if maas_rand_seed is None:
> + maas_rand_seed = time.time_ns()
> + python_hash_seed = os.environ.get("PYTHONHASHSEED")
> + if python_hash_seed is None:
> + python_hash_seed = random.randint(1, 4294967295)
> + os.environ["PYTHONHASHSEED"] = str(python_hash_seed)
> + return maas_rand_seed, python_hash_seed
> +
> +
> +@pytest.fixture(autouse=True, scope="function")
scope="function" is the default, you can drop it
> +def random_seed(configure_seeds):
> + maas_rand_seed, python_hash_seed = configure_seeds
> + random.seed(maas_rand_seed)
> + yield
> + print(
> + f"MAAS_RAND_SEED={maas_rand_seed} "
> + f"PYTHONHASHSEED={python_hash_seed}",
> + )
--
https://code.launchpad.net/~bjornt/maas/+git/maas/+merge/433519
Your team MAAS Committers is subscribed to branch maas:master.
References