1
0
mirror of https://github.com/openfaas/faas.git synced 2025-06-21 00:06:38 +00:00

Merge master into breakout_swarm

Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
Alex Ellis
2018-02-01 09:25:39 +00:00
parent afeb7bbce4
commit f954bf0733
1953 changed files with 614131 additions and 175582 deletions
contrib
prometheus-arm64
prometheus
docker-compose.armhf.ymldocker-compose.yml
gateway
DockerfileGopkg.lockGopkg.toml
handlers
metrics
server.go
tests
vendor.conf
vendor
github.com
Azure
Microsoft
Nvveen
Sirupsen
beorn7
docker
cli
distribution
.gitignore.mailmapAUTHORSBUILDING.mdCHANGELOG.mdCONTRIBUTING.mdDockerfile
Godeps
MAINTAINERSMakefileREADME.mdRELEASE-CHECKLIST.mdROADMAP.mdblobs.gocircle.yml
cmd
digest
registry-api-descriptor-template
registry
configuration
context
contrib
coverpkg.sh
digest
docs
errors.go
health
manifest
manifests.go
notifications
project
reference
registry.go
registry
api
auth
client
doc.go
handlers
listener
middleware
registry
repository
proxy
registry.goregistry_test.goroot.go
storage
testutil
uuid
vendor.conf
version
docker
LICENSENOTICEREADME.md
api
client
README.mdcheckpoint_create.gocheckpoint_delete.gocheckpoint_list.goclient.goclient_unix.goclient_windows.gocontainer_attach.gocontainer_commit.gocontainer_copy.gocontainer_create.gocontainer_diff.gocontainer_exec.gocontainer_export.gocontainer_inspect.gocontainer_kill.gocontainer_list.gocontainer_logs.gocontainer_pause.gocontainer_prune.gocontainer_remove.gocontainer_rename.gocontainer_resize.gocontainer_restart.gocontainer_start.gocontainer_stats.gocontainer_stop.gocontainer_top.gocontainer_unpause.gocontainer_update.gocontainer_wait.godisk_usage.goerrors.goevents.gohijack.goimage_build.goimage_create.goimage_history.goimage_import.goimage_inspect.goimage_list.goimage_load.goimage_prune.goimage_pull.goimage_push.goimage_remove.goimage_save.goimage_search.goimage_tag.goinfo.gointerface.gointerface_experimental.gointerface_stable.gologin.gonetwork_connect.gonetwork_create.gonetwork_disconnect.gonetwork_inspect.gonetwork_list.gonetwork_prune.gonetwork_remove.gonode_inspect.gonode_list.gonode_remove.gonode_update.goping.goplugin_create.goplugin_disable.goplugin_enable.goplugin_inspect.goplugin_install.goplugin_list.goplugin_push.goplugin_remove.goplugin_set.goplugin_upgrade.gorequest.gosecret_create.gosecret_inspect.gosecret_list.gosecret_remove.gosecret_update.goservice_create.goservice_inspect.goservice_list.goservice_logs.goservice_remove.goservice_update.goswarm_get_unlock_key.goswarm_init.goswarm_inspect.goswarm_join.goswarm_leave.goswarm_unlock.goswarm_update.gotask_inspect.gotask_list.gotask_logs.gotransport.goutils.goversion.govolume_create.govolume_inspect.govolume_list.govolume_prune.govolume_remove.go
opts
pkg
registry
vendor.conf
go-connections
go-units
libtrust
gogo
protobuf
.gitignore.mailmap.travis.ymlAUTHORSCONTRIBUTORSGOLANG_CONTRIBUTORSMakefileREADMEReadme.md
_conformance
bench.md
codec
custom_types.mdextensions.md
gogoproto
gogoreplace
install-protobuf.sh
io
jsonpb
plugin
proto
protobuf
protoc-gen-combo
protoc-gen-gofast
protoc-gen-gogo
protoc-gen-gogofast
protoc-gen-gogofaster
protoc-gen-gogoslick
protoc-gen-gogotypes
protoc-gen-gostring
protoc-min-version
sortkeys
test
.gitignoreMakefile
asymetric-issue125
bug_test.go
casttype
castvalue
combos
custom-dash-type
custom
custombytesnonstruct
dashfilename
data
defaultconflict
embedconflict
empty-issue70
enumcustomname
enumdecl
enumdecl_all
enumprefix
enumstringer
example
extension_test.go
filedotname
fuzztests
group
importdedup
indeximport-issue72
int64support
issue260
issue261
issue262
issue312
issue322
issue330
issue34
issue42order
issue8
jsonpb-gogo
mapdefaults
mapsproto2
mixbench
moredefaults
nopackage
oneof
oneof3
oneofembed
packed
proto3extension
protosize
registration
required
sizerconflict
sizeunderscore
stdtypes
t.go
tags
theproto3
thetest.pb.gothetest.protothetestpb_test.go
typedecl
typedecl_all
typedeclimport
types
unmarshalmerge
unrecognized
unrecognizedgroup
uuid.gouuid_test.go
types
vanity
version
golang
gorilla
matttproud
nats-io
opencontainers
openfaas
pkg
prometheus
client_golang
client_model
common
procfs
spf13
golang.org
x
net
sys
LICENSEPATENTSREADME
unix
README.mdasm_darwin_386.sasm_darwin_amd64.sasm_darwin_arm.sasm_darwin_arm64.sasm_dragonfly_amd64.sasm_freebsd_386.sasm_freebsd_amd64.sasm_freebsd_arm.sasm_linux_386.sasm_linux_amd64.sasm_linux_arm.sasm_linux_arm64.sasm_linux_mips64x.sasm_linux_mipsx.sasm_linux_ppc64x.sasm_linux_s390x.sasm_netbsd_386.sasm_netbsd_amd64.sasm_netbsd_arm.sasm_openbsd_386.sasm_openbsd_amd64.sasm_solaris_amd64.sbluetooth_linux.goconstants.godirent.goendian_big.goendian_little.goenv_unix.goenv_unset.goflock.goflock_linux_32bit.gogccgo.gogccgo_c.cgccgo_linux_amd64.gogccgo_linux_sparc64.goopenbsd_pledge.gorace.gorace0.gosockcmsg_linux.gosockcmsg_unix.gostr.gosyscall.gosyscall_bsd.gosyscall_darwin.gosyscall_darwin_386.gosyscall_darwin_amd64.gosyscall_darwin_arm.gosyscall_darwin_arm64.gosyscall_dragonfly.gosyscall_dragonfly_amd64.gosyscall_freebsd.gosyscall_freebsd_386.gosyscall_freebsd_amd64.gosyscall_freebsd_arm.gosyscall_linux.gosyscall_linux_386.gosyscall_linux_amd64.gosyscall_linux_amd64_gc.gosyscall_linux_arm.gosyscall_linux_arm64.gosyscall_linux_mips64x.gosyscall_linux_mipsx.gosyscall_linux_ppc64x.gosyscall_linux_s390x.gosyscall_linux_sparc64.gosyscall_netbsd.gosyscall_netbsd_386.gosyscall_netbsd_amd64.gosyscall_netbsd_arm.gosyscall_no_getwd.gosyscall_openbsd.gosyscall_openbsd_386.gosyscall_openbsd_amd64.gosyscall_solaris.gosyscall_solaris_amd64.gosyscall_unix.gosyscall_unix_gc.gozerrors_darwin_386.gozerrors_darwin_amd64.gozerrors_darwin_arm.gozerrors_darwin_arm64.gozerrors_dragonfly_amd64.gozerrors_freebsd_386.gozerrors_freebsd_amd64.gozerrors_freebsd_arm.gozerrors_linux_386.gozerrors_linux_amd64.gozerrors_linux_arm.gozerrors_linux_arm64.gozerrors_linux_mips.gozerrors_linux_mips64.gozerrors_linux_mips64le.gozerrors_linux_mipsle.gozerrors_linux_ppc64.gozerrors_linux_ppc64le.gozerrors_linux_s390x.gozerrors_linux_sparc64.gozerrors_netbsd_386.gozerrors_netbsd_amd64.gozerrors_netbsd_arm.gozerrors_openbsd_386.gozerrors_openbsd_amd64.gozerrors_solaris_amd64.gozsyscall_darwin_386.gozsyscall_darwin_amd64.gozsyscall_darwin_arm.gozsyscall_darwin_arm64.gozsyscall_dragonfly_amd64.gozsyscall_freebsd_386.gozsyscall_freebsd_amd64.gozsyscall_freebsd_arm.gozsyscall_linux_386.gozsyscall_linux_amd64.gozsyscall_linux_arm.gozsyscall_linux_arm64.gozsyscall_linux_mips.gozsyscall_linux_mips64.gozsyscall_linux_mips64le.gozsyscall_linux_mipsle.gozsyscall_linux_ppc64.gozsyscall_linux_ppc64le.gozsyscall_linux_s390x.gozsyscall_linux_sparc64.gozsyscall_netbsd_386.gozsyscall_netbsd_amd64.gozsyscall_netbsd_arm.gozsyscall_openbsd_386.gozsyscall_openbsd_amd64.gozsyscall_solaris_amd64.gozsysctl_openbsd.gozsysnum_darwin_386.gozsysnum_darwin_amd64.gozsysnum_darwin_arm.gozsysnum_darwin_arm64.gozsysnum_dragonfly_amd64.gozsysnum_freebsd_386.gozsysnum_freebsd_amd64.gozsysnum_freebsd_arm.gozsysnum_linux_386.gozsysnum_linux_amd64.gozsysnum_linux_arm.gozsysnum_linux_arm64.gozsysnum_linux_mips.gozsysnum_linux_mips64.gozsysnum_linux_mips64le.gozsysnum_linux_mipsle.gozsysnum_linux_ppc64.gozsysnum_linux_ppc64le.gozsysnum_linux_s390x.gozsysnum_linux_sparc64.gozsysnum_netbsd_386.gozsysnum_netbsd_amd64.gozsysnum_netbsd_arm.gozsysnum_openbsd_386.gozsysnum_openbsd_amd64.gozsysnum_solaris_amd64.goztypes_darwin_386.goztypes_darwin_amd64.goztypes_darwin_arm.goztypes_darwin_arm64.goztypes_dragonfly_amd64.goztypes_freebsd_386.goztypes_freebsd_amd64.goztypes_freebsd_arm.goztypes_linux_386.goztypes_linux_amd64.goztypes_linux_arm.goztypes_linux_arm64.goztypes_linux_mips.goztypes_linux_mips64.goztypes_linux_mips64le.goztypes_linux_mipsle.goztypes_linux_ppc64.goztypes_linux_ppc64le.goztypes_linux_s390x.goztypes_linux_sparc64.goztypes_netbsd_386.goztypes_netbsd_amd64.goztypes_netbsd_arm.goztypes_openbsd_386.goztypes_openbsd_amd64.goztypes_solaris_amd64.go
windows
prometheus

@ -0,0 +1,273 @@
package procfs
import (
"fmt"
"reflect"
"strings"
"testing"
"time"
)
func TestMountStats(t *testing.T) {
tests := []struct {
name string
s string
mounts []*Mount
invalid bool
}{
{
name: "no devices",
s: `hello`,
},
{
name: "device has too few fields",
s: `device foo`,
invalid: true,
},
{
name: "device incorrect format",
s: `device rootfs BAD on / with fstype rootfs`,
invalid: true,
},
{
name: "device incorrect format",
s: `device rootfs mounted BAD / with fstype rootfs`,
invalid: true,
},
{
name: "device incorrect format",
s: `device rootfs mounted on / BAD fstype rootfs`,
invalid: true,
},
{
name: "device incorrect format",
s: `device rootfs mounted on / with BAD rootfs`,
invalid: true,
},
{
name: "device rootfs cannot have stats",
s: `device rootfs mounted on / with fstype rootfs stats`,
invalid: true,
},
{
name: "NFSv4 device with too little info",
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=1.1\nhello",
invalid: true,
},
{
name: "NFSv4 device with bad bytes",
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=1.1\nbytes: 0",
invalid: true,
},
{
name: "NFSv4 device with bad events",
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=1.1\nevents: 0",
invalid: true,
},
{
name: "NFSv4 device with bad per-op stats",
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=1.1\nper-op statistics\nFOO 0",
invalid: true,
},
{
name: "NFSv4 device with bad transport stats",
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=1.1\nxprt: tcp",
invalid: true,
},
{
name: "NFSv4 device with bad transport version",
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=foo\nxprt: tcp 0",
invalid: true,
},
{
name: "NFSv4 device with bad transport stats version 1.0",
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=1.0\nxprt: tcp 0 0 0 0 0 0 0 0 0 0 0 0 0",
invalid: true,
},
{
name: "NFSv4 device with bad transport stats version 1.1",
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs4 statvers=1.1\nxprt: tcp 0 0 0 0 0 0 0 0 0 0",
invalid: true,
},
{
name: "NFSv3 device with transport stats version 1.0 OK",
s: "device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs statvers=1.0\nxprt: tcp 1 2 3 4 5 6 7 8 9 10",
mounts: []*Mount{{
Device: "192.168.1.1:/srv",
Mount: "/mnt/nfs",
Type: "nfs",
Stats: &MountStatsNFS{
StatVersion: "1.0",
Transport: NFSTransportStats{
Port: 1,
Bind: 2,
Connect: 3,
ConnectIdleTime: 4,
IdleTime: 5 * time.Second,
Sends: 6,
Receives: 7,
BadTransactionIDs: 8,
CumulativeActiveRequests: 9,
CumulativeBacklog: 10,
},
},
}},
},
{
name: "device rootfs OK",
s: `device rootfs mounted on / with fstype rootfs`,
mounts: []*Mount{{
Device: "rootfs",
Mount: "/",
Type: "rootfs",
}},
},
{
name: "NFSv3 device with minimal stats OK",
s: `device 192.168.1.1:/srv mounted on /mnt/nfs with fstype nfs statvers=1.1`,
mounts: []*Mount{{
Device: "192.168.1.1:/srv",
Mount: "/mnt/nfs",
Type: "nfs",
Stats: &MountStatsNFS{
StatVersion: "1.1",
},
}},
},
{
name: "fixtures OK",
mounts: []*Mount{
{
Device: "rootfs",
Mount: "/",
Type: "rootfs",
},
{
Device: "sysfs",
Mount: "/sys",
Type: "sysfs",
},
{
Device: "proc",
Mount: "/proc",
Type: "proc",
},
{
Device: "/dev/sda1",
Mount: "/",
Type: "ext4",
},
{
Device: "192.168.1.1:/srv/test",
Mount: "/mnt/nfs/test",
Type: "nfs4",
Stats: &MountStatsNFS{
StatVersion: "1.1",
Age: 13968 * time.Second,
Bytes: NFSBytesStats{
Read: 1207640230,
ReadTotal: 1210214218,
ReadPages: 295483,
},
Events: NFSEventsStats{
InodeRevalidate: 52,
DnodeRevalidate: 226,
VFSOpen: 1,
VFSLookup: 13,
VFSAccess: 398,
VFSReadPages: 331,
VFSWritePages: 47,
VFSFlush: 77,
VFSFileRelease: 77,
},
Operations: []NFSOperationStats{
{
Operation: "NULL",
},
{
Operation: "READ",
Requests: 1298,
Transmissions: 1298,
BytesSent: 207680,
BytesReceived: 1210292152,
CumulativeQueueTime: 6 * time.Millisecond,
CumulativeTotalResponseTime: 79386 * time.Millisecond,
CumulativeTotalRequestTime: 79407 * time.Millisecond,
},
{
Operation: "WRITE",
},
},
Transport: NFSTransportStats{
Port: 832,
Connect: 1,
IdleTime: 11 * time.Second,
Sends: 6428,
Receives: 6428,
CumulativeActiveRequests: 12154,
MaximumRPCSlotsUsed: 24,
CumulativeSendingQueue: 26,
CumulativePendingQueue: 5726,
},
},
},
},
},
}
for i, tt := range tests {
t.Logf("[%02d] test %q", i, tt.name)
var mounts []*Mount
var err error
if tt.s != "" {
mounts, err = parseMountStats(strings.NewReader(tt.s))
} else {
proc, e := FS("fixtures").NewProc(26231)
if e != nil {
t.Fatalf("failed to create proc: %v", err)
}
mounts, err = proc.MountStats()
}
if tt.invalid && err == nil {
t.Error("expected an error, but none occurred")
}
if !tt.invalid && err != nil {
t.Errorf("unexpected error: %v", err)
}
if want, have := tt.mounts, mounts; !reflect.DeepEqual(want, have) {
t.Errorf("mounts:\nwant:\n%v\nhave:\n%v", mountsStr(want), mountsStr(have))
}
}
}
func mountsStr(mounts []*Mount) string {
var out string
for i, m := range mounts {
out += fmt.Sprintf("[%d] %q on %q (%q)", i, m.Device, m.Mount, m.Type)
stats, ok := m.Stats.(*MountStatsNFS)
if !ok {
out += "\n"
continue
}
out += fmt.Sprintf("\n\t- v%s, age: %s", stats.StatVersion, stats.Age)
out += fmt.Sprintf("\n\t- bytes: %v", stats.Bytes)
out += fmt.Sprintf("\n\t- events: %v", stats.Events)
out += fmt.Sprintf("\n\t- transport: %v", stats.Transport)
out += fmt.Sprintf("\n\t- per-operation stats:")
for _, o := range stats.Operations {
out += fmt.Sprintf("\n\t\t- %v", o)
}
out += "\n"
}
return out
}