Commit 0b0ec9b5 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #46342 from vaibhavsood/master

Automatic merge from submit-queue (batch tested with PRs 47075, 46342) Remove hardcode for blocksize, use stat(), fixes test failure on SLES **What this PR does / why we need it**: Removes hardcoding for blocksize, fixes test failure on SLES **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #44022 **Special notes for your reviewer**: **Release note**: ```release-note ```
parents aa35738a a4809bc3
......@@ -22,6 +22,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"syscall"
"testing"
utiltesting "k8s.io/client-go/util/testing"
......@@ -29,7 +30,15 @@ import (
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)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment