-
Notifications
You must be signed in to change notification settings - Fork 84
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
Python function test #71
Comments
@LucasRoesler would you have any links etc that you can share on this for @vidz1979 ? @vidz1979 please edit and fill out the whole issue template |
@alexellis i just tested this, it is a bug, I can replicate it and the cause was this 79b444b FROM build as test
ARG TEST_COMMAND=tox
ARG TEST_ENABLED=true
RUN [ "$TEST_ENABLED" = "false" ] && echo "skipping tests" || eval "$TEST_COMMAND" We (me) moved the test command into a separate Docker stage, but because the final stage doesn't depend on it, it is pruned from the build and never executes. If you, for example, force FROM test as ship instead of FROM build as ship I verified that this works. |
I was thinking about this a bit. I am not sure what the best option is here. If the goal is a small final image, running tests is going to work against us, because the env will need all dev time dependencies. one option that we could use, is to install everything in the |
I confirm that doing |
Running into the similar issue using the I find it intriguing we're running into this issue more recently although the apparent root cause is old - Docker multi stage build ignoring intermediate stages, caused by From what I understand @LucasRoesler proposes a python specific sandboxing solution. If we could come up with a more generic solution, folks in other langs for openfaas could benefit too. |
Just chiming in that |
In terms of generic solutions. Obviously the "disable buildkit" works for now, but you can imagine this might eventually be deprecated, I am pretty sure it is already the default builder for most installations now. I hate depending on this or even needing to tell every new user that they have to disable a defaultndocker behavior to get th expected behavior. For the solution to be fully generic for any language and avoid including the test later in the final image, it means we have to do something via docker itself. The only approach I see is to allow passing a build target to the Every other solution I can think of would be highly language specific. |
I ended up going for a language specific solution to not ship test related assets, for the same reason I didn't think it was good UX having to pass (and document) I'll have a look into using build target and implications to UX. Thanks. |
@ccfontes if we get some input from @alexellis i would be happy to add a new flag to the The python specific alternative that i can think of is to install the whole env in the build layer, run the tests, then install the env again into a |
Does it makes sense to go with this solution? |
@alexellis If you have an idea why it makes sense or doesn't make sense to go with #71 (comment) solution, it would be helpful to state that idea, would you agree? |
I misread, and very sorry for the misunderstanding. 🙏 I'm OK with @LucasRoesler's solution. Doing the same in faas-bb dockerfile (kind of). It makes a language specific cleanup of the test deps. |
@ccfontes and @alexellis i has pushed a PR #73 |
My actions before raising this issue
Expected Behaviour
Using python3-http template, there is a file
handler_test.py
. Modified it to not pass the test:I've built the function and I was expecting to get an test error. Did a local run and also got no test errors.
Current Behaviour
I didn't get any type of test errors.
Possible Solution
Steps to Reproduce (for bugs)
Context
Testing code is essential. Providing a solid way to write and run tests is a must.
Your Environment
faas-cli version
):CLI:
commit: f72db8de657001a2967582c535fe8351c259c5f6
version: 0.16.17
Docker version
docker version
(e.g. Docker 17.0.05 ):Docker Community 24.0.7
Are you using Docker Swarm or Kubernetes (FaaS-netes)?
Kubernetes
Operating System and version (e.g. Linux, Windows, MacOS):
Linux Ubuntu
Code example or link to GitHub repo or gist to reproduce problem:
Other diagnostic information / logs from troubleshooting guide
Next steps
You may join Slack for community support.
The text was updated successfully, but these errors were encountered: