MariaDB / MariaDB/feedback-plugin-backend

MDBF-424: Multiple problems when running the tests

Open
#5 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4
Forks
6
PR merge metrics
No merged PRs in 30d

Description

One should run tests from src/feedback/tests folder.

$ python manage.py test

However there are couple of problems:

1. Problem - missing alter grant

User has to have alter privilege on all tables

 ./manage.py test
Creating test database for alias 'default'...
Traceback (most recent call last):
  File "/home/anel/mariadb/feedback-plugin-backend/env/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/home/anel/mariadb/feedback-plugin-backend/env/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
    return self.cursor.execute(query, args)
  File "/home/anel/mariadb/feedback-plugin-backend/env/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/home/anel/mariadb/feedback-plugin-backend/env/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/home/anel/mariadb/feedback-plugin-backend/env/lib/python3.8/site-packages/MySQLdb/connections.py", line 254, in query
    _mysql.connection.query(self, query)
MySQLdb._exceptions.OperationalError: (1142, "ALTER command denied to user 'feedback'@'localhost' for table 'django_content_type'")

One need to update the privilege in docker/mariadb/create_database_user.py as it was the example for me which privilege user should have.

  • Observation
    After setting up the alter privilege obtained in 1.problem, we can see that database is created (since we have create priv on all tables), but we need priv on test_feedback_plugin - just notification about reason of having the privilege.
$ ./manage.py test
Creating test database for alias 'default'...
Got an error creating the test database: (1007, "Can't create database 'test_feedback_plugin'; database exists")
Type 'yes' if you would like to try deleting the test database 'test_feedback_plugin', or 'no' to cancel: yes
Destroying old test database for alias 'default'...
Got an error recreating the test database: (1044, "Access denied for user 'feedback'@'localhost' to database 'test_feedback_plugin'")
2. Problem - python 3.9 version of zoneinfo
$ ./manage.py test
Creating test database for alias 'default'...
Got an error creating the test database: (1007, "Can't create database 'test_feedback_plugin'; database exists")
Type 'yes' if you would like to try deleting the test database 'test_feedback_plugin', or 'no' to cancel: yes
Destroying old test database for alias 'default'...
System check identified no issues (0 silenced).
.....E
======================================================================
ERROR: feedback_plugin.tests.test_process_raw_data (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: feedback_plugin.tests.test_process_raw_data
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/home/anel/mariadb/feedback-plugin-backend/src/feedback_plugin/tests/test_process_raw_data.py", line 3, in <module>
    from zoneinfo import ZoneInfo
ModuleNotFoundError: No module named 'zoneinfo'


----------------------------------------------------------------------
Ran 6 tests in 0.062s

FAILED (errors=1)
Destroying test database for alias 'default'...

Instead one should use alternative module backports.zoneinfo

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running python manage.py test from src/feedback/tests and review the reported database errors. Inspect docker/mariadb/create_database_user.py for the test user's privileges and feedback_plugin/tests/test_process_raw_data.py for the zoneinfo import. Done means the test suite runs successfully with the documented MariaDB privileges and Python 3.8 environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
mariadb, python
Domain
databases, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.