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 support for MySQL and MariaDB #388

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

davidkleiven
Copy link

I would like to use Sumatra with MySQL backend (the reason why I can't use PostGres is that central IT where I work only want to have MySQL databases on their servers). I added a patch that allows you use MySQL as backend. By testing it locally it seems to work. Would this be an interesting add-on for the sumatra project?

I am happy to write more rigorous tests, but in that case: Should it be a separate file that is basically copy of tests/system/test_postgres.py?

@coveralls
Copy link

coveralls commented Feb 20, 2020

Coverage Status

Coverage decreased (-0.07%) to 69.657% when pulling 42842f4 on davidkleiven:mysqlSupport into 99503e2 on open-research:master.

@davidkleiven davidkleiven changed the title WIP: Add support for MySQL and MariaDB Add support for MySQL and MariaDB Feb 22, 2020
@apdavison
Copy link
Contributor

Many thanks for this contribution. For the sake of maintainability, I would appreciate some tests.

I think your suggestion of basing this on tests/system/test_postgres.py is a good one. Note that you will also need to create a Dockerfile to run the MySQL test instance, along the lines of test/system/fixtures/Dockerfile.postgres

@apdavison apdavison added this to the 0.8 milestone Feb 24, 2020
@apdavison apdavison self-assigned this Feb 24, 2020
@davidkleiven
Copy link
Author

Ok, I will try that. @apdavison How does one actually run those tests? I tried to run the postgres tests by executing

docker build -t postgresql_test - < fixtures/Dockerfile.postgres
python test_postgres.py

The python version is 3.6.9.
Then I get the error message

docker.errors.APIError: 400 Client Error: Bad Request ("b'{"message":"starting container with non-empty request body was deprecated since API v1.22 and removed in v1.24"}'")

@davidkleiven
Copy link
Author

@apdavison I created a docker file that builds e.g. the command

docker build -t mysql_test - < fixtures/Dockerfile.mysql

runs fine. However, when I then try to run python test/system/test_mysql.py I get the following output

/tmp/tmpm07b7f0z/sumatra_exercise
Create repository
Add main file
Commit main file
Set up a Sumatra project
Traceback (most recent call last):
  File "/home/davidkl/.local/lib/python3.6/site-packages/sarge/__init__.py", line 655, in run
    self.process = p = Popen(self.args, **self.kwargs)
  File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'smt': 'smt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test/system/test_mysql.py", line 115, in <module>
    run_test(*step[1:])
  File "/home/davidkl/Documents/sumatra/test/system/utils.py", line 204, in run_test
    p = run(command)
  File "/home/davidkl/Documents/sumatra/test/system/utils.py", line 60, in run
    return sarge.run(command, cwd=working_dir, stdout=sarge.Capture(timeout=10, buffer_size=1))
  File "/home/davidkl/.local/lib/python3.6/site-packages/sarge/__init__.py", line 1462, in run
    p.run(input=input, async_=async_)
  File "/home/davidkl/.local/lib/python3.6/site-packages/sarge/__init__.py", line 1071, in run
    self.run_node(node, input=input, async_=False)
  File "/home/davidkl/.local/lib/python3.6/site-packages/sarge/__init__.py", line 1187, in run_node
    result = getattr(self, method)(node, input, async_)
  File "/home/davidkl/.local/lib/python3.6/site-packages/sarge/__init__.py", line 1333, in run_command_node
    node.cmd.run(input=input, async_=async_)
  File "/home/davidkl/.local/lib/python3.6/site-packages/sarge/__init__.py", line 658, in run
    raise ValueError('Command not found: %s' % self.args[0])
ValueError: Command not found: smt

I tested and the same happens for the test_postgressql.py (after I did a minor change to get passeed the error mentioned above, since this PR is on MySQL I did not include that change here). I am a newcommer when it comes to docker so I don't know how I can actually run the tests and check that it works. Any help is appreciated :)

@apdavison
Copy link
Contributor

It's been some time since I ran the postgres tests (they are not run by the CI system). I'll try to find time to look at this later this week. Please ping me if you haven't heard anything by next week.

@davidkleiven
Copy link
Author

@apdavison did you have a chance to try the postgres tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants