-
Notifications
You must be signed in to change notification settings - Fork 203
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
Enh/test remove ssh #1334
Enh/test remove ssh #1334
Conversation
Introducing a new unit (or better integration) test about removing a snapshot via SSH because there wasn't something like this before. I need this test because of the _rsync incompatibility problem_ (#1247). It is intended to fail with a newer rsync version and to pass with an old one. I checked it with _Debian testing_ (_rsync 3.2.6_) and _Debian 11 stable "bullseye"_ (_rsync 3.2.3_). The target of the test is the method `snapshots.Snapsthots.remove()`. As I explain there in the doc string the removing method seems a bit wired to me. But maybe there are good reasons for this so I didn't modified that behaviour. But I added a check for the rsync return code. Before my PR it was ignored and had no effect when rsync failed. My testing class directly derive from `unittest.TestCase` and do not use one of the classes in `generic.py`. The latter isn't an elegant solution but this wasn't the reason why I avoided there use. I needed to introduce blanks in the path names to trigger the "rsync problem I need". I collected all the code fragments from the `setUp()` etc methods in `generic.py` and build my own _helper_ methods. I copied and refactored that code into private methods of my testing class. I'm sure we can improve that in the future and find a more _generic_ solution to reuse that fragments for other unittests also. But it is IMHO a good start and also helped me to improve my understanding of BIT internals. Sorry I tried to resist but I did some code formating. I also added some docstrings while trying to understand some details. Related: #1247
What is maybe important to be added to the CHANGELOG:
I'm sure you can find a better way to phrase this. Maybe it will cause unexpected side effects in the future. So the terms "remove" and "rsync" are IMHO important here if someone search the CHANGELOG. |
Based on our discussion on the mailing list I modified the code. Now It is not a perfect solution of course but IMHO a good compromise to make my unittest testable and not breaking to much other things. If and how the GUI should react on that return value of IMHO we can merge that now so I can step further on my primary #1247 . |
Very helpful PR! I will do a small code "review" the next days but am not able to runtime-test it (I am not using SSH ATM) so I hope @emtiu could do this (uses SSH AFAIR) |
@buhtzz Could you give me please some more background (I am not into the
If the test result depends on the installed Just to be sure:
Background of my questions: If we merge this change than there is a certain risk to get new issues until the support for new The shorter this time of period is the better - if it may take longer it could be better to send a single PR instead (containing this unit test + the changes to support the new
Changing the semantics of an existing method may have severe impact on existing functionality I can try to double-check this but I need to know:
What does happen currently in the GUI if an exception is raised in I want to assure that the PR does not change the behavior of the GUI (eg. because the newly introduced return value is ignored for now but the thrown exception in the old code was handled and a message box shown eg. via a registered error listener)? |
Your questions are complex. I'm not sure I got every point. To Arch:
Very complex. Some things are explained in the manpage or changelog. The whole picture is about how arguments are send to the remote machine via SSH. In the past you needed to escape blanks But the new (more modern and compared to other tools usual) behavior was introduce round about rsync 3.0.0 as optional but default with 3.2.4. To fix this in short: We add the option
I hope so. But I suspect Arch does it only with stable versions of software.
Correct.
The unittests are the PoC. That is why I implement them.
Hard to say because it seems to me that most of the SSH situations are not covered by unittests. Currently I try to understand how backupPermissions() work to create a SSH unittest for it.
Because we only release a new stable version after the rsync thing is totally fixed I don't see that problem. It is an advantage if the tests fail in such situations and not a problem. It is a bigger problem if people do use that rsync-incompatible code without being informed about problems it cause.
Absolutely. 🗡️
I also thought about it. But because of a lot of missing unittests it will be impossible to review. Again: The new introduced unittests (there come more) don't hurt because they exist only in upstream/unstable/pre-release version of BIT. If there really is a distro out there shipping BIT from
I haven't change the semantic but introduced one. The method was silent before.
The method didn't raised something or returned something before. It was silent. It only produced a WARNING in the logging output when the rsync call failed. And the latter was ignored and never checked by the whole application.
It does not.
There was no exception in the "old code". There was nothing in the old code. See the current master branch
I only found that problem because of my manual-testing-protocol and checking the terminal output. |
@buhtzz THX for clarifying my questions, I think I do now understand intentions.
not necessarily, they are quite eager to use new versions from Git (even not released) and they are already using
Agreed,
OK, so the fix is clear but the the main efforts are implementing missing unittests to avoid introducing another bug.
If have done a little review of the code and merged it into a local branch (result: builds and unit tests succeed). I just have added review questions to four code locations that were unclear to me, could you please check this (esp. if the THX for improving the documentation and code coverage! |
Dear Jürgen, Sorry for the debug-prints. I need to be more diligent here! No 🐝 -stamp for this. My intention was hard to explain in the first place because test driven development is so natural to me as breathing. In the consequence I often miss the correct words to explain it. The BIT project is a bit different but in other (more fresh) projects I often write the test first and implement the feature after that. And all this will become more easier to maintain with full access to the repo and deciding about a branching model. EDIT
I couldn't find review comments in the files. Mayb I did something wrong with the GitHub frontend? |
No pushing. Just a sidenote. 😄 I have a follow-up PR in the back. Beside what it adds (a new test case) it reorganize and clears up a bit the private methods (starting with |
I can see my review comments if I scroll up here in the PR, if they don't appear in your front-end this would be a bug of Github.
My review comments are not blocking this PR, I think it helps me to understand non-obvious parts and gives us the chance to reconsider implementations. BTW: If you want you could add the commits of the "follow-up PR" to this PR (if they belong together) |
Mhm... Did you mean in the "Files canged" tab? I suspect the problem sits in front of my own monitor but I can't see any comment there. 😃 Can you name file and a line number as an example please?
A bit to much at the current point. There are also other PRs open. |
Abstract
Introducing a new unit (or better integration) test about removing a snapshot via SSH because there wasn't something like this before. I need this test because of the rsync incompatibility problem (#1247). It is intended to fail with a newer rsync version and to pass with an old one. I checked it with Debian testing (rsync 3.2.6) and Debian 11 stable "bullseye" (rsync 3.2.3).
Details
Target
The target of the test is the method
snapshots.Snapsthots.remove()
. As I explain there in the doc string the removing method seems a bit wired to me. But maybe there are good reasons for this so I didn't modified that behaviour.But I added a check for the rsync return code. Before my PR it was ignored and had no effect when rsync failed.
Unittest
My testing class directly derive from
unittest.TestCase
and do not use one of the classes ingeneric.py
. The latter isn't an elegant solution but this wasn't the reason why I avoided there use. I needed to introduce blanks in the path names to trigger the "rsync problem I need".I collected all the code fragments from the
setUp()
etc methods ingeneric.py
and build my own helper methods. I copied and refactored that code into private methods of my testing class. I'm sure we can improve that in the future and find a more generic solution to reuse that fragments for other unittests also. But it is IMHO a good start and also helped me to improve my understanding of BIT internals.PEP8 and docstrings
Sorry I tried to resist but I did some code formating. I also added some docstrings while trying to understand some details.