-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Separate unit tests for index types #580
Conversation
357f14b
to
2de70a9
Compare
The strategy makes sense and normalizing the tests like this must be the key strategy to avoid duplication and arbitrary symmetry breaking (i.e. having different tests for different configurations). Thanks for addressing this @jsmassa ! I am not familiar enough with the attribute-ref mismatches. For schema settings I would suggest to always assume the stricter requirements ( Also, is there still a reason to have attribute-refs only optionally? Edit: Yes, of course, because they depend on schema-on-write. But does this mean that when we always provide a schema all tests can be run with attribute-refs? |
A related serious problem I just stumbled over in #332 is that many tests use the same database, which worked so far for the memory database because the connections were not (properly) shared. It would be good if the db Edit: I have solved this there for now by manually duplicating the connections for the tests. |
The schema isn't really a problem. Yes, we can always add a schema, but we could also only add it when required. That doesn't make much of a difference, I think. |
1 similar comment
The schema isn't really a problem. Yes, we can always add a schema, but we could also only add it when required. That doesn't make much of a difference, I think. |
Could we just grab max-eid at the beginning of the tests and use this as the offset? |
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.
Looks good to me. Nice work!
This is approximately how I did it for the attribute reference tests. Some of the tests used specific input datoms though in addition to the expected output datoms, so the input had to be manipulated as well. This lead me to write some helper functions to shift collections of datoms according to the amount of the system entity datoms. So far, there are also separate functions to shift the value as well which is needed for attributes with reference value type. Of course, this can be made simpler with a more complex helper function detecting when the value is a reference and has to be shifted. In some instances there might not be a way around using functions to shift the entity IDs to the correct values, but I would say that in the end, a database user will not care about which ID an entity gets allocated inside the database or if the attributes are saved as references or keywords. This is why I think that, ideally, we should avoid checking those details for high-level functions like I would say that the strategies I used for the attribute reference tests in |
I agree that we should not overfit to specific eids and rewrite tests to not rely on them in general is the right way forward. |
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.
👍
* separate index type tests * Do not use tools/unittest * Remove focused flag * Remove unnecessary ssh bits
Addresses #520
Turns all default values for a database into dynamic vars, so they can be set in
tests.edn
to test specific information.The idea is to use the default configuration for all tests, so each test has to be written only once.
Problematic with this strategy are
:attribute-refs?
because the entity IDs are shifted and depending on the function used either keyword or eids are returned, and:schema-on-write
because it needs a schema to be transacted, which means that here entity IDs are also shiftedFor these cases, we would need some kind of translation, similar to the way it is done in the test/datahike/test/attribute-refs test namespaces. If possible, I would like to get rid of these test namespaces as they only contain a subset of the tests and are cumbersome to maintain.
Also, we would need to rewrite a lot of the tests to not check for the entity id but for example run queries as it is already done in some updated tests
Unproblematic, however, are config options such like
:store-backend
and:keep-history?
Please, tell me if this strategy makes sense or if there is some problem with it that I have overlooked.
I am also interested to hear which config options you think should be tested, or which combinations you think would make sense.