mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Remove hardcode for blocksize, use stat(), fixes test failure on SLES
This commit is contained in:
parent
7c76e3994c
commit
5324dcb37b
@ -23,13 +23,22 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"syscall"
|
||||
|
||||
utiltesting "k8s.io/client-go/util/testing"
|
||||
. "k8s.io/kubernetes/pkg/volume"
|
||||
volumetest "k8s.io/kubernetes/pkg/volume/testing"
|
||||
)
|
||||
|
||||
const expectedBlockSize = 4096
|
||||
func getExpectedBlockSize(path string) (int64) {
|
||||
statfs := &syscall.Statfs_t{}
|
||||
err := syscall.Statfs(path, statfs)
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
|
||||
return int64(statfs.Bsize)
|
||||
}
|
||||
|
||||
// TestMetricsDuGetCapacity tests that MetricsDu can read disk usage
|
||||
// for path
|
||||
@ -69,7 +78,7 @@ func TestMetricsDuGetCapacity(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error when calling GetMetrics %v", err)
|
||||
}
|
||||
if e, a := (expectedEmptyDirUsage.Value() + expectedBlockSize), actual.Used.Value(); e != a {
|
||||
if e, a := (expectedEmptyDirUsage.Value() + getExpectedBlockSize(filepath.Join(tmpDir, "f1"))), actual.Used.Value(); e != a {
|
||||
t.Errorf("Unexpected Used for directory with file. Expected %v, got %d.", e, a)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user