Skip to content

Commit

Permalink
chore(bors): merge pull request #882
Browse files Browse the repository at this point in the history
882: build(paperclip): support multiple platforms r=tiagolobocastro a=tiagolobocastro

    test(bdd/thin): fix racy thin prov test
    
    Add retry waiting for condition to be met.
    
    Signed-off-by: Tiago Castro <[email protected]>

---

    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 <[email protected]>


Co-authored-by: Tiago Castro <[email protected]>
  • Loading branch information
mayastor-bors and tiagolobocastro committed Oct 29, 2024
2 parents 874b13f + a61f06a commit f69c13e
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 64 deletions.
3 changes: 2 additions & 1 deletion nix/pkgs/paperclip/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ".";
Expand All @@ -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;
};
}
7 changes: 6 additions & 1 deletion nix/pkgs/paperclip/source.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
52 changes: 0 additions & 52 deletions scripts/nix/update-openapi-generator.sh

This file was deleted.

64 changes: 64 additions & 0 deletions scripts/nix/update-paperclip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env bash

set -eu -o pipefail

SCRIPTDIR=$(dirname "$0")
ROOTDIR="$SCRIPTDIR"/../..

OWNER="paperclip-rs";
REPO="paperclip";
REV=${REV:-}
ARCH_OS=("x86_64-unknown-linux-musl" "aarch64-unknown-linux-musl" "x86_64-apple-darwin" "aarch64-apple-darwin")
ARCH_OS_SHA256s=""


github_rel_tag() {
curl -sSf "https://api.github.com/repos/$OWNER/$REPO/releases/latest" | jq -r '.tag_name'
}

github_sha256() {
tag="$1"
arch_os="$2"
nix-prefetch-url \
--type sha256 \
"https://github.com/$OWNER/$REPO/releases/download/$tag/paperclip-$arch_os.tar.gz" 2>&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 <<EOF >$source_file
{
"owner": "$OWNER",
"repo": "$REPO",
"rev": "$tag",
"hash": {
$ARCH_OS_SHA256s
}
}
EOF
echo
1 change: 1 addition & 0 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ mkShell {
jq
llvmPackages.libclang
nixpkgs-fmt
nix
openapi-generator-cli
openssl
pkg-config
Expand Down
24 changes: 14 additions & 10 deletions tests/bdd/features/capacity/thin/volume/test_rebuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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

0 comments on commit f69c13e

Please sign in to comment.