Commit 846b1a70 authored by Thomas Gerbet's avatar Thomas Gerbet
Browse files

nixos/atticd: use `garage' in the test instead of `minio`

Related #490996, `minio` is not supported upstream anymore.
parent c97aa3f2
Loading
Loading
Loading
Loading
+29 −18
Original line number Diff line number Diff line
{ lib, pkgs, ... }:

let
  accessKey = "BKIKJAA5BMMU2RHO6IBB";
  secretKey = "V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12";
  accessKey = "GKaaaaaaaaaaaaaaaaaaaaaaaa";
  secretKey = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
  s3Addr = "127.0.0.1:9000";

  minioCredentialsFile = pkgs.writeText "minio-credentials-full" ''
    MINIO_ROOT_USER=${accessKey}
    MINIO_ROOT_PASSWORD=${secretKey}
  '';
  environmentFile = pkgs.runCommand "atticd-env" { } ''
    echo ATTIC_SERVER_TOKEN_RS256_SECRET_BASE64="$(${lib.getExe pkgs.openssl} genrsa -traditional 4096 | ${pkgs.coreutils}/bin/base64 -w0)" > $out
  '';
@@ -36,8 +33,8 @@ in
          storage = {
            type = "s3";
            bucket = "attic";
            region = "us-east-1";
            endpoint = "http://127.0.0.1:9000";
            region = "garage";
            endpoint = "http://${s3Addr}";

            credentials = {
              access_key_id = accessKey;
@@ -49,14 +46,24 @@ in
        inherit environmentFile;
      };

      services.minio = {
      services.garage = {
        enable = true;
        rootCredentialsFile = minioCredentialsFile;
        package = pkgs.garage_2;
        settings = {
          rpc_bind_addr = "127.0.0.1:3901";
          rpc_public_addr = "127.0.0.1:3901";
          rpc_secret = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
          replication_factor = 1;

          s3_api = {
            s3_region = "garage";
            api_bind_addr = s3Addr;
          };
        };
      };

      environment.systemPackages = [
        pkgs.attic-client
        pkgs.minio-client
      ];
    };
  };
@@ -74,15 +81,19 @@ in
          local.succeed("attic push test-cache ${environmentFile}")

      with subtest("s3 storage push"):
          s3.wait_for_unit("atticd.service")
          s3.wait_for_unit("minio.service")
          s3.wait_for_open_port(9000)
          s3.wait_for_unit("garage.service")
          s3.wait_for_open_port(3901)
          garage_node_id = s3.succeed("garage status | tail -n1 | awk '{ print $1 }'")
          s3.succeed(
              "mc alias set minio "
              + "http://localhost:9000 "
              + "${accessKey} ${secretKey} --api s3v4",
              "mc mb minio/attic",
              f"garage layout assign -c 100MB -z garage {garage_node_id}",
              "garage layout apply --version 1",
              "garage key import ${accessKey} ${secretKey} --yes",
              "garage bucket create attic",
              "garage bucket allow --read --write --owner attic --key ${accessKey}"
          )

          s3.wait_for_unit("atticd.service")
          s3.wait_for_open_port(9000)
          token = s3.succeed("atticd-atticadm make-token --sub stop --validity 1y --create-cache '*' --pull '*' --push '*' --delete '*' --configure-cache '*' --configure-cache-retention '*'").strip()

          s3.succeed(f"attic login s3 http://localhost:8080 {token}")