-
Notifications
You must be signed in to change notification settings - Fork 16
(FACT-1784) Correctly initialize lparstat data source #31
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
Conversation
lib/src/sources/lparstat_source.cc
Outdated
| { | ||
| if (!data_) { | ||
| data_.reset(new lparstat_data); | ||
| data_.reset(new lparstat_data {"", 0, 0, 0}); |
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 would be better to just give lparstat_data a proper constructor, so that it is always correctly initialized
170038c to
2504c83
Compare
lib/tests/sources/lparstat_source.cc
Outdated
| REQUIRE(lparstat_source.wpar_configured_id() == 1); | ||
| } | ||
|
|
||
| WHEN("An lparstat executable is available but this is not an AIX machine") { |
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 test looks like it's just making sure that the lparstat data is initialized correctly. I'd change the name to indicate that.
ekinanp
left a comment
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.
The feature changes LGTM. Only suggestion I have is for the tests. Looking at how the detector tests are structured, it seems like we determine whether something runs inside LPAR/WPAR or outside LPAR/WPAR from just oslevel's output. But the detector functions look at partition_number (for LPAR) and wpar_key (for WPAR) to detect those hypervisors -- something that lparstat displays, not oslevel. So my suggestion would be to make oslevel valid for both those tests, but change the lparstat output to something invalid. Then in the lparstat source tests, I'd maybe add some tests that indicates "If we're on an AIX machine and lparstat is available, we collect its information" and "If we are not on an AIX machine and lparstat is available, we don't collect anything".
|
@ekinanp as I understand it, WPARs were introduced in AIX 6.1; If you try to run |
2504c83 to
fe97485
Compare
|
@caseywilliams Yes, but those details (checking oslevel, making sure it is > 6.1 for WPAR) are in the lparstat source, not the detectors. The detectors are only concerned with some parts of what the source returns (partition_number and wpar_key for LPAR and WPAR, respectively) when it comes to hypervisor detection after the source is done processing its information. That is why I suggest adding the oslevel specific tests in the lparstat source tests, and keep the detector tests focused on just lparstat related stuff (think of it as "mocking out" the lparstat source, if that makes sense). |
|
@ekinanp oh! I was looking in the wrong place - you're right, that could be clearer - I'll change it |
lib/tests/sources/lparstat_source.cc
Outdated
| } | ||
|
|
||
| WHEN("An lparstat executable is available but this is not an AIX machine") { | ||
| THEN("the source does not attempt to collect any data and empty values are correctly initialized") { |
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.
Yes, this is much clearer. Thanks.
fe97485 to
8a9c091
Compare
lib/tests/sources/lparstat_source.cc
Outdated
| } | ||
| } | ||
|
|
||
| WHEN("WPAR information is available") { |
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'd probably change the structure to something like:
WHEN("LPAR information is available") {
WHEN("WPAR information is unavailable") {
}
WHEN("WPAR information is available") {
}
}
because you check the lpar information in both cases anyways.
lib/tests/detectors/lpar_detector.cc
Outdated
| } | ||
| } | ||
|
|
||
| WHEN("Running outside of an LPAR but `lparstat` is available") { |
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'd change these to:
WHEN("Running on a non-AIX machine") {
THEN("the result is not valid") {
}
}
WHEN("Running on an AIX machine") {
WHEN("lparstat is available") {
THEN(...)
}
WHEN("lparstat is unavailable") {
THEN(...)
}
}
makes it clearer that these detectors only make sense for AIX machines.
lib/tests/detectors/wpar_detector.cc
Outdated
| } | ||
| } | ||
|
|
||
| WHEN("Running outside of a WPAR but `lparstat` is available") { |
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.
Same idea as my comment above for the lpar detector.
8a9c091 to
f318da5
Compare
f318da5 to
4f3243d
Compare
4f3243d to
07fd21c
Compare
ekinanp
left a comment
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.
Nice! I have only one comment.
lib/tests/detectors/wpar_detector.cc
Outdated
| WHEN("Running inside a WPAR") { | ||
| lparstat_fixture lparstat_source {"7.1.0.0", "output/lparstat/wpar.txt"}; | ||
| WHEN("Running on AIX") { | ||
| WHEN("Running inside an LPAR") { |
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.
Do you think the LPAR WHEN is necessary? i.e. Does it have to run under LPAR for it to run inside WPAR or can it run inside WPAR independently of LPAR? If it's the latter, it might be helpful to remove the WHEN("Running inside an LPAR") part so that someone looking at this won't think that WPAR has to be in LPAR.
Outside of AIX, the data in the lparstat source was left uninitialized; This caused false positives for LPAR/WPAR on power8 machines.
07fd21c to
204db80
Compare
Outside of AIX, the data in the lparstat source was left uninitialized;
This caused false positives for LPAR/WPAR on power8 machines.