Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
85 changes: 78 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,26 @@ on:
pull_request:
branches: [main, master]

permissions:
contents: read

env:
GO_VERSION: "1.26"
GOLANGCI_LINT_VERSION: v2.15.0

jobs:
build-and-unit-test:
name: Build and Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
go-version: ${{ env.GO_VERSION }}
check-latest: true
cache: true

- name: Download dependencies
Expand All @@ -38,20 +46,83 @@ jobs:
fi

- name: Unit Tests
run: make test-unit
shell: bash
run: make test-unit 2>&1 | tee unit-test.log

- name: Coverage summary
run: |
{
echo "## Unit test coverage"
echo
echo "**Total: $(go tool cover -func=coverage.out | awk '/^total:/ {print $NF}')**"
echo
echo "| Package | Coverage |"
echo "| --- | --- |"
awk '$1 == "ok" && $4 == "coverage:" {print "| " $2 " | " $5 " |"}' unit-test.log
} >> "$GITHUB_STEP_SUMMARY"

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ env.GO_VERSION }}
check-latest: true
cache: true

- name: Check Go version matches go.mod
run: |
gomod=$(go list -m -f '{{.GoVersion}}' | cut -d. -f1,2)
if [ "$gomod" != "$GO_VERSION" ]; then
echo "::error file=go.mod::go.mod requires Go $gomod but CI uses Go $GO_VERSION. Update GO_VERSION in .github/workflows/ci.yml."
exit 1
fi

- name: golangci-lint
uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}

- name: Check go.mod and go.sum are tidy
run: |
go mod tidy
git diff --exit-code go.mod go.sum

govulncheck:
name: Vulnerability Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ env.GO_VERSION }}
check-latest: true
cache: true

- name: Run govulncheck
run: make vuln

integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
needs: build-and-unit-test
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
go-version: ${{ env.GO_VERSION }}
check-latest: true
cache: true

- name: Install FUSE
Expand Down
22 changes: 14 additions & 8 deletions .github/workflows/docker-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,24 @@ on:
# Allow manual trigger
workflow_dispatch:

permissions:
contents: read

jobs:
docker-multinode-tests:
name: Multi-Node Docker Tests
runs-on: ubuntu-latest
timeout-minutes: 15
timeout-minutes: 30
permissions:
contents: read
checks: write

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1

- name: Build test images
run: |
Expand Down Expand Up @@ -52,9 +58,9 @@ jobs:
docker compose -f tests/docker/docker-compose.test.yml up -d \
node1 node2 node3 node4 orchestrator

# Wait for orchestrator to complete (poll every 5s, timeout 10min)
# Wait for orchestrator to complete (poll every 5s, timeout 20min)
echo "Waiting for orchestrator to complete..."
TIMEOUT=600
TIMEOUT=1200
ELAPSED=0
while [ $ELAPSED -lt $TIMEOUT ]; do
# Check if orchestrator is still running
Expand Down Expand Up @@ -91,7 +97,7 @@ jobs:
docker logs goclusterfs-orchestrator 2>&1 >> tests/docker/results/container-logs.txt || true
docker compose -f tests/docker/docker-compose.test.yml down
exit 1
timeout-minutes: 12
timeout-minutes: 22

- name: Collect logs on failure
if: failure()
Expand All @@ -111,14 +117,14 @@ jobs:

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: docker-test-results
path: tests/docker/results/
retention-days: 7

- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
uses: mikepenz/action-junit-report@6ef3fdcfcd5f0b5d14df3e659ef19b8c6820f93d # v6.6.1
if: always()
with:
report_paths: 'tests/docker/results/junit.xml'
Expand Down
12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Build artifacts
goclusterfs
goclusterfs-mount
GoClusterFS
/goclusterfs
/goclusterfs-mount
/goclusterfs-fsck
/GoClusterFS
/coverage.out

# Test artifacts
*.img
Expand All @@ -20,9 +22,9 @@ Thumbs.db

# Go
vendor/
mount
/mount

# VM test runtime artifacts
tests/vm/runtime/
tests/vm/results/
fsck
/fsck
38 changes: 38 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: "2"

linters:
default: none
enable:
- govet
- ineffassign
- staticcheck
- unused
settings:
staticcheck:
checks:
- all
- -ST1000
- -ST1003
- -ST1016
- -ST1020
- -ST1021
- -ST1022
- -QF1008
exclusions:
# Known findings as of 2026-10-24 in code other open PRs are changing; delete each rule once fixed.
rules:
- path: ^main\.go$
linters: [staticcheck]
text: "SA1019: os\\.SEEK_"
- path: ^internal/goclusterfs/fs\.go$
linters: [unused]
text: "errRetryCreate|field sb is unused"
- path: ^internal/extent/extent_test\.go$
linters: [staticcheck]
text: "SA4006: this value of found is never used"
- path: ^internal/fsck/phase7_snapshots\.go$
linters: [staticcheck]
text: "SA9003"
- path: ^internal/dir/dir_test\.go$
linters: [staticcheck]
text: "SA1019: .*inode\\.Table\\)\\.Alloc is deprecated"
32 changes: 23 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# GoClusterFS Makefile
# Build and test automation for the distributed filesystem

.PHONY: build build-mount test test-unit test-integration test-all test-parity test-multinode-docker docker-build-test docker-clean-test test-multinode-vm vm-clean clean fmt vet check-fuse check-qemu lint help
.PHONY: build build-mount build-fsck test test-unit test-integration test-all test-parity test-multinode-docker docker-build-test docker-clean-test test-multinode-vm vm-clean clean fmt vet check-fuse check-qemu lint vuln help

# Go parameters
GOCMD=go
Expand All @@ -13,24 +13,34 @@ GOMOD=$(GOCMD) mod

# Binary names
MOUNT_BINARY=goclusterfs-mount
FSCK_BINARY=goclusterfs-fsck

GOLANGCI_LINT_VERSION=v2.15.0
GOVULNCHECK_VERSION=v1.9.0
COVER_PROFILE=coverage.out

# Default target
.DEFAULT_GOAL := help

# Build all binaries
build: build-mount
build: build-mount build-fsck

build-mount:
@echo "Building $(MOUNT_BINARY)..."
$(GOBUILD) -o $(MOUNT_BINARY) ./cmd/mount
@echo "Built $(MOUNT_BINARY) successfully"

build-fsck:
@echo "Building $(FSCK_BINARY)..."
$(GOBUILD) -o $(FSCK_BINARY) ./cmd/fsck
@echo "Built $(FSCK_BINARY) successfully"

# Unit tests (fast, no FUSE needed)
test: test-unit

test-unit:
@echo "Running unit tests..."
$(GOTEST) -v ./internal/...
@echo "Running unit tests with race detector..."
$(GOTEST) -v -race -covermode=atomic -coverprofile=$(COVER_PROFILE) ./internal/...

# Integration tests (requires FUSE and built binary)
test-integration: check-fuse build-mount
Expand Down Expand Up @@ -148,14 +158,16 @@ check-fuse:
@which fusermount > /dev/null 2>&1 || (echo "Error: fusermount not found. Install FUSE first." && exit 1)
@echo "FUSE is available"

# Run linter (if golangci-lint is installed)
lint:
@which golangci-lint > /dev/null 2>&1 && golangci-lint run ./... || echo "golangci-lint not installed, skipping"
$(GOCMD) run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run ./...

vuln:
$(GOCMD) run golang.org/x/vuln/cmd/govulncheck@$(GOVULNCHECK_VERSION) ./...

# Utilities
clean:
@echo "Cleaning build artifacts..."
rm -f $(MOUNT_BINARY) GoClusterFS
rm -f $(MOUNT_BINARY) $(FSCK_BINARY) $(COVER_PROFILE)
rm -f *.img
@echo "Clean complete"

Expand All @@ -181,10 +193,11 @@ help:
@echo " Build:"
@echo " build - Build all binaries"
@echo " build-mount - Build goclusterfs-mount binary"
@echo " build-fsck - Build goclusterfs-fsck binary"
@echo ""
@echo " Test:"
@echo " test - Run unit tests (alias for test-unit)"
@echo " test-unit - Run unit tests only (fast, no FUSE needed)"
@echo " test-unit - Run unit tests with race detector and coverage (no FUSE needed)"
@echo " test-integration - Run integration tests (requires FUSE)"
@echo " test-all - Run all tests (unit + integration)"
@echo " test-parity - Validate test coverage across environments"
Expand All @@ -207,7 +220,8 @@ help:
@echo " Code Quality:"
@echo " fmt - Format code with go fmt"
@echo " vet - Run go vet"
@echo " lint - Run golangci-lint (if installed)"
@echo " lint - Run golangci-lint $(GOLANGCI_LINT_VERSION) with .golangci.yml"
@echo " vuln - Run govulncheck $(GOVULNCHECK_VERSION)"
@echo ""
@echo " Utilities:"
@echo " clean - Remove build artifacts"
Expand Down
5 changes: 2 additions & 3 deletions internal/cache/broadcast/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,8 @@ func (b *Broadcaster) heartbeatLoop() {
return
case <-ticker.C:
msg := b.builder.Heartbeat()
if err := b.transport.Send(msg); err != nil {
// Heartbeat failures are expected during network issues
}
// Heartbeat failures are expected during network issues
_ = b.transport.Send(msg)
}
}
}
Expand Down
30 changes: 0 additions & 30 deletions internal/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package cache
import (
"testing"
"time"

"github.com/supporttools/GoClusterFS/internal/inode"
)

// TestLRU tests the generic LRU cache implementation.
Expand Down Expand Up @@ -273,34 +271,6 @@ func TestConfig(t *testing.T) {
})
}

// mockInodeTable implements a simple mock for testing cache operations.
type mockInodeTable struct {
inodes map[uint32]*inode.Inode
}

func newMockInodeTable() *mockInodeTable {
return &mockInodeTable{
inodes: make(map[uint32]*inode.Inode),
}
}

func (m *mockInodeTable) Read(inodeNum uint32) (*inode.Inode, error) {
ino, ok := m.inodes[inodeNum]
if !ok {
return &inode.Inode{}, nil // Return empty inode (Magic == 0)
}
return ino, nil
}

func (m *mockInodeTable) Write(ino *inode.Inode) error {
m.inodes[ino.InodeNum] = ino
return nil
}

func (m *mockInodeTable) setInode(ino *inode.Inode) {
m.inodes[ino.InodeNum] = ino
}

// Note: Full integration tests for Manager.GetInode require a real inode.Table
// which needs storage.Device. Those tests belong in integration tests.
// Here we test what we can in isolation.
Expand Down
Loading
Loading