Permalink
Browse files

Add MTU to interface test (#288)

* Add mtu for interface test

References #287

* Add mtu to shared integration test

The default MTU in Docker is 1500 bytes, so this seems like a reasonable
value against which to test the MTU feature.

References #287

* Update success counts in test.sh

References #287
  • Loading branch information...
AlexandreCarlton authored and aelsabbahy committed Dec 19, 2017
1 parent 4f1f0e4 commit 0de910042c5f8d1adef4f2d007f8d329808011bd
Showing with 22 additions and 2 deletions.
  1. +1 −0 docs/manual.md
  2. +1 −0 integration-tests/goss/goss-shared.yaml
  3. +2 −2 integration-tests/test.sh
  4. +9 −0 resource/interface.go
  5. +9 −0 system/interface.go
View
@@ -584,6 +584,7 @@ interface:
addrs:
- 172.17.0.2/16
- fe80::42:acff:fe11:2/64
mtu: 1500
```
@@ -151,6 +151,7 @@ interface:
addrs:
contain-element:
have-prefix: '172.17'
mtu: 1500
http:
https://www.google.com:
status: 200
@@ -44,9 +44,9 @@ out=$(docker_exec "/goss/$os/goss-linux-$arch" --vars "/goss/vars.yaml" -g "/gos
echo "$out"
if [[ $os == "arch" ]]; then
egrep -q 'Count: 68, Failed: 0' <<<"$out"
egrep -q 'Count: 69, Failed: 0' <<<"$out"
else
egrep -q 'Count: 82, Failed: 0' <<<"$out"
egrep -q 'Count: 83, Failed: 0' <<<"$out"
fi
if [[ ! $os == "arch" ]]; then
View
@@ -11,6 +11,7 @@ type Interface struct {
Name string `json:"-" yaml:"-"`
Exists matcher `json:"exists" yaml:"exists"`
Addrs matcher `json:"addrs,omitempty" yaml:"addrs,omitempty"`
MTU matcher `json:"mtu,omitempty" yaml:"mtu,omitempty"`
}
func (i *Interface) ID() string { return i.Name }
@@ -32,6 +33,9 @@ func (i *Interface) Validate(sys *system.System) []TestResult {
if i.Addrs != nil {
results = append(results, ValidateValue(i, "addrs", i.Addrs, sysInterface.Addrs, skip))
}
if i.MTU != nil {
results = append(results, ValidateValue(i, "mtu", i.MTU, sysInterface.MTU, skip))
}
return results
}
@@ -47,5 +51,10 @@ func NewInterface(sysInterface system.Interface, config util.Config) (*Interface
i.Addrs = addrs
}
}
if !contains(config.IgnoreList, "mtu") {
if mtu, err := sysInterface.MTU(); err == nil {
i.MTU = mtu
}
}
return i, nil
}
View
@@ -10,6 +10,7 @@ type Interface interface {
Name() string
Exists() (bool, error)
Addrs() ([]string, error)
MTU() (int, error)
}
type DefInterface struct {
@@ -75,3 +76,11 @@ func (i *DefInterface) Addrs() ([]string, error) {
}
return ret, nil
}
func (i *DefInterface) MTU() (int, error) {
if err := i.setup(); err != nil {
return 0, err
}
return i.iface.MTU, nil
}

0 comments on commit 0de9100

Please sign in to comment.