-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix the Cheetah template renderer in salt.utils.templates, and unit-tests for Jinja, Cheetah, Mako, Genshi, wempy templates, #51718
Conversation
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.
@arizvisa Since this is a bug fix, can you please write a regression test? Also, There is a warning from the linter. Thanks. :)
Wrt this lint text (python3 incompat), how does one distinguish between calling The issue is that if the text is unicode, then |
Also, how do I write a regression test since it had never worked before (for 1 year at least)? Plus nobody has written tests for anything but Jinja? Do any of these other templates even work? |
Okay, good the lint test passed. I explicitly tested the Python version and explicitly called It seems hacky due to having to call private methods, but I'm not sure of a cleaner way to accomplish this since |
Any word on the questions for this too? Technically it's a new feature since the Cheetah template engine hasn't worked since |
Some of these tests need to be punted as the junkins one failed only because it couldn't connect to y'alls slack. |
(forced pushed due to rebase) |
Hmm..why is
|
Force-pushed due to rebase. |
Any word on this? |
@arizvisa Are you able to add a test that covers this change? |
Nah, there aren't any tests for any of the other template renderers (other than Jinja) to base it off of. This is why Cheetah hasn't been detected as non-working until using it. I don't do engineering as my primary job and so I don't have any way of justifying development on this to the company I work for. If there were testcases for any of the other renderers (other than Jinja), then I could do a search+replace for it, though. The patch is simple, however, and so essentially the test could be just a smoke-test which should've been implemented when the feature was added anyways. |
Are you guys using the "Needs Testcase" label yet? |
Re-based against master and force-pushed. |
Umm...wtf? |
Hah. okay. Updated PR to target the master branch. |
Well that was fun learning the syntax of all the available template types... |
@dwoz, @xeacott: Hey, good sirs. For the unit tests in this PR. It seems as if I need to import the related template modules into the test system since they haven't had any tests written for them before. I looked around in the documentation, but didn't see any references on how to properly do this. Is there some place to add them under tests/integration, or do I need to add them to one of the kitchen-related files to get them to be installed for testing? (edited to not end the last sentence with a preposition) |
Hey @Ch3LL, can you help me out with my question? I'm not sure what's the proper way to update kitchen or tests/integration to add the required modules for the testcases that i wrote for this PR. |
I have a couple versions of Python, but this is using a virtualenv and my PATH definitely pointing to it. This is on a fedora box (fc31), logs of everything that was done to make those commits are at https://gist.github.com/arizvisa/94b51853762b41a74d4479caa1460788 |
By this I mean the pre-commit command |
I see that you now also have conflicts so you will also need to rebase. |
kk, gladly. |
… call the correct methods depending on Python2 vs Python3.
….utils.test_templates since nobody has done this.
… all of the files under requirements/static/py* with the hopes that the unit-tests pick them up.
…empy) to all of the files under requirements/static/py* with the hopes that the unit-tests pick them up." This reverts commit 80bab2727399a0c1ae79b611d2615b9b1c84363c as apparently it didn't work.
… the requirements.txt file with the hope that the unit-tests will pick them up.
…empy) to the requirements.txt file with the hope that the unit-tests will pick them up." This reverts commit 00613c40d8775fb2ac75374092372471063b5a87 as apparently wempy's setup doesn't work properly on Python3.
… wempy) to the requirements/base.txt file with the hope that the unit-tests will pick them up properly.
…esulted in rendering with genshi for a test that should've been against wempy.
…ils.test_templates so it doesn't check for xml that wasn't defined in the template.
…i, Mako, wempy) to the requirements/base.txt file with the hope that the unit-tests will pick them up properly." This reverts commit 43f9a0a3f9dd3498cb3b136104d1810e271381fb.
… wempy) to the requirements/static/*.in files so that the unit-tests will pick them up properly (credit to @Ch3LL and @s0undt3ch).
… of the RenderTestCase class.
(force push due to rebase) |
Do you want a freeze of the requirements from the virtualenv in a gist? Its an old virtualenv so its likely not using the most recent of anything else other than |
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.
Thank You for putting up with me 😄
Nah, I'm good. Thank You. |
Thanks guys. Now for my etcd returner PR, heh. |
@s0undt3ch Double pyobjc requirement has sneaked in: https://github.com/saltstack/salt/blob/master/requirements/static/py2.7/darwin.txt#L135-L138 |
No worries, #55712 |
What does this PR do?
The author of the Cheetah template in salt.utils.templates forgot to explicitly call
str()
orunicode()
on the template in order to render it. This PR checks thetmplstr
parameter and uses it to distinguish which method to call so that templates using the Cheetah engine will work.What issues does this PR fix or reference?
This fixes issue #51711.
Previous Behavior
The Cheetah template engine did not work and would result in an exception due to the template not returning a string type.
New Behavior
Now the Cheetah template engine works and renders properly.
Tests written?
No.
Commits signed with GPG?
No.