diff options
author | Jordan Christiansen <xordspar0@gmail.com> | 2020-10-31 09:32:52 -0500 |
---|---|---|
committer | Jordan Christiansen <xordspar0@gmail.com> | 2020-10-31 10:07:11 -0500 |
commit | 03579649063d669f9f57d534f74136befef98c62 (patch) | |
tree | 3b2d9d5e5e52c46c53d6e5b9c439f26067f9a0b2 /pkg/util/utils_test.go | |
parent | 2aaa036f560e2c42ebb033869eeef539dbc47fef (diff) | |
download | podman-03579649063d669f9f57d534f74136befef98c62.tar.gz podman-03579649063d669f9f57d534f74136befef98c62.tar.bz2 podman-03579649063d669f9f57d534f74136befef98c62.zip |
Centralize cores and period/quota conversion code
Signed-off-by: Jordan Christiansen <xordspar0@gmail.com>
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) +} |