From 7a48f9ebce85e32b9b47e44657cd26cc70873c07 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Fri, 1 Nov 2024 19:47:08 +0100 Subject: [PATCH] postgresqlPackages.pgvecto-rs: make passthru.tests work with correct package Same reasoning as commit before. --- nixos/tests/pgvecto-rs.nix | 31 +++++++++---------- .../sql/postgresql/ext/pgvecto-rs/default.nix | 4 +-- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/nixos/tests/pgvecto-rs.nix b/nixos/tests/pgvecto-rs.nix index 8d9d6c0b88f51..1b1689183127f 100644 --- a/nixos/tests/pgvecto-rs.nix +++ b/nixos/tests/pgvecto-rs.nix @@ -1,6 +1,3 @@ -# mostly copied from ./timescaledb.nix which was copied from ./postgresql.nix -# as it seemed unapproriate to test additional extensions for postgresql there. - { system ? builtins.currentSystem , config ? { } , pkgs ? import ../.. { inherit system config; } @@ -10,7 +7,6 @@ with import ../lib/testing-python.nix { inherit system pkgs; }; with pkgs.lib; let - postgresql-versions = import ../../pkgs/servers/sql/postgresql pkgs; # Test cases from https://docs.pgvecto.rs/use-cases/hybrid-search.html test-sql = pkgs.writeText "postgresql-test" '' CREATE EXTENSION vectors; @@ -27,8 +23,9 @@ let ('a thin cat sat on a mat and ate a thin rat', '[7, 8, 9]'), ('a thin dog sat on a mat and ate a thin rat', '[10, 11, 12]'); ''; - make-postgresql-test = postgresql-name: postgresql-package: makeTest { - name = postgresql-name; + + makePgVectorsTest = postgresqlPackage: makeTest { + name = "pgvecto-rs-${postgresqlPackage.name}"; meta = with pkgs.lib.maintainers; { maintainers = [ diogotcorreia ]; }; @@ -37,7 +34,7 @@ let { services.postgresql = { enable = true; - package = postgresql-package; + package = postgresqlPackage; extraPlugins = ps: with ps; [ pgvecto-rs ]; @@ -45,7 +42,11 @@ let }; }; - testScript = '' + testScript = { nodes, ... }: + let + inherit (nodes.machine.services.postgresql.package.pkgs) pgvecto-rs; + in + '' def check_count(statement, lines): return 'test $(sudo -u postgres psql postgres -tAc "{}"|wc -l) -eq {}'.format( statement, lines @@ -56,7 +57,7 @@ let machine.wait_for_unit("postgresql") with subtest("Postgresql with extension vectors is available just after unit start"): - machine.succeed(check_count("SELECT * FROM pg_available_extensions WHERE name = 'vectors' AND default_version = '${postgresql-package.pkgs.pgvecto-rs.version}';", 1)) + machine.succeed(check_count("SELECT * FROM pg_available_extensions WHERE name = 'vectors' AND default_version = '${pgvecto-rs.version}';", 1)) machine.succeed("sudo -u postgres psql -f ${test-sql}") @@ -66,11 +67,9 @@ let ''; }; - applicablePostgresqlVersions = filterAttrs (_: value: versionAtLeast value.version "14") postgresql-versions; in -mapAttrs' - (name: package: { - inherit name; - value = make-postgresql-test name package; - }) - applicablePostgresqlVersions +{ + default = makePgVectorsTest pkgs.postgresql; + jit = makePgVectorsTest pkgs.postgresql_jit; + passthru.override = p: makePgVectorsTest p; +} diff --git a/pkgs/servers/sql/postgresql/ext/pgvecto-rs/default.nix b/pkgs/servers/sql/postgresql/ext/pgvecto-rs/default.nix index 117319e606f0f..40cde8eeae0ba 100644 --- a/pkgs/servers/sql/postgresql/ext/pgvecto-rs/default.nix +++ b/pkgs/servers/sql/postgresql/ext/pgvecto-rs/default.nix @@ -86,9 +86,7 @@ in passthru = { updateScript = nix-update-script { }; - tests = { - pgvecto-rs = nixosTests.pgvecto-rs; - }; + tests = nixosTests.pgvecto-rs.passthru.override postgresql; }; meta = with lib; {