Skip to content
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

cover pkg/ipmi 2 try #2252

Merged
merged 9 commits into from Feb 5, 2022
Merged

cover pkg/ipmi 2 try #2252

merged 9 commits into from Feb 5, 2022

Conversation

ChriMarMe
Copy link
Contributor

@ChriMarMe ChriMarMe commented Jan 3, 2022

  • Abstract syscall implementation behind interface
  • Hide syscalls behind interface to improve testability
  • Add mock tests for ipmi
  • Add vm tests for ipmi
    Signed-off-by: Christopher Meis christopher.meis@9elements.com

@ChriMarMe ChriMarMe changed the title pkg/ipmi 2 try cover pkg/ipmi 2 try Jan 3, 2022
@ChriMarMe
Copy link
Contributor Author

#2182 (comment)

@codecov
Copy link

codecov bot commented Jan 3, 2022

Codecov Report

Merging #2252 (a04ace4) into main (95ec011) will increase coverage by 0.12%.
The diff coverage is 70.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2252      +/-   ##
==========================================
+ Coverage   67.02%   67.14%   +0.12%     
==========================================
  Files         381      383       +2     
  Lines       39582    39615      +33     
==========================================
+ Hits        26529    26599      +70     
+ Misses      11970    11916      -54     
- Partials     1083     1100      +17     
Impacted Files Coverage Δ
pkg/ipmi/ipmi.go 40.10% <23.07%> (+40.10%) ⬆️
pkg/ipmi/dev.go 92.85% <92.85%> (ø)
pkg/ipmi/handler.go 100.00% <100.00%> (ø)
pkg/ipmi/ipmi_linux.go 66.66% <100.00%> (+66.66%) ⬆️
pkg/acpi/sdt.go 0.00% <0.00%> (-76.67%) ⬇️
pkg/acpi/bios.go 0.00% <0.00%> (-67.57%) ⬇️
pkg/acpi/raw.go 67.85% <0.00%> (-10.72%) ⬇️
pkg/acpi/rsdp.go 38.46% <0.00%> (-10.26%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 95ec011...a04ace4. Read the comment docs.

@ChriMarMe
Copy link
Contributor Author

I will give it a try and start working on an integration test.

@ChriMarMe
Copy link
Contributor Author

Wait. @rjoleary did you suggest I write a whole new docker image and make a custom qemu version run in the CI just to test ipmi? Because that's what I understand from the comment you left and the pdf you refered to.

@hugelgupf
Copy link
Member

Could you do this PR without moving code around? It's a lot harder to review without knowing what you changed, and we'd have a clearer diff if no code was moved.

@hugelgupf
Copy link
Member

Wait. @rjoleary did you suggest I write a whole new docker image and make a custom qemu version run in the CI just to test ipmi? Because that's what I understand from the comment you left and the pdf you refered to.

I will let @rjoleary clarify but an automated test with a real IPMI target to test against would be really really dope and really good use of time. Updating the QEMU in our existing docker image is not a lot of work.

@ChriMarMe
Copy link
Contributor Author

Could you do this PR without moving code around? It's a lot harder to review without knowing what you changed, and we'd have a clearer diff if no code was moved.

This is just a new branch with the same commit as in #2182 This PR was reviewed by @rminnich until it reached a good state and then I squashed it into one commit.

@ChriMarMe ChriMarMe added Awaiting reviewer Waiting for a reviewer. coverage Pull requests related to code coverage labels Jan 11, 2022
pkg/ipmi/dev.go Outdated Show resolved Hide resolved
pkg/ipmi/ipmi.go Outdated Show resolved Hide resolved
Copy link
Member

@hugelgupf hugelgupf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless @rjoleary or @rminnich agreed to or requested it, would you mind undoing the code moving? It makes it harder to see the diff of the ipmi code and what in the code changed. I don't disagree with the new split, actually, I would just rather see it in a different PR so that the diff is clean to read in this PR.

@hugelgupf
Copy link
Member

(Ignore my comment, I see this is obsolete in favor of the VM test)

@ChriMarMe
Copy link
Contributor Author

@johnnylinwiwynn Thank you very much.

This can be merged when #2274 is done.

rminnich
rminnich previously approved these changes Jan 15, 2022
pkg/ipmi/dev.go Outdated Show resolved Hide resolved
@rminnich rminnich added Awaiting author Waiting for new changes or feedback for author. and removed Awaiting reviewer Waiting for a reviewer. labels Jan 15, 2022
Copy link
Member

@hugelgupf hugelgupf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless @rjoleary or @rminnich agreed to or requested it, would you mind undoing the code moving? It makes it harder to see the diff of the ipmi code and what in the code changed. I don't disagree with the new split, actually, I would just rather see it in a different PR so that the diff is clean to read in this PR.

Since we do plan to merge this, would you mind addressing this?

@ChriMarMe
Copy link
Contributor Author

ChriMarMe commented Jan 17, 2022

Will do

@ChriMarMe
Copy link
Contributor Author

#2281

@ChriMarMe
Copy link
Contributor Author

Also this has to wait a little longer. Need to comply with the comment here first before we can get this in.
#2193 (comment)

@ChriMarMe ChriMarMe added Awaiting reviewer Waiting for a reviewer. and removed Awaiting author Waiting for new changes or feedback for author. labels Jan 25, 2022
rminnich
rminnich previously approved these changes Jan 25, 2022
Copy link
Member

@rminnich rminnich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm approving it and it's up to you.

return conn.Read(f)
}

type handler interface {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is where this gets weird and why it's hard for me to say.

Will this test run on a plan 9 system, and use an imported /sys from a linux system? Or vice versa? That's extremely unlikely, but my world, not uncommon. But at that point, we might someday choose to support multiple GOOS in one binary ... but that's a very unlikely situation?

Anyway, I tend to trust Chris K on stuff like this, so I'd take his direction; or, since he does not feel too strongly, this may be a case where we should let you decide, since the big goal here is to have 9e make more decisions of this type as time goes on. Are you comfortable making this decision? I am fine with whatever you wish to do.

As you can see, it's kind of borderline.

@rminnich rminnich added Awaiting author Waiting for new changes or feedback for author. and removed Awaiting reviewer Waiting for a reviewer. labels Jan 25, 2022
@ChriMarMe ChriMarMe force-pushed the cover/pkg/ipmi branch 2 times, most recently from c3ec4e6 to f9da4fd Compare January 26, 2022 04:54
* Abstract syscall implementation behind interface
* Hide syscalls behind interface to improve testability
* Add tests for ipmi

Signed-off-by: Christopher Meis <christopher.meis@9elements.com>
* Fix GetDeviceID data parsing

Signed-off-by: Christopher Meis <christopher.meis@9elements.com>
* Add call to qemu for executing test in vm

Signed-off-by: Christopher Meis <christopher.meis@9elements.com>
* Comply with desired error string format

Signed-off-by: Christopher Meis <christopher.meis@9elements.com>
* Add tests for to run in qemu utilizing the BMC simulator

Signed-off-by: Christopher Meis <christopher.meis@9elements.com>
…n-image-amd64

* Updated docker images has been deployed but without version increase, because version was tainted.

Signed-off-by: Christopher Meis <christopher.meis@9elements.com>
* Make tests more detailed

Signed-off-by: Christopher Meis <christopher.meis@9elements.com>
@ChriMarMe
Copy link
Contributor Author

Looking forward to the last review or will it be merged directly? Only the flying spaghetti monster knows!

@ChriMarMe
Copy link
Contributor Author

Oh! Now I remember why I had the mock and the interface. I had to prevent using the dev.SendRequest method, because it calls f.RawConn, which is not possible with a normal file. The mock allowed me to get coverage for the most top level ipmi functions. I couldnt figure out how to create a file with the required properties to satisfy the call to SyscallConn. It was an additional layer of abstraction to actually run the functions without an ipmi interface available. Now we run the tests with the ipmi interface available, but the device does not support all features implemented. So we can't cover all functions. The problem with the file rawconn still persists in this environment, because as soon as I try to abstract the interface with a normal file it wont work.

This. Any idea might help. I'm a little clueless now. Is there a different solution of the RawConn problem and I dont see it?

@ChriMarMe ChriMarMe added Awaiting reviewer Waiting for a reviewer. and removed Awaiting author Waiting for new changes or feedback for author. labels Feb 2, 2022
@rminnich rminnich added the automerge Applying this label auto-merges the PR when ready label Feb 5, 2022
@rminnich rminnich dismissed hugelgupf’s stale review February 5, 2022 00:21

I think we've worked it out, and we need to get this in. Sorry if that was the wrong thing to do.

@probot-auto-merge probot-auto-merge bot merged commit b7f2ee0 into main Feb 5, 2022
@ChriMarMe ChriMarMe deleted the cover/pkg/ipmi branch March 18, 2022 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Applying this label auto-merges the PR when ready Awaiting reviewer Waiting for a reviewer. coverage Pull requests related to code coverage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants