From 73e335a0731397139d5abaa085c7e5f614782d4d Mon Sep 17 00:00:00 2001 From: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.com> Date: Thu, 26 Nov 2026 06:32:38 +0500 Subject: [PATCH] test/s3: run rclone fstests in CI with an expected-failures list (#13013) * test/s3: result checker for rclone fstests * test/s3: run rclone fstests against SeaweedFS with expected failures * ci: add rclone fstests workflow * test/s3: catch parent-only failures and panics in rclone fstests check * test/s3: check parent assertions and skips in rclone fstests, widen paths * test/s3: drop issue numbers from the rclone expected-failures notes Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Konstantin Lebedev Co-authored-by: Chris Lu Co-authored-by: Claude Opus 5.5 --- .github/workflows/s3-rclone-tests.yml | 69 +++++++++ test/s3/rclone_fstests/.gitignore | 9 ++ test/s3/rclone_fstests/Makefile | 139 +++++++++++++++++ test/s3/rclone_fstests/check_results.py | 140 +++++++++++++++++ test/s3/rclone_fstests/expected_failures.txt | 33 ++++ test/s3/rclone_fstests/expected_skips.txt | 23 +++ test/s3/rclone_fstests/rclone.conf | 13 ++ test/s3/rclone_fstests/test_check_results.py | 151 +++++++++++++++++++ test/s3/rclone_fstests/test_s3.json | 20 +++ 9 files changed, 597 insertions(+) create mode 100644 .github/workflows/s3-rclone-tests.yml create mode 100644 test/s3/rclone_fstests/.gitignore create mode 100644 test/s3/rclone_fstests/Makefile create mode 100644 test/s3/rclone_fstests/check_results.py create mode 100644 test/s3/rclone_fstests/expected_failures.txt create mode 100644 test/s3/rclone_fstests/expected_skips.txt create mode 100644 test/s3/rclone_fstests/rclone.conf create mode 100644 test/s3/rclone_fstests/test_check_results.py create mode 100644 test/s3/rclone_fstests/test_s3.json diff --git a/.github/workflows/s3-rclone-tests.yml b/.github/workflows/s3-rclone-tests.yml new file mode 100644 index 0000000000..51745700d4 --- /dev/null +++ b/.github/workflows/s3-rclone-tests.yml @@ -0,0 +1,69 @@ +name: "S3 rclone fstests" + +on: + push: + branches: [ master ] + paths: + - 'weed/s3api/**' + - 'weed/filer/**' + - 'weed/server/**' + - 'weed/command/mini.go' + - 'go.mod' + - 'go.sum' + - 'test/s3/rclone_fstests/**' + - '.github/workflows/s3-rclone-tests.yml' + pull_request: + branches: [ master ] + paths: + - 'weed/s3api/**' + - 'weed/filer/**' + - 'weed/server/**' + - 'weed/command/mini.go' + - 'go.mod' + - 'go.sum' + - 'test/s3/rclone_fstests/**' + - '.github/workflows/s3-rclone-tests.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.event_name == 'push' && github.ref) || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' || (github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')) }} + +permissions: + contents: read + +jobs: + s3-rclone-fstests: + name: rclone fstests (S3 backend) + runs-on: ubuntu-24.04 + timeout-minutes: 40 + steps: + - name: Check out code + uses: actions/checkout@v7 + + - name: Set up Go + uses: actions/setup-go@v7 + with: + go-version-file: 'go.mod' + cache: ${{ runner.environment == 'github-hosted' }} + + - name: Test the result checker + working-directory: test/s3/rclone_fstests + run: python3 -m unittest -v test_check_results + + - name: Run rclone fstests + working-directory: test/s3/rclone_fstests + run: make test + + - name: Show server log on failure + if: failure() + working-directory: test/s3/rclone_fstests + run: tail -200 weed-test.log || true + + - name: Upload results + if: always() + uses: actions/upload-artifact@v7 + with: + name: s3-rclone-fstests-results + path: test/s3/rclone_fstests/results.jsonl + if-no-files-found: ignore + retention-days: 7 diff --git a/test/s3/rclone_fstests/.gitignore b/test/s3/rclone_fstests/.gitignore new file mode 100644 index 0000000000..27dd1e44f6 --- /dev/null +++ b/test/s3/rclone_fstests/.gitignore @@ -0,0 +1,9 @@ +rclone/ +rclone-s3.test +test-volume-data/ +results.jsonl +weed-test.log +weed-server.pid +weed-server.started +__pycache__/ +suite.exit diff --git a/test/s3/rclone_fstests/Makefile b/test/s3/rclone_fstests/Makefile new file mode 100644 index 0000000000..0b72031907 --- /dev/null +++ b/test/s3/rclone_fstests/Makefile @@ -0,0 +1,139 @@ +# Runs rclone's integration tests for its S3 backend (fstests, TestIntegration) +# against a local SeaweedFS S3 gateway and compares the results with +# expected_failures.txt. + +.PHONY: all test help build-weed build-suite start-server stop-server run-suite test-with-server logs clean + +SUITE_REPO := https://github.com/rclone/rclone.git +SUITE_COMMIT := 5e2a70fee058ca16948d37d4dabd4aabb4549dd2 +SUITE_DIR := rclone +SUITE_BINARY := rclone-s3.test +SUITE_STAMP := $(SUITE_DIR)/.seaweedfs-prepared + +WEED_BINARY := ../../../weed/weed_binary +S3_PORT ?= 8338 +MASTER_PORT ?= 9338 +VOLUME_PORT ?= 8088 +FILER_PORT ?= 8891 +WEBDAV_PORT ?= 7338 +ADMIN_PORT ?= 23649 +SERVER_DIR := ./test-volume-data +S3_CONFIG := ./test_s3.json +# Succeeds while weed-server.pid names the server start-server launched: the +# process at that pid must have the start time recorded with it, so a process +# that reused the pid is left alone. +OWN_SERVER_RUNNING = [ -f weed-server.pid ] && [ -s weed-server.started ] && \ + [ "$$(ps -p "$$(cat weed-server.pid)" -o lstart= 2>/dev/null)" = "$$(cat weed-server.started)" ] + +.DEFAULT_GOAL := help + +all: test + +test: test-with-server + +help: + @echo "rclone fstests (S3 backend) against SeaweedFS" + @echo "" + @echo " build-weed - Build the SeaweedFS binary" + @echo " build-suite - Fetch the suite at $(SUITE_COMMIT) and build it" + @echo " start-server - Start weed mini with S3 on port $(S3_PORT)" + @echo " run-suite - Run the suite and check expected_failures.txt" + @echo " stop-server - Stop the test server" + @echo " test-with-server - Start server, run suite, stop server" + @echo " logs - Show server logs" + @echo " clean - Remove test artifacts" + +build-weed: + @cd ../../../weed && go build -o weed_binary . + +build-suite: + @if [ "$$(cat $(SUITE_STAMP) 2>/dev/null)" != "$(SUITE_COMMIT)" ]; then \ + rm -rf $(SUITE_DIR) && mkdir -p $(SUITE_DIR) && \ + git -C $(SUITE_DIR) init -q && \ + git -C $(SUITE_DIR) fetch -q --depth 1 $(SUITE_REPO) $(SUITE_COMMIT) && \ + git -C $(SUITE_DIR) checkout -q FETCH_HEAD && \ + echo "$(SUITE_COMMIT)" > $(SUITE_STAMP); \ + fi + @# rclone is its own module; GOWORK=off keeps any go.work above it out of the build. + @cd $(SUITE_DIR) && GOWORK=off go test -c -o ../$(SUITE_BINARY) ./backend/s3 + +start-server: build-weed + @if curl -sS --max-time 2 -o /dev/null http://127.0.0.1:$(S3_PORT)/ >/dev/null 2>&1; then \ + echo "port $(S3_PORT) is already served by another process; refusing to test against it"; \ + exit 1; \ + fi + @if $(OWN_SERVER_RUNNING); then \ + echo "the server this Makefile started (pid $$(cat weed-server.pid)) is still running; run make stop-server first"; \ + exit 1; \ + fi + @rm -rf weed-server.pid weed-server.started $(SERVER_DIR) + @mkdir -p $(SERVER_DIR) + @$(WEED_BINARY) mini \ + -dir=$(SERVER_DIR) \ + -ip=127.0.0.1 \ + -ip.bind=127.0.0.1 \ + -master.port=$(MASTER_PORT) \ + -volume.port=$(VOLUME_PORT) \ + -filer.port=$(FILER_PORT) \ + -webdav.port=$(WEBDAV_PORT) \ + -admin.port=$(ADMIN_PORT) \ + -admin.port.legacy=0 \ + -s3.port=$(S3_PORT) \ + -s3.config=$(S3_CONFIG) \ + -master.peers=none \ + > weed-test.log 2>&1 & echo $$! > weed-server.pid; \ + ps -p $$! -o lstart= > weed-server.started + @for i in $$(seq 1 60); do \ + kill -0 $$(cat weed-server.pid) 2>/dev/null || { \ + echo "SeaweedFS server exited during startup"; \ + cat weed-test.log; \ + exit 1; \ + }; \ + if curl -sS --max-time 2 -o /dev/null http://127.0.0.1:$(S3_PORT)/ >/dev/null 2>&1; then \ + echo "SeaweedFS S3 server is ready on port $(S3_PORT)"; \ + exit 0; \ + fi; \ + sleep 1; \ + done; \ + echo "SeaweedFS S3 server failed to start"; \ + cat weed-test.log; \ + $(MAKE) --no-print-directory stop-server; \ + exit 1 + +stop-server: + @if [ -f weed-server.pid ]; then \ + if $(OWN_SERVER_RUNNING); then \ + kill $$(cat weed-server.pid) 2>/dev/null || true; \ + for i in $$(seq 1 30); do $(OWN_SERVER_RUNNING) || break; sleep 1; done; \ + if $(OWN_SERVER_RUNNING); then \ + echo "the server this Makefile started (pid $$(cat weed-server.pid)) is still running after 30s; keeping weed-server.pid"; \ + exit 1; \ + fi; \ + fi; \ + rm -f weed-server.pid weed-server.started; \ + fi + +# The suite's exit status does not fail this step: check_results.py decides from +# the results which failures are expected. It still gets the status, because a +# panic (exit 2) can leave every started test with a status while later tests +# never ran. +run-suite: build-suite + @cd $(SUITE_DIR)/backend/s3 && \ + { RCLONE_CONFIG=$(CURDIR)/rclone.conf \ + RCLONE_CONFIG_SWFS_ENDPOINT=http://127.0.0.1:$(S3_PORT) \ + $(CURDIR)/$(SUITE_BINARY) -test.v -test.run '^TestIntegration$$' -test.timeout 20m -remote swfs:; \ + echo $$? > $(CURDIR)/suite.exit; } 2>&1 | \ + go tool test2json -p rclone > $(CURDIR)/results.jsonl || true + python3 check_results.py results.jsonl expected_failures.txt --skips expected_skips.txt --exit-code suite.exit + +test-with-server: + @$(MAKE) start-server || exit $$?; \ + $(MAKE) run-suite; TEST_RESULT=$$?; \ + $(MAKE) stop-server; STOP_RESULT=$$?; \ + if [ $$TEST_RESULT -ne 0 ]; then exit $$TEST_RESULT; fi; exit $$STOP_RESULT + +logs: + @test -f weed-test.log && tail -100 weed-test.log || echo "No log file found" + +clean: stop-server + @rm -rf $(SERVER_DIR) $(SUITE_DIR) $(SUITE_BINARY) results.jsonl suite.exit weed-test.log weed-server.pid weed-server.started __pycache__ diff --git a/test/s3/rclone_fstests/check_results.py b/test/s3/rclone_fstests/check_results.py new file mode 100644 index 0000000000..b4e2127707 --- /dev/null +++ b/test/s3/rclone_fstests/check_results.py @@ -0,0 +1,140 @@ +#!/usr/bin/env python3 +"""Compare rclone fstests results (go test2json events) with the expected lists. + +A test fails CI when its result differs from what the lists say: +- a leaf subtest that failed must be in expected_failures.txt; +- a parent test fails whenever one of its children does, so its status alone + says nothing new. It counts as failing on its own when it has no failed + subtest or when testify reported an assertion under it ("Error Trace:" in + the output test2json attributes to it, e.g. a deferred cleanup check), and + then it must be listed too; +- a skipped test must be in expected_skips.txt, so a feature that silently + turns into a skip (Object Lock, versioning) is noticed; +- a listed test that passed, was skipped instead of failing, ran instead of + being skipped, or did not run at all fails CI as well, so the lists only + ever shrink together with fixes. +Tests that started but never finished, and a test binary exit code other than +0 or 1 (panic, -test.timeout), fail CI too. +""" +import argparse +import json +import sys + +FINAL_ACTIONS = ("pass", "fail", "skip") +OWN_ASSERTION_MARKER = "Error Trace:" + + +def load_expected(path): + expected = set() + with open(path) as f: + for line in f: + fields = line.split("#", 1)[0].split() + if fields: + expected.add(fields[0]) + return expected + + +def load_events(path): + events = [] + with open(path) as f: + for line in f: + try: + events.append(json.loads(line)) + except ValueError: + continue + return events + + +def evaluate(events, expected, exit_code=None, expected_skips=None): + """Return the problems found; skips are only checked when expected_skips is given.""" + started, status, asserted = set(), {}, set() + package_failed = False + for e in events: + action, test = e.get("Action"), e.get("Test") + if not test: + package_failed = package_failed or action == "fail" + continue + if action == "run": + started.add(test) + elif action in FINAL_ACTIONS: + status[test] = action + elif action == "output" and OWN_ASSERTION_MARKER in e.get("Output", ""): + asserted.add(test) + + names = started | set(status) + if not names: + return ["no test results: the suite could not start against the server"] + + problems = [] + # test2json fails the package whenever a test failed; only a package failure + # with no failed test behind it points at something outside the tests. + if package_failed and "fail" not in status.values() and all(n in status for n in names): + problems.append("the test binary failed outside any test (panic or -test.timeout?)") + for name in sorted(names - set(status)): + problems.append(f"{name}: started but never finished (panic or -test.timeout?)") + # A failing run exits 1. A panic exits 2 after reporting the panicking test and + # its parents as failed, so every test has a status, yet the rest never ran. + if exit_code not in (None, 0, 1): + problems.append(f"the test binary ended with exit code {exit_code} (panic or -test.timeout?); later tests did not run") + + def has_children(name): + return any(o.startswith(name + "/") for o in names) + + def failed_on_its_own(name): + if status.get(name) != "fail": + return False + if name in asserted or not has_children(name): + return True + return not any(o.startswith(name + "/") and status.get(o) == "fail" for o in names) + + for name in sorted(names): + if failed_on_its_own(name) and name not in expected: + kind = "unexpected failure" if not has_children(name) else "unexpected failure of the test itself, not of its subtests" + problems.append(f"{name}: {kind}") + for name in sorted(expected): + result = status.get(name) + if result == "pass": + problems.append(f"{name}: XPASS, remove it from expected_failures.txt") + elif result == "fail" and not failed_on_its_own(name): + problems.append(f"{name}: now fails only through its subtests, remove it from expected_failures.txt") + elif result != "fail": + problems.append(f"{name}: listed as an expected failure but did not fail ({result or 'not run'})") + + if expected_skips is not None: + for name in sorted(n for n in names if status.get(n) == "skip" and n not in expected_skips): + problems.append(f"{name}: unexpected skip") + for name in sorted(expected_skips): + result = status.get(name) + if result != "skip": + problems.append(f"{name}: listed as an expected skip but {result or 'did not run'}") + return problems + + +def main(): + ap = argparse.ArgumentParser(description=__doc__.splitlines()[0]) + ap.add_argument("results", help="test2json output (JSON lines)") + ap.add_argument("expected_failures") + ap.add_argument("--skips", help="expected_skips.txt; without it skips are not checked") + ap.add_argument("--exit-code", help="file holding the test binary's exit status") + args = ap.parse_args() + + events = load_events(args.results) + expected = load_expected(args.expected_failures) + skips = load_expected(args.skips) if args.skips else None + exit_code = None + if args.exit_code: + with open(args.exit_code) as f: + exit_code = int(f.read().strip()) + problems = evaluate(events, expected, exit_code, skips) + if problems: + print("rclone fstests do not match the expected lists:", file=sys.stderr) + for p in problems: + print(" " + p, file=sys.stderr) + sys.exit(1) + passed = sum(1 for e in events if e.get("Action") == "pass" and e.get("Test")) + print(f"rclone fstests OK: {passed} passed (parents included), " + f"{len(expected)} expected failures still fail, {len(skips or ())} expected skips") + + +if __name__ == "__main__": + main() diff --git a/test/s3/rclone_fstests/expected_failures.txt b/test/s3/rclone_fstests/expected_failures.txt new file mode 100644 index 0000000000..18b81853e9 --- /dev/null +++ b/test/s3/rclone_fstests/expected_failures.txt @@ -0,0 +1,33 @@ +# rclone fstests (TestIntegration, S3 backend) that SeaweedFS is expected to fail. +# check_results.py fails CI on any other failure, and on any test listed here +# that passes, is skipped or does not run, so remove an entry together with the +# fix that makes it pass. +# Format: # reason + +# Deleting the last key under a prefix leaves its filer directory behind, and +# the empty directory is listed as a CommonPrefix until EmptyFolderCleaner +# removes it (s3.empty_folder_cleanup_delay, 2m by default, drained by a 30s +# tick). These tests list right after earlier tests deleted +# their files, so the leftover directories show up. Some leftovers come from the +# failing FsEncoding tests below, so fixing those may change these listings too. +TestIntegration/FsMkdir/FsPutFiles/FsListDirFile2 # empty directories listed until cleanup +TestIntegration/FsMkdir/FsPutFiles/FsListRDirFile2 # empty directories listed until cleanup +TestIntegration/FsMkdir/FsPutFiles/FsListLevel2 # empty directories listed until cleanup +TestIntegration/FsMkdir/FsPutFiles/FromRoot/ListEntries # empty directories listed until cleanup + +# An object whose name has control characters, a backslash or a vertical tab is +# listed under a different name than the one it was written with. +TestIntegration/FsMkdir/FsEncoding/control_chars # name listed differently from how it was written +TestIntegration/FsMkdir/FsEncoding/punctuation # name with a backslash listed differently +TestIntegration/FsMkdir/FsEncoding/leading_VT # name with a vertical tab listed differently +TestIntegration/FsMkdir/FsEncoding/trailing_VT # name with a vertical tab listed differently + +# SeaweedFS answers CreateBucket on a bucket the caller owns with +# BucketAlreadyOwnedByYou, which rclone expects only with use_already_exists set; +# the SeaweedFS provider defaults it to false and rclone.conf keeps that (see there). +TestIntegration/FsMkdir/FsPutFiles/Internal/Versions/Mkdir # rclone provider quirk use_already_exists=false + +# The test itself, not its subtests: FsMkdir ends by removing the test bucket, +# and DeleteBucket answers 409 BucketNotEmpty although no keys are left - +# leftover empty directories or FsEncoding objects that were not deleted. +TestIntegration/FsMkdir # DeleteBucket returns BucketNotEmpty at the end of the run diff --git a/test/s3/rclone_fstests/expected_skips.txt b/test/s3/rclone_fstests/expected_skips.txt new file mode 100644 index 0000000000..329e28b940 --- /dev/null +++ b/test/s3/rclone_fstests/expected_skips.txt @@ -0,0 +1,23 @@ +# rclone fstests (TestIntegration, S3 backend) that are expected to be skipped. +# check_results.py fails CI on any other skip, so a feature that silently turns +# into a skip (e.g. Object Lock or versioning setup failing) is noticed, and on +# any test listed here that runs, so remove an entry once it does. +# These skips come from rclone itself: features the S3 backend does not have or +# that the remote does not advertise. +# Format: +TestIntegration/FsCheckWrap +TestIntegration/FsMkdir/FsOpenWriterAt +TestIntegration/FsMkdir/FsChangeNotify +TestIntegration/FsMkdir/FsPutFiles/FsNewObjectCaseInsensitive +TestIntegration/FsMkdir/FsPutFiles/FsMove +TestIntegration/FsMkdir/FsPutFiles/FsDirMove +TestIntegration/FsMkdir/FsPutFiles/ObjectSetMetadata +TestIntegration/FsMkdir/FsPutFiles/SetTier +TestIntegration/FsMkdir/FsPutFiles/ObjectCheckWrap +TestIntegration/FsMkdir/FsPutFiles/Bucket +TestIntegration/FsMkdir/FsPutFiles/ObjectAbout +TestIntegration/FsMkdir/FsPutFiles/Internal/RmdirRoot +TestIntegration/FsMkdir/FsDirSetModTime +TestIntegration/FsMkdir/FsMkdirMetadata +TestIntegration/FsMkdir/FsDirectory +TestIntegration/FsShutdown diff --git a/test/s3/rclone_fstests/rclone.conf b/test/s3/rclone_fstests/rclone.conf new file mode 100644 index 0000000000..0bf9e84269 --- /dev/null +++ b/test/s3/rclone_fstests/rclone.conf @@ -0,0 +1,13 @@ +# rclone remote used by the Makefile. The endpoint comes from +# RCLONE_CONFIG_SWFS_ENDPOINT so it follows S3_PORT. +# +# use_already_exists stays at the SeaweedFS provider default (false): with it +# set, the ObjectLock tests fail on rclone's own CreateBucket for a bucket the +# test already created with Object Lock, which SeaweedFS answers with +# BucketAlreadyExists. See Internal/Versions/Mkdir in expected_failures.txt. +[swfs] +type = s3 +provider = SeaweedFS +access_key_id = admin +secret_access_key = admin +force_path_style = true diff --git a/test/s3/rclone_fstests/test_check_results.py b/test/s3/rclone_fstests/test_check_results.py new file mode 100644 index 0000000000..03bf8ab566 --- /dev/null +++ b/test/s3/rclone_fstests/test_check_results.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python3 +"""Unit tests for check_results.py. Run: python3 -m unittest -v test_check_results""" +import os +import tempfile +import unittest + +import check_results + + +def ev(action, test=None): + event = {"Action": action, "Package": "rclone"} + if test is not None: + event["Test"] = test + return event + + +def finished(test, action): + return [ev("run", test), ev(action, test)] + + +def output(test, text): + event = ev("output", test) + event["Output"] = text + return event + + +def own_assertion_run(): + """T/P/A fails, then T/P fails its own deferred assertion.""" + return ( + [ev("run", "T"), ev("run", "T/P"), ev("run", "T/P/A"), ev("fail", "T/P/A")] + + [output("T/P", " \tError Trace:\tx_test.go:1\n"), ev("fail", "T/P")] + + [ev("fail", "T"), ev("fail")] + ) + + +class EvaluateTest(unittest.TestCase): + def test_all_pass_ok(self): + events = finished("TestIntegration", "pass") + finished("TestIntegration/A", "pass") + self.assertEqual(check_results.evaluate(events, set()), []) + + def test_unexpected_leaf_failure(self): + events = finished("TestIntegration/A", "fail") + finished("TestIntegration", "fail") + problems = check_results.evaluate(events, set()) + self.assertEqual(len(problems), 1) + self.assertIn("TestIntegration/A", problems[0]) + + def test_parent_of_expected_failure_ignored(self): + events = ( + finished("TestIntegration/FsMkdir/X", "fail") + + finished("TestIntegration/FsMkdir", "fail") + + finished("TestIntegration", "fail") + ) + self.assertEqual(check_results.evaluate(events, {"TestIntegration/FsMkdir/X"}), []) + + def test_expected_now_passes_fails(self): + events = finished("T", "pass") + finished("T/A", "pass") + problems = check_results.evaluate(events, {"T/A"}) + self.assertEqual(len(problems), 1) + self.assertIn("XPASS", problems[0]) + + def test_listed_skip_or_missing_fails(self): + events = finished("T", "pass") + finished("T/Skipped", "skip") + problems = check_results.evaluate(events, {"T/Skipped", "T/Missing"}) + self.assertEqual(len(problems), 2) + self.assertTrue(any("T/Skipped" in p for p in problems)) + self.assertTrue(any("T/Missing" in p for p in problems)) + + def test_unlisted_skip_ok(self): + events = finished("T", "pass") + finished("T/A", "skip") + self.assertEqual(check_results.evaluate(events, set()), []) + + def test_package_failure_fails(self): + events = [ev("run", "T"), ev("run", "T/A"), ev("output"), ev("fail")] + self.assertNotEqual(check_results.evaluate(events, set()), []) + + def test_package_fail_from_expected_failures_ok(self): + # go test2json reports the package as failed whenever any test failed. + events = finished("T/A", "fail") + finished("T", "fail") + [ev("fail")] + self.assertEqual(check_results.evaluate(events, {"T/A"}), []) + + def test_package_fail_without_failed_test_fails(self): + events = finished("T", "pass") + [ev("fail")] + self.assertNotEqual(check_results.evaluate(events, set()), []) + + def test_parent_failing_on_its_own_fails(self): + # All children pass, but the parent fails (e.g. its own cleanup). + events = finished("T/P/A", "pass") + finished("T/P", "fail") + finished("T", "fail") + [ev("fail")] + problems = check_results.evaluate(events, set()) + self.assertEqual(len(problems), 1) + self.assertIn("T/P", problems[0]) + + def test_panic_in_expected_test_fails(self): + # A panicking test and its parents all report fail, then the binary exits 2. + events = finished("T/A", "fail") + finished("T", "fail") + [ev("fail")] + problems = check_results.evaluate(events, {"T/A"}, exit_code=2) + self.assertEqual(len(problems), 1) + self.assertIn("exit code 2", problems[0]) + + def test_failing_run_exit_code_one_ok(self): + events = finished("T/A", "fail") + finished("T", "fail") + [ev("fail")] + self.assertEqual(check_results.evaluate(events, {"T/A"}, exit_code=1), []) + + def test_parent_own_assertion_with_failed_child_fails(self): + # testify prints "Error Trace:" under the test that asserted; test2json + # attributes that output to the parent, not to the expected child. + events = own_assertion_run() + problems = check_results.evaluate(events, {"T/P/A"}) + self.assertEqual(len(problems), 1) + self.assertIn("T/P:", problems[0]) + + def test_expected_parent_own_failure_ok(self): + self.assertEqual(check_results.evaluate(own_assertion_run(), {"T/P/A", "T/P"}), []) + + def test_expected_parent_failing_only_through_child_fails(self): + events = finished("T/P/A", "fail") + finished("T/P", "fail") + finished("T", "fail") + [ev("fail")] + problems = check_results.evaluate(events, {"T/P/A", "T/P"}) + self.assertEqual(len(problems), 1) + self.assertIn("T/P:", problems[0]) + + def test_unlisted_skip_fails_with_skip_list(self): + events = finished("T", "pass") + finished("T/A", "skip") + problems = check_results.evaluate(events, set(), expected_skips=set()) + self.assertEqual(len(problems), 1) + self.assertIn("T/A", problems[0]) + + def test_listed_skip_ok(self): + events = finished("T", "pass") + finished("T/A", "skip") + self.assertEqual(check_results.evaluate(events, set(), expected_skips={"T/A"}), []) + + def test_listed_skip_that_runs_fails(self): + events = finished("T", "pass") + finished("T/A", "pass") + problems = check_results.evaluate(events, set(), expected_skips={"T/A"}) + self.assertEqual(len(problems), 1) + self.assertIn("T/A", problems[0]) + + def test_no_results_fails(self): + self.assertNotEqual(check_results.evaluate([], set()), []) + + +class LoadExpectedTest(unittest.TestCase): + def test_load_expected_strips_comments(self): + with tempfile.NamedTemporaryFile("w", suffix=".txt", delete=False) as f: + f.write("# c\n\nT/A # why\nT/B\n") + try: + self.assertEqual(check_results.load_expected(f.name), {"T/A", "T/B"}) + finally: + os.unlink(f.name) + + +if __name__ == "__main__": + unittest.main() diff --git a/test/s3/rclone_fstests/test_s3.json b/test/s3/rclone_fstests/test_s3.json new file mode 100644 index 0000000000..1f9b460008 --- /dev/null +++ b/test/s3/rclone_fstests/test_s3.json @@ -0,0 +1,20 @@ +{ + "identities": [ + { + "name": "admin", + "credentials": [ + { + "accessKey": "admin", + "secretKey": "admin" + } + ], + "actions": [ + "Admin", + "Read", + "List", + "Tagging", + "Write" + ] + } + ] +}