This commit enables the parametrization for "legacy-combined" protocol. All failing tests with that have been either fixed or disabled. Notably: - A couple of tests (e.g. involving builders) could be made to work with a non-local store, but this would require some refactoring to testlib in order to make certain configuration settings generic over local and remote operations. We've disabled those for now, in order to make progress - The store tests all run locally only because of their nature - The flakes tests also all run locally only because my energy for fixing them is limited (and it's a *lot* of test failures, with probably little overall benefit in terms of test coverage) Change-Id: I56fa249a64f7c17c952f688ec89e9687f2a13f12
51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
from pathlib import Path
|
|
|
|
from testlib.fixtures.file_helper import with_files
|
|
from testlib.fixtures.nix import Nix, NixDaemon
|
|
from testlib.utils import get_global_asset
|
|
|
|
import pytest
|
|
|
|
pytestmark = pytest.mark.no_daemon
|
|
|
|
|
|
@with_files({"config.nix": get_global_asset("config.nix")})
|
|
class TestOptimizeStore:
|
|
def _test_optimise_store(self, nix: Nix):
|
|
def build(name: str, *extra_args: str) -> Path:
|
|
expr = f"""
|
|
with import ./config.nix; mkDerivation {{
|
|
name = "{name}";
|
|
builder = builtins.toFile "builder" "mkdir $out; echo hello > $out/foo";
|
|
}}
|
|
"""
|
|
|
|
result = nix.nix_build(["-E", expr, "--no-out-link", *extra_args]).run().ok()
|
|
return Path(result.stdout_plain)
|
|
|
|
out1 = build("foo1", "--auto-optimise-store")
|
|
out2 = build("foo2", "--auto-optimise-store")
|
|
|
|
assert (out1 / "foo").samefile(out2 / "foo")
|
|
assert (out1 / "foo").stat().st_nlink == 3
|
|
|
|
out3 = build("foo3", "--no-auto-optimise-store")
|
|
|
|
assert not (out1 / "foo").samefile(out3 / "foo")
|
|
|
|
nix.nix_store(["--optimise"]).run().ok()
|
|
|
|
assert (out1 / "foo").samefile(out3 / "foo")
|
|
|
|
nix.nix_store(["--gc"]).run().ok()
|
|
|
|
assert list((nix.env.dirs.real_store_dir / ".links").glob("*")) == []
|
|
|
|
def test_optimise_store(self, nix: Nix):
|
|
self._test_optimise_store(nix)
|
|
|
|
def test_optimise_store_daemon(self, nix: Nix, daemon: NixDaemon):
|
|
nix.settings.auto_optimise_store = True
|
|
with daemon(nix, [], {"trusted-users": "*"}) as inner:
|
|
self._test_optimise_store(inner)
|