From 0e53e22bd8150f35d195df00272d344cf920027f Mon Sep 17 00:00:00 2001 From: Tiago Castro Date: Mon, 28 Oct 2024 19:44:53 +0000 Subject: [PATCH 1/2] build(paperclip): support multiple platforms Supports building paperclip from multiple plaforms. Also updates old openapi update script to update paperclip. Signed-off-by: Tiago Castro --- nix/pkgs/paperclip/default.nix | 3 +- nix/pkgs/paperclip/source.json | 7 ++- scripts/nix/update-openapi-generator.sh | 52 -------------------- scripts/nix/update-paperclip.sh | 64 +++++++++++++++++++++++++ shell.nix | 1 + 5 files changed, 73 insertions(+), 54 deletions(-) delete mode 100755 scripts/nix/update-openapi-generator.sh create mode 100755 scripts/nix/update-paperclip.sh diff --git a/nix/pkgs/paperclip/default.nix b/nix/pkgs/paperclip/default.nix index 79f641a88..55e5fcf59 100644 --- a/nix/pkgs/paperclip/default.nix +++ b/nix/pkgs/paperclip/default.nix @@ -10,7 +10,7 @@ pkgs.stdenv.mkDerivation { src = pkgs.fetchurl { name = "paperclip-${src_json.rev}.tar.gz"; url = "https://github.com/${src_json.owner}/${src_json.repo}/releases/download/${src_json.rev}/paperclip-${hostPlatform}.tar.gz"; - sha256 = src_json.hash; + sha256 = src_json.hash.${hostPlatform}; }; sourceRoot = "."; @@ -24,5 +24,6 @@ pkgs.stdenv.mkDerivation { meta = with lib; { homepage = "https://github.com/${src_json.owner}/${src_json.repo}"; description = "OpenApi v3 Generator"; + platforms = platforms.linux ++ platforms.darwin; }; } diff --git a/nix/pkgs/paperclip/source.json b/nix/pkgs/paperclip/source.json index 666e64b0e..4315cdf54 100644 --- a/nix/pkgs/paperclip/source.json +++ b/nix/pkgs/paperclip/source.json @@ -2,5 +2,10 @@ "owner": "paperclip-rs", "repo": "paperclip", "rev": "v0.9.4", - "hash": "sha256-DIt+09p4TnTQq4b9ZNdq9f08Yiqc+Llco6B7zceX5FU=" + "hash": { + "x86_64-unknown-linux-musl": "0mg4jz3wsyx0ldfbky4w59i3rzgmdbbn9zc6mg878kkqvb9px2qc", + "aarch64-unknown-linux-musl": "1jzgijiglb6l0wdci2zadcrajgasdrir9kvg48va2hfzca9rv1lm", + "x86_64-apple-darwin": "1vbv237qgxgqsrrwhpl0j7zs2qwab7wb6670syb2ym89al1z8k6m", + "aarch64-apple-darwin": "0hhkhpvsk75bxsd34nv6g01hn9wbxfrrdjjcw7sf2b9r97n90xpj" + } } diff --git a/scripts/nix/update-openapi-generator.sh b/scripts/nix/update-openapi-generator.sh deleted file mode 100755 index af675cf07..000000000 --- a/scripts/nix/update-openapi-generator.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env bash - -set -eu -o pipefail - -SCRIPTDIR=$(dirname "$0") -ROOTDIR="$SCRIPTDIR"/../../ - -owner="openebs"; -repo="openapi-generator"; -branch="rust_mayastor"; - -github_rev() { - curl -sSf "https://api.github.com/repos/$owner/$repo/branches/$branch" | \ - jq '.commit.sha' | \ - sed 's/"//g' -} - -github_sha256() { - nix-prefetch-url \ - --unpack \ - --type sha256 \ - "https://github.com/$owner/$repo/archive/$branch.tar.gz" 2>&1 | \ - tail -1 -} - -echo "=== ${owner}/${repo}@${branch} ===" - -echo -n "Looking up latest revision ... " -rev=$(github_rev "${owner}" "${repo}" "${branch}"); -echo "revision is \`$rev\`." - -sha256=$(github_sha256 "${owner}" "${repo}" "$rev"); -echo "sha256 is \`$sha256\`." - -if [ "$sha256" == "" ]; then - echo "sha256 is not valid!" - exit 2 -fi -source_file="$ROOTDIR/nix/pkgs/openapi-generator/source.json" - -echo "Previous Content of source file (``$source_file``):" -cat "$source_file" -echo "New Content of source file (``$source_file``) written." -cat <&1 | \ + tail -1 +} + +echo "=== $OWNER/$REPO ===" + +echo -n "Looking up latest release for $OWNER/$REPO... " +if [ -z "$REV" ]; then + tag=$(github_rel_tag); +else + tag="$REV" +fi +echo "$tag" + +for arch_os in "${ARCH_OS[@]}"; do + echo -n "Looking up sha25 for $arch_os... " + sha256=$(github_sha256 "$tag" "$arch_os"); + echo "$sha256" + if [ "$ARCH_OS_SHA256s" != "" ]; then + ARCH_OS_SHA256s="$ARCH_OS_SHA256s, + " + fi + ARCH_OS_SHA256s="$ARCH_OS_SHA256s\"$arch_os\": \"$sha256\"" +done + +source_file="$ROOTDIR/nix/pkgs/paperclip/source.json" + +echo "Previous Content of source file (``$source_file``):" +cat "$source_file" +echo "New Content of source file (``$source_file``) written." +cat <$source_file +{ + "owner": "$OWNER", + "repo": "$REPO", + "rev": "$tag", + "hash": { + $ARCH_OS_SHA256s + } +} +EOF +echo diff --git a/shell.nix b/shell.nix index 5b57f61c5..666e1c586 100644 --- a/shell.nix +++ b/shell.nix @@ -33,6 +33,7 @@ mkShell { jq llvmPackages.libclang nixpkgs-fmt + nix openapi-generator-cli openssl pkg-config From a61f06ac243a616ef71d90eb9fa646023ce99af8 Mon Sep 17 00:00:00 2001 From: Tiago Castro Date: Tue, 29 Oct 2024 22:24:33 +0000 Subject: [PATCH 2/2] test(bdd/thin): fix racy thin prov test Add retry waiting for condition to be met. Signed-off-by: Tiago Castro --- .../capacity/thin/volume/test_rebuild.py | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/bdd/features/capacity/thin/volume/test_rebuild.py b/tests/bdd/features/capacity/thin/volume/test_rebuild.py index 859143645..e5c44c838 100644 --- a/tests/bdd/features/capacity/thin/volume/test_rebuild.py +++ b/tests/bdd/features/capacity/thin/volume/test_rebuild.py @@ -210,16 +210,7 @@ def the_faulted_replica_is_relocated_to_another_pool_with_sufficient_free_space( @then("the new replica allocation equals the volume allocation") def the_new_replica_allocation_equals_the_volume_allocation(): """the new replica allocation equals the volume allocation.""" - volume = ApiClient.volumes_api().get_volume(pytest.volume.spec.uuid) - total_allocated = 0 - - for replica in volume.state.replica_topology.values(): - assert replica.usage.capacity == volume.state.usage.capacity - assert replica.usage.allocated == volume.state.usage.allocated - total_allocated += replica.usage.allocated - - assert volume.state.usage.total_allocated == total_allocated - assert volume.state.usage.allocated > 10 * 1024 * 1024 + 4 * 1024 * 1024 + wait_volume_replica_allocated(pytest.volume) @then("the total number of healthy replicas is restored") @@ -308,3 +299,16 @@ def wait_volume_new_replica(volume, prev_replicas): ) ) assert len(new_replicas) == 1 + + +@retry(wait_fixed=200, stop_max_attempt_number=20) +def wait_volume_replica_allocated(volume): + volume = ApiClient.volumes_api().get_volume(volume.spec.uuid) + total_allocated = 0 + for replica in volume.state.replica_topology.values(): + assert replica.usage.capacity == volume.state.usage.capacity + assert replica.usage.allocated == volume.state.usage.allocated + total_allocated += replica.usage.allocated + + assert volume.state.usage.total_allocated == total_allocated + assert volume.state.usage.allocated > 10 * 1024 * 1024 + 4 * 1024 * 1024