WIP: jepsen.garage nixos test #725
5 changed files with 5707 additions and 17 deletions
|
@ -95,17 +95,17 @@
|
|||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1707091808,
|
||||
"narHash": "sha256-LahKBAfGbY836gtpVNnWwBTIzN7yf/uYM/S0g393r0Y=",
|
||||
"lastModified": 1708296515,
|
||||
"narHash": "sha256-FyF489fYNAUy7b6dkYV6rGPyzp+4tThhr80KNAaF/yY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9f2ee8c91ac42da3ae6c6a1d21555f283458247e",
|
||||
"rev": "b98a4e1746acceb92c509bc496ef3d0e5ad8d4aa",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9f2ee8c91ac42da3ae6c6a1d21555f283458247e",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
|
|
102
flake.nix
102
flake.nix
|
@ -4,7 +4,7 @@
|
|||
|
||||
# Nixpkgs 23.11 as of 2024-02-07, has rustc v1.73
|
||||
inputs.nixpkgs.url =
|
||||
"github:NixOS/nixpkgs/9f2ee8c91ac42da3ae6c6a1d21555f283458247e";
|
||||
"github:NixOS/nixpkgs/nixos-unstable";
|
||||
|
||||
inputs.flake-compat.url = "github:nix-community/flake-compat";
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
|||
release = true;
|
||||
}).workspace.garage { compileMode = "build"; };
|
||||
in
|
||||
{
|
||||
rec {
|
||||
# default = native release build
|
||||
default = packageFor null;
|
||||
# other = cross-compiled, statically-linked builds
|
||||
|
@ -54,9 +54,105 @@
|
|||
i386 = packageFor "i686-unknown-linux-musl";
|
||||
arm64 = packageFor "aarch64-unknown-linux-musl";
|
||||
arm = packageFor "armv6l-unknown-linux-musl";
|
||||
|
||||
jepsen-garage = pkgs.callPackage (
|
||||
{ runCommand, makeWrapper, fetchMavenArtifact, fetchgit, lib, clojure }:
|
||||
|
||||
let cljsdeps = import ./script/jepsen.garage/deps.nix { inherit (pkgs) fetchMavenArtifact fetchgit lib; };
|
||||
classp = cljsdeps.makeClasspaths {};
|
||||
|
||||
in runCommand "jepsen.garage" {
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
} ''
|
||||
mkdir -p $out/share
|
||||
cp -r ${./script/jepsen.garage/src} $out/share/src
|
||||
substituteInPlace $out/share/src/jepsen/garage/daemon.clj --replace "https://garagehq.deuxfleurs.fr/_releases/" "http://runner/"
|
||||
makeWrapper ${clojure}/bin/clojure $out/bin/jepsen.garage --add-flags "-Scp $out/share/src:${classp} -m jepsen.garage"
|
||||
''
|
||||
) {};
|
||||
|
||||
nixosTest = pkgs.nixosTest ({lib, pkgs, ... }: let
|
||||
|
||||
snakeOilPrivateKey = pkgs.writeText "privkey.snakeoil" ''
|
||||
-----BEGIN EC PRIVATE KEY-----
|
||||
MHcCAQEEIHQf/khLvYrQ8IOika5yqtWvI0oquHlpRLTZiJy5dRJmoAoGCCqGSM49
|
||||
AwEHoUQDQgAEKF0DYGbBwbj06tA3fd/+yP44cvmwmHBWXZCKbS+RQlAKvLXMWkpN
|
||||
r1lwMyJZoSGgBHoUahoYjTh9/sJL7XLJtA==
|
||||
-----END EC PRIVATE KEY-----
|
||||
'';
|
||||
snakeOilPublicKey = pkgs.lib.concatStrings [
|
||||
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHA"
|
||||
"yNTYAAABBBChdA2BmwcG49OrQN33f/sj+OHL5sJhwVl2Qim0vkUJQCry1zFpKTa"
|
||||
"9ZcDMiWaEhoAR6FGoaGI04ff7CS+1yybQ= snakeoil"
|
||||
];
|
||||
|
||||
nodeFn = n: lib.nameValuePair "n${toString (1+n)}" {
|
||||
services.openssh.enable = true;
|
||||
users.users.root.openssh.authorizedKeys.keys = [snakeOilPublicKey];
|
||||
environment.systemPackages = [
|
||||
pkgs.wget
|
||||
(pkgs.writeShellScriptBin "apt-get" ''
|
||||
exit 0
|
||||
'')
|
||||
(lib.hiPrio (pkgs.writeShellScriptBin "dpkg" ''
|
||||
exit 0
|
||||
''))
|
||||
(lib.hiPrio (pkgs.writeShellScriptBin "ntpdate" ''
|
||||
hwclock -s
|
||||
''))
|
||||
|
||||
(pkgs.dpkg.overrideAttrs (old: {
|
||||
configureFlags = lib.remove "--disable-start-stop-daemon" old.configureFlags;
|
||||
}))
|
||||
|
||||
pkgs.gcc
|
||||
];
|
||||
};
|
||||
nodeCount = 7;
|
||||
|
||||
in {
|
||||
name = "garage-jepsen";
|
||||
|
||||
nodes = {
|
||||
runner = { nodes, ... }: {
|
||||
environment.systemPackages = [
|
||||
jepsen-garage
|
||||
|
||||
(pkgs.writeShellScriptBin "git" ''
|
||||
echo 0000000000000000000000000000000000000000
|
||||
'')
|
||||
|
||||
pkgs.gnuplot
|
||||
];
|
||||
networking.firewall.allowedTCPPorts = [ 80 ];
|
||||
environment.etc.jepsen-nodes.text = lib.concatStringsSep "\n" (lib.genList (n: nodes."n${toString (n+1)}".networking.primaryIPAddress) nodeCount);
|
||||
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts.default = {
|
||||
locations."/v0.9.0/x86_64-unknown-linux-musl/".alias = "${packageFor pkgs.pkgsStatic.stdenv.hostPlatform.config}/bin/";
|
||||
};
|
||||
};
|
||||
};
|
||||
} // lib.listToAttrs (lib.genList nodeFn nodeCount);
|
||||
|
||||
testScript = ''
|
||||
start_all()
|
||||
|
||||
n1.wait_for_unit("sshd.service")
|
||||
|
||||
runner.succeed("mkdir ~/.ssh")
|
||||
runner.succeed(
|
||||
"cat ${snakeOilPrivateKey} > ~/.ssh/id_ecdsa"
|
||||
)
|
||||
runner.succeed("chmod 600 ~/.ssh/id_ecdsa")
|
||||
|
||||
runner.succeed("source <(ssh-agent) && ssh-add && jepsen.garage test --nodes-file /etc/jepsen-nodes --time-limit 60 --rate 100 --concurrency 20 --workload reg1 --ops-per-key 100")
|
||||
'';
|
||||
});
|
||||
};
|
||||
|
||||
# ---- developpment shell, for making native builds only ----
|
||||
# ---- development shell, for making native builds only ----
|
||||
devShells =
|
||||
let
|
||||
shellWithPackages = (packages: (compile {
|
||||
|
|
7
script/jepsen.garage/deps.edn
Normal file
7
script/jepsen.garage/deps.edn
Normal file
|
@ -0,0 +1,7 @@
|
|||
{:paths ["src"]
|
||||
:deps
|
||||
{
|
||||
org.clojure/clojure {:mvn/version "1.11.1"}
|
||||
jepsen {:mvn/version "0.3.5"}
|
||||
amazonica {:mvn/version "0.3.163"}
|
||||
}}
|
5597
script/jepsen.garage/deps.nix
Normal file
5597
script/jepsen.garage/deps.nix
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,10 +0,0 @@
|
|||
(defproject jepsen.garage "0.1.0-SNAPSHOT"
|
||||
:description "Jepsen testing for Garage"
|
||||
:url "https://git.deuxfleurs.fr/Deuxfleurs/garage"
|
||||
:license {:name "AGPLv3"
|
||||
:url "https://www.gnu.org/licenses/agpl-3.0.en.html"}
|
||||
:main jepsen.garage
|
||||
:dependencies [[org.clojure/clojure "1.11.1"]
|
||||
[jepsen "0.3.3-SNAPSHOT"]
|
||||
[amazonica "0.3.163"]]
|
||||
:repl-options {:init-ns jepsen.garage})
|
Loading…
Reference in a new issue