mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-23 22:40:39 +02:00
* fuse integration: add POSIX compliance test suite Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * ci: add posix-compliance workflow Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fuse integration: skip non-executable weed path candidates * fuse integration: size readv buffer to the written segment * fuse integration: reference posix_Makefile explicitly in recursive make calls GNU make does not propagate -f through MAKEFLAGS, so bare $(MAKE) re-read the default Makefile in this directory. * fuse integration: fail posix test targets when go test fails Every suite pipes go test through tee under /bin/sh, so the recipe status was tee's and test failures stayed green. Run recipes under bash -o pipefail and emit the color escapes with printf since bash echo does not expand them. * fuse integration: run only benchmarks in benchmark-posix go test -bench=. without -run also executes the whole suite, mixing compliance output into the benchmark log. * fuse integration: emit single-number test counts in reports grep -c prints 0 and exits nonzero when nothing matches, so '|| echo 0' produced two lines that broke the expr arithmetic and JSON fields. awk prints exactly one count either way. * fuse integration: skip the sendfile test on macOS macOS sendfile(2) only accepts a socket destination; the test copies into a regular file and always gets ENOTSOCK. * fuse integration: honor TestConfig and own only self-started resources NewFuseTestFramework dropped its config argument and Cleanup read a fresh DefaultTestConfig, so SkipCleanup never did anything. Cleanup also skipped teardown whenever TEST_SKIP_CLUSTER_SETUP was set, even when TEST_MOUNT_POINT was empty and Setup had started the cluster itself. The framework now keeps the config it was built with, runs external-mount tests inside a per-run work dir under the mount, and only skips teardown when an external mount was actually used. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fuse integration: pass the debug flag before the subcommand -v is a weed global flag; appended after master/volume/filer/mount it lands on the subcommand flagset, which rejects it and the process dies at flag parsing whenever EnableDebug is on. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fuse integration: require a real mount before running tests Setup creates the mount point before weed mount starts, so statting and listing it succeeded on the plain directory and tests ran against local disk whenever the mount was slow or died. waitForMount now waits until the mount point's device id differs from its parent's. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fuse integration: resolve the weed binary to an absolute path The started processes run with cmd.Dir at the framework's temp dir, so a relative candidate like ../weed no longer resolves. Prefer PATH, then probe the usual build outputs and return absolute paths only. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fuse integration: build the external test work dir with MkdirTemp The suite staged cloned tools and generated scripts under a predictable /tmp path another user could pre-create and swap mid-run. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fuse integration: use the pjdfstest tree setup-pjdfstest installs The test gated on a pjdfstest binary in PATH but then proved a suite it cloned itself, so a tree installed by make setup-pjdfstest was never found. Look for the built suite under external_tools first, then clone into the work dir as before. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * ci: require a real mount before posix tests The wait loop fell back to listing the mount point, which passes on the directory created before weed mount runs — a dead or slow mount meant the suite exercised local disk. Only mountpoint counts now, and a dead mount process fails fast instead of timing out. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * ci: collect failure logs before cleanup deletes them The always-on cleanup step removed /tmp/seaweedfs before the failure-only debug step could copy the service logs, so failed runs uploaded nothing. Run cleanup after log collection. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fuse integration: point MOUNT_POINT at TEST_MOUNT_POINT Targets that work against MOUNT_POINT (pjdfstest, nfstest, fio configs) ignored TEST_MOUNT_POINT and ran against the local-disk default while the go tests used the external mount. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fuse integration: skip the permission-denied check as root Root bypasses mode-bit checks, so writing the read-only file succeeded and the assertion failed in root-run environments like containers. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fuse integration: align the posix docs with the suite The doc listed a docker-test-posix target and make variables that do not exist, and ran go test against single files that cannot compile alone. The roadmap also still claimed the platform-specific tests this suite now implements were all skipped. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fuse integration: honor SkipCleanup in the mini-based framework too Same gap as the fuse-package framework: Cleanup read a fresh DefaultTestConfig, so a test's SkipCleanup setting was ignored. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fuse integration: normalize config in Setup and clean the work dir too Setup(nil) panicked on config.EnableDebug and external-mount Cleanup left the temp dir behind; use the stored config for the start* calls and remove tempDir alongside the external work dir. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * ci: point external posix suites at the workflow FUSE mount * fuse integration: create the fio target directory before running * fuse integration: use unix.O_DIRECT instead of a hard-coded x86 value 0x4000 is O_DIRECT only on x86 and amd64; on arm64 it is O_DIRECTORY. The test module already depends on golang.org/x/sys. * fuse integration: run autoreconf and configure before building pjdfstest A fresh pjdfstest clone is autotools-based and has no Makefile, so the Go-side setup fallback always failed and the suite silently skipped. * ci: require external posix tools only when setup installed them setup-external-tools always exits 0 because each sub-target tolerates failure, so POSIX_REQUIRE_EXTERNAL_TOOLS was set even with no tools installed and the suite then hard-failed on the missing suites. * ci: fail the posix workflow when the mount point is not a FUSE mount The file write/read check passes on the plain directory created before weed mount, so a dead mount let the whole suite grade the local disk. * fuse integration: skip when the host has no FUSE device node Setup failed the test outright on machines without /dev/fuse instead of skipping; cover every suite entry point by skipping inside Setup. * fuse integration: drop the chmod 666 /dev/fuse troubleshooting tip World-writable device access is a security risk; the fuse group membership on the line below is the safe fix. * fuse integration: require go 1.21+ in check-go, not 1.20+ * fuse integration: refuse external suites on an unmounted path * fuse integration: verify TEST_MOUNT_POINT is a real mount * fuse integration: clean TEST_MOUNT_POINT before the parent-device check filepath.Dir of a trailing-slash path returns the mount itself, so a mounted TEST_MOUNT_POINT ending in / was refused. * fuse integration: detect WinFsp mounts on Windows in mountedAt A directory mount is a reparse point and a drive mount is a volume root; a plain directory is now refused instead of accepted. * fuse integration: strip a trailing slash off MOUNT_POINT in require-mounted The mount-table grep fallback on hosts without mountpoint(8) would not match a slash-suffixed entry. * fuse integration: require an external mount to be a FUSE filesystem A device-ID boundary alone does not prove FUSE: a tmpfs mount would pass mountedAt and report its results as FUSE compliance. Check the filesystem type (statfs magic on linux, fstypename on the BSDs); platforms without a check keep the mount and write verification. --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
532 lines
25 KiB
Plaintext
532 lines
25 KiB
Plaintext
# SeaweedFS POSIX Compliance Testing Makefile
|
|
|
|
SHELL := /bin/bash
|
|
# go test is piped through tee everywhere; without pipefail a failing suite
|
|
# still exits 0 because only tee's status propagates.
|
|
.SHELLFLAGS := -o pipefail -c
|
|
|
|
# Configuration
|
|
WEED_BINARY := $(shell which weed 2>/dev/null || echo "../../weed")
|
|
GO_VERSION := 1.21
|
|
TEST_TIMEOUT := 45m
|
|
COVERAGE_FILE := posix_coverage.out
|
|
REPORT_DIR := reports
|
|
EXTERNAL_TOOLS_DIR := external_tools
|
|
MOUNT_POINT ?= /tmp/seaweedfs_mount
|
|
ifneq ($(TEST_MOUNT_POINT),)
|
|
MOUNT_POINT := $(TEST_MOUNT_POINT)
|
|
endif
|
|
|
|
# Go test command prefix for external mount points
|
|
GO_TEST_PREFIX :=
|
|
ifneq ($(TEST_MOUNT_POINT),)
|
|
GO_TEST_PREFIX := TEST_MOUNT_POINT="$(TEST_MOUNT_POINT)" TEST_SKIP_CLUSTER_SETUP="true"
|
|
endif
|
|
|
|
# Test categories
|
|
POSIX_BASIC_TESTS := posix_compliance_test.go
|
|
POSIX_EXTENDED_TESTS := posix_extended_test.go
|
|
POSIX_EXTERNAL_TESTS := posix_external_test.go
|
|
|
|
# -f is not propagated through MAKEFLAGS, so recursive calls must name this
|
|
# file explicitly or the sub-make reads the default Makefile instead.
|
|
MAKE_SELF := $(MAKE) -f $(firstword $(MAKEFILE_LIST))
|
|
|
|
# Colors for output — bash echo does not expand \033, so bake the escapes in
|
|
RED := $(shell printf '\033[31m')
|
|
GREEN := $(shell printf '\033[32m')
|
|
YELLOW := $(shell printf '\033[33m')
|
|
BLUE := $(shell printf '\033[34m')
|
|
MAGENTA := $(shell printf '\033[35m')
|
|
CYAN := $(shell printf '\033[36m')
|
|
WHITE := $(shell printf '\033[37m')
|
|
RESET := $(shell printf '\033[0m')
|
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
# Prerequisites checks
|
|
check-binary:
|
|
@if [ ! -f "$(WEED_BINARY)" ]; then \
|
|
echo "$(RED)❌ SeaweedFS binary not found at $(WEED_BINARY)$(RESET)"; \
|
|
echo " Please run 'make' in the root directory first"; \
|
|
exit 1; \
|
|
fi
|
|
@echo "$(GREEN)[OK] SeaweedFS binary found at $(WEED_BINARY)$(RESET)"
|
|
|
|
check-fuse:
|
|
@if command -v fusermount >/dev/null 2>&1; then \
|
|
echo "$(GREEN)[OK] FUSE is installed (Linux)$(RESET)"; \
|
|
elif command -v umount >/dev/null 2>&1 && [ "$$(uname)" = "Darwin" ]; then \
|
|
echo "$(GREEN)[OK] FUSE is available (macOS)$(RESET)"; \
|
|
else \
|
|
echo "$(RED)❌ FUSE not found. Please install:$(RESET)"; \
|
|
echo " Ubuntu/Debian: sudo apt-get install fuse"; \
|
|
echo " CentOS/RHEL: sudo yum install fuse"; \
|
|
echo " macOS: brew install macfuse"; \
|
|
exit 1; \
|
|
fi
|
|
|
|
check-go:
|
|
@go version | grep -Eq "go(1\.(2[1-9]|[3-9][0-9]+)|[2-9]\.)" || \
|
|
(echo "$(RED)❌ Go $(GO_VERSION)+ required. Current: $$(go version)$(RESET)" && exit 1)
|
|
@echo "$(GREEN)[OK] Go version check passed$(RESET)"
|
|
|
|
check-prereqs: check-go check-fuse check-binary
|
|
@echo "$(GREEN)[OK] All prerequisites satisfied$(RESET)"
|
|
|
|
# Setup and initialization
|
|
|
|
|
|
setup-reports:
|
|
@mkdir -p $(REPORT_DIR)
|
|
@mkdir -p $(EXTERNAL_TOOLS_DIR)
|
|
|
|
setup-external-tools: setup-reports
|
|
@echo "$(BLUE)🛠️ Setting up external POSIX test tools...$(RESET)"
|
|
@$(MAKE_SELF) setup-pjdfstest || echo "$(YELLOW)[WARNING] pjdfstest setup failed - continuing without it$(RESET)"
|
|
@$(MAKE_SELF) setup-nfstest || echo "$(YELLOW)[WARNING] nfstest setup failed - continuing without it$(RESET)"
|
|
@$(MAKE_SELF) setup-fio || echo "$(YELLOW)[WARNING] FIO setup failed - continuing without it$(RESET)"
|
|
|
|
# External tools setup
|
|
setup-pjdfstest:
|
|
@if [ ! -d "$(EXTERNAL_TOOLS_DIR)/pjdfstest" ]; then \
|
|
echo "$(BLUE)[SETUP] Setting up pjdfstest...$(RESET)"; \
|
|
if ! command -v autoreconf >/dev/null 2>&1; then \
|
|
echo "$(YELLOW)[WARNING] autoreconf not found - installing build-essential...$(RESET)"; \
|
|
if command -v apt-get >/dev/null 2>&1; then \
|
|
sudo apt-get update && sudo apt-get install -y build-essential autoconf automake libtool; \
|
|
elif command -v yum >/dev/null 2>&1; then \
|
|
sudo yum install -y gcc make autoconf automake libtool; \
|
|
else \
|
|
echo "$(YELLOW)[WARNING] Please install build tools manually$(RESET)"; \
|
|
exit 1; \
|
|
fi; \
|
|
fi; \
|
|
cd $(EXTERNAL_TOOLS_DIR) && \
|
|
git clone https://github.com/pjd/pjdfstest.git && \
|
|
cd pjdfstest && \
|
|
autoreconf -ifs && \
|
|
./configure && \
|
|
make; \
|
|
else \
|
|
echo "$(GREEN)[OK] pjdfstest already setup$(RESET)"; \
|
|
fi
|
|
|
|
setup-nfstest:
|
|
@echo "$(BLUE)[INSTALL] Installing nfstest...$(RESET)"
|
|
@pip3 install --user nfstest || \
|
|
echo "$(YELLOW)[WARNING] nfstest installation failed. Install manually: pip3 install nfstest$(RESET)"
|
|
|
|
setup-fio:
|
|
@if ! command -v fio >/dev/null 2>&1; then \
|
|
echo "$(BLUE)[SETUP] Installing FIO...$(RESET)"; \
|
|
if command -v apt-get >/dev/null 2>&1; then \
|
|
sudo apt-get update && sudo apt-get install -y fio; \
|
|
elif command -v yum >/dev/null 2>&1; then \
|
|
sudo yum install -y fio; \
|
|
elif command -v brew >/dev/null 2>&1; then \
|
|
brew install fio; \
|
|
else \
|
|
echo "$(YELLOW)[WARNING] Please install FIO manually$(RESET)"; \
|
|
fi; \
|
|
else \
|
|
echo "$(GREEN)[OK] FIO already installed$(RESET)"; \
|
|
fi
|
|
|
|
# Core test execution
|
|
test-posix-basic: check-prereqs setup-reports
|
|
@echo "$(CYAN)[TEST] Running basic POSIX compliance tests...$(RESET)"
|
|
ifneq ($(TEST_MOUNT_POINT),)
|
|
@echo "$(BLUE)Using external mount point: $(TEST_MOUNT_POINT)$(RESET)"
|
|
endif
|
|
@$(GO_TEST_PREFIX) go test -v -timeout $(TEST_TIMEOUT) -failfast=false -run TestPOSIXCompliance . 2>&1 | \
|
|
tee $(REPORT_DIR)/posix_basic_results.log
|
|
|
|
test-posix-extended: check-prereqs setup-reports
|
|
@echo "$(CYAN)[TEST] Running extended POSIX compliance tests...$(RESET)"
|
|
ifneq ($(TEST_MOUNT_POINT),)
|
|
@echo "$(BLUE)Using external mount point: $(TEST_MOUNT_POINT)$(RESET)"
|
|
endif
|
|
@$(GO_TEST_PREFIX) go test -v -timeout $(TEST_TIMEOUT) -failfast=false -run TestPOSIXExtended . 2>&1 | \
|
|
tee $(REPORT_DIR)/posix_extended_results.log
|
|
|
|
test-posix-external: check-prereqs setup-reports
|
|
@echo "$(CYAN)[TEST] Running external POSIX test suite integration...$(RESET)"
|
|
ifneq ($(TEST_MOUNT_POINT),)
|
|
@echo "$(BLUE)Using external mount point: $(TEST_MOUNT_POINT)$(RESET)"
|
|
endif
|
|
@if [ -d "$(EXTERNAL_TOOLS_DIR)/pjdfstest" ] || command -v nfstest_posix >/dev/null 2>&1; then \
|
|
echo "$(GREEN)[OK] External tools available - running external tests$(RESET)"; \
|
|
$(GO_TEST_PREFIX) go test -v -timeout $(TEST_TIMEOUT) -failfast=false -run TestExternalPOSIXSuites . 2>&1 | \
|
|
tee $(REPORT_DIR)/posix_external_results.log; \
|
|
else \
|
|
echo "$(YELLOW)[WARNING] External tools not available - skipping external tests$(RESET)"; \
|
|
echo "External tests skipped - tools not available" > $(REPORT_DIR)/posix_external_results.log; \
|
|
fi
|
|
|
|
# Comprehensive test suites
|
|
test-posix-full: test-posix-basic test-posix-extended test-posix-external
|
|
@echo "$(GREEN)[OK] Full POSIX compliance test suite completed$(RESET)"
|
|
@$(MAKE_SELF) generate-report
|
|
|
|
test-posix-critical: check-prereqs setup-reports
|
|
@echo "$(CYAN)[TEST] Running critical POSIX compliance tests...$(RESET)"
|
|
ifneq ($(TEST_MOUNT_POINT),)
|
|
@echo "$(BLUE)Using external mount point: $(TEST_MOUNT_POINT)$(RESET)"
|
|
endif
|
|
@$(GO_TEST_PREFIX) go test -v -timeout 15m -failfast=false \
|
|
-run "TestPOSIXCompliance/(FileOperations|DirectoryOperations|PermissionTests|IOOperations)" \
|
|
. 2>&1 | tee $(REPORT_DIR)/posix_critical_results.log
|
|
|
|
test-posix-stress: check-prereqs setup-reports
|
|
@echo "$(CYAN)[TEST] Running POSIX stress tests...$(RESET)"
|
|
ifneq ($(TEST_MOUNT_POINT),)
|
|
@echo "$(BLUE)Using external mount point: $(TEST_MOUNT_POINT)$(RESET)"
|
|
endif
|
|
@if [ -d "$(EXTERNAL_TOOLS_DIR)/pjdfstest" ] || command -v nfstest_posix >/dev/null 2>&1; then \
|
|
echo "$(GREEN)[OK] External tools available - running stress tests$(RESET)"; \
|
|
$(GO_TEST_PREFIX) go test -v -timeout $(TEST_TIMEOUT) -failfast=false \
|
|
-run "TestExternalPOSIXSuites/CustomPOSIXTests" \
|
|
. 2>&1 | tee $(REPORT_DIR)/posix_stress_results.log; \
|
|
else \
|
|
echo "$(YELLOW)[WARNING] External tools not available - skipping stress tests$(RESET)"; \
|
|
echo "Stress tests skipped - tools not available" > $(REPORT_DIR)/posix_stress_results.log; \
|
|
fi
|
|
|
|
# Performance and benchmarks
|
|
benchmark-posix: check-prereqs setup-reports
|
|
@echo "$(CYAN)📈 Running POSIX performance benchmarks...$(RESET)"
|
|
ifneq ($(TEST_MOUNT_POINT),)
|
|
@echo "$(BLUE)Using external mount point: $(TEST_MOUNT_POINT)$(RESET)"
|
|
endif
|
|
@$(GO_TEST_PREFIX) go test -v -timeout $(TEST_TIMEOUT) -run '^$$' -bench=. -benchmem \
|
|
. 2>&1 | \
|
|
tee $(REPORT_DIR)/posix_benchmark_results.log
|
|
|
|
profile-posix: check-prereqs setup-reports
|
|
@echo "$(CYAN)[PROFILE] Running POSIX tests with profiling...$(RESET)"
|
|
ifneq ($(TEST_MOUNT_POINT),)
|
|
@echo "$(BLUE)Using external mount point: $(TEST_MOUNT_POINT)$(RESET)"
|
|
endif
|
|
@$(GO_TEST_PREFIX) go test -v -timeout $(TEST_TIMEOUT) -cpuprofile $(REPORT_DIR)/posix.cpu.prof \
|
|
-memprofile $(REPORT_DIR)/posix.mem.prof -run TestPOSIXCompliance .
|
|
@echo "$(GREEN)[PROFILE] Profiles generated:$(RESET)"
|
|
@echo " CPU: $(REPORT_DIR)/posix.cpu.prof"
|
|
@echo " Memory: $(REPORT_DIR)/posix.mem.prof"
|
|
@echo "$(BLUE)View with: go tool pprof $(REPORT_DIR)/posix.cpu.prof$(RESET)"
|
|
|
|
# Coverage analysis
|
|
coverage-posix: check-prereqs setup-reports
|
|
@echo "$(CYAN)[COVERAGE] Running POSIX tests with coverage analysis...$(RESET)"
|
|
ifneq ($(TEST_MOUNT_POINT),)
|
|
@echo "$(BLUE)Using external mount point: $(TEST_MOUNT_POINT)$(RESET)"
|
|
endif
|
|
@$(GO_TEST_PREFIX) go test -v -timeout $(TEST_TIMEOUT) -coverprofile=$(REPORT_DIR)/$(COVERAGE_FILE) \
|
|
.
|
|
@go tool cover -html=$(REPORT_DIR)/$(COVERAGE_FILE) -o $(REPORT_DIR)/posix_coverage.html
|
|
@echo "$(GREEN)[COVERAGE] Coverage report generated: $(REPORT_DIR)/posix_coverage.html$(RESET)"
|
|
|
|
# The external suites exercise whatever filesystem MOUNT_POINT resolves to;
|
|
# mkdir -p would happily point them at a plain local directory and report a
|
|
# pass the mount never earned.
|
|
require-mounted:
|
|
@mnt="$(MOUNT_POINT)"; mnt="$${mnt%/}"; \
|
|
if ! mountpoint -q "$$mnt" 2>/dev/null && ! mount | grep -qF " $$mnt "; then \
|
|
echo "$(RED)❌ $$mnt is not a mounted filesystem - refusing to run against the local disk$(RESET)"; \
|
|
exit 1; \
|
|
fi
|
|
|
|
# External tool tests
|
|
test-pjdfstest: setup-pjdfstest setup-reports require-mounted
|
|
@echo "$(CYAN)[TEST] Running pjdfstest suite...$(RESET)"
|
|
@if [ -d "$(EXTERNAL_TOOLS_DIR)/pjdfstest" ]; then \
|
|
mkdir -p $(MOUNT_POINT)/pjdfstest_workdir; \
|
|
cd $(MOUNT_POINT)/pjdfstest_workdir && \
|
|
prove -r $(CURDIR)/$(EXTERNAL_TOOLS_DIR)/pjdfstest/tests/ 2>&1 | tee $(CURDIR)/$(REPORT_DIR)/pjdfstest_results.log; \
|
|
else \
|
|
echo "$(RED)❌ pjdfstest not setup$(RESET)"; \
|
|
exit 1; \
|
|
fi
|
|
|
|
test-nfstest-posix: setup-nfstest setup-reports require-mounted
|
|
@echo "$(CYAN)[TEST] Running nfstest_posix...$(RESET)"
|
|
@if command -v nfstest_posix >/dev/null 2>&1; then \
|
|
mkdir -p $(MOUNT_POINT); \
|
|
nfstest_posix --path $(MOUNT_POINT) --verbose 2>&1 | \
|
|
tee $(REPORT_DIR)/nfstest_results.log; \
|
|
else \
|
|
echo "$(YELLOW)[WARNING] nfstest_posix not available$(RESET)"; \
|
|
fi
|
|
|
|
# FIO-based performance tests
|
|
test-fio-posix: setup-reports require-mounted
|
|
@echo "$(CYAN)[TEST] Running FIO-based POSIX I/O tests...$(RESET)"
|
|
@$(MAKE_SELF) create-fio-configs
|
|
@if command -v fio >/dev/null 2>&1; then \
|
|
mkdir -p $(MOUNT_POINT); \
|
|
for config in $(REPORT_DIR)/fio_*.conf; do \
|
|
echo "$(BLUE)Running FIO config: $$config$(RESET)"; \
|
|
fio $$config --output=$(REPORT_DIR)/$$(basename $$config .conf)_results.log; \
|
|
done; \
|
|
else \
|
|
echo "$(YELLOW)[WARNING] FIO not available$(RESET)"; \
|
|
fi
|
|
|
|
create-fio-configs: setup-reports
|
|
@echo "$(BLUE)[CONFIG] Creating FIO test configurations...$(RESET)"
|
|
@echo "[global]" > $(REPORT_DIR)/fio_random_rw.conf
|
|
@echo "name=posix_random_rw" >> $(REPORT_DIR)/fio_random_rw.conf
|
|
@echo "ioengine=sync" >> $(REPORT_DIR)/fio_random_rw.conf
|
|
@echo "iodepth=1" >> $(REPORT_DIR)/fio_random_rw.conf
|
|
@echo "rw=randrw" >> $(REPORT_DIR)/fio_random_rw.conf
|
|
@echo "bs=4k" >> $(REPORT_DIR)/fio_random_rw.conf
|
|
@echo "direct=0" >> $(REPORT_DIR)/fio_random_rw.conf
|
|
@echo "size=100m" >> $(REPORT_DIR)/fio_random_rw.conf
|
|
@echo "numjobs=4" >> $(REPORT_DIR)/fio_random_rw.conf
|
|
@echo "runtime=30" >> $(REPORT_DIR)/fio_random_rw.conf
|
|
@echo "time_based" >> $(REPORT_DIR)/fio_random_rw.conf
|
|
@echo "" >> $(REPORT_DIR)/fio_random_rw.conf
|
|
@echo "[random_rw_test]" >> $(REPORT_DIR)/fio_random_rw.conf
|
|
@echo "directory=$(MOUNT_POINT)" >> $(REPORT_DIR)/fio_random_rw.conf
|
|
@echo "[global]" > $(REPORT_DIR)/fio_sequential.conf
|
|
@echo "name=posix_sequential" >> $(REPORT_DIR)/fio_sequential.conf
|
|
@echo "ioengine=sync" >> $(REPORT_DIR)/fio_sequential.conf
|
|
@echo "iodepth=1" >> $(REPORT_DIR)/fio_sequential.conf
|
|
@echo "bs=1m" >> $(REPORT_DIR)/fio_sequential.conf
|
|
@echo "direct=0" >> $(REPORT_DIR)/fio_sequential.conf
|
|
@echo "size=500m" >> $(REPORT_DIR)/fio_sequential.conf
|
|
@echo "runtime=60" >> $(REPORT_DIR)/fio_sequential.conf
|
|
@echo "time_based" >> $(REPORT_DIR)/fio_sequential.conf
|
|
@echo "" >> $(REPORT_DIR)/fio_sequential.conf
|
|
@echo "[seq_write]" >> $(REPORT_DIR)/fio_sequential.conf
|
|
@echo "rw=write" >> $(REPORT_DIR)/fio_sequential.conf
|
|
@echo "directory=$(MOUNT_POINT)" >> $(REPORT_DIR)/fio_sequential.conf
|
|
@echo "" >> $(REPORT_DIR)/fio_sequential.conf
|
|
@echo "[seq_read]" >> $(REPORT_DIR)/fio_sequential.conf
|
|
@echo "rw=read" >> $(REPORT_DIR)/fio_sequential.conf
|
|
@echo "directory=$(MOUNT_POINT)" >> $(REPORT_DIR)/fio_sequential.conf
|
|
|
|
# Reporting and analysis
|
|
generate-report: setup-reports
|
|
@echo "$(BLUE)[REPORT] Generating comprehensive POSIX compliance report...$(RESET)"
|
|
@$(MAKE_SELF) generate-html-report
|
|
@$(MAKE_SELF) generate-text-report
|
|
@$(MAKE_SELF) generate-json-report
|
|
|
|
generate-html-report:
|
|
@echo "$(BLUE)[REPORT] Generating HTML report...$(RESET)"
|
|
@echo "<!DOCTYPE html>" > $(REPORT_DIR)/posix_compliance_report.html
|
|
@echo "<html><head><title>SeaweedFS POSIX Compliance Report</title>" >> $(REPORT_DIR)/posix_compliance_report.html
|
|
@echo "<style>body{font-family:Arial;margin:20px}.pass{color:green}.fail{color:red}.summary{background:#f5f5f5;padding:10px;margin:10px 0}.test-section{margin:20px 0;border-left:3px solid #ddd;padding-left:15px}</style>" >> $(REPORT_DIR)/posix_compliance_report.html
|
|
@echo "</head><body><h1>SeaweedFS POSIX Compliance Report</h1>" >> $(REPORT_DIR)/posix_compliance_report.html
|
|
@echo "<p>Generated on: $$(date)</p>" >> $(REPORT_DIR)/posix_compliance_report.html
|
|
@echo "<div class='summary'>" >> $(REPORT_DIR)/posix_compliance_report.html
|
|
@echo "<h2>Test Summary</h2>" >> $(REPORT_DIR)/posix_compliance_report.html
|
|
@if [ -f "$(REPORT_DIR)/posix_basic_results.log" ]; then \
|
|
TOTAL=$$(awk '/RUN|PASS|FAIL/{c++} END{print c+0}' $(REPORT_DIR)/posix_basic_results.log 2>/dev/null || echo 0); \
|
|
PASSED=$$(awk '/PASS:/{c++} END{print c+0}' $(REPORT_DIR)/posix_basic_results.log 2>/dev/null || echo 0); \
|
|
FAILED=$$(awk '/FAIL:/{c++} END{print c+0}' $(REPORT_DIR)/posix_basic_results.log 2>/dev/null || echo 0); \
|
|
echo "<p>Basic Tests: <span class='pass'>$$PASSED passed</span>, <span class='fail'>$$FAILED failed</span></p>" >> $(REPORT_DIR)/posix_compliance_report.html; \
|
|
fi
|
|
@if [ -f "$(REPORT_DIR)/posix_critical_results.log" ]; then \
|
|
TOTAL=$$(awk '/RUN|PASS|FAIL/{c++} END{print c+0}' $(REPORT_DIR)/posix_critical_results.log 2>/dev/null || echo 0); \
|
|
PASSED=$$(awk '/PASS:/{c++} END{print c+0}' $(REPORT_DIR)/posix_critical_results.log 2>/dev/null || echo 0); \
|
|
FAILED=$$(awk '/FAIL:/{c++} END{print c+0}' $(REPORT_DIR)/posix_critical_results.log 2>/dev/null || echo 0); \
|
|
echo "<p>Critical Tests: <span class='pass'>$$PASSED passed</span>, <span class='fail'>$$FAILED failed</span></p>" >> $(REPORT_DIR)/posix_compliance_report.html; \
|
|
fi
|
|
@echo "</div>" >> $(REPORT_DIR)/posix_compliance_report.html
|
|
@echo "<h2>Detailed Results</h2>" >> $(REPORT_DIR)/posix_compliance_report.html
|
|
@for logfile in $(REPORT_DIR)/*.log; do \
|
|
if [ -f "$$logfile" ]; then \
|
|
basename=$$(basename "$$logfile" .log); \
|
|
echo "<div class='test-section'>" >> $(REPORT_DIR)/posix_compliance_report.html; \
|
|
echo "<h3>$$basename</h3>" >> $(REPORT_DIR)/posix_compliance_report.html; \
|
|
echo "<pre>" >> $(REPORT_DIR)/posix_compliance_report.html; \
|
|
tail -50 "$$logfile" | sed 's/&/\&/g; s/</\</g; s/>/\>/g' >> $(REPORT_DIR)/posix_compliance_report.html; \
|
|
echo "</pre></div>" >> $(REPORT_DIR)/posix_compliance_report.html; \
|
|
fi; \
|
|
done
|
|
@echo "</body></html>" >> $(REPORT_DIR)/posix_compliance_report.html
|
|
@echo "$(GREEN)[OK] HTML report generated: $(REPORT_DIR)/posix_compliance_report.html$(RESET)"
|
|
|
|
generate-text-report:
|
|
@echo "$(BLUE)[REPORT] Generating text report...$(RESET)"
|
|
@echo "SeaweedFS POSIX Compliance Report" > $(REPORT_DIR)/posix_compliance_summary.txt
|
|
@echo "=================================" >> $(REPORT_DIR)/posix_compliance_summary.txt
|
|
@echo "" >> $(REPORT_DIR)/posix_compliance_summary.txt
|
|
@echo "Generated: $$(date)" >> $(REPORT_DIR)/posix_compliance_summary.txt
|
|
@echo "SeaweedFS Version: $$($(WEED_BINARY) version 2>/dev/null || echo 'Unknown')" >> $(REPORT_DIR)/posix_compliance_summary.txt
|
|
@echo "" >> $(REPORT_DIR)/posix_compliance_summary.txt
|
|
@echo "Test Summary: See individual log files for detailed results" >> $(REPORT_DIR)/posix_compliance_summary.txt
|
|
@echo "$(GREEN)[OK] Text report generated: $(REPORT_DIR)/posix_compliance_summary.txt$(RESET)"
|
|
|
|
generate-json-report:
|
|
@echo "$(BLUE)[REPORT] Generating JSON report...$(RESET)"
|
|
@echo "{" > $(REPORT_DIR)/posix_compliance_report.json
|
|
@echo " \"report_type\": \"posix_compliance\"," >> $(REPORT_DIR)/posix_compliance_report.json
|
|
@echo " \"timestamp\": \"$$(date -u +"%Y-%m-%dT%H:%M:%SZ")\"," >> $(REPORT_DIR)/posix_compliance_report.json
|
|
@echo " \"seaweedfs_version\": \"$$($(WEED_BINARY) version 2>/dev/null | head -n1 | sed 's/\\/\\\\/g; s/\"/\\\"/g' || echo 'Unknown')\"," >> $(REPORT_DIR)/posix_compliance_report.json
|
|
@echo " \"test_environment\": { \"os\": \"$$(uname -s)\", \"arch\": \"$$(uname -m)\" }," >> $(REPORT_DIR)/posix_compliance_report.json
|
|
@echo " \"test_suites\": {" >> $(REPORT_DIR)/posix_compliance_report.json
|
|
@FIRST=true; \
|
|
for logfile in $(REPORT_DIR)/*.log; do \
|
|
if [ -f "$$logfile" ]; then \
|
|
basename=$$(basename "$$logfile" .log); \
|
|
if [ "$$FIRST" = "true" ]; then \
|
|
FIRST=false; \
|
|
else \
|
|
echo " ," >> $(REPORT_DIR)/posix_compliance_report.json; \
|
|
fi; \
|
|
PASSED=$$(awk '/PASS:/{c++} END{print c+0}' "$$logfile" 2>/dev/null || echo 0); \
|
|
FAILED=$$(awk '/FAIL:/{c++} END{print c+0}' "$$logfile" 2>/dev/null || echo 0); \
|
|
TOTAL=$$(expr "$$PASSED" + "$$FAILED" 2>/dev/null || echo 0); \
|
|
echo " \"$$basename\": {" >> $(REPORT_DIR)/posix_compliance_report.json; \
|
|
echo " \"total_tests\": $$TOTAL," >> $(REPORT_DIR)/posix_compliance_report.json; \
|
|
echo " \"passed\": $$PASSED," >> $(REPORT_DIR)/posix_compliance_report.json; \
|
|
echo " \"failed\": $$FAILED," >> $(REPORT_DIR)/posix_compliance_report.json; \
|
|
if [ "$$TOTAL" -gt 0 ] 2>/dev/null; then \
|
|
SUCCESS_RATE=$$(awk "BEGIN {printf \"%.2f\", ($$PASSED/$$TOTAL)*100}" 2>/dev/null || echo "0.00"); \
|
|
else \
|
|
SUCCESS_RATE="0.00"; \
|
|
fi; \
|
|
echo " \"success_rate\": \"$$SUCCESS_RATE%\"" >> $(REPORT_DIR)/posix_compliance_report.json; \
|
|
echo " }" >> $(REPORT_DIR)/posix_compliance_report.json; \
|
|
fi; \
|
|
done
|
|
@echo " }," >> $(REPORT_DIR)/posix_compliance_report.json
|
|
@TOTAL_PASSED=0; TOTAL_FAILED=0; \
|
|
for logfile in $(REPORT_DIR)/*.log; do \
|
|
if [ -f "$$logfile" ]; then \
|
|
PASSED=$$(awk '/PASS:/{c++} END{print c+0}' "$$logfile" 2>/dev/null || echo 0); \
|
|
FAILED=$$(awk '/FAIL:/{c++} END{print c+0}' "$$logfile" 2>/dev/null || echo 0); \
|
|
TOTAL_PASSED=$$(expr "$$TOTAL_PASSED" + "$$PASSED" 2>/dev/null || echo "$$TOTAL_PASSED"); \
|
|
TOTAL_FAILED=$$(expr "$$TOTAL_FAILED" + "$$FAILED" 2>/dev/null || echo "$$TOTAL_FAILED"); \
|
|
fi; \
|
|
done; \
|
|
GRAND_TOTAL=$$(expr "$$TOTAL_PASSED" + "$$TOTAL_FAILED" 2>/dev/null || echo 0); \
|
|
if [ "$$GRAND_TOTAL" -gt 0 ] 2>/dev/null; then \
|
|
OVERALL_SUCCESS=$$(awk "BEGIN {printf \"%.2f\", ($$TOTAL_PASSED/$$GRAND_TOTAL)*100}" 2>/dev/null || echo "0.00"); \
|
|
else \
|
|
OVERALL_SUCCESS="0.00"; \
|
|
fi; \
|
|
echo " \"summary\": {" >> $(REPORT_DIR)/posix_compliance_report.json; \
|
|
echo " \"total_tests\": $$GRAND_TOTAL," >> $(REPORT_DIR)/posix_compliance_report.json; \
|
|
echo " \"total_passed\": $$TOTAL_PASSED," >> $(REPORT_DIR)/posix_compliance_report.json; \
|
|
echo " \"total_failed\": $$TOTAL_FAILED," >> $(REPORT_DIR)/posix_compliance_report.json; \
|
|
echo " \"overall_success_rate\": \"$$OVERALL_SUCCESS%\"" >> $(REPORT_DIR)/posix_compliance_report.json; \
|
|
echo " }" >> $(REPORT_DIR)/posix_compliance_report.json
|
|
@echo "}" >> $(REPORT_DIR)/posix_compliance_report.json
|
|
@echo "$(GREEN)[OK] JSON report generated: $(REPORT_DIR)/posix_compliance_report.json$(RESET)"
|
|
|
|
# Cleanup and maintenance
|
|
clean:
|
|
@echo "$(YELLOW)🧹 Cleaning up test artifacts...$(RESET)"
|
|
@rm -rf $(REPORT_DIR)
|
|
@rm -rf /tmp/seaweedfs_*_test_*
|
|
@go clean -testcache
|
|
@echo "$(GREEN)[OK] Cleanup complete$(RESET)"
|
|
|
|
clean-external-tools:
|
|
@echo "$(YELLOW)🧹 Cleaning up external tools...$(RESET)"
|
|
@rm -rf $(EXTERNAL_TOOLS_DIR)
|
|
|
|
clean-all: clean clean-external-tools
|
|
|
|
# Development and debugging
|
|
validate:
|
|
@echo "$(BLUE)[OK] Validating test files...$(RESET)"
|
|
@go build -o /dev/null ./...
|
|
@echo "$(GREEN)[OK] All test files compile successfully$(RESET)"
|
|
|
|
fmt:
|
|
@echo "$(BLUE)🎨 Formatting Go code...$(RESET)"
|
|
@go fmt ./...
|
|
|
|
lint:
|
|
@echo "$(BLUE)🔍 Running linter...$(RESET)"
|
|
@if command -v golangci-lint >/dev/null 2>&1; then \
|
|
golangci-lint run; \
|
|
else \
|
|
echo "$(YELLOW)[WARNING] golangci-lint not found, running go vet instead$(RESET)"; \
|
|
go vet ./...; \
|
|
fi
|
|
|
|
# CI/CD integration
|
|
ci-posix-tests: check-prereqs setup-external-tools
|
|
@echo "$(CYAN)🚀 Running POSIX tests for CI/CD...$(RESET)"
|
|
@$(MAKE_SELF) test-posix-critical
|
|
@$(MAKE_SELF) generate-report
|
|
|
|
|
|
|
|
# Documentation and help
|
|
list-tests:
|
|
@echo "$(BLUE)📋 Available POSIX test functions:$(RESET)"
|
|
@grep -r "^func Test" *.go 2>/dev/null | sed 's/.*func \(Test[^(]*\).*/ \1/' | sort || echo "No test files found"
|
|
|
|
test-info:
|
|
@echo "$(BLUE)[INFO] POSIX Test Information:$(RESET)"
|
|
@echo "Test files:"
|
|
@echo " - $(POSIX_BASIC_TESTS): Core POSIX compliance tests"
|
|
@echo " - $(POSIX_EXTENDED_TESTS): Extended POSIX feature tests"
|
|
@echo " - $(POSIX_EXTERNAL_TESTS): External test suite integration"
|
|
@echo ""
|
|
@echo "External tools:"
|
|
@echo " - pjdfstest: Comprehensive POSIX filesystem test suite"
|
|
@echo " - nfstest: Network filesystem POSIX API verification"
|
|
@echo " - FIO: Flexible I/O performance testing"
|
|
|
|
help:
|
|
@echo "$(CYAN)SeaweedFS POSIX Compliance Testing$(RESET)"
|
|
@echo "=================================="
|
|
@echo ""
|
|
@echo "$(WHITE)Prerequisites:$(RESET)"
|
|
@echo " $(GREEN)make check-prereqs$(RESET) - Check all prerequisites"
|
|
@echo " $(GREEN)make setup-external-tools$(RESET) - Setup external POSIX test tools"
|
|
@echo ""
|
|
@echo "$(WHITE)Core POSIX Tests:$(RESET)"
|
|
@echo " $(GREEN)make test-posix-basic$(RESET) - Run basic POSIX compliance tests"
|
|
@echo " $(GREEN)make test-posix-extended$(RESET) - Run extended POSIX feature tests"
|
|
@echo " $(GREEN)make test-posix-external$(RESET) - Run external test suite integration"
|
|
@echo " $(GREEN)make test-posix-full$(RESET) - Run complete POSIX test suite"
|
|
@echo ""
|
|
@echo "$(WHITE)Focused Tests:$(RESET)"
|
|
@echo " $(GREEN)make test-posix-critical$(RESET) - Run critical POSIX compliance tests"
|
|
@echo " $(GREEN)make test-posix-stress$(RESET) - Run POSIX stress tests"
|
|
@echo ""
|
|
@echo "$(WHITE)Performance & Analysis:$(RESET)"
|
|
@echo " $(GREEN)make benchmark-posix$(RESET) - Run POSIX performance benchmarks"
|
|
@echo " $(GREEN)make profile-posix$(RESET) - Run tests with performance profiling"
|
|
@echo " $(GREEN)make coverage-posix$(RESET) - Run tests with coverage analysis"
|
|
@echo " $(GREEN)make test-fio-posix$(RESET) - Run FIO-based I/O performance tests"
|
|
@echo ""
|
|
@echo "$(WHITE)External Test Suites:$(RESET)"
|
|
@echo " $(GREEN)make test-pjdfstest$(RESET) - Run pjdfstest suite"
|
|
@echo " $(GREEN)make test-nfstest-posix$(RESET) - Run nfstest_posix"
|
|
@echo ""
|
|
@echo "$(WHITE)Reporting:$(RESET)"
|
|
@echo " $(GREEN)make generate-report$(RESET) - Generate comprehensive compliance report"
|
|
@echo ""
|
|
@echo "$(WHITE)Development:$(RESET)"
|
|
@echo " $(GREEN)make validate$(RESET) - Validate test file compilation"
|
|
@echo " $(GREEN)make fmt$(RESET) - Format Go code"
|
|
@echo " $(GREEN)make lint$(RESET) - Run linter"
|
|
@echo " $(GREEN)make list-tests$(RESET) - List available test functions"
|
|
@echo ""
|
|
@echo "$(WHITE)Maintenance:$(RESET)"
|
|
@echo " $(GREEN)make clean$(RESET) - Clean up test artifacts"
|
|
@echo " $(GREEN)make clean-all$(RESET) - Clean everything including external tools"
|
|
@echo ""
|
|
@echo "$(WHITE)CI/CD Integration:$(RESET)"
|
|
@echo " $(GREEN)make ci-posix-tests$(RESET) - Run POSIX tests optimized for CI/CD"
|
|
|
|
|
|
.PHONY: help check-prereqs check-binary check-fuse check-go setup-reports \
|
|
setup-external-tools setup-pjdfstest setup-nfstest setup-fio \
|
|
test-posix-basic test-posix-extended test-posix-external test-posix-full \
|
|
test-posix-critical test-posix-stress benchmark-posix profile-posix coverage-posix \
|
|
test-pjdfstest test-nfstest-posix test-fio-posix create-fio-configs \
|
|
generate-report generate-html-report generate-text-report generate-json-report \
|
|
clean clean-external-tools clean-all validate fmt lint ci-posix-tests \
|
|
list-tests test-info
|