mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00
nixos/tests/glitchtip: init
Co-authored-by: Nico Felbinger <nico@felbinger.eu>
This commit is contained in:
parent
5da710d274
commit
dd87a30c58
4 changed files with 109 additions and 0 deletions
|
@ -434,6 +434,7 @@ in {
|
||||||
gitolite-fcgiwrap = handleTest ./gitolite-fcgiwrap.nix {};
|
gitolite-fcgiwrap = handleTest ./gitolite-fcgiwrap.nix {};
|
||||||
glance = runTest ./glance.nix;
|
glance = runTest ./glance.nix;
|
||||||
glances = runTest ./glances.nix;
|
glances = runTest ./glances.nix;
|
||||||
|
glitchtip = runTest ./glitchtip.nix;
|
||||||
glusterfs = handleTest ./glusterfs.nix {};
|
glusterfs = handleTest ./glusterfs.nix {};
|
||||||
gnome = handleTest ./gnome.nix {};
|
gnome = handleTest ./gnome.nix {};
|
||||||
gnome-extensions = handleTest ./gnome-extensions.nix {};
|
gnome-extensions = handleTest ./gnome-extensions.nix {};
|
||||||
|
|
103
nixos/tests/glitchtip.nix
Normal file
103
nixos/tests/glitchtip.nix
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
domain = "http://glitchtip.local:8000";
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
name = "glitchtip";
|
||||||
|
meta.maintainers = with lib.maintainers; [
|
||||||
|
defelo
|
||||||
|
felbinger
|
||||||
|
];
|
||||||
|
|
||||||
|
nodes.machine =
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
services.glitchtip = {
|
||||||
|
enable = true;
|
||||||
|
port = 8000;
|
||||||
|
settings.GLITCHTIP_DOMAIN = domain;
|
||||||
|
environmentFiles = [
|
||||||
|
(builtins.toFile "glitchtip.env" ''
|
||||||
|
SECRET_KEY=8Hz7YCGzo7fiicHb8Qr22ZqwoIB7lSRx
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
environment.systemPackages = [ pkgs.sentry-cli ];
|
||||||
|
|
||||||
|
networking.hosts."127.0.0.1" = [ "glitchtip.local" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
interactive.nodes.machine = {
|
||||||
|
services.glitchtip.listenAddress = "0.0.0.0";
|
||||||
|
networking.firewall.allowedTCPPorts = [ 8000 ];
|
||||||
|
virtualisation.forwardPorts = [
|
||||||
|
{
|
||||||
|
from = "host";
|
||||||
|
host.port = 8000;
|
||||||
|
guest.port = 8000;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
import json
|
||||||
|
import re
|
||||||
|
import time
|
||||||
|
|
||||||
|
machine.wait_for_unit("glitchtip.service")
|
||||||
|
machine.wait_for_unit("glitchtip-worker.service")
|
||||||
|
machine.wait_for_open_port(8000)
|
||||||
|
|
||||||
|
origin_url = "${domain}"
|
||||||
|
cookie_jar_path = "/tmp/cookies.txt"
|
||||||
|
curl = f"curl -b {cookie_jar_path} -c {cookie_jar_path} -fS -H 'Origin: {origin_url}'"
|
||||||
|
|
||||||
|
# create superuser account
|
||||||
|
machine.succeed("DJANGO_SUPERUSER_PASSWORD=password glitchtip-manage createsuperuser --no-input --email=admin@example.com")
|
||||||
|
|
||||||
|
# login
|
||||||
|
machine.fail(f"{curl} -s {origin_url}/_allauth/browser/v1/auth/session") # get the csrf token, returns a 401
|
||||||
|
csrf_token = machine.succeed(f"grep csrftoken {cookie_jar_path} | cut -f7").rstrip()
|
||||||
|
machine.succeed(f"{curl} {origin_url}/_allauth/browser/v1/auth/login -s -H 'X-Csrftoken: {csrf_token}' -H 'Content-Type: application/json' -d '{{\"email\": \"admin@example.com\", \"password\": \"password\"}}'")
|
||||||
|
|
||||||
|
resp = json.loads(machine.succeed(f"{curl} {origin_url}/api/0/users/me/"))
|
||||||
|
assert resp["email"] == "admin@example.com"
|
||||||
|
assert resp["isSuperuser"] is True
|
||||||
|
|
||||||
|
# create organization
|
||||||
|
csrf_token = machine.succeed(f"grep csrftoken {cookie_jar_path} | cut -f7").rstrip()
|
||||||
|
machine.succeed(f"{curl} {origin_url}/api/0/organizations/ -s -H 'X-Csrftoken: {csrf_token}' -H 'Content-Type: application/json' -d '{{\"name\": \"main\"}}'")
|
||||||
|
|
||||||
|
resp = json.loads(machine.succeed(f"{curl} {origin_url}/api/0/organizations/"))
|
||||||
|
assert len(resp) == 1
|
||||||
|
assert resp[0]["name"] == "main"
|
||||||
|
assert resp[0]["slug"] == "main"
|
||||||
|
|
||||||
|
# create team
|
||||||
|
csrf_token = machine.succeed(f"grep csrftoken {cookie_jar_path} | cut -f7").rstrip()
|
||||||
|
machine.succeed(f"{curl} {origin_url}/api/0/organizations/main/teams/ -s -H 'X-Csrftoken: {csrf_token}' -H 'Content-Type: application/json' -d '{{\"slug\": \"test\"}}'")
|
||||||
|
|
||||||
|
# create project
|
||||||
|
csrf_token = machine.succeed(f"grep csrftoken {cookie_jar_path} | cut -f7").rstrip()
|
||||||
|
machine.succeed(f"{curl} {origin_url}/api/0/teams/main/test/projects/ -s -H 'X-Csrftoken: {csrf_token}' -H 'Content-Type: application/json' -d '{{\"name\": \"test\"}}'")
|
||||||
|
|
||||||
|
# fetch dsn
|
||||||
|
resp = json.loads(machine.succeed(f"{curl} {origin_url}/api/0/projects/main/test/keys/"))
|
||||||
|
assert len(resp) == 1
|
||||||
|
assert re.match(r"^http://[\da-f]+@glitchtip\.local:8000/\d+$", dsn := resp[0]["dsn"]["public"])
|
||||||
|
|
||||||
|
# send event
|
||||||
|
machine.succeed(f"SENTRY_DSN={dsn} sentry-cli send-event -m 'hello world'")
|
||||||
|
|
||||||
|
for _ in range(20):
|
||||||
|
resp = json.loads(machine.succeed(f"{curl} {origin_url}/api/0/organizations/main/issues/?query=is:unresolved"))
|
||||||
|
if len(resp) != 0: break
|
||||||
|
time.sleep(1)
|
||||||
|
assert len(resp) == 1
|
||||||
|
assert resp[0]["title"] == "hello world"
|
||||||
|
assert int(resp[0]["count"]) == 1
|
||||||
|
'';
|
||||||
|
}
|
|
@ -5,6 +5,7 @@
|
||||||
callPackage,
|
callPackage,
|
||||||
stdenv,
|
stdenv,
|
||||||
makeWrapper,
|
makeWrapper,
|
||||||
|
nixosTests,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -111,6 +112,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit frontend python;
|
inherit frontend python;
|
||||||
|
tests = { inherit (nixosTests) glitchtip; };
|
||||||
updateScript = ./update.sh;
|
updateScript = ./update.sh;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
milksnake,
|
milksnake,
|
||||||
cffi,
|
cffi,
|
||||||
pytestCheckHook,
|
pytestCheckHook,
|
||||||
|
nixosTests,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
buildPythonPackage rec {
|
buildPythonPackage rec {
|
||||||
|
@ -63,6 +64,8 @@ buildPythonPackage rec {
|
||||||
|
|
||||||
pythonImportsCheck = [ "symbolic" ];
|
pythonImportsCheck = [ "symbolic" ];
|
||||||
|
|
||||||
|
passthru.tests = { inherit (nixosTests) glitchtip; };
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "Python library for dealing with symbol files and more";
|
description = "Python library for dealing with symbol files and more";
|
||||||
homepage = "https://github.com/getsentry/symbolic";
|
homepage = "https://github.com/getsentry/symbolic";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue