-
Notifications
You must be signed in to change notification settings - Fork 5
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
Packaged executable integration tests - initial integration tests with docker #391
Conversation
Can we keep the env variable simple? Just I'm also wondering if there's any self executing logic where in our code and if there is, we may want to out out bundled executable into the Note that in comparison to |
One should note that using Only if set, is it used. And you want to have a check that if set, and is empty string or an invalid path or path to non-executable, throw an exception. This could be done in |
I've modified pkSpawn to use the packaged executable if the pkgPath is set. I've been testing this on |
Tested it under Ubuntu and it works fine. So windows seems to be the problem here. |
According to https://nodejs.org/docs/latest-v16.x/api/process.html#processkillpid-signal. "On Windows, where POSIX signals do not exist, the signal argument will be ignored, and the process will be killed forcefully and abruptly (similar to 'SIGKILL'). See Signal Events for more details.". This might just be a Using |
As far I know windows does have signals. But in this case, you're right that windows does not support This becomes complicated, because we are using SIGTERM to perform graceful exit of the agent. There are equivalent windows events in https://stackoverflow.com/questions/2055753/how-to-gracefully-terminate-a-process#2055810. So we might have to find a way for nodejs to receive the equivalent of a graceful exit signal, and send that signal instead in our tests if we want it to also work on windows. |
According to this we may need to add some new handlers. We will then need to confirm the behaviour on windows by closing the window, ending via task manager and using
I can't find any info on what exactly happens when you do |
Yea that makes sense. Basically to deal with Windows, we have to also listen for So in our jest tests, when we want to signal graceful termination, we send it I think we could just make our graceful termination trigger upon all of these signals for the polykey agent:
Then change all of our tests that are using We should also have tests that test each signal for a given system. So on windows, we expect |
Sometimes |
Just some extra notes on what I've tried when testing the signal problem with windows.
|
I have a working bash script that allows us to run the docker image in a similar way to running the normal polykey command. This runs fine in the terminal. However I can't for the life of me get an output on the stdout and stderr when running the script via |
Problem was PBCAK... I wasn't allowing the process any time to output anything before the test ended. it's outputting the streams with no problem. |
The script works now. It should mostly be a drop in replacement for running the bin commands. One major difference is that the node path will have to be specified with the |
Testing this with the
|
The container has the root PID... I think you could resolve this by also mapping the host pids in the docker container, just like host network and host IPC? |
For 2., this is because the container is the |
For 3., see this https://hynek.me/articles/docker-signals/, we would need to make that this is correct, as our orchestration system will rely on signals. (AWS ECS). Also the linked article: https://engineeringblog.yelp.com/2016/01/dumb-init-an-init-for-docker.html |
With this and cutting out some un-needed expectations,the |
Things I need to look into changing.
|
And using |
Tomorrow separate out what can be merged into staging so we can do the testnet deployment procedures. Focus on |
All of the agent start tests are functional now. The tests rely on some env variables to be set.
Note that I've created a modified Still todo:
|
That seems like an improvement over
This should be
Are these needed? I was expecting the CI/CD to automatically set the docker image path inside the docker run script that is used by At the same time, the In this case, testing a separate pk executable, should just trigger automatically based on the existence of However I imagine that now our integration tests would be changed to run Kind of like: echo 'exec docker run ...' > ./tmp/docker-run.sh
chmod u+x ./tmp/docker-run.sh
PK_COMMAND='./tmp/docker-run.sh' npm test -- ./tests/bin
# In the ideal case, this should be possible
PK_COMMAND='docker run ...' npm test -- ./tests/bin |
I am not entirely convinced that some of the bin tests are not able to run via the integration? I think all the bin tests should be runnable for integration. Using Later we can have "docker" specific tests, but that's separate from Another issue is |
Regarding:
Before you do this, please verify with If there isn't, then we don't need to modify this, we can continue using |
Right now the two tests i'm skipping are
When using |
Can you copy paste the output of |
I think it's much simpler to just set an env variable for the docker image here than trying to meta-generate the script to contain it. Using |
pstree output.
|
d8078d3
to
c0cd81d
Compare
Commits have been cleaned up. |
Regarding the usage of There are 3 functions for executing things:
The Now the problem is that Furthermore, when using Therefore, if we are switching to using Instead any usage of We are using However as for the The simplest solution is to escape every space character when Something like: arg.replace(/ /g, '\\ ') |
Note that there could still be issues in the future, it's best to make sure that our test arguments doesn't use too many fancy stuff in the future to avoid problems. |
This might be a better escaping function:
It also escapes a few other special variables that may be interpreted specially when I just tested it with:
It works quite nicely to make sure it's all interpreted as a raw string. |
I'm consolidating all of the child_process spawning commands inside of I don't want to split this function between the two files and I'm not sure if it's a good idea to have the two files depend on each other. I could;
Not sure what to do here, I'm leaning towards 2. |
We're moving Future enhancement requires the |
This should allow for faster testing since we skip the CPU intensive keypair generation. Related #420
Also enabled `FF_NETWORK_PER_BUILD` flag for CI. Related #407
This will remove the container when it ends. #407
Disabling tests that don't work with docker for now. #407
`DOCKER_OPTIONS` env variable containing all the docker run parameters to make the test work is provided to the command. #410
…time The `runTestIfPlatform` commands will default to running if `PK_TEST_PLATFORM` is not set. #410
This is to key every major spawning command in one place in case we need to modify how we spawn using `ts-node`.
882516f
to
3affbca
Compare
Is is due to a compatability problems when using `shell: true` with `child_process.execFile`.
Ok, this should be good to merge now. all the tests should be passing. I haven't enabled the integration tests to check them for a little bit but they are passing locally so they should be passing there as well. |
Description
This PR modifies the
tests/bin
tests to target a packaged executable for the tests. This will be done by setting thepk_pkg_executable_path
as the path to the desired executable we wish to test. This should then apply all bin tests to this executable.The details are inside of issue MatrixAI/Polykey-CLI#10.
Issues Fixed
pkStdio
,pkExec
andpkSpawn
utils to target executables #410tests/bin/keys/reset.test.ts
andtests/bin/keys/renew.test.ts
stopping the PolykeyAgent #347Tasks
Given the scope of this PR, sub-tasks will be tracked with each issue.
pkStdio
,pkExec
andpkSpawn
utils to target executables #4103. Signal Handling for windows Polykey-CLI#13- addressed in new PR4. update tests to support win build Integration Tests for Windows Polykey-CLI#11- addressed in new PR5. update tests to support mac build Integration Tests for MacOS Polykey-CLI#12- addressed in new PRFinal checklist