Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/code-checker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
run: |
PR=${{ github.event.pull_request.number }}
SELF="Lint"
REQUIRED_CHECKS=("Lint" "Go Mod Tidy Check" "Unit Test" "E2E Local" "E2E Object Storage" "E2E Service" "Component Integration Test" "Chaos Test")
REQUIRED_CHECKS=("Lint" "Go Mod Tidy Check" "Unit Test" "E2E Local" "E2E Object Storage" "E2E Service" "Component Integration Test" "Chaos Test" "Operator Test")
CHECKS=$(gh pr checks $PR --json name,bucket 2>/dev/null || echo "[]")
ALL_PASSED=true
for check in "${REQUIRED_CHECKS[@]}"; do
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
run: |
PR=${{ github.event.pull_request.number }}
SELF="Go Mod Tidy Check"
REQUIRED_CHECKS=("Lint" "Go Mod Tidy Check" "Unit Test" "E2E Local" "E2E Object Storage" "E2E Service" "Component Integration Test" "Chaos Test")
REQUIRED_CHECKS=("Lint" "Go Mod Tidy Check" "Unit Test" "E2E Local" "E2E Object Storage" "E2E Service" "Component Integration Test" "Chaos Test" "Operator Test")
CHECKS=$(gh pr checks $PR --json name,bucket 2>/dev/null || echo "[]")
ALL_PASSED=true
for check in "${REQUIRED_CHECKS[@]}"; do
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-test-chaos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
run: |
PR=${{ github.event.pull_request.number }}
SELF="${{ github.workflow }}"
REQUIRED_CHECKS=("Lint" "Go Mod Tidy Check" "Unit Test" "E2E Local" "E2E Object Storage" "E2E Service" "Component Integration Test" "Chaos Test")
REQUIRED_CHECKS=("Lint" "Go Mod Tidy Check" "Unit Test" "E2E Local" "E2E Object Storage" "E2E Service" "Component Integration Test" "Chaos Test" "Operator Test")
CHECKS=$(gh pr checks $PR --json name,bucket 2>/dev/null || echo "[]")
ALL_PASSED=true
for check in "${REQUIRED_CHECKS[@]}"; do
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-test-components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ jobs:
run: |
PR=${{ github.event.pull_request.number }}
SELF="${{ github.workflow }}"
REQUIRED_CHECKS=("Lint" "Go Mod Tidy Check" "Unit Test" "E2E Local" "E2E Object Storage" "E2E Service" "Component Integration Test" "Chaos Test")
REQUIRED_CHECKS=("Lint" "Go Mod Tidy Check" "Unit Test" "E2E Local" "E2E Object Storage" "E2E Service" "Component Integration Test" "Chaos Test" "Operator Test")
CHECKS=$(gh pr checks $PR --json name,bucket 2>/dev/null || echo "[]")
ALL_PASSED=true
for check in "${REQUIRED_CHECKS[@]}"; do
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-test-e2e-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
run: |
PR=${{ github.event.pull_request.number }}
SELF="${{ github.workflow }}"
REQUIRED_CHECKS=("Lint" "Go Mod Tidy Check" "Unit Test" "E2E Local" "E2E Object Storage" "E2E Service" "Component Integration Test" "Chaos Test")
REQUIRED_CHECKS=("Lint" "Go Mod Tidy Check" "Unit Test" "E2E Local" "E2E Object Storage" "E2E Service" "Component Integration Test" "Chaos Test" "Operator Test")
CHECKS=$(gh pr checks $PR --json name,bucket 2>/dev/null || echo "[]")
ALL_PASSED=true
for check in "${REQUIRED_CHECKS[@]}"; do
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-test-e2e-objectstorage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
run: |
PR=${{ github.event.pull_request.number }}
SELF="${{ github.workflow }}"
REQUIRED_CHECKS=("Lint" "Go Mod Tidy Check" "Unit Test" "E2E Local" "E2E Object Storage" "E2E Service" "Component Integration Test" "Chaos Test")
REQUIRED_CHECKS=("Lint" "Go Mod Tidy Check" "Unit Test" "E2E Local" "E2E Object Storage" "E2E Service" "Component Integration Test" "Chaos Test" "Operator Test")
CHECKS=$(gh pr checks $PR --json name,bucket 2>/dev/null || echo "[]")
ALL_PASSED=true
for check in "${REQUIRED_CHECKS[@]}"; do
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-test-e2e-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:
run: |
PR=${{ github.event.pull_request.number }}
SELF="${{ github.workflow }}"
REQUIRED_CHECKS=("Lint" "Go Mod Tidy Check" "Unit Test" "E2E Local" "E2E Object Storage" "E2E Service" "Component Integration Test" "Chaos Test")
REQUIRED_CHECKS=("Lint" "Go Mod Tidy Check" "Unit Test" "E2E Local" "E2E Object Storage" "E2E Service" "Component Integration Test" "Chaos Test" "Operator Test")
CHECKS=$(gh pr checks $PR --json name,bucket 2>/dev/null || echo "[]")
ALL_PASSED=true
for check in "${REQUIRED_CHECKS[@]}"; do
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/operator-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Operator Test

on:
workflow_dispatch:
push:
branches:
- master
- dev
paths:
- "deployments/operator/**"
- ".github/workflows/operator-test.yaml"
pull_request:
branches:
- master
- dev
paths:
- "deployments/operator/**"
- ".github/workflows/operator-test.yaml"

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
operator-test:
name: Operator Test
runs-on: ubuntu-latest
timeout-minutes: 30
defaults:
run:
working-directory: deployments/operator
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.25"
cache: true
cache-dependency-path: deployments/operator/go.sum

- name: Run linter
run: |
make lint

- name: Run tests
run: |
make test

- name: Build operator binary
run: |
make build

- name: Build Docker image
run: |
make docker-build IMG=woodpecker-operator:test

- name: Handle failure
if: failure() && github.event_name == 'pull_request'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR=${{ github.event.pull_request.number }}
gh pr comment $PR --body "❌ **Operator Test** failed. Comment \`/rerun-operator\` to rerun, or \`/rerun\` to rerun all failed checks."
3 changes: 2 additions & 1 deletion .github/workflows/rerun-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
WORKFLOW_MAP["/rerun-e2e-service"]="integration-test-e2e-service.yaml"
WORKFLOW_MAP["/rerun-component-test"]="integration-test-components.yaml"
WORKFLOW_MAP["/rerun-chaos"]="integration-test-chaos.yaml"
WORKFLOW_MAP["/rerun-operator"]="operator-test.yaml"

HEAD_SHA=$(gh pr view $PR --repo $REPO --json headRefOid -q '.headRefOid')

Expand Down Expand Up @@ -86,5 +87,5 @@ jobs:
gh pr comment $PR --repo $REPO --body "Rerunning **${CMD#/rerun-}** workflow. Check the [Actions tab](https://github.com/${REPO}/actions) for progress."

else
gh pr comment $PR --repo $REPO --body "Unknown command \`${CMD}\`. Available commands: \`/rerun\`, \`/rerun-lint\`, \`/rerun-mod-tidy\`, \`/rerun-unit-test\`, \`/rerun-e2e-local\`, \`/rerun-e2e-objectstorage\`, \`/rerun-e2e-service\`, \`/rerun-component-test\`, \`/rerun-chaos\`."
gh pr comment $PR --repo $REPO --body "Unknown command \`${CMD}\`. Available commands: \`/rerun\`, \`/rerun-lint\`, \`/rerun-mod-tidy\`, \`/rerun-unit-test\`, \`/rerun-e2e-local\`, \`/rerun-e2e-objectstorage\`, \`/rerun-e2e-service\`, \`/rerun-component-test\`, \`/rerun-chaos\`, \`/rerun-operator\`."
fi
4 changes: 2 additions & 2 deletions .github/workflows/unit-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Run unit tests
run: |
go test -race -short -cover -coverprofile=coverage.out -covermode=atomic -failfast -timeout=20m \
$(go list ./... | grep -v -E '(tests/integration|tests/benchmark|tests/stability|tests/docker)')
$(go list ./... | grep -v -E '(tests/)')

- name: Upload coverage to Codecov
if: success()
Expand All @@ -69,7 +69,7 @@ jobs:
run: |
PR=${{ github.event.pull_request.number }}
SELF="${{ github.workflow }}"
REQUIRED_CHECKS=("Lint" "Go Mod Tidy Check" "Unit Test" "E2E Local" "E2E Object Storage" "E2E Service" "Component Integration Test" "Chaos Test")
REQUIRED_CHECKS=("Lint" "Go Mod Tidy Check" "Unit Test" "E2E Local" "E2E Object Storage" "E2E Service" "Component Integration Test" "Chaos Test" "Operator Test")
CHECKS=$(gh pr checks $PR --json name,bucket 2>/dev/null || echo "[]")
ALL_PASSED=true
for check in "${REQUIRED_CHECKS[@]}"; do
Expand Down
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*.dll
*.so
*.dylib
bin/*
bin/
**/bin/

**/.idea/*
**/.vscode/*
Expand All @@ -28,3 +29,7 @@ go.work.sum

# env file
.env

# cmake build
**/cmake_build/*
**/external/output
45 changes: 41 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,12 @@ proto_clean:
rm -f */*.pb.go

.PHONY: build
build: ## Build binary for current platform
go build -v -o bin/woodpecker ./cmd
build:
@bash -c 'source $(PWD)/scripts/setenv.sh && go build -v -o bin/woodpecker ./cmd'

test: build ## Run all tests
go test -cover -race ./...
.PHONY: test
test:
@bash -c 'source $(PWD)/scripts/setenv.sh && go test -cover -race ./...'

.PHONY: lint
lint: ## Run golangci-lint
Expand Down Expand Up @@ -127,6 +128,8 @@ integration-test-components: ## Run component integration tests (non-e2e)

clean: ## Clean built binaries
rm -f $(BIN_DIR)/*
rm -rf $(PWD)/cmake_build
rm -rf $(PWD)/external/output

# Docker targets (using new build system)
docker: ## Build Docker image (auto-detect architecture)
Expand Down Expand Up @@ -166,3 +169,37 @@ cluster-status: ## Check cluster status

cluster-test: ## Test cluster connectivity
cd deployments && ./deploy.sh test

# ==================== CPP BUILD ========
INSTALL_PATH := $(PWD)/bin
LIBRARY_PATH := $(PWD)/lib
OS := $(shell uname -s)
mode = Release
use_asan = OFF
ifeq ($(USE_ASAN), ON)
use_asan = ${USE_ASAN}
CGO_LDFLAGS := $(shell go env CGO_LDFLAGS) -fno-stack-protector -fno-omit-frame-pointer -fno-var-tracking -fsanitize=address
CGO_CFLAGS := $(shell go env CGO_CFLAGS) -fno-stack-protector -fno-omit-frame-pointer -fno-var-tracking -fsanitize=address
MILVUS_GO_BUILD_TAGS := $(MILVUS_GO_BUILD_TAGS),use_asan
endif

use_opendal = OFF
ifdef USE_OPENDAL
use_opendal = ${USE_OPENDAL}
endif

# default git branch is dev
export GIT_BRANCH=dev

ifeq (${ENABLE_AZURE}, false)
AZURE_OPTION := -Z
endif


build-3rdparty:
@echo "Build thirdparty using conanfile.py ..."
@(env bash $(PWD)/scripts/3rdparty_build.sh -o ${use_opendal} -t ${mode})

build-external: build-3rdparty
@echo "Building Milvus external cpp library ..."
@(env bash $(PWD)/scripts/external_build.sh -t ${mode} -a ${use_asan} ${AZURE_OPTION} -o ${use_opendal} )
113 changes: 113 additions & 0 deletions common/conc/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package conc

import (
"sync/atomic"
"testing"
"time"

Expand Down Expand Up @@ -87,3 +88,115 @@ func TestPoolWithPanic(t *testing.T) {
_, err := future.Await()
assert.Error(t, err)
}

func TestPoolSubmitWithError(t *testing.T) {
pool := NewPool[int](2)
defer pool.Release()

future := pool.Submit(func() (int, error) {
return 0, assert.AnError
})

_, err := future.Await()
assert.ErrorIs(t, err, assert.AnError)
}

func TestPoolSubmitWithPreHandler(t *testing.T) {
var called atomic.Bool
pool := NewPool[int](2, WithPreHandler(func() {
called.Store(true)
}))
defer pool.Release()

future := pool.Submit(func() (int, error) {
return 42, nil
})

res, err := future.Await()
assert.NoError(t, err)
assert.Equal(t, 42, res)
assert.True(t, called.Load())
}

func TestPoolSubmitToReleasedPool(t *testing.T) {
pool := NewPool[int](2)
pool.Release()

future := pool.Submit(func() (int, error) {
return 0, nil
})

_, err := future.Await()
assert.Error(t, err)
}

func TestPoolStatusMethods(t *testing.T) {
pool := NewPool[int](4)
defer pool.Release()

assert.Equal(t, 4, pool.Cap())
assert.GreaterOrEqual(t, pool.Free(), 0)
assert.GreaterOrEqual(t, pool.Running(), 0)
assert.False(t, pool.IsClosed())

pool.Release()
assert.True(t, pool.IsClosed())
}

func TestPoolReleaseTimeout(t *testing.T) {
pool := NewPool[int](2)
err := pool.ReleaseTimeout(time.Second)
assert.NoError(t, err)
assert.True(t, pool.IsClosed())
}

func TestNewPoolInvalidCapPanics(t *testing.T) {
// ants.NewPool returns error when preAlloc=true with negative size
assert.Panics(t, func() {
NewPool[int](-1, WithPreAlloc(true))
})
}

func TestWarmupPool(t *testing.T) {
pool := NewPool[int](2)
defer pool.Release()

var count atomic.Int32
WarmupPool(pool, func() {
count.Add(1)
})
assert.Equal(t, int32(2), count.Load())
}

func TestPoolWithExpiryDuration(t *testing.T) {
pool := NewPool[int](2, WithExpiryDuration(time.Second))
defer pool.Release()

future := pool.Submit(func() (int, error) {
return 1, nil
})
res, err := future.Await()
assert.NoError(t, err)
assert.Equal(t, 1, res)
}

func TestPoolWithCustomPanicHandler(t *testing.T) {
var panicCaught atomic.Bool
pool := NewPool[int](1, WithConcealPanic(true), func(opt *poolOption) {
opt.panicHandler = func(v any) {
panicCaught.Store(true)
}
})
defer pool.Release()

future := pool.Submit(func() (int, error) {
panic("custom handler test")
})

_, _ = future.Await()
// The panic handler runs in the worker goroutine after future.ch is closed,
// so we need to poll until it completes.
assert.Eventually(t, func() bool {
return panicCaught.Load()
}, 5*time.Second, 10*time.Millisecond)
}
Loading
Loading