-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Used memory field corrected (#4461) #4462
Conversation
Can one of the admins verify this patch? |
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically on build-eu-00. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
jenkins, test it |
Hi @amandahla, is there a test case you can add for this? It would be nice to have something in place that demonstrates this fixes the issue and prevents future regression. And BTW if you put "Closes #4461" in the commit message then the issue will automatically be closed when this merges. |
@andrewkroh hs.Summary.QuickStats.OverallMemoryUsage is a int32 value for memory usage in MB. Thanks for the tip about close issues! |
I recommend splitting up the logic from |
@andrewkroh I'm not sure if I get the idea. Is something like this? |
Yeah, sort of. I guess I was thinking more like this (or some other break down of the existing logic to make it unit testable without the use of the data simulator).
|
@andrewkroh Another try :) |
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.
Looks like you got the idea. 👍
@@ -0,0 +1,129 @@ | |||
package host |
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.
It looks like this file is only used for testing. If so it should be named with the _test.go
suffix so that it is only compiled and used in tests. But I would probably just move the HostSystemTest
definition into the data_test.go
.
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.
It looks like you could have got away with a much smaller set of stub data for your testing purposes because eventMapping
only needs a few of the fields.
cpu := event["cpu"].(common.MapStr) | ||
|
||
cpuUsed := cpu["used"].(common.MapStr) | ||
assert.EqualValues(t, 67, cpuUsed["mhz"]) |
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.
FYI It should be possible to write this as
value, _ := event.Get("cpu.used.mhz")
assert.EqualValues(t, 67, value)
Personally, I find using the dotted field notational easier to work with.
Change for correct the used memory field.