vendor cleanup: remove unused,non-go and test files

This commit is contained in:
Madhu Rajanna
2019-01-16 00:05:52 +05:30
parent 52cf4aa902
commit b10ba188e7
15421 changed files with 17 additions and 4208853 deletions

View File

@ -1,62 +0,0 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"doc.go",
] + select({
"@io_bazel_rules_go//go/platform:windows": [
"perfcounter_nodestats.go",
"perfcounters.go",
"version.go",
"winstats.go",
],
"//conditions:default": [],
}),
importpath = "k8s.io/kubernetes/pkg/kubelet/winstats",
visibility = ["//visibility:public"],
deps = select({
"@io_bazel_rules_go//go/platform:windows": [
"//vendor/github.com/JeffAshton/win_pdh:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/google/cadvisor/info/v1:go_default_library",
"//vendor/github.com/google/cadvisor/info/v2:go_default_library",
"//vendor/golang.org/x/sys/windows:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/wait:go_default_library",
],
"//conditions:default": [],
}),
)
go_test(
name = "go_default_test",
srcs = select({
"@io_bazel_rules_go//go/platform:windows": [
"winstats_test.go",
],
"//conditions:default": [],
}),
embed = [":go_default_library"],
deps = select({
"@io_bazel_rules_go//go/platform:windows": [
"//vendor/github.com/google/cadvisor/info/v1:go_default_library",
"//vendor/github.com/google/cadvisor/info/v2:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
],
"//conditions:default": [],
}),
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@ -1,18 +0,0 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package winstats provides a client to get node and pod level stats on windows
package winstats // import "k8s.io/kubernetes/pkg/kubelet/winstats"

View File

@ -1,200 +0,0 @@
// +build windows
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package winstats
import (
"errors"
"os"
"runtime"
"sync"
"time"
"unsafe"
"github.com/golang/glog"
cadvisorapi "github.com/google/cadvisor/info/v1"
"golang.org/x/sys/windows"
"k8s.io/apimachinery/pkg/util/wait"
)
// MemoryStatusEx is the same as Windows structure MEMORYSTATUSEX
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa366770(v=vs.85).aspx
type MemoryStatusEx struct {
Length uint32
MemoryLoad uint32
TotalPhys uint64
AvailPhys uint64
TotalPageFile uint64
AvailPageFile uint64
TotalVirtual uint64
AvailVirtual uint64
AvailExtendedVirtual uint64
}
var (
modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
procGlobalMemoryStatusEx = modkernel32.NewProc("GlobalMemoryStatusEx")
)
// NewPerfCounterClient creates a client using perf counters
func NewPerfCounterClient() (Client, error) {
return newClient(&perfCounterNodeStatsClient{})
}
// perfCounterNodeStatsClient is a client that provides Windows Stats via PerfCounters
type perfCounterNodeStatsClient struct {
nodeMetrics
mu sync.RWMutex // mu protects nodeMetrics
nodeInfo
}
func (p *perfCounterNodeStatsClient) startMonitoring() error {
memory, err := getPhysicallyInstalledSystemMemoryBytes()
if err != nil {
return err
}
kernelVersion, err := getKernelVersion()
if err != nil {
return err
}
osImageVersion, err := getOSImageVersion()
if err != nil {
return err
}
p.nodeInfo = nodeInfo{
kernelVersion: kernelVersion,
osImageVersion: osImageVersion,
memoryPhysicalCapacityBytes: memory,
startTime: time.Now(),
}
cpuCounter, err := newPerfCounter(cpuQuery)
if err != nil {
return err
}
memWorkingSetCounter, err := newPerfCounter(memoryPrivWorkingSetQuery)
if err != nil {
return err
}
memCommittedBytesCounter, err := newPerfCounter(memoryCommittedBytesQuery)
if err != nil {
return err
}
go wait.Forever(func() {
p.collectMetricsData(cpuCounter, memWorkingSetCounter, memCommittedBytesCounter)
}, perfCounterUpdatePeriod)
return nil
}
func (p *perfCounterNodeStatsClient) getMachineInfo() (*cadvisorapi.MachineInfo, error) {
hostname, err := os.Hostname()
if err != nil {
return nil, err
}
return &cadvisorapi.MachineInfo{
NumCores: runtime.NumCPU(),
MemoryCapacity: p.nodeInfo.memoryPhysicalCapacityBytes,
MachineID: hostname,
}, nil
}
func (p *perfCounterNodeStatsClient) getVersionInfo() (*cadvisorapi.VersionInfo, error) {
return &cadvisorapi.VersionInfo{
KernelVersion: p.nodeInfo.kernelVersion,
ContainerOsVersion: p.nodeInfo.osImageVersion,
}, nil
}
func (p *perfCounterNodeStatsClient) getNodeMetrics() (nodeMetrics, error) {
p.mu.RLock()
defer p.mu.RUnlock()
return p.nodeMetrics, nil
}
func (p *perfCounterNodeStatsClient) getNodeInfo() nodeInfo {
return p.nodeInfo
}
func (p *perfCounterNodeStatsClient) collectMetricsData(cpuCounter, memWorkingSetCounter, memCommittedBytesCounter *perfCounter) {
cpuValue, err := cpuCounter.getData()
if err != nil {
glog.Errorf("Unable to get cpu perf counter data; err: %v", err)
return
}
memWorkingSetValue, err := memWorkingSetCounter.getData()
if err != nil {
glog.Errorf("Unable to get memWorkingSet perf counter data; err: %v", err)
return
}
memCommittedBytesValue, err := memCommittedBytesCounter.getData()
if err != nil {
glog.Errorf("Unable to get memCommittedBytes perf counter data; err: %v", err)
return
}
p.mu.Lock()
defer p.mu.Unlock()
p.nodeMetrics = nodeMetrics{
cpuUsageCoreNanoSeconds: p.convertCPUValue(cpuValue),
memoryPrivWorkingSetBytes: memWorkingSetValue,
memoryCommittedBytes: memCommittedBytesValue,
timeStamp: time.Now(),
}
}
func (p *perfCounterNodeStatsClient) convertCPUValue(cpuValue uint64) uint64 {
cpuCores := runtime.NumCPU()
// This converts perf counter data which is cpu percentage for all cores into nanoseconds.
// The formula is (cpuPercentage / 100.0) * #cores * 1e+9 (nano seconds). More info here:
// https://github.com/kubernetes/heapster/issues/650
newValue := p.nodeMetrics.cpuUsageCoreNanoSeconds + uint64((float64(cpuValue)/100.0)*float64(cpuCores)*1e9)
return newValue
}
func getPhysicallyInstalledSystemMemoryBytes() (uint64, error) {
// We use GlobalMemoryStatusEx instead of GetPhysicallyInstalledSystemMemory
// on Windows node for the following reasons:
// 1. GetPhysicallyInstalledSystemMemory retrieves the amount of physically
// installed RAM from the computer's SMBIOS firmware tables.
// https://msdn.microsoft.com/en-us/library/windows/desktop/cc300158(v=vs.85).aspx
// On some VM, it is unable to read data from SMBIOS and fails with ERROR_INVALID_DATA.
// 2. On Linux node, total physical memory is read from MemTotal in /proc/meminfo.
// GlobalMemoryStatusEx returns the amount of physical memory that is available
// for the operating system to use. The amount returned by GlobalMemoryStatusEx
// is closer in parity with Linux
// https://www.kernel.org/doc/Documentation/filesystems/proc.txt
var statex MemoryStatusEx
statex.Length = uint32(unsafe.Sizeof(statex))
ret, _, _ := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&statex)))
if ret == 0 {
return 0, errors.New("unable to read physical memory")
}
return statex.TotalPhys, nil
}

View File

@ -1,102 +0,0 @@
// +build windows
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package winstats
import (
"errors"
"fmt"
"time"
"unsafe"
"github.com/JeffAshton/win_pdh"
)
const (
cpuQuery = "\\Processor(_Total)\\% Processor Time"
memoryPrivWorkingSetQuery = "\\Process(_Total)\\Working Set - Private"
memoryCommittedBytesQuery = "\\Memory\\Committed Bytes"
// Perf counters are updated every second. This is the same as the default cadvisor collection period
// see https://github.com/google/cadvisor/blob/master/docs/runtime_options.md#housekeeping
perfCounterUpdatePeriod = 1 * time.Second
)
type perfCounter struct {
queryHandle win_pdh.PDH_HQUERY
counterHandle win_pdh.PDH_HCOUNTER
}
func newPerfCounter(counter string) (*perfCounter, error) {
var queryHandle win_pdh.PDH_HQUERY
var counterHandle win_pdh.PDH_HCOUNTER
ret := win_pdh.PdhOpenQuery(0, 0, &queryHandle)
if ret != win_pdh.ERROR_SUCCESS {
return nil, errors.New("unable to open query through DLL call")
}
ret = win_pdh.PdhValidatePath(counter)
if ret != win_pdh.ERROR_SUCCESS {
return nil, fmt.Errorf("unable to valid path to counter. Error code is %x", ret)
}
ret = win_pdh.PdhAddEnglishCounter(queryHandle, counter, 0, &counterHandle)
if ret != win_pdh.ERROR_SUCCESS {
return nil, fmt.Errorf("unable to add process counter. Error code is %x", ret)
}
ret = win_pdh.PdhCollectQueryData(queryHandle)
if ret != win_pdh.ERROR_SUCCESS {
return nil, fmt.Errorf("unable to collect data from counter. Error code is %x", ret)
}
return &perfCounter{
queryHandle: queryHandle,
counterHandle: counterHandle,
}, nil
}
func (p *perfCounter) getData() (uint64, error) {
ret := win_pdh.PdhCollectQueryData(p.queryHandle)
if ret != win_pdh.ERROR_SUCCESS {
return 0, fmt.Errorf("unable to collect data from counter. Error code is %x", ret)
}
var bufSize, bufCount uint32
var size = uint32(unsafe.Sizeof(win_pdh.PDH_FMT_COUNTERVALUE_ITEM_DOUBLE{}))
var emptyBuf [1]win_pdh.PDH_FMT_COUNTERVALUE_ITEM_DOUBLE // need at least 1 addressable null ptr.
var data uint64
ret = win_pdh.PdhGetFormattedCounterArrayDouble(p.counterHandle, &bufSize, &bufCount, &emptyBuf[0])
if ret != win_pdh.PDH_MORE_DATA {
return 0, fmt.Errorf("unable to collect data from counter. Error code is %x", ret)
}
filledBuf := make([]win_pdh.PDH_FMT_COUNTERVALUE_ITEM_DOUBLE, bufCount*size)
ret = win_pdh.PdhGetFormattedCounterArrayDouble(p.counterHandle, &bufSize, &bufCount, &filledBuf[0])
if ret != win_pdh.ERROR_SUCCESS {
return 0, fmt.Errorf("unable to collect data from counter. Error code is %x", ret)
}
for i := 0; i < int(bufCount); i++ {
c := filledBuf[i]
data = uint64(c.FmtValue.DoubleValue)
}
return data, nil
}

View File

@ -1,115 +0,0 @@
// +build windows
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package winstats
import (
"fmt"
"unsafe"
"golang.org/x/sys/windows"
)
// getCurrentVersionVal gets value of specified key from registry.
func getCurrentVersionVal(key string) (string, error) {
var h windows.Handle
if err := windows.RegOpenKeyEx(windows.HKEY_LOCAL_MACHINE,
windows.StringToUTF16Ptr(`SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\`),
0,
windows.KEY_READ,
&h); err != nil {
return "", err
}
defer windows.RegCloseKey(h)
var buf [128]uint16
var typ uint32
n := uint32(len(buf) * int(unsafe.Sizeof(buf[0]))) // api expects array of bytes, not uint16
if err := windows.RegQueryValueEx(h,
windows.StringToUTF16Ptr(key),
nil,
&typ,
(*byte)(unsafe.Pointer(&buf[0])),
&n); err != nil {
return "", err
}
return windows.UTF16ToString(buf[:]), nil
}
// getVersionRevision gets revision from UBR registry.
func getVersionRevision() (uint16, error) {
revisionString, err := getCurrentVersionVal("UBR")
if err != nil {
return 0, err
}
revision, err := windows.UTF16FromString(revisionString)
if err != nil {
return 0, err
}
return revision[0], nil
}
// getKernelVersion gets the version of windows kernel.
func getKernelVersion() (string, error) {
// Get CurrentBuildNumber.
buildNumber, err := getCurrentVersionVal("CurrentBuildNumber")
if err != nil {
return "", err
}
// Get CurrentMajorVersionNumber.
majorVersionNumberString, err := getCurrentVersionVal("CurrentMajorVersionNumber")
if err != nil {
return "", err
}
majorVersionNumber, err := windows.UTF16FromString(majorVersionNumberString)
if err != nil {
return "", err
}
// Get CurrentMinorVersionNumber.
minorVersionNumberString, err := getCurrentVersionVal("CurrentMinorVersionNumber")
if err != nil {
return "", err
}
minorVersionNumber, err := windows.UTF16FromString(minorVersionNumberString)
if err != nil {
return "", err
}
// Get UBR.
revision, err := getVersionRevision()
if err != nil {
return "", err
}
return fmt.Sprintf("%d.%d.%s.%d\n", majorVersionNumber[0], minorVersionNumber[0], buildNumber, revision), nil
}
// getOSImageVersion gets the osImage name and version.
func getOSImageVersion() (string, error) {
productName, err := getCurrentVersionVal("ProductName")
if err != nil {
return "", nil
}
return productName, nil
}

View File

@ -1,172 +0,0 @@
// +build windows
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package winstats provides a client to get node and pod level stats on windows
package winstats
import (
"syscall"
"time"
"unsafe"
cadvisorapi "github.com/google/cadvisor/info/v1"
cadvisorapiv2 "github.com/google/cadvisor/info/v2"
)
var (
procGetDiskFreeSpaceEx = modkernel32.NewProc("GetDiskFreeSpaceExW")
)
// Client is an interface that is used to get stats information.
type Client interface {
WinContainerInfos() (map[string]cadvisorapiv2.ContainerInfo, error)
WinMachineInfo() (*cadvisorapi.MachineInfo, error)
WinVersionInfo() (*cadvisorapi.VersionInfo, error)
GetDirFsInfo(path string) (cadvisorapiv2.FsInfo, error)
}
// StatsClient is a client that implements the Client interface
type StatsClient struct {
client winNodeStatsClient
}
type winNodeStatsClient interface {
startMonitoring() error
getNodeMetrics() (nodeMetrics, error)
getNodeInfo() nodeInfo
getMachineInfo() (*cadvisorapi.MachineInfo, error)
getVersionInfo() (*cadvisorapi.VersionInfo, error)
}
type nodeMetrics struct {
cpuUsageCoreNanoSeconds uint64
memoryPrivWorkingSetBytes uint64
memoryCommittedBytes uint64
timeStamp time.Time
}
type nodeInfo struct {
memoryPhysicalCapacityBytes uint64
kernelVersion string
osImageVersion string
// startTime is the time when the node was started
startTime time.Time
}
// newClient constructs a Client.
func newClient(statsNodeClient winNodeStatsClient) (Client, error) {
statsClient := new(StatsClient)
statsClient.client = statsNodeClient
err := statsClient.client.startMonitoring()
if err != nil {
return nil, err
}
return statsClient, nil
}
// WinContainerInfos returns a map of container infos. The map contains node and
// pod level stats. Analogous to cadvisor GetContainerInfoV2 method.
func (c *StatsClient) WinContainerInfos() (map[string]cadvisorapiv2.ContainerInfo, error) {
infos := make(map[string]cadvisorapiv2.ContainerInfo)
rootContainerInfo, err := c.createRootContainerInfo()
if err != nil {
return nil, err
}
infos["/"] = *rootContainerInfo
return infos, nil
}
// WinMachineInfo returns a cadvisorapi.MachineInfo with details about the
// node machine. Analogous to cadvisor MachineInfo method.
func (c *StatsClient) WinMachineInfo() (*cadvisorapi.MachineInfo, error) {
return c.client.getMachineInfo()
}
// WinVersionInfo returns a cadvisorapi.VersionInfo with version info of
// the kernel and docker runtime. Analogous to cadvisor VersionInfo method.
func (c *StatsClient) WinVersionInfo() (*cadvisorapi.VersionInfo, error) {
return c.client.getVersionInfo()
}
func (c *StatsClient) createRootContainerInfo() (*cadvisorapiv2.ContainerInfo, error) {
nodeMetrics, err := c.client.getNodeMetrics()
if err != nil {
return nil, err
}
var stats []*cadvisorapiv2.ContainerStats
stats = append(stats, &cadvisorapiv2.ContainerStats{
Timestamp: nodeMetrics.timeStamp,
Cpu: &cadvisorapi.CpuStats{
Usage: cadvisorapi.CpuUsage{
Total: nodeMetrics.cpuUsageCoreNanoSeconds,
},
},
Memory: &cadvisorapi.MemoryStats{
WorkingSet: nodeMetrics.memoryPrivWorkingSetBytes,
Usage: nodeMetrics.memoryCommittedBytes,
},
})
nodeInfo := c.client.getNodeInfo()
rootInfo := cadvisorapiv2.ContainerInfo{
Spec: cadvisorapiv2.ContainerSpec{
CreationTime: nodeInfo.startTime,
HasCpu: true,
HasMemory: true,
Memory: cadvisorapiv2.MemorySpec{
Limit: nodeInfo.memoryPhysicalCapacityBytes,
},
},
Stats: stats,
}
return &rootInfo, nil
}
// GetDirFsInfo returns filesystem capacity and usage information.
func (c *StatsClient) GetDirFsInfo(path string) (cadvisorapiv2.FsInfo, error) {
var freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes int64
var err error
ret, _, err := syscall.Syscall6(
procGetDiskFreeSpaceEx.Addr(),
4,
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(path))),
uintptr(unsafe.Pointer(&freeBytesAvailable)),
uintptr(unsafe.Pointer(&totalNumberOfBytes)),
uintptr(unsafe.Pointer(&totalNumberOfFreeBytes)),
0,
0,
)
if ret == 0 {
return cadvisorapiv2.FsInfo{}, err
}
return cadvisorapiv2.FsInfo{
Timestamp: time.Now(),
Capacity: uint64(totalNumberOfBytes),
Available: uint64(freeBytesAvailable),
Usage: uint64(totalNumberOfBytes - freeBytesAvailable),
}, nil
}

View File

@ -1,127 +0,0 @@
// +build windows
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package winstats
import (
"testing"
"time"
cadvisorapi "github.com/google/cadvisor/info/v1"
cadvisorapiv2 "github.com/google/cadvisor/info/v2"
"github.com/stretchr/testify/assert"
)
var timeStamp = time.Now()
type fakeWinNodeStatsClient struct{}
func (f fakeWinNodeStatsClient) startMonitoring() error {
return nil
}
func (f fakeWinNodeStatsClient) getNodeMetrics() (nodeMetrics, error) {
return nodeMetrics{
cpuUsageCoreNanoSeconds: 123,
memoryPrivWorkingSetBytes: 1234,
memoryCommittedBytes: 12345,
timeStamp: timeStamp,
}, nil
}
func (f fakeWinNodeStatsClient) getNodeInfo() nodeInfo {
return nodeInfo{
kernelVersion: "v42",
memoryPhysicalCapacityBytes: 1.6e+10,
}
}
func (f fakeWinNodeStatsClient) getMachineInfo() (*cadvisorapi.MachineInfo, error) {
return &cadvisorapi.MachineInfo{
NumCores: 4,
MemoryCapacity: 1.6e+10,
MachineID: "somehostname",
}, nil
}
func (f fakeWinNodeStatsClient) getVersionInfo() (*cadvisorapi.VersionInfo, error) {
return &cadvisorapi.VersionInfo{
KernelVersion: "v42",
}, nil
}
func TestWinContainerInfos(t *testing.T) {
c := getClient(t)
actualRootInfos, err := c.WinContainerInfos()
assert.NoError(t, err)
var stats []*cadvisorapiv2.ContainerStats
stats = append(stats, &cadvisorapiv2.ContainerStats{
Timestamp: timeStamp,
Cpu: &cadvisorapi.CpuStats{
Usage: cadvisorapi.CpuUsage{
Total: 123,
},
},
Memory: &cadvisorapi.MemoryStats{
WorkingSet: 1234,
Usage: 12345,
},
})
infos := make(map[string]cadvisorapiv2.ContainerInfo)
infos["/"] = cadvisorapiv2.ContainerInfo{
Spec: cadvisorapiv2.ContainerSpec{
HasCpu: true,
HasMemory: true,
Memory: cadvisorapiv2.MemorySpec{
Limit: 1.6e+10,
},
},
Stats: stats,
}
assert.Equal(t, actualRootInfos, infos)
}
func TestWinMachineInfo(t *testing.T) {
c := getClient(t)
machineInfo, err := c.WinMachineInfo()
assert.NoError(t, err)
assert.Equal(t, machineInfo, &cadvisorapi.MachineInfo{
NumCores: 4,
MemoryCapacity: 1.6e+10,
MachineID: "somehostname"})
}
func TestWinVersionInfo(t *testing.T) {
c := getClient(t)
versionInfo, err := c.WinVersionInfo()
assert.NoError(t, err)
assert.Equal(t, versionInfo, &cadvisorapi.VersionInfo{
KernelVersion: "v42"})
}
func getClient(t *testing.T) Client {
f := fakeWinNodeStatsClient{}
c, err := newClient(f)
assert.NoError(t, err)
assert.NotNil(t, c)
return c
}