From 085e4529f3c4f91dd377cadbbe7a2bf321989438 Mon Sep 17 00:00:00 2001 From: Craig MacKenzie Date: Thu, 4 Jan 2024 08:00:13 -0500 Subject: [PATCH 1/2] Update notice to 2024. (#124) What the title says. --- NOTICE.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NOTICE.txt b/NOTICE.txt index d5bc83116b..8e1b7d7c9a 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -1,5 +1,5 @@ Elastic Agent System Metrics -Copyright 2022-2023 Elasticsearch BV +Copyright 2022-2024 Elasticsearch BV This product includes software developed by The Apache Software Foundation (http://www.apache.org/). @@ -2104,11 +2104,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- Dependency : github.com/cyphar/filepath-securejoin -Version: v0.2.3 +Version: v0.2.4 Licence type (autodetected): BSD-3-Clause -------------------------------------------------------------------------------- -Contents of probable licence file $GOMODCACHE/github.com/cyphar/filepath-securejoin@v0.2.3/LICENSE: +Contents of probable licence file $GOMODCACHE/github.com/cyphar/filepath-securejoin@v0.2.4/LICENSE: Copyright (C) 2014-2015 Docker Inc & Go Authors. All rights reserved. Copyright (C) 2017 SUSE LLC. All rights reserved. From 44721e527a0c23f0d84ba6288a5d8e9b5d112770 Mon Sep 17 00:00:00 2001 From: Alex K <8418476+fearful-symmetry@users.noreply.github.com> Date: Fri, 5 Jan 2024 14:00:23 -0800 Subject: [PATCH 2/2] Fix process filter test (#126) ## What does this PR do? Fixes an issue that came to light with https://github.com/elastic/elastic-agent-system-metrics/pull/125 In certain instances, `FilterTest` will fail, if the process with the most memory usage and most CPU usage are the same. --- .golangci.yml | 2 +- metric/system/process/process_test.go | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 550de6e308..bca8e89a31 100755 --- a/.golangci.yml +++ b/.golangci.yml @@ -101,7 +101,7 @@ linters-settings: nolintlint: # Enable to ensure that nolint directives are all used. Default is true. - allow-unused: false + allow-unused: true # Disable to ensure that nolint directives don't have a leading space. Default is true. allow-leading-space: false # Exclude following linters from requiring an explanation. Default is []. diff --git a/metric/system/process/process_test.go b/metric/system/process/process_test.go index 330bcfda4c..a6cbda4ac3 100644 --- a/metric/system/process/process_test.go +++ b/metric/system/process/process_test.go @@ -173,7 +173,7 @@ func TestNetworkFilter(t *testing.T) { _, exists := data.GetValue("network.ip.Forwarding") require.NoError(t, exists, "filter did not preserve key") - ipMetrics, exists := data.GetValue("network.ip") + ipMetrics, _ := data.GetValue("network.ip") require.Equal(t, 1, len(ipMetrics.(map[string]interface{}))) } @@ -196,7 +196,10 @@ func TestFilter(t *testing.T) { procData, _, err := testConfig.Get() assert.NoError(t, err, "GetOne") - assert.Equal(t, 2, len(procData)) + // the total count of processes can either be one or two, + // depending on if the highest-mem-usage process and + // highest-cpu-usage process are the same. + assert.GreaterOrEqual(t, len(procData), 1) testZero := Stats{ Procs: []string{".*"}, @@ -581,7 +584,7 @@ func TestIncludeTopProcesses(t *testing.T) { //go:generate docker run --rm -v ./testdata:/app --entrypoint g++ docker.elastic.co/beats-dev/golang-crossbuild:1.21.0-main -pthread -std=c++11 -o /app/threads /app/threads.cpp //go:generate docker run --rm -v ./testdata:/app --entrypoint o64-clang++ docker.elastic.co/beats-dev/golang-crossbuild:1.21.0-darwin -pthread -std=c++11 -o /app/threads-darwin /app/threads.cpp //go:generate docker run --rm -v ./testdata:/app --entrypoint x86_64-w64-mingw32-g++-posix docker.elastic.co/beats-dev/golang-crossbuild:1.21.0-main -pthread -std=c++11 -o /app/threads.exe /app/threads.cpp -func runThreads(t *testing.T) *exec.Cmd { +func runThreads(t *testing.T) *exec.Cmd { //nolint: deadcode,structcheck,unused // needed by other platforms t.Helper() supportedPlatforms := []string{"linux/amd64", "darwin/amd64", "windows/amd64"} @@ -654,7 +657,7 @@ func initTestResolver() (Stats, error) { return testConfig, err } -func sliceContains(s []string, e string) bool { +func sliceContains(s []string, e string) bool { //nolint: deadcode,structcheck,unused // needed by other platforms for _, v := range s { if e == v { return true