2023-03-07 09:36:05 +01:00
|
|
|
# Run tests with nix-build -A tests.integration.keycloak
|
2023-02-23 08:04:44 +01:00
|
|
|
{ nixpkgs ? <nixpkgs>
|
2023-03-07 09:21:20 +01:00
|
|
|
, systems ? [ "i686-linux" "x86_64-linux" ]
|
2023-02-23 08:04:44 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2023-03-07 09:21:20 +01:00
|
|
|
pkgs = import nixpkgs {};
|
2023-02-23 08:04:44 +01:00
|
|
|
|
|
|
|
version = "1.0";
|
2023-03-07 09:21:20 +01:00
|
|
|
|
2023-03-07 09:36:05 +01:00
|
|
|
disnixos = pkgs.callPackage ./common.nix { inherit nixpkgs; };
|
2023-02-23 08:04:44 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
rec {
|
|
|
|
tarball = disnixos.sourceTarball {
|
|
|
|
name = "testproject-zip";
|
|
|
|
inherit version;
|
2023-03-07 09:21:20 +01:00
|
|
|
src = ../../.;
|
2023-02-23 08:04:44 +01:00
|
|
|
officialRelease = false;
|
|
|
|
};
|
|
|
|
|
2023-03-07 09:21:20 +01:00
|
|
|
builds = {
|
2023-03-07 09:36:05 +01:00
|
|
|
simple = disnixos.genBuilds systems {
|
|
|
|
name = "test-project-manifest";
|
|
|
|
inherit version;
|
|
|
|
inherit tarball;
|
|
|
|
servicesFile = "tests/integration/keycloak/services.nix";
|
|
|
|
networkFile = "tests/integration/keycloak/network.nix";
|
|
|
|
distributionFile = "tests/integration/keycloak/distribution.nix";
|
|
|
|
};
|
2023-03-07 09:21:20 +01:00
|
|
|
};
|
2023-02-23 08:04:44 +01:00
|
|
|
|
2023-03-07 09:21:20 +01:00
|
|
|
tests = {
|
2023-03-07 09:36:05 +01:00
|
|
|
simple = disnixos.disnixTest builtins.currentSystem builds.simple {
|
2023-03-07 09:21:20 +01:00
|
|
|
name = "test-project-test";
|
|
|
|
inherit tarball;
|
|
|
|
networkFile = "tests/integration/keycloak/network.nix";
|
|
|
|
# dysnomiaStateDir = /var/state/dysnomia;
|
2023-02-23 08:04:44 +01:00
|
|
|
testScript =
|
|
|
|
''
|
2023-03-15 07:55:17 +01:00
|
|
|
def assert_service_started(machine, name):
|
|
|
|
code, log = machine.systemctl("status " + name)
|
|
|
|
if code != 0:
|
|
|
|
raise Exception(name + " could not be started:\n---\n" + log + "---\n")
|
2023-03-07 09:21:20 +01:00
|
|
|
|
2023-03-15 07:55:17 +01:00
|
|
|
def assert_database_exists(machine, name):
|
|
|
|
if machine.succeed("""psql -XtA -U postgres -h localhost -c "SELECT 1 FROM pg_database WHERE datname='{}'" """.format(name)) != '1\n':
|
|
|
|
raise Exception("could not find database '{}' in postgresql".format(name))
|
|
|
|
|
|
|
|
with subtest("check postgres service started"):
|
|
|
|
assert_service_started(test1, "postgresql.service")
|
|
|
|
|
|
|
|
with subtest("check db is created"):
|
|
|
|
assert_database_exists(test1, "keycloak")
|
2023-02-23 08:04:44 +01:00
|
|
|
'';
|
|
|
|
};
|
2023-03-07 09:21:20 +01:00
|
|
|
};
|
|
|
|
}.tests
|