Skip to content

Commit

Permalink
Merge pull request #220812 from anpin/feature/promscale-rebase
Browse files Browse the repository at this point in the history
promscale: 0.10.0 -> 0.17.0
  • Loading branch information
marsam authored Apr 25, 2023
2 parents d88ddc1 + 0e191c7 commit 5249a7c
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 26 deletions.
10 changes: 10 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,16 @@
githubId = 1342360;
name = "Andrew Morgan";
};
anpin = {
email = "pavel@anpin.fyi";
github = "anpin";
githubId = 6060545;
matrix = "@anpin:matrix.org";
name = "Pavel Anpin";
keys = [{
fingerprint = "06E8 4FF6 0CCF 7AFD 5101 76C9 0FBC D3EE 6310 7407";
}];
};
anpryl = {
email = "anpryl@gmail.com";
github = "anpryl";
Expand Down
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ in {
tiddlywiki = handleTest ./tiddlywiki.nix {};
tigervnc = handleTest ./tigervnc.nix {};
timescaledb = handleTest ./timescaledb.nix {};
promscale = handleTest ./promscale.nix {};
timezone = handleTest ./timezone.nix {};
tinc = handleTest ./tinc {};
tinydns = handleTest ./tinydns.nix {};
Expand Down
60 changes: 60 additions & 0 deletions nixos/tests/promscale.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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; }
}:

with import ../lib/testing-python.nix { inherit system pkgs; };
with pkgs.lib;

let
postgresql-versions = import ../../pkgs/servers/sql/postgresql pkgs;
test-sql = pkgs.writeText "postgresql-test" ''
CREATE USER promscale SUPERUSER PASSWORD 'promscale';
CREATE DATABASE promscale OWNER promscale;
'';

make-postgresql-test = postgresql-name: postgresql-package: makeTest {
name = postgresql-name;
meta = with pkgs.lib.maintainers; {
maintainers = [ anpin ];
};

nodes.machine = { config, pkgs, ... }:
{
services.postgresql = {
enable = true;
package = postgresql-package;
extraPlugins = with postgresql-package.pkgs; [
timescaledb
promscale_extension
];
settings = { shared_preload_libraries = "timescaledb, promscale"; };
};
environment.systemPackages = with pkgs; [ promscale ];
};

testScript = ''
machine.start()
machine.wait_for_unit("postgresql")
with subtest("Postgresql with extensions timescaledb and promscale is available just after unit start"):
print(machine.succeed("sudo -u postgres psql -f ${test-sql}"))
machine.succeed("sudo -u postgres psql promscale -c 'SHOW shared_preload_libraries;' | grep promscale")
machine.succeed(
"promscale --db.name promscale --db.password promscale --db.user promscale --db.ssl-mode allow --startup.install-extensions --startup.only"
)
machine.succeed("sudo -u postgres psql promscale -c 'SELECT ps_trace.get_trace_retention_period();' | grep '(1 row)'")
machine.shutdown()
'';
};
#version 15 is not supported yet
applicablePostgresqlVersions = filterAttrs (_: value: versionAtLeast value.version "12" && !(versionAtLeast value.version "15")) postgresql-versions;
in
mapAttrs'
(name: package: {
inherit name;
value = make-postgresql-test name package;
})
applicablePostgresqlVersions

This file was deleted.

18 changes: 9 additions & 9 deletions pkgs/servers/monitoring/prometheus/promscale/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@

buildGoModule rec {
pname = "promscale";
version = "0.10.0";
version = "0.17.0";

src = fetchFromGitHub {
owner = "timescale";
repo = pname;
rev = version;
sha256 = "sha256-KF+aD9vJYqNJkJftx27ZsxmOIXZ/2ciKwjwcTw0GBvY=";
sha256 = "sha256-JizUI9XRzOEHF1kAblYQRYB11z9KWX7od3lPiRN+JNI=";
};

patches = [
./0001-remove-jaeger-test-dep.patch
];

vendorSha256 = "sha256-/cjRM8CrOKnx0BcRu2+MLV28MYLOrG5x1DN24mRUJzQ=";
vendorSha256 = "sha256-lnyKsipr/f9W9LWLb2lizKGLvIbS3XnSlOH1u1B87OY=";

ldflags = [
"-s"
"-w"
"-X github.com/timescale/promscale/pkg/version.Version=${version}"
"-X github.com/timescale/promscale/pkg/version.CommitHash=${src.rev}"
];

preBuild = ''
# Without this build fails with
# main module (github.com/timescale/promscale) does not contain package github.com/timescale/promscale/migration-tool/cmd/prom-migrator
rm -r migration-tool
'';
checkPhase = ''
runHook preCheck
Expand All @@ -51,6 +51,6 @@ buildGoModule rec {
changelog = "https://github.com/timescale/promscale/blob/${version}/CHANGELOG.md";
license = licenses.asl20;
platforms = platforms.unix;
maintainers = with maintainers; [ _0x4A6F ];
maintainers = with maintainers; [ _0x4A6F anpin ];
};
}
60 changes: 60 additions & 0 deletions pkgs/servers/sql/postgresql/ext/promscale_extension.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{ lib
, fetchFromGitHub
, fetchpatch
, buildPgxExtension
, postgresql
, stdenv
, nixosTests
}:

buildPgxExtension rec {
inherit postgresql;

pname = "promscale_extension";
version = "0.8.0";

src = fetchFromGitHub {
owner = "timescale";
repo = "promscale_extension";
rev = version;
sha256 = "sha256-vyEfQMGguHrHYdBEEmbev29L2uCa/4xL9DpGIniUwfI=";
};

cargoSha256 = "sha256-VK9DObkg4trcGUXxxISCd0zqU3vc1Qt6NxqpgKIARCQ=";

cargoPatches = [
# there is a duplicate definition in the lock file which fails to build with buildRustPackage
(fetchpatch {
name = "cargo-vendor.patch";
url = "https://github.com/timescale/promscale_extension/commit/3048bd959430e9abc2c1d5c772ab6b4fc1dc6a95.patch";
hash = "sha256-xTk4Ml8GN06QlJdrvAdVK21r30ZR/S83y5A5jJPdOw4=";
})
];

preBuild = ''
patchShebangs create-upgrade-symlinks.sh extract-extension-version.sh
## Hack to boostrap the build because some pgx commands require this file. It gets re-generated later.
cp templates/promscale.control ./promscale.control
'';
postInstall = ''
ln -s $out/lib/promscale-${version}.so $out/lib/promscale.so
'';
passthru.tests = {
promscale = nixosTests.promscale;
};

# tests take really long
doCheck = false;

meta = with lib; {
description = "Promscale is an open source observability backend for metrics and traces powered by SQL";
homepage = "https://github.com/timescale/promscale_extension";
maintainers = with maintainers; [ anpin ];
platforms = postgresql.meta.platforms;
license = licenses.unfree;

# as it needs to be used with timescaledb, simply use the condition from there
broken = versionOlder postgresql.version "12"
|| versionAtLeast postgresql.version "15";
};
}
2 changes: 2 additions & 0 deletions pkgs/servers/sql/postgresql/packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ self: super: {

pg_safeupdate = super.callPackage ./ext/pg_safeupdate.nix { };

promscale_extension = super.callPackage ./ext/promscale_extension.nix { };

repmgr = super.callPackage ./ext/repmgr.nix { };

rum = super.callPackage ./ext/rum.nix { };
Expand Down

0 comments on commit 5249a7c

Please sign in to comment.