mirror of
https://github.com/weaveworks/scope.git
synced 2026-02-14 18:09:59 +00:00
1)backend/Dockerfile 2) probe/endpoint/dns_snooper.go
3) client/Dockerfile 4) docker/Dockerfile.cloud-agent
5) probe/process/walker_linux_test.go & 6) tools/lint
1)'backend/Dockerfile' : Conditional added so that the cross-compiling should
be done on amd64. Also removed support for sh-lint for ppc64le for now.
As the version for shfmt mentioned in the dockerfile is not available for
ppc64le and the later version does't work fine with existing application.
2)'probe/endpoint/dns_snooper.go' : Renamed this file so as to reuse for ppc64le
and added a build-constraint. Now this file will be build for amd64 on linux
and ppc64le on linux.
3)'client/Dockerfile' : Modified the version of the base image for node from
8.4.0 to 8.11, as this version supports multiarch.
4)'docker/Dockerfile.cloud-agent' : Modified the version of the base image for
golang from 1.10.2-strech to 1.10.2, which supports multiarch.
5) 'probe/process/walker_linux_test.go' : Test fixed to run for ppc64le,
modified the code to accept RSSBytes based on pageSize value per
architecture, instead of hard-coded values.
6)'tools/lint' : Modified the file to skip the sh-lint implementation for ppc64le.
PR #3231
103 lines
2.4 KiB
Go
103 lines
2.4 KiB
Go
package process_test
|
|
|
|
import (
|
|
"os"
|
|
"reflect"
|
|
"testing"
|
|
|
|
fs_hook "github.com/weaveworks/common/fs"
|
|
"github.com/weaveworks/common/test"
|
|
"github.com/weaveworks/common/test/fs"
|
|
"github.com/weaveworks/scope/probe/process"
|
|
)
|
|
|
|
var mockFS = fs.Dir("",
|
|
fs.Dir("proc",
|
|
fs.Dir("3",
|
|
fs.File{
|
|
FName: "cmdline",
|
|
FContents: "curl\000google.com",
|
|
},
|
|
fs.File{
|
|
FName: "stat",
|
|
FContents: "3 na R 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 2 2048",
|
|
},
|
|
fs.File{
|
|
FName: "limits",
|
|
FContents: "Limit Soft-Limit Hard-Limit Units\nMax open files 32768 65536 files",
|
|
},
|
|
fs.Dir("fd", fs.File{FName: "0"}, fs.File{FName: "1"}, fs.File{FName: "2"}),
|
|
),
|
|
fs.Dir("2",
|
|
fs.File{
|
|
FName: "cmdline",
|
|
FContents: "bash",
|
|
},
|
|
fs.File{
|
|
FName: "stat",
|
|
FContents: "2 na R 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0",
|
|
},
|
|
fs.File{
|
|
FName: "limits",
|
|
FContents: ``,
|
|
},
|
|
fs.Dir("fd", fs.File{FName: "1"}, fs.File{FName: "2"}),
|
|
),
|
|
fs.Dir("4",
|
|
fs.File{
|
|
FName: "cmdline",
|
|
FContents: "apache",
|
|
},
|
|
fs.File{
|
|
FName: "stat",
|
|
FContents: "4 na R 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0",
|
|
},
|
|
fs.File{
|
|
FName: "limits",
|
|
FContents: ``,
|
|
},
|
|
fs.Dir("fd", fs.File{FName: "0"}),
|
|
),
|
|
fs.Dir("notapid"),
|
|
fs.Dir("1",
|
|
fs.File{
|
|
FName: "cmdline",
|
|
FContents: "init",
|
|
},
|
|
fs.File{
|
|
FName: "stat",
|
|
FContents: "1 na R 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0",
|
|
},
|
|
fs.File{
|
|
FName: "limits",
|
|
FContents: ``,
|
|
},
|
|
fs.Dir("fd"),
|
|
),
|
|
),
|
|
)
|
|
|
|
func TestWalker(t *testing.T) {
|
|
fs_hook.Mock(mockFS)
|
|
defer fs_hook.Restore()
|
|
var pageSize uint64
|
|
pageSize = (uint64)(os.Getpagesize() * 2)
|
|
|
|
want := map[int]process.Process{
|
|
3: {PID: 3, PPID: 2, Name: "curl", Cmdline: "curl google.com", Threads: 1, RSSBytes: pageSize, RSSBytesLimit: 2048, OpenFilesCount: 3, OpenFilesLimit: 32768},
|
|
2: {PID: 2, PPID: 1, Name: "bash", Cmdline: "bash", Threads: 1, OpenFilesCount: 2},
|
|
4: {PID: 4, PPID: 3, Name: "apache", Cmdline: "apache", Threads: 1, OpenFilesCount: 1},
|
|
1: {PID: 1, PPID: 0, Name: "init", Cmdline: "init", Threads: 1, OpenFilesCount: 0},
|
|
}
|
|
|
|
have := map[int]process.Process{}
|
|
walker := process.NewWalker("/proc", false)
|
|
err := walker.Walk(func(p, _ process.Process) {
|
|
have[p.PID] = p
|
|
})
|
|
|
|
if err != nil || !reflect.DeepEqual(want, have) {
|
|
t.Errorf("%v (%v)", test.Diff(want, have), err)
|
|
}
|
|
}
|