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
2 changes: 2 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
- Lint/format shortcuts: `make format`, `make lint`, `make lint-fix`, `make yamllint`, `make unused`.

## Fixtures And Generated Outputs
- Tests that only read filesystem data must use checked-in fixtures instead of creating static input files with `os.WriteFile` or similar APIs. Extend existing fixture-driven test tables where possible.
- Parser tests accepting `io.Reader` should use in-memory readers. Reserve temporary filesystem setup for tests that require isolation or exercise filesystem changes; explain why checked-in fixtures are insufficient.
- Do not edit unpacked `collector/fixtures/sys/` or `collector/fixtures/udev/` as source of truth; update `collector/fixtures/sys.ttar` and `collector/fixtures/udev.ttar` with `make update_fixtures`.
- To refresh e2e metric golden files, run `make build tools` first, then `./end-to-end-test.sh -u`; it writes the appropriate `collector/fixtures/e2e-output*.txt`.
- `end-to-end-test.sh` filters collector flags by OS/build context using `tools/tools match`, so an ignored flag in e2e may mean the collector is build-tag-gated for that platform rather than broken (see `Rules`).
Expand Down
27 changes: 1 addition & 26 deletions collector/diskstats_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
"fmt"
"io"
"log/slog"
"os"
"path/filepath"
"strings"
"testing"

Expand Down Expand Up @@ -363,30 +361,7 @@ node_disk_written_bytes_total{device="vda"} 1.0938236928e+11
// not exist (preserving backward compatibility with the previous
// SysBlockDeviceQueueStats zero-value behaviour, issue #3282).
func TestRotationalLabel(t *testing.T) {
tempProc := t.TempDir()
tempSys := t.TempDir()

// Create a valid rotational=1 file (HDD).
err := os.MkdirAll(filepath.Join(tempSys, "block/sda/queue"), 0o755)
if err != nil {
t.Fatal(err)
}
err = os.WriteFile(filepath.Join(tempSys, "block/sda/queue/rotational"), []byte("1\n"), 0o644)
if err != nil {
t.Fatal(err)
}

// Create a rotational=0 file (SSD).
err = os.MkdirAll(filepath.Join(tempSys, "block/sdb/queue"), 0o755)
if err != nil {
t.Fatal(err)
}
err = os.WriteFile(filepath.Join(tempSys, "block/sdb/queue/rotational"), []byte("0\n"), 0o644)
if err != nil {
t.Fatal(err)
}

fs, err := blockdevice.NewFS(tempProc, tempSys)
fs, err := blockdevice.NewFS("fixtures/proc", "fixtures/sys/diskstats")
if err != nil {
t.Fatal(err)
}
Expand Down
Loading
Loading