Skip to content
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

Add testing framework for Django to ensure compatibility #7905

Closed
GuptaManan100 opened this issue Apr 20, 2021 · 7 comments
Closed

Add testing framework for Django to ensure compatibility #7905

GuptaManan100 opened this issue Apr 20, 2021 · 7 comments
Assignees
Labels
Component: Query Serving LFX Type: Enhancement Logical improvement (somewhere between a bug and feature)

Comments

@GuptaManan100
Copy link
Member

This issue is for tracking the addition of a comprehensive test suite to ensure compatibility with Django framework. For now, Vitess Framework Testing has minimal coverage for Django but we want to add a comprehensive test suite.

The Django docs can be used for this purpose in a very similar fashion to rails testing. The rails testing code is available at Rails Testing that uses the Rails Guides

@GuptaManan100 GuptaManan100 self-assigned this Apr 20, 2021
@GuptaManan100 GuptaManan100 added Component: Query Serving Type: Enhancement Logical improvement (somewhere between a bug and feature) labels Apr 20, 2021
@abhaykatheria
Copy link

abhaykatheria commented May 12, 2021

This seems really interesting. I have a couple of questions -

  • The current Django project doesn't have much functionality to it. Do we need to add more views and models to it ..?
  • Django creates a new test DB and rollbacks transactions of every test to make every test independent from others. Can we populate the test_db with the data from production DB and then run tests on it or run tests on the prod DB?(by prod DB I mean vitess's DB)

P.S: I am looking forward to contributing to this project under lfx mentorship program, So I wanted to make a POC before applying :)

@GuptaManan100
Copy link
Member Author

We do not care much about the view, but yes we want to add exhaustive tests for the model layer of django. The idea is to go through the guide of django regarding the model layer https://docs.djangoproject.com/en/3.2/topics/db/ and add tests for all the different values. For example, there a guide regarding the different field types, so to test it, we would create a model which has fields for all types and test that they work perfectly.

I don't think there is any specific requirement to create a test DB, we can use the production DB itself, the way the current test do.

@govindgoel
Copy link

govindgoel commented May 17, 2021

This is great, @GuptaManan100 you have provided insights regarding the project so my understanding is that we need to add tests for the model layer of Django. Is this understanding correct please do tell me.

I look forward to contribute to the project under the LFX mentorship program.

@Aniket118
Copy link

Hello @GuptaManan100 I have worked on a lot Django based project. I am looking forward to work on this project. Can you please guide me how can I contribute to it?
Is there any criteria?

@GuptaManan100
Copy link
Member Author

This project is meant for LFX program. You can contribute to Vitess or its framework-testing repository on other issues.

@Aniket118
Copy link

I have applied it from there can you tell how people will be working on this project? @GuptaManan100

GuptaManan100 pushed a commit to planetscale/vitess-framework-testing that referenced this issue May 31, 2021
This commit adds 'testApp' to the existing project and will be used for
creating further tests.

This commit also adds tests for creating, reading, updating, and
deleting django models.

This is work towards vitessio/vitess#7905

Signed-off-by: abhaykatheria <[email protected]>
abhaykatheria added a commit to abhaykatheria/vitess-framework-testing that referenced this issue Jun 1, 2021
some of their parameters.

This commit also adds model-baker as a requirement which
is used to create mock objects of model classes and facilitates
testing.

work towards vitessio/vitess#7905

Signed-off-by: Abhay Katheria <[email protected]>
abhaykatheria added a commit to abhaykatheria/vitess-framework-testing that referenced this issue Jun 1, 2021
This commit adds test for different django fields and
some of their parameters.

This commit also adds model-bakery as a requirement which
is used to create mock objects of model classes and facilitates
testing.

work towards vitessio/vitess#7905

Signed-off-by: abhaykatheria <[email protected]>
abhaykatheria added a commit to abhaykatheria/vitess-framework-testing that referenced this issue Jun 2, 2021
This commit adds test for different django fields and
some of their parameters.

This commit also adds model-bakery as a requirement which
is used to create mock objects of model classes and facilitates
testing.

work towards vitessio/vitess#7905

Signed-off-by: abhaykatheria <[email protected]>
abhaykatheria added a commit to abhaykatheria/vitess-framework-testing that referenced this issue Jun 2, 2021
This commit adds test for different django fields and
some of their parameters.

This commit also adds model-bakery as a requirement which
is used to create mock objects of model classes and facilitates
testing.

work towards vitessio/vitess#7905

Signed-off-by: abhaykatheria <[email protected]>
abhaykatheria added a commit to abhaykatheria/vitess-framework-testing that referenced this issue Jun 2, 2021
This commit adds test for different django fields and
some of their parameters.

This commit also adds model-bakery as a requirement which
is used to create mock objects of model classes and facilitates
testing.

work towards vitessio/vitess#7905

Signed-off-by: abhaykatheria <[email protected]>
abhaykatheria added a commit to abhaykatheria/vitess-framework-testing that referenced this issue Jun 2, 2021
This commit adds test for different django fields and
some of their parameters.

This commit also adds model-bakery as a requirement which
is used to create mock objects of model classes and facilitates
testing.

work towards vitessio/vitess#7905

Signed-off-by: abhaykatheria <[email protected]>
abhaykatheria added a commit to abhaykatheria/vitess-framework-testing that referenced this issue Jun 2, 2021
This commit adds test for different django fields and
some of their parameters.

This commit also adds model-bakery as a requirement which
is used to create mock objects of model classes and facilitates
testing.

work towards vitessio/vitess#7905

Signed-off-by: abhaykatheria <[email protected]>
abhaykatheria added a commit to abhaykatheria/vitess-framework-testing that referenced this issue Jun 2, 2021
This commit adds test for different django fields and
some of their parameters.

This commit also adds model-bakery as a requirement which
is used to create mock objects of model classes and facilitates
testing.

work towards vitessio/vitess#7905

Signed-off-by: abhaykatheria <[email protected]>
abhaykatheria added a commit to abhaykatheria/vitess-framework-testing that referenced this issue Jun 2, 2021
This commit adds test for different django fields and
some of their parameters.

This commit also adds model-bakery as a requirement which
is used to create mock objects of model classes and facilitates
testing.

work towards vitessio/vitess#7905

Signed-off-by: abhaykatheria <[email protected]>
abhaykatheria added a commit to abhaykatheria/vitess-framework-testing that referenced this issue Jun 2, 2021
This commit adds test for different django fields and
some of their parameters.

Image field is not tested because of issues with discovery of
pillow by django.

This commit also adds model-bakery as a requirement which
is used to create mock objects of model classes and facilitates
testing.

work towards vitessio/vitess#7905

Signed-off-by: Abhay Katheria <[email protected]>
abhaykatheria added a commit to abhaykatheria/vitess-framework-testing that referenced this issue Jun 2, 2021
This commit adds test for different django fields and
some of their parameters.

Image Field is not tested due to issues with pillow installation.

This commit also adds model-bakery as a requirement which
is used to create mock objects of model classes and facilitates
testing.

work towards vitessio/vitess#7905

Signed-off-by: Abhay Katheria <[email protected]>
abhaykatheria added a commit to abhaykatheria/vitess-framework-testing that referenced this issue Jun 2, 2021
This commit adds test for different django fields and
some of their parameters.

This commit also adds model-bakery as a requirement which
is used to create mock objects of model classes and facilitates
testing.

work towards vitessio/vitess#7905

Signed-off-by: Abhay Katheria <[email protected]>
GuptaManan100 pushed a commit to planetscale/vitess-framework-testing that referenced this issue Jun 7, 2021
* Django field testing

This commit adds test for different django fields and
some of their parameters.

This commit also adds model-bakery as a requirement which
is used to create mock objects of model classes and facilitates
testing.

work towards vitessio/vitess#7905

Signed-off-by: Abhay Katheria <[email protected]>

* Added deps for pillow in docker file

* Added separate run statement for deps required by pillow which needs to be persistent and updated the url for django fields guide
@abhaykatheria
Copy link

The framework testing of Django's compatibility is completed as per the Django's guide on model layer. Unsharded testing works with both v3 and gen4 planner, but the sharded tests only work with the gen4 planner and fail on the v3 planner. At present, the vttestserver image is based on the v3 planner and hence the sharded tests are failing in Github actions. The setting up of vschema and sequences is done as described in vitess docs and is inspired by rails6 testing.
The pull requests that solved this issue are -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Query Serving LFX Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

No branches or pull requests

4 participants