Added container-runners.py to test against different environments
parent
ea95fd208b
commit
035b80087a
@ -0,0 +1,18 @@
|
||||
# Tests for wait-for-it
|
||||
|
||||
* wait-for-it.py - pytests for wait-for-it.sh
|
||||
* container-runners.py - Runs wait-for-it.py tests in multiple containers
|
||||
* requirements.txt - pip requirements for container-runners.py
|
||||
|
||||
To run the basic tests:
|
||||
|
||||
```
|
||||
python wait-for-it.py
|
||||
```
|
||||
|
||||
Many of the issues encountered have been related to differences between operating system versions. The container-runners.py script provides an easy way to run the python wait-for-it.py tests against multiple system configurations:
|
||||
|
||||
```
|
||||
pip install -r requirements.txt
|
||||
python container-runners.py
|
||||
```
|
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Unit tests to run wait-for-it.py unit tests in several different docker images
|
||||
|
||||
import unittest
|
||||
from ddt import ddt, data
|
||||
import os
|
||||
import docker
|
||||
|
||||
client = docker.from_env()
|
||||
app_path = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..'))
|
||||
volumes = {app_path: {'bind': '/app', 'mode': 'ro'}}
|
||||
|
||||
@ddt
|
||||
class TestContainers(unittest.TestCase):
|
||||
"""
|
||||
Test multiple container types with the test cases in wait-for-it.py
|
||||
"""
|
||||
|
||||
@data(
|
||||
"python:3.5-buster",
|
||||
"python:3.5-stretch",
|
||||
"dougg/alpine-busybox:alpine-3.11.3_busybox-1.30.1",
|
||||
"dougg/alpine-busybox:alpine-3.11.3_busybox-1.31.1",
|
||||
)
|
||||
def test_image(self, image):
|
||||
print(image)
|
||||
command="/app/test/wait-for-it.py"
|
||||
container = client.containers.run(image, command=command, volumes=volumes, detach=True)
|
||||
result = container.wait()
|
||||
logs = container.logs()
|
||||
container.remove()
|
||||
self.assertEqual(result, 0, logs)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,2 @@
|
||||
docker>=2.0.0
|
||||
dtt>=1.2.0
|
Loading…
Reference in New Issue