diff --git a/plugins/inputs/disk/disk_test.go b/plugins/inputs/disk/disk_test.go index 975fd58c6..2abe8ad2a 100644 --- a/plugins/inputs/disk/disk_test.go +++ b/plugins/inputs/disk/disk_test.go @@ -571,6 +571,7 @@ func TestDiskUsageIssues(t *testing.T) { map[string]string{ "device": "sda1", "fstype": "ext4", + "label": "root", "mode": "rw", "path": "/", }, @@ -592,6 +593,7 @@ func TestDiskUsageIssues(t *testing.T) { map[string]string{ "device": "sdb", "fstype": "ext4", + "label": "storage", "mode": "rw", "path": "/mnt/storage", }, @@ -616,12 +618,18 @@ func TestDiskUsageIssues(t *testing.T) { t.Run(tt.name, func(t *testing.T) { // Setup the environment hostMountPrefix := tt.prefix - hostProcPrefix, err := filepath.Abs(filepath.Join("testdata", strings.ReplaceAll(tt.name, " ", "_"))) + + hostProcPrefix, err := filepath.Abs(filepath.Join("testdata", strings.ReplaceAll(tt.name, " ", "_"), "proc")) + require.NoError(t, err) + + hostSysPrefix, err := filepath.Abs(filepath.Join("testdata", strings.ReplaceAll(tt.name, " ", "_"), "sys")) require.NoError(t, err) // Get the partitions in the test-case os.Clearenv() t.Setenv("HOST_PROC", hostProcPrefix) + t.Setenv("HOST_SYS", hostSysPrefix) + partitions, err := diskUtil.Partitions(true) require.NoError(t, err) diff --git a/plugins/inputs/disk/testdata/issue_10297/1/mountinfo b/plugins/inputs/disk/testdata/issue_10297/proc/1/mountinfo similarity index 100% rename from plugins/inputs/disk/testdata/issue_10297/1/mountinfo rename to plugins/inputs/disk/testdata/issue_10297/proc/1/mountinfo diff --git a/plugins/inputs/disk/testdata/issue_10297/sys/block/sda1/dm/name b/plugins/inputs/disk/testdata/issue_10297/sys/block/sda1/dm/name new file mode 100644 index 000000000..d8649da39 --- /dev/null +++ b/plugins/inputs/disk/testdata/issue_10297/sys/block/sda1/dm/name @@ -0,0 +1 @@ +root diff --git a/plugins/inputs/disk/testdata/issue_10297/sys/block/sdb/dm/name b/plugins/inputs/disk/testdata/issue_10297/sys/block/sdb/dm/name new file mode 100644 index 000000000..fa780e25d --- /dev/null +++ b/plugins/inputs/disk/testdata/issue_10297/sys/block/sdb/dm/name @@ -0,0 +1 @@ +storage diff --git a/plugins/inputs/disk/testdata/success/1/mountinfo b/plugins/inputs/disk/testdata/success/proc/1/mountinfo similarity index 100% rename from plugins/inputs/disk/testdata/success/1/mountinfo rename to plugins/inputs/disk/testdata/success/proc/1/mountinfo