-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Migrating helm chart tests to helm_tests to prevent test DB init #32394
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
Conversation
potiuk
left a comment
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.
Loooks good - pending static checks fixes. Thanks for taking care of it :). Good idea with adding docstrings.
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.
Ah. Forgot it. Few more things are needed:
-
.dockerignore -> it should be added to not be excluded when Docker image is built (see
!tests,!kubernetes_tests). Probably also adding!docker_testsis a good idea. We do not run docker tests in breeze usually, but having them in CI image would be nice. -
you also need to add it to
VOLUMES_FOR_SELECTED_MOUNTSin docker_command_utils.py inbreeze- this way the folder will be also mounted when you run breeze command from local sources and you will be able to run the tests with latest sources when you are inside of breeze. Once you add it there, pre-commit will automatically update it in other places. -
probably
helm_testsis a better name after looking theere - it will be following the convention we already have there (docker_tests, kubernetes_tests)
|
All these points are valid. Making the changes to accommodate them |
still some "test-charts" in there. |
|
Woops. Looks like the IDE didnt catch it all. Made them manually |
|
Looks good - only static checks need to be fixed |
|
Not sure what the failure is. doesn't look related to the changes in this PR |
potiuk
left a comment
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.
Ah... I look at the checks and I was surprised, I have not seen Helm tests running. This
One more thing in selective checks (in breeze) we detect if Helm tests should be run:
FileGroupForCi.HELM_FILES: [
r"^chart",
r"^airflow/kubernetes",
r"^tests/kubernetes",
r"^tests/charts",
],
|
Yeah I have made the changes there right: https://github.com/apache/airflow/pull/32394/files#diff-c6f469502ccc758f597b999e8ab5aebeba2ae82fb6dc8166e7d8a25969bcf3faR129 |
|
There is one unnerving thing here as well - for some reason (and I have no idea why yet) I cannot see the "Unit tests: Helm" running in this PR. I will take a look after you fix all the static checks (and please rebase to latest main as well). |
|
Let me rebase and let the CI run once. I am not sure what is failing in the static checks. It is not so clear from logs |
Look at the output of it. It says exactly what it is - and prints you the command tat you should run to fix it. It's about changed |
|
Thought that was a false alarm. Checking it |
|
Ah.. Looking at the generated image, there is one more problem: This is why you had this "static check" failures. The image generation should not be needed, but there is one more place where "tests" / "charts" was used and now the list of allowed packages is wrong. |
|
You can switch to "swipe" view for the image generated and you will see what happened. |
|
BTW. It would also be great to filter out the |
|
For some reason, in your environment there is |
|
Oh, thanks for explaining so patiently. I could not see the folder because it was a hidden one! Silly me |
|
Now.... Coming back to unit tests that faik .. There seems to be coming from that chang. For example the first one determines the folder where chart is - this way: And after the tests were moved from the "tests/charts" to "helm-tests" - this is no longer working - because instead of looking for chart in "/opt/airflow/chart", it looks in "/opt/chart". So I think you need to also take a look at those tests that are failling and fix similar cases. |
|
BTW. And yeah, those are all (except pycache problems I kind of expected to see in this PR, so this is not really strange or unexpected :) |
Not a problem, I think there is a value in doing it, as you will learn quite a bit more on how things work in Airflow CI/Breeze/tests etc. - I know well things that are obvious to me as I worked on it for quite some time, aren't necessary obvious to others. I think the important thing is that YOU do not loose the patience, and will go through all that with open approach accepting that there are completely new things coming up that you have to learn about and where this "simple" PR will take quite some time to complete, and that things will be looking wrong at times. There are quite a few moving pieces here that make the whole system works - the fact that you have breeze where you can run it all manually, local venv, but also CI that uses breeze and reproducible enviroment make it much more complex (but not complicated) I think. Complex in the sense that there are multiple pieces of puzzle that work together and each has a role, but every single one is simple (once you know the role, and know that it is there at all). |
|
Thanks for the detailed mentoring, @potiuk |
|
Hopefully we should get a green CI now. I have run the tests in the whole module. All looks good 👍🏽 |
|
🤞 |
|
1 test left it seems :) |
|
@potiuk I think we are done with it now. Hopefully this time it will :) |
|
Clean build finally, @potiuk 🙂 |
| @pytest.fixture(scope="class", autouse=True) | ||
| def isolate_chart(request): | ||
| chart_dir = Path(__file__).parents[3] / "chart" | ||
| chart_dir = Path(__file__).parents[3] / "airflow" / "chart" |
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.
| chart_dir = Path(__file__).parents[3] / "airflow" / "chart" | |
| chart_dir = Path(__file__).parents[2] / "chart" |
This is how it should be. Having "airflow" hard-coded, you assume that that Airflow has been checked out as "airflow" directory, which does not necessarily needs to be true. This would cause subtle problems that could be very difficult to fix when you will be running the tests in loca environment.
You can easily checkout airflow with a different "folder" name or even create a work-tree if you work on different branches in the same directory where you keep several different versions of airflow checked out.
For example I have:
code
| - airflow -> here I mostly work on main
| - airflow-copy -> here I mostly work on v2-6-test branch or similar
The airflow-copy is a worktree of the "airflow" repoository - which means that I have one git repository but I can have different branches of the same repo checked out in different folders.
If you do parents[3] / "airflow" / "chart", what will happen is that when I run tests in "airflow-copy", it will copy chart from the "airflow" folder, which might be an old tag or branch. That would be extremely difficult test failure to trace in those cases.
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.
(Also in other places)
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.
Great point. Thanks for the explanation. I will make the changes :)
potiuk
left a comment
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.
The "chart" directory deterrmining needs to be fixed (see comment)
|
@potiuk has any new hook been added to check for re2 library over re? The static checks fail with the error.. |
|
🎉 🎉 |
…che#32394) --------- Co-authored-by: Amogh Desai <adesai@adesai-MBP16.local>


Seems that pytest will walk up looking for other conftest.py files beyond the tests/charts repo due to which the helm chart tests require DB init to be done which should not be the case. The tests inside
testsfinds the nearest_clear_dbfixture and continues to use it. We should not use that conftest fixture for helm chart tests.So likely then #28631 had side-effect of trying to clear db where it was not initialized
This PR moves the helm charts tests outside
tests/chartstotest-charts. Tested using the steps:pip install -e ."[devel]" --constraint https://raw.githubusercontent.com/apache/airflow/constraints-main/constraints-source-providers-3.8.txt^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rstor{issue_number}.significant.rst, in newsfragments.