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

Consider checking in a static fs hierarchy for tests #66

Closed
jpo-joyent opened this issue Sep 28, 2018 · 7 comments
Closed

Consider checking in a static fs hierarchy for tests #66

jpo-joyent opened this issue Sep 28, 2018 · 7 comments
Assignees
Milestone

Comments

@jpo-joyent
Copy link
Contributor

Currently, go test runs against your local machine, and some tests fail depending on what hardware that machine actually has.

It might be a good idea to check in a single fs hierarchy to run tests against (using GHW_CHROOT), and could also serve as a handy reference of file formats for contributors without access to various hardware.

@jaypipes
Copy link
Owner

I think this is an excellent idea, @jpo-joyent. I'll try to modify our test setup accordingly and make use of the GHW_CHROOT functionality to place a temporary filesystem down for the tests to use.

@jaypipes jaypipes self-assigned this Oct 11, 2018
@jaypipes jaypipes added this to the 0.2 milestone Oct 11, 2018
@jaypipes jaypipes modified the milestones: 0.2, 1.0 Oct 19, 2018
jaypipes added a commit that referenced this issue Jan 19, 2020
jaypipes added a commit that referenced this issue Jan 19, 2020
Adds in symlinks to block device directories (excluding loopbacks) for
static snapshot of sysfs.

Issue #66
jaypipes added a commit that referenced this issue Feb 2, 2020
Issue #66

Read a block device's /sys/block/$DEVICE directory link target and
populate the ghw snapshot filesystem with the pseudofiles in the block
device directory.
jaypipes added a commit that referenced this issue Feb 2, 2020
Adds a test script (hack/run-against-snapshot.sh) that builds the ghwc
binary into a Docker image, extracts a snapshot created by ghwc-snapshot
into a tmpdir, and runs the ghwc Docker image after bind-mounting the
snapshot tmpdir as /host.

This allows us to test ghw against a snapshot static filesystem from a
user's machine (Linux only for now)

Issue #66
jaypipes added a commit that referenced this issue Mar 8, 2020
Adds partition directories into the Linux snapshot, allowing ghwc to
retrieve partition information when executing in a readonly test
snapshot image.

Issue #66
@ffromani
Copy link
Collaborator

ffromani commented Dec 3, 2020

Hi there! I'd love to contribute because I'm interested in testing the syfs reading portion of pkg/cpu, pkg/memory and few others.
Few questions (been doing similar things in the past)

  • should the testing fs hierarchy be static (e.g. subtree somewhere under test you just check in the source tree)?
  • same as above, but maybe with some .tgz file we uncompress on the fly to run tests?
  • should the testing fs hierarchy generated programmatically, so it does exist only when test runs?

@jaypipes
Copy link
Owner

jaypipes commented Dec 3, 2020

Hi @fromanirh! Check out the ghw-snapshot tool:

https://github.com/jaypipes/ghw/blob/master/cmd/ghw-snapshot/main.go

You can run it like so:

go run ./cmd/ghw-snapshot/main.go

After running that, you will see a $OS-$ARCH-$HASHSYSTEMNAME.tar.gz file in the current directory.

You can investigate this snapshot of tmpfs using the hack/run-against-snapshot.sh script:

https://github.com/jaypipes/ghw/blob/master/hack/run-against-snapshot.sh

Of course, I'm very happy to accept any and all contributions that improve the test coverage in ghw, so please don't let this discourage you! :)

@ffromani
Copy link
Collaborator

ffromani commented Dec 4, 2020

Thanks for the information @jaypipes ! Far from discouraging, this is a great building block!
I'd like to make use of snapshots systematically in the test suite. I'm most interested in the cpu + topology packages, but we can iterate from there.

Do you think a flow like this could be a good direction?

  1. file a PR with few snapshots to be used as test data. Example: few cores (laptop), many cores (12-16 from a beefy workstation), any-cores multi-numa (from server box)
  2. enhance the testsuite to (optionally?) unpack the snapshots before the start up
  3. pass the locations to unit tests (env vars?), so they can chroot into them and be fully independent from the host
  4. clean up on exit

I can contribute (and I'd love to) code & snapshots if we decide to go this direction.

@jaypipes
Copy link
Owner

jaypipes commented Dec 7, 2020

@fromanirh sounds like a great direction to me! :)

@ffromani
Copy link
Collaborator

ffromani commented Dec 7, 2020

@jaypipes great! I'll file PRs to implement this direction ASAP, referencing this issue. Thanks!

@jaypipes
Copy link
Owner

jaypipes commented Dec 7, 2020

@jaypipes great! I'll file PRs to implement this direction ASAP, referencing this issue. Thanks!

Rock on :) Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants