kubo/test/sharness
Andrew Gillis 0ae9b2b903
Update migration sharness tests for new migrations (#8053)
* Update migration sharness tests for new migrations

With the new migrations, go-ipfs no longer uses fs-repo-migrations to do repo migrations, and was downloading real migration binaries from the network and running them.  This caused failure, but was not caught because the test was expecting `ipfs daemon --migrate` to fail for other reasons.

This PR fixes the migration tests by creating the appropriate fake migration binaries in the PATH so that those get run and avoid downloading the real ones.  This also fixes a test that was previously marked broken.
2021-04-15 14:47:11 -04:00
..
lib use standard multibase format labels 2020-08-17 21:43:01 -07:00
t0024-files fix t0024 on osx 2017-09-03 18:43:18 -07:00
t0051-object-data Add global --cid-base option and enable it for most commands. 2019-01-17 15:54:32 -05:00
t0053-dag-data fix printing out of binary escaped data for test 2017-02-09 10:31:18 -08:00
t0054-dag-car-import-export-data Dag import functionality only ( no progress ) 2020-04-08 14:54:49 -07:00
t0060-data multistream tests use data from file 2016-04-07 15:55:41 -07:00
t0110-gateway-data gateway: fix seeker can't seek on specific files 2017-10-18 20:10:22 +02:00
t0116-prometheus-data test(sharness): fix for opencensus updates 2021-03-30 17:07:55 -07:00
t0275-cid-security-data cidsec: add test for command closing right away 2018-04-20 17:07:39 +02:00
t0280-plugin-data plugins: add support for plugin configs 2019-08-29 17:17:23 -07:00
t0280-plugin-git-data git: add git plugin tests 2017-07-12 23:38:32 +02:00
.gitignore make(sharness): add plugins as part of sharness build 2017-07-12 21:53:59 +02:00
GNUmakefile fix: require gmake 2019-08-01 12:18:56 -07:00
README.md Fix typos and cleanup 2020-04-20 22:00:01 +03:00
Rules.mk test(graphsync): test server-side graphsync 2020-02-26 09:11:17 -08:00
t0001-tests-work.sh Simplify grep in test to pass on MacOS 2020-03-12 04:42:53 +01:00
t0010-basic-commands.sh Fix typos and cleanup 2020-04-20 22:00:01 +03:00
t0015-basic-sh-functions.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0018-indent.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0020-init.sh switch ipfs init default key 2020-08-19 08:31:44 -07:00
t0021-config.sh dep: update go-ipfs-config 2019-05-01 12:43:04 -07:00
t0022-init-default.sh switch ipfs init default key 2020-08-19 08:31:44 -07:00
t0023-shutdown.sh wait for all connections to close before exiting on shutdown. 2018-07-31 13:07:19 -07:00
t0024-datastore-config.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0025-datastores.sh switch ipfs init default key 2020-08-19 08:31:44 -07:00
t0026-id.sh fix: revert changes to the user agent 2020-03-13 13:50:11 -07:00
t0027-rotate.sh test: add rotate self test 2020-08-21 20:08:24 +02:00
t0030-mount.sh test(sharness): test the local symlink 2020-05-19 18:59:54 -07:00
t0031-mount-publish.sh test(sharness): fix fuse tests 2020-05-14 13:14:38 -07:00
t0040-add-and-cat.sh Fix typos and cleanup 2020-04-20 22:00:01 +03:00
t0041-ping.sh ping: fixup sharness tests 2019-05-08 23:15:16 -07:00
t0042-add-skip.sh feat(file-ignore): add ignore opts to add cmd 2020-03-20 09:22:04 -07:00
t0043-add-w.sh switch to base32 by default for CIDv1 2019-05-13 10:57:53 -07:00
t0044-add-symlink.sh switch to base32 by default for CIDv1 2019-05-13 10:57:53 -07:00
t0045-ls.sh Test ls and add with escaped character 2020-12-17 19:32:03 -08:00
t0046-id-hash.sh test: handle id -> identity rename 2019-08-23 17:02:23 -07:00
t0050-block.sh Fix typos and cleanup 2020-04-20 22:00:01 +03:00
t0051-object.sh fix: return an error when an unknown object type is passed 2020-11-30 17:59:37 -08:00
t0052-object-diff.sh switch to base32 by default for CIDv1 2019-05-13 10:57:53 -07:00
t0053-dag.sh add ipfs dag stat command (#7553) 2020-08-17 14:29:36 -04:00
t0054-dag-car-import-export.sh Add an extra guard for the issue encountered in #7207 2020-04-24 14:20:07 +02:00
t0060-daemon.sh feat: disable secio by default 2020-08-17 08:16:54 -04:00
t0061-daemon-opts.sh feat: remove secio support 2021-02-25 13:36:40 -08:00
t0062-daemon-api.sh Fix typos and cleanup 2020-04-20 22:00:01 +03:00
t0063-daemon-init.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0063-external.sh add test for sharness locking 2018-07-05 14:33:01 -07:00
t0064-api-file.sh test: test operations when the API file is stale 2019-06-29 11:17:46 +02:00
t0065-active-requests.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0066-migration.sh Update migration sharness tests for new migrations (#8053) 2021-04-15 14:47:11 -04:00
t0067-unix-api.sh daemon: support unix domain sockets for the API/gateway 2019-09-30 17:21:28 -07:00
t0070-user-config.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0080-repo.sh test(sharness): make repo gc test more robust 2020-04-23 15:10:16 -07:00
t0081-repo-pinning.sh fix(pin): wait till after fetching to remove direct pin 2019-10-08 17:12:44 +09:00
t0082-repo-gc-auto.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0084-repo-read-rehash.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0085-pins.sh pin: fix pin update X Y where X==Y 2019-09-23 16:29:26 -07:00
t0086-repo-verify.sh fix the repo verify test 2018-06-01 23:39:32 -07:00
t0087-repo-robust-gc.sh Fix typos and cleanup 2020-04-20 22:00:01 +03:00
t0088-repo-stat-symlink.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0090-get.sh Fix typos and cleanup 2020-04-20 22:00:01 +03:00
t0095-refs.sh Add two more missed cleanup clauses 2019-12-23 15:41:39 +01:00
t0100-name.sh add --ipns-base to publish and subs commands 2020-08-17 21:43:02 -07:00
t0101-iptb-name.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0110-gateway.sh refactor: show error, delay redirect 2021-02-27 00:57:05 +01:00
t0111-gateway-writeable.sh test: update gateway tests for dir-index-html v1.1.0 2020-08-19 20:31:23 -04:00
t0112-gateway-cors.sh fix: localhost API access via ipv6 2020-10-20 00:46:40 +02:00
t0113-gateway-symlink.sh test(sharness): add gateway symlink test 2020-01-05 16:43:44 -08:00
t0114-gateway-subdomains.sh fix: remove use of Clear-Site-Data 2021-01-29 22:08:16 +01:00
t0115-gateway-dir-listing.sh chore: dir-index-html 1.2.1 2020-09-29 02:40:49 +02:00
t0116-prometheus.sh test(sharness): verify the list of exported metrics 2021-03-17 15:04:38 -07:00
t0120-bootstrap.sh test(sharness): fix bootstrap test for quic bootstrap addrs 2020-05-22 16:57:58 -07:00
t0121-bootstrap-iptb.sh At some point the directory name changed to testbeds 2019-12-23 15:41:39 +01:00
t0125-twonode.sh feat: remove secio support 2021-02-25 13:36:40 -08:00
t0130-multinode.sh feat: add a transport config section 2020-06-16 15:15:47 -07:00
t0131-multinode-client-routing.sh Fix typos and cleanup 2020-04-20 22:00:01 +03:00
t0140-swarm.sh test(sharness): ensure addresses end in p2p addr 2020-06-02 09:26:06 -07:00
t0141-addfilter.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0142-testfilter.sh quic: remove experimental status and add it to the default config 2020-05-22 04:54:19 +02:00
t0150-clisuggest.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0151-sysdiag.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0160-resolve.sh switch ipfs init default key 2020-08-19 08:31:44 -07:00
t0165-keystore.sh test(sharness): correctly use test_must_fail 2021-02-25 14:17:09 -08:00
t0170-dht.sh fix: fix 'dht query' command to actually return the closest peers 2020-04-13 17:42:03 -07:00
t0171-peering.sh fix: spelling 2020-05-25 20:24:43 -07:00
t0175-provider.sh Introduce first strategic provider: do nothing 2019-05-29 16:20:31 -07:00
t0175-reprovider.sh Fix Typos 2019-12-25 03:12:41 +00:00
t0175-strategic-provider.sh Introduce first strategic provider: do nothing 2019-05-29 16:20:31 -07:00
t0180-p2p.sh sharness: switch p2p dnsaddr that was supposed to have only a single address in it to use a specific example 2020-08-24 19:11:01 -04:00
t0180-pubsub-gossipsub.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0180-pubsub.sh test(sharness): fix pubsub tests 2020-05-22 16:21:15 -07:00
t0181-private-network.sh Add two more missed cleanup clauses 2019-12-23 15:41:39 +01:00
t0182-circuit-relay.sh fix: remove internal relay discovery 2020-03-31 12:24:55 -07:00
t0183-namesys-pubsub.sh add --ipns-base to publish and subs commands 2020-08-17 21:43:02 -07:00
t0184-http-proxy-over-p2p.sh p2p-proxy: earlier peerID validation check 2020-12-01 12:24:18 -05:00
t0185-autonat.sh feat: add autonat config options 2020-04-14 20:54:58 -07:00
t0190-quic-ping.sh feat: add a transport config section 2020-06-16 15:15:47 -07:00
t0191-noise.sh feat: remove secio support 2021-02-25 13:36:40 -08:00
t0200-unixfs-ls.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0210-tar.sh Add global --cid-base option and enable it for most commands. 2019-01-17 15:54:32 -05:00
t0220-bitswap.sh humanize for ipfs bitswap stat 2019-04-26 02:54:48 -07:00
t0221-graphsync.sh test(graphsync): test server-side graphsync 2020-02-26 09:11:17 -08:00
t0230-channel-streaming-http-content-type.sh HTTP API: Disallow GET requests on API 2020-04-05 09:57:57 +02:00
t0231-channel-streaming.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0235-cli-request.sh socat is not part of any default install, make tests conditional 2019-12-23 15:41:30 +01:00
t0236-cli-api-dns-resolve.sh socat is not part of any default install, make tests conditional 2019-12-23 15:41:30 +01:00
t0240-republisher.sh testing: slow down republisher sharness test 2018-12-18 20:57:30 -08:00
t0250-files-api.sh Fix typos and cleanup 2020-04-20 22:00:01 +03:00
t0251-files-flushing.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0252-files-gc.sh fix broken gc test 2018-09-19 14:35:54 -07:00
t0260-sharding.sh switch to base32 by default for CIDv1 2019-05-13 10:57:53 -07:00
t0270-filestore.sh Fix typos and cleanup 2020-04-20 22:00:01 +03:00
t0271-filestore-utils.sh switch to base32 by default for CIDv1 2019-05-13 10:57:53 -07:00
t0272-urlstore.sh Fix typos and cleanup 2020-04-20 22:00:01 +03:00
t0275-cid-security.sh test(sharness): pass correct timeout format to go-timeout 2021-03-10 17:34:13 -08:00
t0276-cidv0v1.sh switch to base32 by default for CIDv1 2019-05-13 10:57:53 -07:00
t0280-plugin-git.sh Remove couple linux-isms: these are not valid on macos 2019-12-23 15:41:39 +01:00
t0280-plugin.sh feat: nice errors when failing to load plugins 2020-08-08 22:53:18 -04:00
t0290-cid.sh chore: update deps 2020-05-26 14:37:05 -07:00
t0300-docker-image.sh Make the docker check more specific 2019-12-23 15:41:30 +01:00
t0301-docker-migrate.sh test(sharness): fix typo 2020-01-17 10:27:36 -08:00
t0400-api-no-gateway.sh fix: localhost API access via ipv6 2020-10-20 00:46:40 +02:00
t0401-api-browser-security.sh fix: localhost API access via ipv6 2020-10-20 00:46:40 +02:00
t0410-api-add.sh Fix typos and cleanup 2020-04-20 22:00:01 +03:00
t0500-issues-and-regressions-offline.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0600-issues-and-regressions-online.sh use standard multibase format labels 2020-08-17 21:43:01 -07:00
t0700-remotepin.sh add remote pinning policy for mfs (#7798) 2021-01-28 18:58:44 -05:00
x0601-pin-fail-test.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00

ipfs whole tests using the sharness framework

Running all the tests

Just use make in this directory to run all the tests. Run with TEST_VERBOSE=1 to get helpful verbose output.

TEST_VERBOSE=1 make

The usual ipfs env flags also apply:

# the output will make your eyes bleed
IPFS_LOGGING=debug TEST_VERBOSE=1 make

To make the tests abort as soon as an error occurs, use the TEST_IMMEDIATE env variable:

# this will abort as soon the first error occurs
TEST_IMMEDIATE=1 make

Running just one test

You can run only one test script by launching it like a regular shell script:

$ ./t0010-basic-commands.sh

Debugging one test

You can use the -v option to make it verbose and the -i option to make it stop as soon as one test fails. For example:

$ ./t0010-basic-commands.sh -v -i

Sharness

When running sharness tests from main Makefile or when test_sharness_deps target is run dependencies for sharness will be downloaded from its github repo and installed in a "lib/sharness" directory.

Please do not change anything in the "lib/sharness" directory.

If you really need some changes in sharness, please fork it from its canonical repo and send pull requests there.

Writing Tests

Please have a look at existing tests and try to follow their example.

When possible and not too inefficient, that means most of the time, an ipfs command should not be on the left side of a pipe, because if the ipfs command fails (exit non zero), the pipe will mask this failure. For example after false | true, echo $? prints 0 (despite false failing).

It should be possible to put most of the code inside test_expect_success, or sometimes test_expect_failure, blocks, and to chain all the commands inside those blocks with &&, or || for diagnostic commands.

Diagnostics

Make your test case output helpful for when running sharness verbosely. This means cating certain files, or running diagnostic commands. For example:

test_expect_success ".ipfs/ has been created" '
  test -d ".ipfs" &&
  test -f ".ipfs/config" &&
  test -d ".ipfs/datastore" &&
  test -d ".ipfs/blocks" ||
  test_fsh ls -al .ipfs
'

The || ... is a diagnostic run when the preceding command fails. test_fsh is a shell function that echoes the args, runs the cmd, and then also fails, making sure the test case fails. (wouldn't want the diagnostic accidentally returning true and making it seem like the test case succeeded!).

Testing commands on daemon or mounted

Use the provided functions in lib/test-lib.sh to run the daemon or mount:

To init, run daemon, and mount in one go:

test_launch_ipfs_daemon_and_mount

test_expect_success "'ipfs add --help' succeeds" '
  ipfs add --help >actual
'

# other tests here...

# don't forget to kill the daemon!!
test_kill_ipfs_daemon

To init, run daemon, and then mount separately:

test_init_ipfs

# tests inited but not running here

test_launch_ipfs_daemon

# tests running but not mounted here

test_mount_ipfs

# tests mounted here

# don't forget to kill the daemon!!
test_kill_ipfs_daemon