From e5cbcebd6515879aec174aad289710d20a078953 Mon Sep 17 00:00:00 2001 From: "joel@joellee.org" Date: Tue, 19 Jul 2022 00:14:49 +0800 Subject: [PATCH 1/4] initial commit --- gotrue/README.md | 27 +++++++++++++++++++++++++++ gotrue/k6/.gitkeep | 0 2 files changed, 27 insertions(+) create mode 100644 gotrue/README.md create mode 100644 gotrue/k6/.gitkeep diff --git a/gotrue/README.md b/gotrue/README.md new file mode 100644 index 0000000..b575920 --- /dev/null +++ b/gotrue/README.md @@ -0,0 +1,27 @@ +# 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 +> +``` + +Deploy with: + +``` +# This assumes there's a `~/.aws/credentials` file(created with aws-cli) with a "supabase-dev" profile. +# If you want to change the profile, go to deploy.nix and edit `accessKeyId = "supabase-dev";` +pgrbench-deploy + +``` + +## Usage +TODO + diff --git a/gotrue/k6/.gitkeep b/gotrue/k6/.gitkeep new file mode 100644 index 0000000..e69de29 From a3eba33932c739e72081dcf59f9e3357628254cf Mon Sep 17 00:00:00 2001 From: "joel@joellee.org" Date: Tue, 19 Jul 2022 12:17:49 +0800 Subject: [PATCH 2/4] feat: add initial nix file w/o tests --- gotrue/default.nix | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 gotrue/default.nix diff --git a/gotrue/default.nix b/gotrue/default.nix new file mode 100644 index 0000000..7b864b2 --- /dev/null +++ b/gotrue/default.nix @@ -0,0 +1,27 @@ +{ callPackage + , lib + , stdenv + , fetchurl + , nixos + , testers + }: + + stdenv.mkDerivation (finalAttrs: { + pname = "gotrue"; + version = "2.8.0"; + + src = fetchurl { + url = "https://github.com/supabase/gotrue/releases/download/v${finalAttrs.version}/gotrue-v${finalAttrs.version}-arm64.tar.gz"; + sha256 = "01rsiz20wc8zvw280p7f18hl5h3nhvkd59cklfxnlccqzp924rs4"; + }; + phases = ["installPhase" "patchPhase"]; + installPhase = '' + mkdir -p $out/bin + tar xzvf $src + cp gotrue $out/bin/gotrue + chmod +x $out/bin/gotrue + ''; + + doCheck = true; + + }) From 77fc156534ab3c49c62fdf7d8cc908993fcd2e2b Mon Sep 17 00:00:00 2001 From: "joel@joellee.org" Date: Mon, 25 Jul 2022 13:13:48 +0800 Subject: [PATCH 3/4] chore: update README --- gotrue/README.md | 11 ++--------- gotrue/default.nix | 10 ++++------ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/gotrue/README.md b/gotrue/README.md index b575920..3046c4c 100644 --- a/gotrue/README.md +++ b/gotrue/README.md @@ -13,15 +13,8 @@ nix-shell > ``` -Deploy with: +## Usage -``` -# This assumes there's a `~/.aws/credentials` file(created with aws-cli) with a "supabase-dev" profile. -# If you want to change the profile, go to deploy.nix and edit `accessKeyId = "supabase-dev";` -pgrbench-deploy -``` - -## Usage -TODO +TODO(Joel): Add K6 scripts diff --git a/gotrue/default.nix b/gotrue/default.nix index 7b864b2..d15eaa1 100644 --- a/gotrue/default.nix +++ b/gotrue/default.nix @@ -8,13 +8,13 @@ stdenv.mkDerivation (finalAttrs: { pname = "gotrue"; - version = "2.8.0"; + version = "2.9.2"; src = fetchurl { - url = "https://github.com/supabase/gotrue/releases/download/v${finalAttrs.version}/gotrue-v${finalAttrs.version}-arm64.tar.gz"; - sha256 = "01rsiz20wc8zvw280p7f18hl5h3nhvkd59cklfxnlccqzp924rs4"; + 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" "patchPhase"]; + phases = ["installPhase"]; installPhase = '' mkdir -p $out/bin tar xzvf $src @@ -22,6 +22,4 @@ chmod +x $out/bin/gotrue ''; - doCheck = true; - }) From a3c7c2f2b96859d458d1d77400b1bb9bcdf3babb Mon Sep 17 00:00:00 2001 From: "joel@joellee.org" Date: Thu, 4 Aug 2022 11:18:53 +0800 Subject: [PATCH 4/4] feat: add shell.nix --- gotrue/shell.nix | 73 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 gotrue/shell.nix 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" + ''; +}