Open davidkleiven opened 4 years ago
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
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"}'")
@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 :)
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.
@apdavison did you have a chance to try the postgres tests?
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
?