1
0
Fork 0

make dummy integration test pass

This commit is contained in:
ibizaman 2023-03-07 00:21:20 -08:00
parent cf3aed2e82
commit 309360a356
7 changed files with 108 additions and 37 deletions

View file

@ -0,0 +1,6 @@
# Integration Tests
Integration tests configure real virtual machines and run tests on
those to assert some properties.
You can find all integration tests under the [tests/integration](/tests/integration) directory.

View file

@ -0,0 +1,40 @@
{ nixpkgs, pkgs }:
let
generateManifestSrc =
{name, tarball}:
pkgs.stdenv.mkDerivation {
name = "${name}-manifest-src";
buildCommand =
''
mkdir -p $out
cd $out
tar xfvj ${tarball}/tarballs/*.tar.bz2 --strip-components=1
'';
};
in
{
disnixTest = system:
{name, manifest, tarball, networkFile, externalNetworkFile ? false, testScript, dysnomiaStateDir ? "", postActivateTimeout ? 1}:
let
manifestSrc = generateManifestSrc {
inherit name tarball;
};
network = if externalNetworkFile then import networkFile else import "${manifestSrc}/${networkFile}";
in
with import "${nixpkgs}/nixos/lib/testing-python.nix" { inherit system; };
simpleTest {
nodes = network;
inherit name;
testScript = import "${pkgs.disnixos}/share/disnixos/generate-testscript.nix" {
inherit network testScript dysnomiaStateDir postActivateTimeout;
inherit (pkgs) disnix daemon socat libxml2;
inherit (pkgs.lib) concatMapStrings;
manifestFile = "${manifest}/manifest.xml";
};
};
}

View file

@ -0,0 +1,6 @@
{ pkgs
, utils
}:
{
keycloak = pkgs.callPackage ./keycloak.nix {};
}

View file

@ -1,58 +1,75 @@
{ nixpkgs ? <nixpkgs>
, system ? builtins.currentSystem
, systems ? [ "i686-linux" "x86_64-linux" ]
}:
let
pkgs = import nixpkgs {inherit system;};
pkgs = import nixpkgs {};
disnixos = import "${pkgs.disnixos}/share/disnixos/testing.nix" {
inherit nixpkgs system;
inherit nixpkgs;
};
version = "1.0";
disnixos2 = pkgs.callPackage ./common.nix { inherit nixpkgs; };
in
rec {
tarball = disnixos.sourceTarball {
name = "testproject-zip";
inherit version;
src = ./.;
src = ../../.;
officialRelease = false;
};
manifest =
disnixos.buildManifest {
name = "test-project-manifest";
version = builtins.readFile ./version;
inherit tarball;
servicesFile = "keycloak/services.nix";
networkFile = "keycloak/network.nix";
distributionFile = "keycloak/distribution.nix";
};
builds = {
simple = pkgs.lib.genAttrs systems (system:
let
pkgs = import nixpkgs { inherit system; };
tests =
disnixos.disnixTest {
name = "test-project-tests";
inherit tarball manifest;
networkFile = "keycloak/network.nix";
dysnomiaStateDir = /var/state/dysnomia;
disnixos = import "${pkgs.disnixos}/share/disnixos/testing.nix" {
inherit nixpkgs system;
};
in
disnixos.buildManifest {
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";
# extraParams = {
# "extra-builtins-file" = ../../extra-builtins.nix;
# };
}
);
};
tests = {
simple = disnixos2.disnixTest builtins.currentSystem {
name = "test-project-test";
inherit tarball;
manifest = builtins.getAttr (builtins.currentSystem) builds.simple;
networkFile = "tests/integration/keycloak/network.nix";
# dysnomiaStateDir = /var/state/dysnomia;
testScript =
''
# Wait until the front-end application is deployed
$test1->waitForFile("/var/tomcat/webapps/testapp");
# Wait a little longer and capture the output of the entry page
my $result = $test1->mustSucceed("sleep 10; curl --fail http://test2:8080/testapp");
# Wait until the front-end application is deployed
# $test1->waitForFile("/var/tomcat/webapps/testapp");
# Wait a little longer and capture the output of the entry page
# my $result = $test1->mustSucceed("sleep 10; curl --fail http://test2:8080/testapp");
'';
};
}
};
}.tests
# let
# utils = import ../../utils.nix {
# inherit pkgs;
# inherit (pkgs) stdenv lib;
# };
# keycloak = import ../../pkgs/keycloak/unit.nix {
# keycloak = import ../../keycloak/unit.nix {
# inherit pkgs utils;
# inherit (pkgs) stdenv lib;
# };

View file

@ -8,7 +8,7 @@ rec {
utils = pkgs.lib.callPackageWith pkgs ../../../utils.nix { };
customPkgs = import ../../../pkgs/all-packages.nix {
customPkgs = import ../../../all-packages.nix {
inherit system pkgs utils;
};
in
@ -26,11 +26,11 @@ rec {
};
};
deployment.keys = {
keycloakinitialadmin.text = ''
KEYCLOAK_ADMIN_PASSWORD="${builtins.extraBuiltins.pass "keycloak.${domain}/admin"}"
'';
};
# deployment.keys = {
# keycloakinitialadmin.text = ''
# KEYCLOAK_ADMIN_PASSWORD="${builtins.extraBuiltins.pass "keycloak.${domain}/admin"}"
# '';
# };
services = {
openssh = {

View file

@ -3,11 +3,12 @@
let
utils = pkgs.lib.callPackageWith pkgs ../../../utils.nix { };
customPkgs = import ../../../pkgs/all-packages.nix {
customPkgs = import ../../../all-packages.nix {
inherit system pkgs utils;
};
in
{
with utils;
rec {
KeycloakPostgresDB = customPkgs.mkPostgresDB {
name = "KeycloakPostgresDB";
database = "keycloak";
@ -18,12 +19,13 @@ in
KeycloakService = customPkgs.mkKeycloakService {
name = "KeycloakService";
subdomain = "keycloak";
# Get these from infrastructure.nix
user = "keycloak";
group = "keycloak";
postgresServiceName = (utils.getTarget "KeycloakPostgresDB").containers.postgresql-database.service_name;
postgresServiceName = (getTarget distribution "KeycloakPostgresDB").containers.postgresql-database.service_name;
initialAdminUsername = "admin";
keys = {
@ -32,13 +34,13 @@ in
};
logLevel = "INFO";
hostname = "keycloak.${getDomain "KeycloakService"}";
hostname = "keycloak.${getDomain distribution "KeycloakService"}";
dbType = "postgres";
dbDatabase = KeycloakPostgresDB.database;
dbUsername = KeycloakPostgresDB.username;
dbHost = {KeycloakPostgresDB}: KeycloakPostgresDB.target.properties.hostname;
dbPort = (getTarget "KeycloakPostgresDB").containers.postgresql-database.port;
dbPort = (getTarget distribution "KeycloakPostgresDB").containers.postgresql-database.port;
inherit KeycloakPostgresDB;
};