-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add first golang-only test #1037
Conversation
This is related to lf-edge#855 Signed-off-by: Pavel Abramov <[email protected]>
Related to lf-edge#855 Signed-off-by: Pavel Abramov <[email protected]>
Related to lf-edge#855 Signed-off-by: Pavel Abramov <[email protected]>
Signed-off-by: Pavel Abramov <[email protected]>
Signed-off-by: Pavel Abramov <[email protected]>
b7e0b3e
to
9dfc87f
Compare
dc6a43d
to
246ea08
Compare
This should close #828 |
Need to change project in tests... |
246ea08
to
9ab7f50
Compare
Just go to tests/sec and run go test Signed-off-by: Pavel Abramov <[email protected]>
b81c89f
to
f5a82a5
Compare
This is a big one! |
3652570
to
80643ca
Compare
locally smoke tests passed, removed sec_test because it's now part of NeoEden. Let's see how pipeline will behave 🤞 |
80643ca
to
7989fc7
Compare
any zfs experts or any advice on how I can run things locally to debug this thing? |
Okay, ZFS is not working, one smoke test failed on shutdown, I remember it was flaky. I'll look into zfs now, but it's getting closer |
7989fc7
to
92b4f5f
Compare
Seems promising, hitting TOOMANYREQUESTS on User app test |
We are using stubs for tests in escript, this will be not needed once NeoEden is merged Signed-off-by: Pavel Abramov <[email protected]>
92b4f5f
to
1be9d4e
Compare
@@ -105,3 +106,10 @@ runs: | |||
./eden setup -v debug --grub-options='set_global dom0_extra_args "$dom0_extra_args eve_install_zfs_with_raid_level "' | |||
shell: bash | |||
working-directory: "./eden" | |||
|
|||
- name: Start and Onboard |
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 disable setup in workflows and move its logic here. Do you have any reason for that?
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.
Will we keep our collect-info and other debugging logic in case of failure on onboarding stage, which is quite predictable?
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.
Hey @giggsoff , nice seeing you here :) So I did it purely from backward compatibility. For some reason escript tests didn't want to onboard through test.
Yes, we keep all collect-info logic there, no changes in that regard
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.
Much better. I can read the docs without too much prior knowledge and get a feel how to do things.
I made some suggestions related to typos and clarifying minor things.
Additional points:
- what about teardown? Don't I need to use
evec
for that? Shouldn't that be at the end ofTestMain
? - People using this might (or might not) be used to
TestMain
, so it is worth putting in them.Run()
in the example. In that light, maybe link to the TestMain official docs? - Is there a better way to pass the node around than is a package-level variable? If not, ok, but worth asking.
- Are there concerns about tests run in parallel? I would think they conflict with a single controller, so it might be worth stating explicitly not to invoke any
.Parallel()
- I still am a little confused at the border between
openevec
andevetestkit
. It is related to the context-passing question. I see very clearly how I useopenevec
to initialize things. But then I useevetestkit
to get a node, and use that node to do things on it. Would "get a node" be part ofopenevec
, and thenevetestkit
is just a set of convenient library functions? I am not sure I get where the border is.
Below is an example of test, which check if AppArmor is enables (specific file on EVE exists). It uses `EveReadFile` function from `evetestkit` | ||
|
||
```go | ||
const appArmorStatus = "/sys/module/apparmor/parameters/enabled" |
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 would be great if this (and many other files) were parametrized, so they could be a property of some library. But that is beyond the scope of here.
2b629fb
to
47dc965
Compare
We can execute openevec.EdenClean(), ideally we should discuss how we should proceed with it. Because technically make clean does more than EdenClean(), it removes files as well, we need to fix it separately, this vicious cycle shouldn't be there (i.e. you should have teardown in tests). Hope that clarifies a bit :D
Done
It's a good question: I would actually gather people to chat about evetestkit and how better to structure things there.
Nice catch! Done
The problem is we haven't defined the border and now would be a really good time to discuss where this border should be. On an all I don't now if this PR is the best place to do so, but I want to talk about design of golang test framework and two entities constituting Eden and what separation would be the best. We surely could (and I think should) start here to get some pointers on that discussion. My take: openevec is about "basic" operations, which is: create EVE image, start controller, start EVE, enable networking with specific configuration, deploy specific App to EVE, ssh to EVE. Sort of create a setup and provide tools to access to components of that configuration based on configuration itself (I want to ssh to EVE, but actually if SDN is enabled I need to forward my request through it I want this logic to be hidden behind openevec, where I just say ssh to EVE; same applies to access controller, could be adam, could be commercial controller, could be anything else, I just want to access controller) Then there's evetestkit which utilizes in some way openevec and provide functions of convenience, like ReadFile (which is actually Ssh to EVE and run cat command) or check that this App on Controller is in UP state (which is actually access controller, how to do that is hidden behind openevec) |
@deitch third take on docs answered your questions above ^^^ |
It really isn't part of the question related to this, as it is to passing variables around between tests. When you have a
Yup, I think you started to do so in a good way:
So is it correct to say that If that is correct - and I think that makes sense, although the naming "evetestkit" is a bit misleading, but not so far that it is worth changing (and I don't have a better name, so I have no right to complain), then I think it is a pretty solid line. If that is true, though, then evetestkit should not depend on anything local or direct access to anything. The only parameters to any of its functions should be one of:
If that is true, then it is a clean, easy to understand division of labour. |
Seems like it's a common practice Regarding the separation: we need to move some of the functions from there for it to be able to utilize openevec only. I suggest we also get input from @shjala and do it in a separate PR, I don't want to bloat this one, let's iterate, it's easier |
Doesn't make it a good practice. 😆
OK, as long as we get it done. The whole point of your excellent work here is to make it easier to use and understand. |
47dc965
to
5afad78
Compare
Okay, most of the requests are done, one left with config marshaling. Once this is merged, before releasing eden 0.1.0 we gotta do following:
|
I think I addressed all the comments, @deitch if you don't have any comments let's merge it after releasing 0.9.13 (we need hotfix for Eden tests) |
We still have work to do to make it cleaner separation for evetestkit, but if I understand you correctly, that is beyond the scope of this PR, so good. One final request: func InitilizeTest()
func InitilizeTestFromConfig() Can you please fix these typos? func InitializeTest()
func InitializeTestFromConfig() It confuses people, hard to search, and doesn't make us look as good. Other than that, good to go. |
Shoot, missed the typo, thanks Avi! |
@deitch fixed the typo |
5afad78
to
1be4617
Compare
yetus is unhappy, but other than that LGTM |
Signed-off-by: Pavel Abramov <[email protected]>
1be4617
to
f703354
Compare
I see now only complaint to bump GHA from Yetus now |
Merging this, yetus complaints are about GHA bumps. Escript is deprecated. May the force be with us |
Nice work! (coming late to the party...) |
Not at all @milan-zededa, we need to port all those escipt tests to new fancy golang framework, want to help? :D |
That's a very tempting offer, I'll think about it ;) |
;-) |
What
Instead of using escript to write tests, one now can write tests fully in golang and run those like this
So there's no layered complexity anymore, compared to calling calling forked from golang test binary, which is written by us which actually interprets text files as bash commands, execs those via exec and sometimes substitute some configuration with that's been written in specification below or call arbitratry bash scripts, or compare values from stdout and file using one character command !
Instead, using openevec package and evetestkit one can write test, which would look something like this
Why
The advantages are
How
First couple of commits are solely focused on removing viper from different parts of openevec. This is needed because throughout the code base viper is treated as shared state between multiple programs, like escript, changers for controller, eden and some parts of openevec. The problem is when you want to have eden as library, i.e. call functions from golang code you pretty much want to have configuration passed as parameter (or be wrapped around methods, like it's done in openevec) and you'd expect it to use those values, so it's easier to track, debug, understand the code (in modern editors you can just call the is referred), but unfortunately, in some places we just assume that some value is written in the configuration file and we just open the file from a "default" path and read its' value, which could be useful, and it certainly gives you better function readability (you don't need to pass parameters) but you don't know what this function depends on, and that actually can be very confusing. And in the scope of this PR it could lead to some weird behavior. Unfortunately, I couldn't remove everything, changers still rely on this, that's why we create configuration and write it to disc. Fortunately, we only consume configuration, so shouldn't be any trickery for now, but we need to get rid of it (see next section)
That actually also led to moving .sh and .csh templates from files to constants inside golang. Easier to debug it that way, plus I want to use config object, not read things from viper config saved somewhere.
Second high-level change is in
96517
commit is moving testcontexts to projects to avoid circular dependency cycles. Again, we don't want to rely on viper in evetestkit to create testcontext, we want it to create it from a configuration object we specify. So some jumps in hoops were needed. But that cleared the way to write golang only testThird major thing is backward compatibility with existing tests. Leaving burning ground behind, would be a barbaric thing to do. Because of changes introduced in configuration file (namely we write config now ourselves, without using any templates WSYSIWYG) broke some (all) tests, so last commit is about making CI/CD work :)
Important (caveats and hoops I had to jump through)
Is it bright future? (Future work)
I believe that with this patch the entry level to write eden tests drops significantly, now you'll be confused by golang code, but you'll be armed with all the tools and the community to improve the code and I do believe there's still big place to improve, but including new people into this will be significantly easier now (he said in naive hope).
Big things that we have to still do after we merge this (help wanted)
Mental health day offYours truly with some notes of graphomania