Skip to content

Commit

Permalink
Make CPU percentage test assertion inclusive
Browse files Browse the repository at this point in the history
We observed in the pipeline this failure:
```
• Failure [1.275 seconds]
SigarShared
/tmp/build/1944c6a2/gopath/src/github.com/cloudfoundry/gosigar/sigar_shared_test.go:14
  ProcCpu
  /tmp/build/1944c6a2/gopath/src/github.com/cloudfoundry/gosigar/sigar_shared_test.go:15
    calculates percentage [It]
    /tmp/build/1944c6a2/gopath/src/github.com/cloudfoundry/gosigar/sigar_shared_test.go:44

    Expected
        <float64>: 1.1
    to be ~
        <float64>: 1

    /tmp/build/1944c6a2/gopath/src/github.com/cloudfoundry/gosigar/sigar_shared_test.go:51
```

This test depends on an actual CPU being stressed by infinitely
calculating the fibonacci sequence.  We suspsect that due to the
variability of the containers in the pipeline, occasionally the
assertion would be barely out of bounds.

Previously, the assertion checked for CPU percentage values from 0.9 -
1.1, exclusive.  We changed this to be inclusive.

Co-authored-by: Chris Selzo <cselzo@vmware.com>
Co-authored-by: Daniel Felipe Ochoa <danielfelipo@vmware.com>
  • Loading branch information
selzoc and danielfor committed Jan 5, 2022
1 parent 3439ebc commit 1df1c66
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sigar_shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ var _ = Describe("SigarShared", func() {

err := pCpu.Get(cpuGenerator.Process.Pid)
Expect(err).ToNot(HaveOccurred())
Expect(pCpu.Percent).To(BeNumerically("~", 1.0, 0.1))
Expect(pCpu.Percent).To(BeNumerically(">=", 0.9))
Expect(pCpu.Percent).To(BeNumerically("<=", 1.1))
})

It("does not conflate multiple processes", func() {
Expand Down

0 comments on commit 1df1c66

Please sign in to comment.