kubo/test/sharness
Chris Boddy 5f246e3211 [http_proxy_over_p2p] httputil.ReverseProxy
Reimplement http-request proxying ala httputil.ReverseProxy.

NB: this is proxies the request synchronously (sends all request-body
before reading any response).

License: MIT
Signed-off-by: Chris Boddy <chris@boddy.im>
2018-11-28 23:17:26 -08:00
..
lib Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0024-files fix t0024 on osx 2017-09-03 18:43:18 -07:00
t0051-object-data no newlines in json objects 2015-11-30 15:23:48 -08:00
t0053-dag-data fix printing out of binary escaped data for test 2017-02-09 10:31:18 -08: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
t0275-cid-security-data cidsec: add test for command closing right away 2018-04-20 17:07:39 +02: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
Makefile make: make default rule 'aggregate' in sharness 2017-02-12 01:18:40 +01:00
README.md document TEST_IMMEDIATE in test/sharness/README.md 2018-09-19 14:35:54 -07:00
Rules.mk Include cid-fmt binary in test/bin. 2018-07-28 02:28:27 -04:00
t0010-basic-commands.sh add ipfs help sub-command test 2018-10-30 16:53:47 +08: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 sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0021-config.sh feat: stop apply command exposing private key over HTTP API 2018-10-24 05:46:00 -07:00
t0022-init-default.sh sharness: Fix tests 2018-04-10 18:31:25 +02: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 sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0030-mount.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0031-mount-publish.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0040-add-and-cat.sh fix ipfs help bug 2018-10-30 15:36:44 +08:00
t0041-ping.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0042-add-skip.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0043-add-w.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0044-add-symlink.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0045-ls.sh fix(commands): reduce complexity w/ typed encoder 2018-11-16 14:53:08 -08:00
t0046-id-hash.sh Add support for inlining via the id-hash to the add command. 2018-08-21 21:56:49 -04:00
t0050-block.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0051-object.sh test object links 2018-09-13 11:10:43 -07:00
t0052-object-diff.sh fix(diff): modify diff logic and comment 2018-09-24 20:39:07 +08:00
t0053-dag.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0060-daemon.sh add Web UI link to daemon startup 2018-11-02 23:00:52 -07:00
t0061-daemon-opts.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0062-daemon-api.sh sharness: Fix tests 2018-04-10 18:31:25 +02: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
t0065-active-requests.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0066-migration.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0070-user-config.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0080-repo.sh fix(sharness): gc repo size tests failing 2018-10-15 09:26:28 +01:00
t0081-repo-pinning.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0082-repo-gc-auto.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0083-repo-fsck.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 fix pin ls output when hash is specified 2018-10-30 15:26:18 +01:00
t0086-repo-verify.sh fix the repo verify test 2018-06-01 23:39:32 -07:00
t0087-repo-robust-gc.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0088-repo-stat-symlink.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0090-get.sh remove extra newline from expected command output 2018-05-31 18:29:22 -07:00
t0095-refs.sh Add sharness tests for the refs -r command using --max-depth 2018-08-27 20:34:52 +02:00
t0100-name.sh add ipfs help sub-command test 2018-10-30 16:53:47 +08:00
t0101-iptb-name.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0110-gateway.sh test: add tess for /debug/pprof-mutex/ endpoint 2018-09-27 03:44:44 +02:00
t0111-gateway-writeable.sh Avoid changing hash for empty non-raw leaves. 2018-05-31 04:27:34 -04:00
t0112-gateway-cors.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0120-bootstrap.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0121-bootstrap-iptb.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0125-twonode.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0130-multinode.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0131-multinode-client-routing.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0140-swarm.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0141-addfilter.sh sharness: Fix tests 2018-04-10 18:31:25 +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 error on resolving non-terminal paths 2018-10-30 12:34:32 -07:00
t0165-keystore.sh fix keystore tests for peer ID inlining patch 2018-05-31 18:29:22 -07:00
t0170-dht.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0175-reprovider.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0180-p2p.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0180-pubsub-gossipsub.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0180-pubsub.sh fix for-each 2018-11-01 20:13:31 -07:00
t0181-private-network.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0182-circuit-relay.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0183-namesys-pubsub.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0184-http-proxy-over-p2p.sh [http_proxy_over_p2p] httputil.ReverseProxy 2018-11-28 23:17:26 -08:00
t0190-quic-ping.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0200-unixfs-ls.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0210-tar.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0220-bitswap.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0230-channel-streaming-http-content-type.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0231-channel-streaming.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0235-cli-request.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0236-cli-api-dns-resolve.sh fix a test failure caused by eagerly killing nc 2018-08-29 16:36:25 -07:00
t0240-republisher.sh Update IPTB test - WIP 2018-11-01 19:33:05 -07:00
t0250-files-api.sh fix(files): add test 2018-10-17 01:06:32 +08: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 resolve: use unixfs ResolveOnce 2018-09-18 01:08:04 +02:00
t0270-filestore.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0271-filestore-utils.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0272-urlstore.sh fix the urlstore tests 2018-08-22 17:14:56 -07:00
t0275-cid-security.sh gx update and fix code to use new Cid type 2018-09-11 22:21:04 -04:00
t0276-cidv0v1.sh Update for plugins split 2018-11-01 19:34:05 -07:00
t0280-plugin-git.sh plugin: fix failing t0280-plugin-git 2018-05-01 18:47:48 +02:00
t0290-cid.sh update t0290-cid with new dash codec 2018-11-03 22:59:56 +01:00
t0300-docker-image.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0301-docker-migrate.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0400-api-security.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0410-api-add.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0500-issues-and-regressions-offline.sh sharness: Fix tests 2018-04-10 18:31:25 +02:00
t0600-issues-and-regressions-online.sh add test about issue #4978 2018-10-05 11:21:54 +08: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 cannonical 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...

# dont 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

# dont forget to kill the daemon!!
test_kill_ipfs_daemon