Skip to content

Commit

Permalink
Fix error messages in validation cgroup tests
Browse files Browse the repository at this point in the history
Symptoms:
```
 ok 3 - blkio weight is set correctly
 # expect: 500, actual: 842352267696
```

After the patch:
```
 ok 3 - blkio weight is set correctly
 # expect: 500, actual: 500
```

I found those issues by patching runc to introduce "off-by-one" bugs and
checking if they are correctly caught by the validation tests:
https://github.com/kinvolk/runc/commits/alban/off-by-one-bugs

Signed-off-by: Alban Crequy <[email protected]>
  • Loading branch information
alban committed Mar 14, 2018
1 parent 36e9b37 commit 984dbc8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions validation/linux_cgroups_cpus.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ func main() {
return err
}
if *lcd.Shares != shares {
return fmt.Errorf("cpus shares limit is not set correctly, expect: %d, actual: %d", shares, lcd.Shares)
return fmt.Errorf("cpus shares limit is not set correctly, expect: %d, actual: %d", shares, *lcd.Shares)
}
if *lcd.Quota != quota {
return fmt.Errorf("cpus quota is not set correctly, expect: %d, actual: %d", quota, lcd.Quota)
return fmt.Errorf("cpus quota is not set correctly, expect: %d, actual: %d", quota, *lcd.Quota)
}
if *lcd.Period != period {
return fmt.Errorf("cpus period is not set correctly, expect: %d, actual: %d", period, lcd.Period)
return fmt.Errorf("cpus period is not set correctly, expect: %d, actual: %d", period, *lcd.Period)
}
if lcd.Cpus != cpus {
return fmt.Errorf("cpus cpus is not set correctly, expect: %s, actual: %s", cpus, lcd.Cpus)
Expand Down
2 changes: 1 addition & 1 deletion validation/linux_cgroups_hugetlb.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func main() {
page := "1GB"
var limit uint64 = 56892210544640
var limit uint64 = 52985 * 1024 * 1024 * 1024 // multiple of hugepage size
g := util.GetDefaultGenerator()
g.SetLinuxCgroupsPath(cgroups.AbsCgroupPath)
g.AddLinuxResourcesHugepageLimit(page, limit)
Expand Down
4 changes: 2 additions & 2 deletions validation/util/linux_resources_blkio.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ func ValidateLinuxResourcesBlockIO(config *rspec.Spec, state *rspec.State) error
}

t.Ok(*lbd.Weight == *config.Linux.Resources.BlockIO.Weight, "blkio weight is set correctly")
t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.BlockIO.Weight, lbd.Weight)
t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.BlockIO.Weight, *lbd.Weight)

t.Ok(*lbd.LeafWeight == *config.Linux.Resources.BlockIO.LeafWeight, "blkio leafWeight is set correctly")
t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.BlockIO.LeafWeight, lbd.LeafWeight)
t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.BlockIO.LeafWeight, *lbd.LeafWeight)

for _, device := range config.Linux.Resources.BlockIO.WeightDevice {
found := false
Expand Down
2 changes: 1 addition & 1 deletion validation/util/linux_resources_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func ValidateLinuxResourcesNetwork(config *rspec.Spec, state *rspec.State) error
}

t.Ok(*lnd.ClassID == *config.Linux.Resources.Network.ClassID, "network ID set correctly")
t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Network.ClassID, lnd.ClassID)
t.Diagnosticf("expect: %d, actual: %d", *config.Linux.Resources.Network.ClassID, *lnd.ClassID)

for _, priority := range config.Linux.Resources.Network.Priorities {
found := false
Expand Down

0 comments on commit 984dbc8

Please sign in to comment.