當前位置: 首頁>>代碼示例>>Golang>>正文


Golang SysInfo.CPURealtimePeriod方法代碼示例

本文整理匯總了Golang中github.com/docker/docker/pkg/sysinfo.SysInfo.CPURealtimePeriod方法的典型用法代碼示例。如果您正苦於以下問題:Golang SysInfo.CPURealtimePeriod方法的具體用法?Golang SysInfo.CPURealtimePeriod怎麽用?Golang SysInfo.CPURealtimePeriod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/docker/docker/pkg/sysinfo.SysInfo的用法示例。


在下文中一共展示了SysInfo.CPURealtimePeriod方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestValidateResources

func TestValidateResources(t *testing.T) {
	type resourceTest struct {
		ConfigCPURealtimePeriod   int64
		ConfigCPURealtimeRuntime  int64
		SysInfoCPURealtimePeriod  bool
		SysInfoCPURealtimeRuntime bool
		ErrorExpected             bool
		FailureMsg                string
	}

	tests := []resourceTest{
		{
			ConfigCPURealtimePeriod:   1000,
			ConfigCPURealtimeRuntime:  1000,
			SysInfoCPURealtimePeriod:  true,
			SysInfoCPURealtimeRuntime: true,
			ErrorExpected:             false,
			FailureMsg:                "Expected valid configuration",
		},
		{
			ConfigCPURealtimePeriod:   5000,
			ConfigCPURealtimeRuntime:  5000,
			SysInfoCPURealtimePeriod:  false,
			SysInfoCPURealtimeRuntime: true,
			ErrorExpected:             true,
			FailureMsg:                "Expected failure when cpu-rt-period is set but kernel doesn't support it",
		},
		{
			ConfigCPURealtimePeriod:   5000,
			ConfigCPURealtimeRuntime:  5000,
			SysInfoCPURealtimePeriod:  true,
			SysInfoCPURealtimeRuntime: false,
			ErrorExpected:             true,
			FailureMsg:                "Expected failure when cpu-rt-runtime is set but kernel doesn't support it",
		},
		{
			ConfigCPURealtimePeriod:   5000,
			ConfigCPURealtimeRuntime:  10000,
			SysInfoCPURealtimePeriod:  true,
			SysInfoCPURealtimeRuntime: false,
			ErrorExpected:             true,
			FailureMsg:                "Expected failure when cpu-rt-runtime is greater than cpu-rt-period",
		},
	}

	for _, rt := range tests {
		var hc container.HostConfig
		hc.Resources.CPURealtimePeriod = rt.ConfigCPURealtimePeriod
		hc.Resources.CPURealtimeRuntime = rt.ConfigCPURealtimeRuntime

		var si sysinfo.SysInfo
		si.CPURealtimePeriod = rt.SysInfoCPURealtimePeriod
		si.CPURealtimeRuntime = rt.SysInfoCPURealtimeRuntime

		if err := ValidateResources(&hc, &si); (err != nil) != rt.ErrorExpected {
			t.Fatal(rt.FailureMsg, err)
		}
	}
}
開發者ID:harche,項目名稱:docker,代碼行數:59,代碼來源:hostconfig_test.go


注:本文中的github.com/docker/docker/pkg/sysinfo.SysInfo.CPURealtimePeriod方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。