diff --git a/gotrue/README.md b/gotrue/README.md new file mode 100644 index 0000000..3046c4c --- /dev/null +++ b/gotrue/README.md @@ -0,0 +1,20 @@ +# GoTrue benchmark(Work in progress) + +Updated and reproducible benchmark for GoTrue by using [Nix](https://nixos.org/) and [k6](https://k6.io). + +## Setup + +This whole setup will be handled by Nix. + +Run `nix-shell`. This will provide an environment where all the dependencies are available. + +``` +nix-shell +> +``` + +## Usage + + +TODO(Joel): Add K6 scripts + diff --git a/gotrue/default.nix b/gotrue/default.nix new file mode 100644 index 0000000..d15eaa1 --- /dev/null +++ b/gotrue/default.nix @@ -0,0 +1,25 @@ +{ callPackage + , lib + , stdenv + , fetchurl + , nixos + , testers + }: + + stdenv.mkDerivation (finalAttrs: { + pname = "gotrue"; + version = "2.9.2"; + + src = fetchurl { + url = "https://github.com/supabase/gotrue/releases/download/v${finalAttrs.version}/gotrue-v${finalAttrs.version}-x86.tar.gz"; + sha256 = "G+3qddI9zyuhx//TA1i1Pt+0Nig2PgEMOXvb9HqfBtY="; + }; + phases = ["installPhase"]; + installPhase = '' + mkdir -p $out/bin + tar xzvf $src + cp gotrue $out/bin/gotrue + chmod +x $out/bin/gotrue + ''; + + }) diff --git a/gotrue/k6/.gitkeep b/gotrue/k6/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/gotrue/shell.nix b/gotrue/shell.nix new file mode 100644 index 0000000..722b4a3 --- /dev/null +++ b/gotrue/shell.nix @@ -0,0 +1,73 @@ +let + nixpkgs = builtins.fetchTarball { + name = "nixos-20.03"; + url = "https://github.com/nixos/nixpkgs/archive/7bc3a08d3a4c700b53a3b27f5acd149f24b931ec.tar.gz"; + sha256 = "1kiz37052zsgvw7a378zg08mpbi1wk8dkgm5j6dy0x4mxvcg8ws3"; + }; + pkgs = import nixpkgs {}; + deploy = + pkgs.writeShellScriptBin "gotrue-deploy" + '' + set -euo pipefail + set +e && nixops info -d gotrue > /dev/null 2> /dev/null + info=$? && set -e + if test $info -eq 1 + then + echo "Creating deployment..." + nixops create deploy.nix -d gotrue + fi + nixops deploy -k -d pgrbench --allow-reboot --confirm + ''; + info = + pkgs.writeShellScriptBin "gotrue-info" + '' + set -euo pipefail + nixops info -d gotrue + ''; + k6 = + pkgs.writeShellScriptBin "gotrue-k6" + '' + set -euo pipefail + nixops ssh -d gotrue client k6 run -q --vus $1 - < $2 + ''; + repeat = + pkgs.writeShellScriptBin "repeat" + '' + set -euo pipefail + number=$1 + shift + for i in `seq $number`; do + echo -e "\nRun: $i" + $@ + done + ''; + ssh = + pkgs.writeShellScriptBin "pgrbench-ssh" + '' + set -euo pipefail + nixops ssh -d pgrbench $1 + ''; + destroy = + pkgs.writeShellScriptBin "gotrue-destroy" + '' + set -euo pipefail + nixops destroy -d gotrue --confirm + nixops delete -d gotrue + rm .deployment.nixops + ''; +in +pkgs.mkShell { + buildInputs = [ + pkgs.nixops + deploy + info + k6 + ssh + destroy + repeat + ]; + shellHook = '' + export NIX_PATH="nixpkgs=${nixpkgs}:." + export NIXOPS_STATE=".deployment.nixops" + ''; +}