Unverified Commit aded718a authored by Wolfgang Walther's avatar Wolfgang Walther
Browse files

postgresqlPackages.apache_datasketches: move nixosTests.apache_datasketches into package

There is no need to fire up a whole VM just to run a two line test of
creating the extension. We can use postgresqlTestExtension for that.
This has the advantage that it runs with postgresqlTestHook, so without
a VM, making it more portable.
parent 139c5466
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -815,7 +815,6 @@ in {
  postfix-raise-smtpd-tls-security-level = handleTest ./postfix-raise-smtpd-tls-security-level.nix {};
  postfixadmin = handleTest ./postfixadmin.nix {};
  postgis = handleTest ./postgis.nix {};
  apache_datasketches = handleTest ./apache_datasketches.nix {};
  postgresql = handleTest ./postgresql.nix {};
  postgresql-jit = handleTest ./postgresql-jit.nix {};
  postgresql-wal-receiver = handleTest ./postgresql-wal-receiver.nix {};
+0 −29
Original line number Diff line number Diff line
import ./make-test-python.nix ({ pkgs, ...} : {
  name = "postgis";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ lsix ]; # TODO: Who's the maintener now?
  };

  nodes = {
    master =
      { pkgs, ... }:

      {
        services.postgresql = let mypg = pkgs.postgresql_15; in {
            enable = true;
            package = mypg;
            extraPlugins = with mypg.pkgs; [
              apache_datasketches
            ];
        };
      };
  };

  testScript = ''
    start_all()
    master.wait_for_unit("postgresql")
    master.sleep(10)  # Hopefully this is long enough!!
    master.succeed("sudo -u postgres psql -c 'CREATE EXTENSION datasketches;'")
    master.succeed("sudo -u postgres psql -c 'SELECT hll_sketch_to_string(hll_sketch_build(1));'")
  '';
})
+10 −4
Original line number Diff line number Diff line
{ stdenv, lib, fetchFromGitHub, postgresql, boost182, nixosTests }:
{ stdenv, lib, fetchFromGitHub, postgresql, boost182, postgresqlTestExtension }:

let
  version = "1.7.0";
@@ -20,7 +20,7 @@ let
  };
in

stdenv.mkDerivation {
stdenv.mkDerivation (finalAttrs: {
  pname = "apache_datasketches";
  inherit version;

@@ -61,7 +61,13 @@ stdenv.mkDerivation {
    runHook postInstall
  '';

  passthru.tests.apache_datasketches = nixosTests.apache_datasketches;
  passthru.tests.extension = postgresqlTestExtension {
    inherit (finalAttrs) finalPackage;
    sql = ''
      CREATE EXTENSION datasketches;
      SELECT hll_sketch_to_string(hll_sketch_build(1));
    '';
  };

  meta = {
    description = "PostgreSQL extension providing approximate algorithms for distinct item counts, quantile estimation and frequent items detection";
@@ -75,4 +81,4 @@ stdenv.mkDerivation {
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ mmusnjak ];
  };
}
})