- 
                Notifications
    
You must be signed in to change notification settings  - Fork 158
 
validation: test cgroups with different input values #637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validation: test cgroups with different input values #637
Conversation
999e411    to
    b70abaf      
    Compare
  
    | 
           I changed prototype of   | 
    
Fix several nil dereference errors in validation tests for cpu & blkio
cgroups, such as:
```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6eee8b]
goroutine 1 [running]:
github.com/opencontainers/runtime-tools/validation/util.ValidateLinuxResourcesBlockIO(0xc420264070,
0xc420248a50, 0x5, 0xc42027e540)
        /home/vagrant/go/src/github.com/opencontainers/runtime-tools/validation/util/linux_resources_blkio.go:37 +0x2bb
github.com/opencontainers/runtime-tools/validation/util.RuntimeOutsideValidate(0xc4200102b0, 0x7c1c00, 0x0, 0x0)
        /home/vagrant/go/src/github.com/opencontainers/runtime-tools/validation/util/test.go:279 +0x397
main.testEmptyBlkio(0x0, 0x0)
        /home/vagrant/go/src/github.com/opencontainers/runtime-tools/validation/linux_cgroups_blkio.go:68 +0x19e
main.main()
        /home/vagrant/go/src/github.com/opencontainers/runtime-tools/validation/linux_cgroups_blkio.go:88 +0x8c
```
Note that this PR fixes only a part of potential nil dereferences in
validation tests. It only touches cpu and blkio, which were discovered
during testing the PR
opencontainers#637.
Signed-off-by: Dongsu Park <[email protected]>
    | 
               | 
          ||
| func (g *Generator) initConfigLinuxResourcesCPU() { | ||
| // InitConfigLinuxResourcesCPU initializes CPU of Linux resources | ||
| func (g *Generator) InitConfigLinuxResourcesCPU() { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change LGTM
| t.Header(0) | ||
| defer t.AutoPlan() | ||
| 
               | 
          ||
| // It's assumed that a device /dev/sda (8:0) exists on the test system. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need this assumption?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@liangchenye
I'm not sure why, as I'm not the original author of the blkio test. The test has always relied on static major/minor numbers, since the beginning:
f1e02ff
What I'm doing with this PR is only to improve the existing test. Though during running the blkio test on my local system, I realized that the test failed because of a missing device /dev/sda (8:0). The local machine had only /dev/nvme (243:0), not /dev/sda. That's why I added the comment above.
Ideally we could improve this part so that it detects the root device at runtime, instead of hard-coding like that. Though I think that it should be done in a separate PR. If you want me to change so, I can make another PR.
        
          
                validation/linux_cgroups_blkio.go
              
                Outdated
          
        
      | return nil | ||
| } | ||
| 
               | 
          ||
| func testEmptyBlkio() error { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it could be part of testBlkioCgroups. We can add more args to the cases struct.  Take https://github.com/opencontainers/runtime-tools/blob/master/validation/state.go#L29 for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@liangchenye That sounds like a good idea. Will try to do that.
          
 The   | 
    
| 
           @liangchenye Sure, in some cases testing values could not be optimal. But I don't have a better idea.  | 
    
e25eb21    to
    83203d0      
    Compare
  
    | 
           Rebased on top of master, and updated CPU & blkio tests. 
  | 
    
83203d0    to
    469cd06      
    Compare
  
    | 
           Updated the PR, to replace   | 
    
469cd06    to
    246c198      
    Compare
  
    | } | ||
| } | ||
| 
               | 
          ||
| t.AutoPlan() | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to your idea, there is t.AutoPlan() in this file that has not been deleted yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@q384566678 Good catch.
I've removed t.AutoPlan() from linux_resources_devices.go as well as linux_resources_blkio.go.
| 
           Looks good, WDYT @liangchenye .  | 
    
246c198    to
    16177dc      
    Compare
  
    To be able to print out TAP results for individual tests, and at the same time, to keep sequential numbers of tests, we need to allow `RuntimeOutsideValidate()` to take a new parameter `t` (*tap.T). Doing that we are able to keep testing helpers in `validation/util`. Signed-off-by: Dongsu Park <[email protected]>
Test memory cgroups with different values for memory limit as well as swappiness. Signed-off-by: Dongsu Park <[email protected]>
Test CPU cgroups with various combinations of input values, as well as an empty cgroup to check for the default values. For that, create `validation/util/linux_resources_cpus.go` that holds test helpers for CPU cgroups. Determine number of CPUs correctly at runtime. If possible, test also realtime runtime as well as realtime periods. Print out result outputs in the TAP format. Signed-off-by: Dongsu Park <[email protected]>
Test if network cgroups tests work correctly, with different test cases, e.g. class ID, prio, interface name, whether net/user namespace is enabled or not. Signed-off-by: Dongsu Park <[email protected]>
Test if blkio cgroups tests work corectly, with different rate values. Also test it with empty weight values in the input json file. Signed-off-by: Dongsu Park <[email protected]>
16177dc    to
    0a7749a      
    Compare
  
    Test if hugetlb cgroups tests work correctly, with different page size values. Also test if the test fails with an error when creating a hugetlb cgroup with a wrong page size like 3GB. Make it also print out correct TAP output. Signed-off-by: Dongsu Park <[email protected]>
This PR tries to cover more test cases by running cgroup tests with different combinations of input values. Also it tries to print out detailed output results in the TAP format.
To do that, first of all, we change prototype of
RuntimeOutsideValidate()as well asAfterFunc(), updating all corresponding call sites. And then we update cgroups tests. Changed cgroups tests are:Especially I needed to update CPU cgroups tests a lot, by following the same semantics of memory cgroups. For that, I had to add helpers in
validation/util/linux_resources_cpus.go./cc @alban