-
Notifications
You must be signed in to change notification settings - Fork 635
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #807 from hakman/tests-mac
Update tests to run also on macOS
- Loading branch information
Showing
10 changed files
with
185 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
Copyright 2023 The Kubernetes Authors All rights reserved. | ||
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 healthchecker | ||
|
||
import ( | ||
"runtime" | ||
"time" | ||
|
||
"github.com/golang/glog" | ||
|
||
"k8s.io/node-problem-detector/cmd/healthchecker/options" | ||
) | ||
|
||
// getUptimeFunc returns the time for which the given service has been running. | ||
func getUptimeFunc(service string) func() (time.Duration, error) { | ||
glog.Fatalf("getUptimeFunc is not supported in %s", runtime.GOOS) | ||
return func() (time.Duration, error) { return time.Second, nil } | ||
} | ||
|
||
// getRepairFunc returns the repair function based on the component. | ||
func getRepairFunc(hco *options.HealthCheckerOptions) func() { | ||
glog.Fatalf("getRepairFunc is not supported in %s", runtime.GOOS) | ||
return func() {} | ||
} | ||
|
||
// checkForPattern returns (true, nil) if logPattern occurs less than logCountThreshold number of times since last | ||
// service restart. (false, nil) otherwise. | ||
func checkForPattern(service, logStartTime, logPattern string, logCountThreshold int) (bool, error) { | ||
glog.Fatalf("checkForPattern is not supported in %s", runtime.GOOS) | ||
return false, nil | ||
} | ||
|
||
func getDockerPath() string { | ||
glog.Fatalf("getDockerPath is not supported in %s", runtime.GOOS) | ||
return "" | ||
} |
2 changes: 2 additions & 0 deletions
2
pkg/healthchecker/types/types_linux.go → pkg/healthchecker/types/types_unix.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//go:build unix | ||
|
||
/* | ||
Copyright 2021 The Kubernetes Authors All rights reserved. | ||
|
29 changes: 29 additions & 0 deletions
29
pkg/systemlogmonitor/logwatchers/filelog/log_watcher_darwin.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
Copyright 2023 The Kubernetes Authors All rights reserved. | ||
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 filelog | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/hpcloud/tail" | ||
) | ||
|
||
// getLogReader returns log reader for filelog log. Note that getLogReader doesn't look back | ||
// to the rolled out logs. | ||
func getLogReader(path string) (io.ReadCloser, error) { | ||
return tail.OpenFile(path) | ||
} |
31 changes: 31 additions & 0 deletions
31
pkg/systemlogmonitor/logwatchers/kmsg/log_watcher_darwin.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
Copyright 2023 The Kubernetes Authors All rights reserved. | ||
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 kmsg | ||
|
||
import ( | ||
"runtime" | ||
|
||
"github.com/golang/glog" | ||
|
||
"k8s.io/node-problem-detector/pkg/systemlogmonitor/logwatchers/types" | ||
) | ||
|
||
// NewKmsgWatcher creates a watcher which will read messages from /dev/kmsg | ||
func NewKmsgWatcher(cfg types.WatcherConfig) types.LogWatcher { | ||
glog.Fatalf("kmsg parser is not supported in %s", runtime.GOOS) | ||
return nil | ||
} |
2 changes: 2 additions & 0 deletions
2
...systemstatsmonitor/cpu_collector_linux.go → pkg/systemstatsmonitor/cpu_collector_unix.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//go:build unix | ||
|
||
/* | ||
Copyright 2020 The Kubernetes Authors All rights reserved. | ||
|
2 changes: 2 additions & 0 deletions
2
...temstatsmonitor/memory_collector_linux.go → ...stemstatsmonitor/memory_collector_unix.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//go:build unix | ||
|
||
/* | ||
Copyright 2020 The Kubernetes Authors All rights reserved. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
Copyright 2023 The Kubernetes Authors All rights reserved. | ||
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 types | ||
|
||
const defaultProcPath = "" | ||
|
||
func (ssc *SystemStatsConfig) validateProcPath() error { | ||
// not supported | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
//go:build unix | ||
|
||
/* | ||
Copyright 2021 The Kubernetes Authors All rights reserved. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
Copyright 2023 The Kubernetes Authors All rights reserved. | ||
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 util | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/shirou/gopsutil/v3/host" | ||
) | ||
|
||
// GetUptimeDuration returns the time elapsed since last boot. | ||
// For example: "cos 77-12293.0.0", "ubuntu 16.04.6 LTS (Xenial Xerus)". | ||
func GetUptimeDuration() (time.Duration, error) { | ||
ut, err := host.Uptime() | ||
if err != nil { | ||
return 0, err | ||
} | ||
return time.Duration(ut), nil | ||
} | ||
|
||
// GetOSVersion retrieves the version of the current operating system. | ||
// For example: "darwin 13.5"". | ||
func GetOSVersion() (string, error) { | ||
platform, _, version, err := host.PlatformInformation() | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return platform + " " + version, nil | ||
} |
File renamed without changes.