diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-11-02 16:02:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-02 16:02:55 +0100 |
commit | 7375a55757fe7615f133db5b097bb4db9a244888 (patch) | |
tree | 6d29d221f696c3aabfa1e847d92f55da41cb27e9 /pkg/util/utils_test.go | |
parent | 8bc0f51e330185bed1be4bcfffd04729b4bc9cd4 (diff) | |
parent | 03579649063d669f9f57d534f74136befef98c62 (diff) | |
download | podman-7375a55757fe7615f133db5b097bb4db9a244888.tar.gz podman-7375a55757fe7615f133db5b097bb4db9a244888.tar.bz2 podman-7375a55757fe7615f133db5b097bb4db9a244888.zip |
Merge pull request #8207 from xordspar0/common-period-quota
Centralize cores and period/quota conversion code
Diffstat (limited to 'pkg/util/utils_test.go')
-rw-r--r-- | pkg/util/utils_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pkg/util/utils_test.go b/pkg/util/utils_test.go index a9b37844e..cb737bd76 100644 --- a/pkg/util/utils_test.go +++ b/pkg/util/utils_test.go @@ -257,3 +257,23 @@ func TestValidateSysctlBadSysctl(t *testing.T) { _, err := ValidateSysctls(strSlice) assert.Error(t, err) } + +func TestCoresToPeriodAndQuota(t *testing.T) { + cores := 1.0 + expectedPeriod := DefaultCPUPeriod + expectedQuota := int64(DefaultCPUPeriod) + + actualPeriod, actualQuota := CoresToPeriodAndQuota(cores) + assert.Equal(t, actualPeriod, expectedPeriod, "Period does not match") + assert.Equal(t, actualQuota, expectedQuota, "Quota does not match") +} + +func TestPeriodAndQuotaToCores(t *testing.T) { + var ( + period uint64 = 100000 + quota int64 = 50000 + expectedCores = 0.5 + ) + + assert.Equal(t, PeriodAndQuotaToCores(period, quota), expectedCores) +} |