Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ipfs test suite #12

Merged
merged 21 commits into from
Jun 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1f88199
WIP test suite automatization
meditans Jun 11, 2020
33c6149
With a derivation that doesn't use nixpkgs
meditans Jun 11, 2020
25f71d3
need to run init.sh first, sigh
Ericson2314 Jun 11, 2020
8a3c073
Complete the tests for ipfs
meditans Jun 11, 2020
682b936
Merge branch 'ipfs-binary-cache-develop' of github.com:obsidiansystem…
meditans Jun 11, 2020
0da205b
Update prefixes for ipfs and ipns in test suite
meditans Jun 11, 2020
753ed62
Add ipfs as a dep for tests
Ericson2314 Jun 11, 2020
4750223
Restart ipfs when the daemon is not running
meditans Jun 11, 2020
b2eccb9
Sometimes read permissions dissapear on the test data for some reason
Ericson2314 Jun 12, 2020
0068f7d
Ensure IPFS daemon is killed after test
Ericson2314 Jun 12, 2020
5352bcb
Just run ipfs tests on linux for now, sigh
Ericson2314 Jun 12, 2020
7599cf0
Fix syntax error from bad paste
Ericson2314 Jun 12, 2020
4348615
Remove `NIX_REMOTE=local` from ipfs test
Ericson2314 Jun 12, 2020
67c63b9
Only call build once in tests/ipfs.sh
matthewbauer Jun 12, 2020
e1d0091
Clear store when beginning ipfs test
matthewbauer Jun 12, 2020
4f3a4c9
Fix typo in ipfs.sh
matthewbauer Jun 12, 2020
4b83835
Fixup unset BUILD_COMMAND
matthewbauer Jun 12, 2020
3cb4a0b
Try to make /nar before nix copy in tests/ipfs.sh
matthewbauer Jun 13, 2020
ad96d21
Revert "Just run ipfs tests on linux for now, sigh"
Ericson2314 Jun 13, 2020
08ee366
ipfs test: Inline some vars used once
Ericson2314 Jun 13, 2020
953ceba
Identify real issue (#3695) and hack around it
Ericson2314 Jun 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion release-common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ rec {
sha256 = "1pij0v449p166f9l29x7ppzk8j7g9k9mp15ilh5qxp29c7fnvxy2";
}) ];
*/
}));
}))
++ lib.optional (stdenv.isLinux || stdenv.isDarwin) ipfs;

propagatedDeps =
[ (boehmgc.override { enableLargeConfig = true; })
Expand Down
2 changes: 1 addition & 1 deletion tests/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source common.sh

test -n "$TEST_ROOT"
if test -d "$TEST_ROOT"; then
chmod -R u+w "$TEST_ROOT"
chmod -R u+rw "$TEST_ROOT"
rm -rf "$TEST_ROOT"
fi
mkdir "$TEST_ROOT"
Expand Down
117 changes: 117 additions & 0 deletions tests/ipfs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
source common.sh

# This are for ./fixed.nix
export IMPURE_VAR1=foo
export IMPURE_VAR2=bar

################################################################################
## Check that the ipfs daemon is present and enabled in your environment
################################################################################

if [[ -z $(type -p ipfs) ]]; then
echo "Ipfs not installed; skipping ipfs tests"
exit 99
fi

# To see if ipfs is connected to the network, we check if we can see some peers
# other than ourselves.
if (! (ipfs log ls));
then
echo "Ipfs daemon not detected; initializing.."
ipfs init
ipfs daemon --offline &
pidIpfsDaemon=$!
trap "kill -9 $pidIpfsDaemon" EXIT
fi

clearStore

################################################################################
## Create the folders for the source and destination stores
################################################################################

IPFS_TESTS=$TEST_ROOT/ipfs_tests
mkdir $IPFS_TESTS

# Here we define some store locations, one for the initial store we upload, and
# the other three for the destination stores to which we'll copy (one for each
# method)
IPFS_SRC_STORE=$IPFS_TESTS/ipfs_source_store

IPFS_DST_HTTP_STORE=$IPFS_TESTS/ipfs_dest_http_store
IPFS_DST_HTTP_LOCAL_STORE=$IPFS_TESTS/ipfs_dest_http_local_store
IPFS_DST_IPFS_STORE=$IPFS_TESTS/ipfs_dest_ipfs_store
IPFS_DST_IPNS_STORE=$IPFS_TESTS/ipfs_dest_ipns_store

################################################################################
## Generate the keys to sign the store
################################################################################

SIGNING_KEY_NAME=nixcache.for.ipfs-1
SIGNING_KEY_PRI_FILE=$IPFS_TESTS/nix-cache-key.sec
SIGNING_KEY_PUB_FILE=$IPFS_TESTS/nix-cache-key.pub

nix-store --generate-binary-cache-key $SIGNING_KEY_NAME $SIGNING_KEY_PRI_FILE $SIGNING_KEY_PUB_FILE

################################################################################
## Create, sign and upload the source store
################################################################################

mkdir -p $IPFS_SRC_STORE
storePaths=$(nix-build ./fixed.nix -A good | sort | uniq)

# Hack around https://github.com/NixOS/nix/issues/3695
for path in $storePaths; do
nix copy --to file://$IPFS_SRC_STORE $path
done
unset path

nix sign-paths --store file://$IPFS_SRC_STORE \
-k $SIGNING_KEY_PRI_FILE $storePaths

IPFS_HASH=$(ipfs add -r $IPFS_SRC_STORE 2>/dev/null | tail -n 1 | awk '{print $2}')

################################################################################
## Create the local http store and download the derivation there
################################################################################

mkdir $IPFS_DST_HTTP_LOCAL_STORE

IPFS_HTTP_LOCAL_PREFIX='http://localhost:8080/ipfs'

DOWNLOAD_LOCATION=$(nix-build ./fixed.nix -A good \
--option substituters $IPFS_HTTP_LOCAL_PREFIX/$IPFS_HASH \
--store $IPFS_DST_HTTP_LOCAL_STORE \
--no-out-link \
-j0 \
--option trusted-public-keys $(cat $SIGNING_KEY_PUB_FILE))

################################################################################
## Create the ipfs store and download the derivation there
################################################################################

mkdir $IPFS_DST_IPFS_STORE

DOWNLOAD_LOCATION=$(nix-build ./fixed.nix -A good \
--option substituters 'ipfs://'$IPFS_HASH \
--store $IPFS_DST_IPFS_STORE \
--no-out-link \
-j0 \
--option trusted-public-keys $(cat $SIGNING_KEY_PUB_FILE))


################################################################################
## Create the ipns store and download the derivation there
################################################################################

# First I have to publish:
IPNS_ID=$(ipfs name publish $IPFS_HASH --allow-offline | awk '{print substr($3,1,length($3)-1)}')

mkdir $IPFS_DST_IPNS_STORE

DOWNLOAD_LOCATION=$(nix-build ./fixed.nix -A good \
--option substituters 'ipns://'$IPNS_ID \
--store $IPFS_DST_IPNS_STORE \
--no-out-link \
-j0 \
--option trusted-public-keys $(cat $SIGNING_KEY_PUB_FILE))
3 changes: 2 additions & 1 deletion tests/local.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ nix_tests = \
nix-copy-ssh.sh \
post-hook.sh \
function-trace.sh \
recursive.sh
recursive.sh \
ipfs.sh
# parallel.sh

install-tests += $(foreach x, $(nix_tests), tests/$(x))
Expand Down