github.com/ferranbt/nomad@v0.9.3-0.20190607002617-85c449b7667c/plugins/drivers/utils_test.go (about) 1 package drivers 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 ) 8 9 func TestResourceUsageRoundTrip(t *testing.T) { 10 input := &ResourceUsage{ 11 CpuStats: &CpuStats{ 12 SystemMode: 0, 13 UserMode: 0.9963907032120152, 14 TotalTicks: 21.920595295932515, 15 ThrottledPeriods: 2321, 16 ThrottledTime: 123, 17 Percent: 0.9963906952696598, 18 Measured: []string{"System Mode", "User Mode", "Percent"}, 19 }, 20 MemoryStats: &MemoryStats{ 21 RSS: 25681920, 22 Swap: 15681920, 23 Usage: 12, 24 MaxUsage: 23, 25 KernelUsage: 34, 26 KernelMaxUsage: 45, 27 Measured: []string{"RSS", "Swap"}, 28 }, 29 } 30 31 parsed := resourceUsageFromProto(resourceUsageToProto(input)) 32 33 require.EqualValues(t, parsed, input) 34 }