-
-
Notifications
You must be signed in to change notification settings - Fork 448
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
Enable test tours only in demo instances. #213
Conversation
c995a5d
to
f08aa39
Compare
I prefer not to put test tours on demo, because you don't need to rely on demo data for tours. In fact, I postulate the contrary: don't depend ever on demo data for your tests. You might need to change your tests when on later versions demo data are changed. |
I'm sorry but I do not agree with you this time, I think that tests should use demo data, instead. Let me explain the benefits. Core tests depend on demo data, so not doing that will complicate your life and get no benefit (as tests in production instances will fail anyway). Creating the required records directly in the test takes almost the same amount of effort as doing that in demo data (in fact, a little bit more), but with the difference that demo data can be human-tested too, while the one created on tests not. Also, tour tests have to be added to |
template/module/demo/assets.xml
Outdated
<!-- Copyright <YEAR(S)> <AUTHOR(S)> | ||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> | ||
|
||
<openerp> |
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.
Should we instead use the new <odoo>
tag?
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.
Not sure when is the moment to update that... I think many people still develop for v8. Maybe when v10 comes out we can update this template more safely.
Totally agree with @yajo Tours are not necessary at all on production envs, only when they are on 👍 |
+1 |
We are not talking about the same topic. I'm telling about test tours, not about demo tours. Tests tours should be independent from demo data and to not be loaded with demo BDs, or you won't be able to test your website developments in any environment with real data. |
What @yajo is trying to do is: IF an asset include a tour which is for a test (frontend test) then it should be good have it in demo instead data due to the fact that this will not work without demo. Remember Tours are used for demo (show case) and tests (phantom) even if I am not pretty sure this PR technically is correct I like the idea conceptually. I give my +1 conceptually speaking. BUT if you want to test your environment with real data and then you need your Tour, put it in data and that's it depends of what kind of test you are doing there is a lot of tests that relly almost completelly in demo data with no posibility of run them in real data (which is conceptually incorreect BTW). I left open the discussion but this should be nice to hear from odoo itself. Now it is complex administer the test itself this concept introduce another variable in the already complex system of inheritances in tours. |
Usually tests depend on demo data, and they are enabled only in development environments. By enabling the asset in demo data, you remove them from production instances and thus increase their performance and security, losing no features.
f08aa39
to
4646d20
Compare
This PR is 6 months old and has 2 x 👍 from @oscarolar and @moylop260 . Can it be merged then? |
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.
I'm for a merge, I like this strategy personally. Sometimes a test is intrinsically linked with the demo data, particularly in the instance of acceptance tests - which is kind of what the tours are IMO.
I have already said that this will prevent to run JS tests in databases without demo, and that's not what we tend to do with normal tests. Why do it with JS ones? |
The tours in some instances could be an acceptance test, highly dependent on data that exists in a static known test set. In some instances this can't co-exist with live data without a lot of changes to make the test dynamic. Ok then so maybe this is an either, or scenario? Something where the demo should explicitly state only in the use of acceptance tests? |
Yeah, I think so that we can find both scenarios. |
Sending tours to end users in production websites impacts performance, which does not happen to normal tests. OTOH, if your test is for instance a shop buy & checkout tour, you expect that in page 1 of your shop there is the built-in iPad item, for example. Chances for that item not to be in page 1 if you create it in the Also, if you have to dedicate 30 minutes to create records in the And if your app does not behave correctly in production instances, then probably you should try to find the problem there, then create some demo data that imitates that problem, fix it, and test it using that demo data. An intermediate approach would be finding a way to load demo data in the |
There are lot of tests that doesn't require that level of specification, but what you want to test are flows. For example, you want to test the sale checkout process. It doesn't matter with which product you do the checkout (maybe only to be an specific type). You only need to make sure the process is completed and the returned page is the expected and so on. Even more, you should create your own data set before launching the JS tour. Following the example, if you create a product in the test itself, you already know its ID, and you can go to the website product page, locate the "Purchase" button, and continue the rest of the process. All of this without the need of demo data that changes very often from version to version and that makes you to change the test in the migrations with no benefit. |
Tours are UI tests. UI needs data. You search for "lalala" and have to check no product appears. You search for "ip" and have to check "ipod" and "ipad" appear. You click purchase on both and check that cart has 2 items, and that the amount is correct. Yes, you can do tests like those you say, but current tours are complex enough, and those tests would be much more scope-limited.
At least you don't need to maintain all the data creation code.
There are a few, but I already explained them, so I won't repeat myself. Let's simply wait until this hits -3 or +3 approvals and merge/close. 😁 |
OK, here is my 👎 One last point: maintaining data creation code makes traceable the error. Instead, when you use demo data, you have to check in 2 places if the test fails due to the data or due to the code itself. |
Just curious, how do deadlocks like this get resolved? Do we look for a net 3 votes on either end? |
I think so |
Blazing a trail then woot! I think your points bring up somewhat of a larger issue though @pedrobaeza. I specifically use demo data in From your comments, I am gathering that you do not like this practice, so I am wondering what you see as an an advantage when creating all the data locally vs using demo data that is already created (assuming the data is from the same module & you aren't creating some crazy demo dependency chain). |
OK, here are my reasons for not relying on demo data:
And this is all I remember right now, but I think it's enough, isn't it? |
I think @lasley is talking about demo data created in your addon. OTOH I have hit this problem before relying on core demo data, and it's not that hard to fix. You simply point to a different XMLID or copy old demo data in your addon. A matter of minutes. Much faster than creating your own chart of accounts (a real pain), or your own products with templates, variants, rates, prices, descriptions, etc., for example.
This is not a benefit but a workaround to not using demo data, that would be there always. Besides, this is not possible in HttpCase (used for tours), because you have to create data inside a
Makes more sense IMHO to find a way to reload the demo data file in the test.
You can call functions in data files too with
This can be a benefit, indeed, fixed too if we find a way to (re)load demo data at the start of a test. We'd have the benefits of both worlds. OTOH, this is not always the case. To make reliable tests, you need a reproducible environment. If anything fails in your production database, it is most likely that tests like those you say will fail too, because the problem will be (probably) that you have an untested scenario that happens in production but is not controlled in the test. That is unconnected to the matter here. Besides, this is less true in tours as I stated above, and there is the performance and bandwidth impact when we talk about tours.
Again, if we find how to reload demo data before the test, this would be fixed. OTOH, tests are run at install, and bare demo DBs are autospawned by bots, so this is not a very critical problem in our current scenario. |
Demo data can be problematic in some cases but also beneficial in other one.
When you create records into your tests you are not aware of potential constrains added by addons installed alongside your addon. In some case demo data solve potential failures when they are updated in the module adding the new constrains.
You are right, If your demo data create
It's partially true. In a lot of cases, you are not aware of addons installed alongside of the addons tested. It's always the case when tests are launched for all the addons in a directory at once (The MQT way) . In such a case, the order in which the tests are ran is defined by odoo and your tests will not extend the generic methods defined by the addons which it does not depend on.
A unittest is valid ONLY if it rely on a reproducible environment. In Odoo tests are designed to be run on an empty database. Even if a test is successful on an existing database, it can be a false positive if the data are modified in a way that hide a real issue. We heavily write unittest in our projects and it's true that the use of demo data can be painful in some cases. The problem when using demo data is to expect at the beginning of your tests that these data are in a specific state (initialized with specific values required by your test). A good practice is to enforce the values expected on your demo data in the setup of your tests to be sure that you are in a predictable state. We must also take care to avoid the creation of account.account in these demo data. But despite these limitations I continue to think that they offer more advantages than disadvantages? We also develop tests using memory records ( |
👍 |
Please can you use the GH review tool to approve/reject? It's easier to count that way 😉 |
@yajo done :) |
@yajo are you going to continue with this? It's need a refresh to latest versions |
Updated, this is ready to merge IMHO. |
Usually tests depend on demo data, and they are enabled only in development environments. By enabling the asset in demo data, you remove them from production instances and thus increase their performance and security, losing no features.
Usually tests depend on demo data, and they are enabled only in development
environments. By enabling the asset in demo data, you remove them from
production instances and thus increase their performance and security, losing
no features.
This follows what was discussed in OCA/web#402 (diff).
@Tecnativa @lasley