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
3 changes: 3 additions & 0 deletions .changes/unreleased/Added-20260910-115216.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Added
body: E2E test on local machine for developers on a kind cluster supporting both linux and MacOS
time: 2026-09-10T11:52:16.94752+02:00
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
_artifacts
88 changes: 88 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: E2E

on:
pull_request:
push:
branches: [main]

permissions:
contents: read

env:
KIND_VERSION: v0.32.0
KUBERNETES_VERSION: v1.32.11
KIND_CLUSTER_NAME: udev-manager-e2e
ARTIFACT_ROOT: ${{ github.workspace }}/_artifacts/kind

jobs:
kind-e2e:
name: E2E - kind cluster
runs-on: ubuntu-latest
timeout-minutes: 25

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache-dependency-path: |
go.sum
test/e2e/go.sum

- name: Install Kind and kubectl
shell: bash
run: |
set -euo pipefail
case "$(uname -m)" in
x86_64) architecture=amd64 ;;
aarch64|arm64) architecture=arm64 ;;
*) echo "unsupported runner architecture: $(uname -m)" >&2; exit 1 ;;
esac

kind_url="https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-${architecture}"
curl -fsSLo kind "${kind_url}"
curl -fsSLo kind.sha256sum "${kind_url}.sha256sum"
echo "$(awk '{print $1}' kind.sha256sum) kind" | sha256sum --check
chmod +x kind
sudo mv kind /usr/local/bin/kind

kubectl_url="https://dl.k8s.io/release/${KUBERNETES_VERSION}/bin/linux/${architecture}/kubectl"
curl -fsSLo kubectl "${kubectl_url}"
curl -fsSLo kubectl.sha256 "${kubectl_url}.sha256"
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
chmod +x kubectl
sudo mv kubectl /usr/local/bin/kubectl

- name: Prepare kernel device drivers
shell: bash
run: |
set -euo pipefail
sudo apt-get update -qq
sudo apt-get install -y -q rdma-core "linux-modules-extra-$(uname -r)"
sudo modprobe nbd nbds_max=8 max_part=8

if sudo modprobe rdma_rxe; then
echo "Using rdma_rxe for software RDMA devices"
elif sudo modprobe siw; then
echo "Using siw for software RDMA devices"
else
echo "Neither rdma_rxe nor siw is available in $(uname -r)" >&2
exit 1
fi

sudo udevadm settle
test -b /dev/nbd0

- name: Run multi-node E2E scenarios
run: make e2e

- name: Upload E2E results and diagnostics
if: always()
uses: actions/upload-artifact@v4
with:
name: kind-e2e-logs
path: _artifacts/
if-no-files-found: ignore
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ go.work.sum

# Claude Code local settings
.claude/settings.local.json

# Kind end-to-end test diagnostics
_artifacts/
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SETUP := apt-get update -qq && apt-get install -y -q libudev-dev

LINT_IMAGE := golangci/golangci-lint:v2.1.6

.PHONY: test build coverage lint
.PHONY: test build coverage lint kind-up kind-down kind-device e2e

test:
docker run --rm -v "$(CURDIR):/go/app" -w /go/app $(IMAGE) \
Expand All @@ -20,3 +20,15 @@ coverage:
lint:
docker run --rm -v "$(CURDIR):/go/app" -w /go/app $(LINT_IMAGE) \
sh -c "$(SETUP) && golangci-lint run ./..."

kind-up:
bash test/kind/kind.sh up

kind-down:
bash test/kind/kind.sh down

kind-device:
bash test/kind/kind.sh device "$(ACTION)" "$(NODE)" "$(LABEL)" "$(SIGNATURE)" "$(DEVICE)" "$(PEER)" "$(RDMA_DEVICE)"

e2e:
bash test/kind/e2e.sh
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,70 @@ make build # compile
make test # run tests with -race
```

### Kind development cluster and E2E tests

The Kind cluster runs the `udev-manager` executable against devices
created by the Linux kernel. It uses GPT-labelled NBD partitions, veth pairs,
and software RDMA (`rdma_rxe`, with `siw` as a fallback). The devices have real
sysfs entries, udev records, and `/dev/infiniband` character devices.
Device construction and the test `udevd` run only in a separate test-toolbox
image; the production image still contains only the normal `udev-manager`
executable and runtime dependencies. Both normal builds and the Kind tests use
the root `udev-manager.Dockerfile`; Docker builds it for the current platform.

Linux requires a rootful Docker daemon and kernel support for NBD partitions
plus either `rdma_rxe` or `siw`.
On macOS, it starts OrbStack when necessary and uses its `orbstack`
Docker context without changing the global Docker context. `docker`, `kind`,
`kubectl`, and Go must be on `PATH`; macOS additionally requires `orbctl`.

```bash
make kind-up # leave a populated cluster running for manual testing
make e2e # create, test, diagnose on failure, and remove an isolated cluster
```

The manual cluster has one control-plane and two workers and uses context
`kind-udev-manager-dev` in the active kubeconfig (`$KUBECONFIG`, or
`~/.kube/config` by default). It includes shared individual and batch
partitions, node-local bandwidth and software-RDMA devices, a matched non-RDMA
interface, RDMA devices rejected by PF/VF filters because they have no PCI
parent, and a NUMA resource on every node.

```bash
make kind-device ACTION=status
make kind-device ACTION=reset
make kind-device ACTION=seed
make kind-device ACTION=add-partition \
LABEL=e2e_disk-hot SIGNATURE=UDEV_MANAGER_E2E_HOT
make kind-device ACTION=remove-partition LABEL=e2e_disk-hot
make kind-device ACTION=add-veth NODE=udev-manager-dev-worker \
DEVICE=e2ebw-manual PEER=e2ebw-peer2
make kind-device ACTION=add-rdma NODE=udev-manager-dev-worker2 \
DEVICE=e2erdma-any PEER=e2eany-peer RDMA_DEVICE=rxe_e2eany
make kind-down
```

Set `KEEP_E2E_CLUSTER=1` to retain a failed E2E cluster. Diagnostics are written
under `_artifacts/kind/`. The E2E command uses a temporary context in the active
kubeconfig and restores the previously selected context when it exits.
`KIND_CLUSTER_NAME`, `UDEV_MANAGER_IMAGE`, `DEVICE_LAB_IMAGE`, and
`DOCKER_CONTEXT` can override the defaults.

The Ginkgo suite in `test/e2e` controls devices through the per-node device-lab
pods. It creates and removes devices between scenarios and generates its
consumer Jobs from Go; the production application contains no simulation or
test-control code. NBD devices are shared by the Linux kernel and exposed on
all Kind nodes, while veth and RDMA devices remain local to their selected node.
Software-RDMA attachment does not emit a second netdev uevent, so that scenario
restarts only the target node's manager pod to re-enumerate after attach/remove;
the partition and bandwidth scenarios exercise live add/remove events directly.
Set `E2E_FOCUS` to a Ginkgo focus expression when debugging one scenario.

The portable E2E suite does not create positive PCI SR-IOV PF/VF devices;
those classifications remain covered by unit tests. An RDMA-capable veth has
no PCI parent and is therefore used to verify that both PF and mixed-case VF
filters reject an unknown device type.

## Examples

See the [examples/](examples/) directory for sample configurations.
176 changes: 176 additions & 0 deletions test/e2e/devices_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
package e2e_test

import (
"context"
"os"

"github.com/ydb-platform/udev-manager/test/e2e/internal/lab"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("udev-manager on a multi-node Kind cluster", Ordered, Serial, func() {
var (
ctx context.Context
testEnv *lab.Lab
topology lab.Topology
)

BeforeAll(func() {
if os.Getenv("E2E_CONTEXT") == "" {
Skip("E2E_CONTEXT is set by make e2e")
}

ctx = context.Background()
var err error
testEnv, err = lab.NewFromEnv()
Expect(err).NotTo(HaveOccurred())
topology, err = testEnv.Topology(ctx)
Expect(err).NotTo(HaveOccurred())
})

BeforeEach(func() {
Expect(testEnv.DeleteTestJobs(ctx)).To(Succeed())
Expect(testEnv.ResetAll(ctx)).To(Succeed())
})

AfterEach(func() {
Expect(testEnv.DeleteTestJobs(ctx)).To(Succeed())
Expect(testEnv.ResetAll(ctx)).To(Succeed())
})

It("runs the production manager and test infrastructure on every node", func() {
Expect(topology.ControlPlanes).To(HaveLen(1))
Expect(topology.Workers).To(HaveLen(2))

for _, node := range topology.All() {
Expect(testEnv.WaitDaemonSetOnNode(ctx, "udevd", node)).To(Succeed())
Expect(testEnv.WaitDaemonSetOnNode(ctx, "device-lab", node)).To(Succeed())
Expect(testEnv.WaitDaemonSetOnNode(ctx, "udev-manager", node)).To(Succeed())
Expect(testEnv.VerifyManagerExecutable(ctx, node)).To(Succeed())
Expect(testEnv.WaitResource(ctx, node, "allocatable", "devices.example/numa-node0", 2)).To(Succeed())
}
})

It("adds, consumes, and removes a shared real partition", func() {
partition, err := testEnv.AddSharedPartition(ctx, "e2e_disk-live", "UDEV_MANAGER_E2E_LIVE")
Expect(err).NotTo(HaveOccurred())

for _, node := range topology.All() {
Expect(testEnv.VerifyPartition(ctx, node, partition, "e2e_disk-live", "UDEV_MANAGER_E2E_LIVE")).To(Succeed())
Expect(testEnv.WaitResource(ctx, node, "allocatable", "devices.example/part-live", 1)).To(Succeed())
}

node, err := testEnv.RunConsumer(ctx, lab.Consumer{
Name: "partition-live",
Resource: "devices.example/part-live",
Command: `test -b "$DEVICES_EXAMPLE_PART_LIVE_PATH" && dd if="$DEVICES_EXAMPLE_PART_LIVE_PATH" bs=64 count=1 status=none | grep -q UDEV_MANAGER_E2E_LIVE`,
})
Expect(err).NotTo(HaveOccurred())
Expect(topology.All()).To(ContainElement(node))

Expect(testEnv.RemoveSharedPartition(ctx, partition)).To(Succeed())
for _, node := range topology.All() {
Expect(testEnv.WaitResource(ctx, node, "allocatable", "devices.example/part-live", 0)).To(Succeed())
}
})

It("updates a batch as partitions are added and removed", func() {
for _, node := range topology.All() {
Expect(testEnv.WaitResource(ctx, node, "allocatable", "devices.example/batch-data", 0)).To(Succeed())
}

partitionA, err := testEnv.AddSharedPartition(ctx, "e2e_batch_a", "UDEV_MANAGER_E2E_BATCH_A")
Expect(err).NotTo(HaveOccurred())
partitionB, err := testEnv.AddSharedPartition(ctx, "e2e_batch_b", "UDEV_MANAGER_E2E_BATCH_B")
Expect(err).NotTo(HaveOccurred())

for _, node := range topology.All() {
Expect(testEnv.WaitResource(ctx, node, "allocatable", "devices.example/batch-data", 2)).To(Succeed())
}

_, err = testEnv.RunConsumer(ctx, lab.Consumer{
Name: "batch-two",
Resource: "devices.example/batch-data",
Command: `test -b "$DEVICES_EXAMPLE_PART_A_PATH" && test -b "$DEVICES_EXAMPLE_PART_B_PATH" && ` +
`dd if="$DEVICES_EXAMPLE_PART_A_PATH" bs=64 count=1 status=none | grep -q UDEV_MANAGER_E2E_BATCH_A && ` +
`dd if="$DEVICES_EXAMPLE_PART_B_PATH" bs=64 count=1 status=none | grep -q UDEV_MANAGER_E2E_BATCH_B`,
})
Expect(err).NotTo(HaveOccurred())

Expect(testEnv.RemoveSharedPartition(ctx, partitionA)).To(Succeed())
for _, node := range topology.All() {
Expect(testEnv.WaitResource(ctx, node, "allocatable", "devices.example/batch-data", 2)).To(Succeed())
}

_, err = testEnv.RunConsumer(ctx, lab.Consumer{
Name: "batch-one",
Resource: "devices.example/batch-data",
Command: `test -z "${DEVICES_EXAMPLE_PART_A_PATH:-}" && test -b "$DEVICES_EXAMPLE_PART_B_PATH" && dd if="$DEVICES_EXAMPLE_PART_B_PATH" bs=64 count=1 status=none | grep -q UDEV_MANAGER_E2E_BATCH_B`,
})
Expect(err).NotTo(HaveOccurred())

Expect(testEnv.RemoveSharedPartition(ctx, partitionB)).To(Succeed())
for _, node := range topology.All() {
Expect(testEnv.WaitResource(ctx, node, "allocatable", "devices.example/batch-data", 0)).To(Succeed())
}
})

It("keeps network bandwidth resources local to their node", func() {
target := topology.Workers[0]
shares, err := testEnv.AddVeth(ctx, target, "e2ebw-local", "e2ebw-peer")
Expect(err).NotTo(HaveOccurred())
Expect(shares).To(BeNumerically(">", 0))
Expect(testEnv.WaitResource(ctx, target, "allocatable", "devices.example/netbw-local", shares)).To(Succeed())
for _, node := range topology.Without(target) {
Expect(testEnv.WaitResourceAbsent(ctx, node, "devices.example/netbw-local")).To(Succeed())
}

node, err := testEnv.RunConsumer(ctx, lab.Consumer{
Name: "bandwidth-local",
Resource: "devices.example/netbw-local",
Command: "true",
})
Expect(err).NotTo(HaveOccurred())
Expect(node).To(Equal(target))

Expect(testEnv.RemoveNetwork(ctx, target, "e2ebw-local")).To(Succeed())
Expect(testEnv.WaitResource(ctx, target, "allocatable", "devices.example/netbw-local", 0)).To(Succeed())
})

It("registers only RDMA-enabled matches and applies PF/VF filters case-insensitively", func() {
target := topology.Workers[1]
_, err := testEnv.AddVeth(ctx, target, "e2enonrdma", "e2enon-peer")
Expect(err).NotTo(HaveOccurred())
for _, node := range topology.All() {
Expect(testEnv.WaitResourceAbsent(ctx, node, "devices.example/netrdma-nonrdma")).To(Succeed())
}

Expect(testEnv.AddRDMA(ctx, target, "e2erdma-any", "e2eany-peer", "rxe_e2eany")).To(Succeed())
Expect(testEnv.WaitResource(ctx, target, "allocatable", "devices.example/netrdma-any", 2)).To(Succeed())
for _, node := range topology.Without(target) {
Expect(testEnv.WaitResourceAbsent(ctx, node, "devices.example/netrdma-any")).To(Succeed())
}

node, err := testEnv.RunConsumer(ctx, lab.Consumer{
Name: "rdma-local",
Resource: "devices.example/netrdma-any",
HostNetwork: true,
Command: `test -n "$(find /dev/infiniband -maxdepth 1 -name 'uverbs*' -type c -print -quit)" && ibv_devices | grep -q rxe_e2eany`,
})
Expect(err).NotTo(HaveOccurred())
Expect(node).To(Equal(target))

Expect(testEnv.AddRDMA(ctx, target, "e2erdma-pf", "e2epf-peer", "rxe_e2epf")).To(Succeed())
Expect(testEnv.AddRDMA(ctx, target, "e2erdma-vf", "e2evf-peer", "rxe_e2evf")).To(Succeed())
for _, resource := range []string{"devices.example/netrdma-pf", "devices.example/netrdma-vf"} {
for _, candidate := range topology.All() {
Expect(testEnv.WaitResourceAbsent(ctx, candidate, resource)).To(Succeed())
}
}

Expect(testEnv.RemoveRDMA(ctx, target, "e2erdma-any", "rxe_e2eany")).To(Succeed())
Expect(testEnv.WaitResource(ctx, target, "allocatable", "devices.example/netrdma-any", 0)).To(Succeed())
})
})
13 changes: 13 additions & 0 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package e2e_test

import (
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

func TestE2E(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "udev-manager Kind E2E Suite")
}
Loading
Loading