-
Notifications
You must be signed in to change notification settings - Fork 115
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
Testing best practices #154
Comments
Hey @andig I'm using qemu to emulate various hardware devices (amd64, arm64, ...) on which I test the final gokrazy instance bundle. |
Thanks @damdo. As far as I understand your approach you're basically creating an entire (vagrant) machine running the packer-generated image? Im wondering if that's necessary though: shouldn't it suffice (at least for testing hardware-independent modules) to run the compiled binary (that ends up in the image) as root process inside Docker? |
Yes I'm running it within Vagrant but that's because of how my dev setup is defined (as code). Not sure about running it as a Linux Container, haven't tried that yet. |
Even when just replacing your program with If there are any remaining performance bottlenecks, we can look into addressing them.
As @damdo mentioned, using qemu is a pretty good way to run gokrazy, in particular because it not only runs the gokrazy kernel, but also provides a full block device. It looks like qemu is available for Mac, too, but I’m not sure how well it works. I hadn’t really explored running gokrazy in Docker so far. Here’s how to do it:
As you can see, the gokrazy init system either lacks permission to mount /tmp, or, when running with So it doesn’t work right now, but with enough changes it could probably be made work. Be careful to not accidentally overwrite your hard disk while playing around with this :) |
Good advise, I wasn't aware of that. But still- I don't even want to have a Raspi running. Especially when I'm travelling.
Maybe my approach is not feasible. I'm still wondering: at the end of the build we have a compiled application plus linux kernel. The compiled application consists of client app plus gokrazy environment. Shouldn't it be possible to reduce the gokrazy environment to the bare minimum necessary? The part without handling block devices, loading the kernel etc? I'd be happy to contribute but would need pointers where to start. |
Yes, but then the question is: what are you still getting from gokrazy? At the point when all you want to do is run your application, why not just build it using the Go tool and then run it on the host or in docker? Why add gokrazy into the mix here? (I’m not saying I’m against making gokrazy work better in Docker. But I do wonder whether it’s valuable to make it work, or whether it just adds more moving pieces to a situation that would be better off with out it :) |
Hey @andig, |
@damdo thank you! I'm following along, but not successful yet:
At this point, the image has not been created. After setting the http password:
Seems there is a problem with installing the packer that I couldn't figure out yet. Seems the problem is that the packer gets cross-compiled, too which it shouldn't? Note: I'm running on M1 Mac (arm64). Re-running with Update Seems I can make progress by doing
and removing the forced |
Oh yes that might happen! When I put together the scripts I didn't take into account The new M1 Macs (arm64) (I have an amd64 one), so we might need to update the build script to do so. It shouldn't be too hard though :) I'll take a look today or tomorrow 👍 |
This is really great. Solved by @damdo without Vagrant now. Close? |
Cool stuff! Maybe we should add a userguide article to explain how to use this (similar to the video, but in textual form)? @damdo, would you be up for contributing such an article? Thanks |
@damdo follow-up problem:
I'm unsure how to stop the qemu instance and (Ctrl-C doesn't work) and release the resources for another test. |
Try Ctrl-a x |
Sure I'd be up for it! I'm actually working on a Go rewrite of the scripts at https://github.com/damdo/gokrazy-on-qemu, removing the build logic in favour of a more unified approach with the new instance-centric design and focusing on an improved machine emulation cli experience for playing/testing with gokrazy (a " I'll keep you posted on my findings and then we can decide if we want to double down on the rewrite and document it on the website or keep the script approach and describe that on the docs. |
I have already removed the entire build part after I figured out that my few lines are doing the same for what I needed. Also takes care of the env var thing. The run part is definitely unique- if that could be part of a gok test command… |
Yes, that could be interesting. For now I'm trying to create a prototype as a separate cli tool, to prove its potential usefulness. But then we could evaluate :) I'll let you know when I have a working prototype and you can let me know what you think. |
Hey @andig so here is the prototype of the cli tool I was working on. It's mainly a way to test gokrazy instances before deploying them on real hardware, but it can aid during development, CI, and more. I've added some basic features and some more experimental ones (OCI registries pull support). Let me know what you think: https://github.com/damdo/gokrazy-machine |
I'm once more working on packaging https://evcc.io. One key challenge for me (Mac developer) ist user-testing the final application. Operating a Raspi, remote-updating etc. is too cumbersome for my taste.
Are there best practices how I could practically test without a target device, maybe by running a packaged (if testing-only) gokrazy-enabled application inside Docker? I'd only be testing application logic, persistence and functionality of the bundled modules (e.g. breakglass), but obviously not Linux kernels etc.
The text was updated successfully, but these errors were encountered: