Just an example...
Details
Details
Diff Detail
Diff Detail
- Lint
Lint Skipped - Unit
Unit Tests Skipped
Comment Actions
Would it be worth updating the diff to "post D836"? It will IMO serve the PoC better then.
| Lint Skipped |
| Unit Tests Skipped |
Would it be worth updating the diff to "post D836"? It will IMO serve the PoC better then.
| 1 | name: test httpd docker image | ||||
|---|---|---|---|---|---|
| 2 | | ||||
| 3 | environment: | ||||
| 4 | rpm: | ||||
| 5 | - docker | ||||
| 6 | - python2-pytest | ||||
| 7 | - python-pip | ||||
| 8 | | ||||
| 9 | actions: | ||||
| 10 | - bash: | ||||
| 11 | command: pip install xunitparser | ||||
| 12 | | ||||
| 13 | - bash: | ||||
| 14 | command: systemctl start docker | ||||
| 15 | | ||||
| 16 | - bash: | ||||
| 17 | command: docker pull httpd | ||||
| 18 | | ||||
| 19 | - bash: | ||||
| 20 | command: py.test dockertest.py --junitxml=${artifactsdir}/output.xml | ||||
| 21 | | ||||
| 22 | - xunit: | ||||
| 23 | file: ${artifactsdir}/output.xml | ||||
| 24 | agregation: allpass | ||||
| 25 | export: test_output | ||||
| 26 | | ||||
| 27 | | ||||
| 28 | - name: report | ||||
| 29 | resultsdb: | ||||
| 30 | results: ${test_output} | ||||
| Property | Old Value | New Value |
|---|---|---|
| File Mode | null | 100755 |
| 1 | #!/usr/bin/env python | ||||
|---|---|---|---|---|---|
| 2 | | ||||
| 3 | | ||||
| 4 | from time import sleep | ||||
| 5 | import os | ||||
| 6 | import pytest | ||||
| 7 | import subprocess | ||||
| 8 | | ||||
| 9 | def system(cmd): | ||||
| 10 | """ | ||||
| 11 | Invoke a shell command. | ||||
| 12 | :returns: A tuple of output, err message, and return code | ||||
| 13 | """ | ||||
| 14 | print cmd | ||||
| 15 | | ||||
| 16 | ret = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, | ||||
| 17 | stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) | ||||
| 18 | out, err = ret.communicate() | ||||
| 19 | return out, err, ret.returncode | ||||
| 20 | | ||||
| 21 | | ||||
| 22 | class TestDockerHttpdSimple(object): | ||||
| 23 | def setup_method(self, test_method): | ||||
| 24 | out, err, ret = system('docker run -d -p 80:80 httpd') | ||||
| 25 | sleep(1) # wait for container | ||||
| 26 | self.container = out | ||||
| 27 | | ||||
| 28 | def teardown_method(self, test_method): | ||||
| 29 | out, err, ret = system('docker rm -f %s' % self.container) | ||||
| 30 | | ||||
| 31 | def test_listening_port80(self): | ||||
| 32 | out, err, ret = system("netstat -lnt | awk '$6 == \"LISTEN\" && $4 ~ \"80$\"'") | ||||
| 33 | assert out != "" | ||||
| 34 | | ||||
| 35 | def test_working_http(self): | ||||
| 36 | out, err, ret = system("curl localhost") | ||||
| 37 | assert ret == 0 | ||||
| 38 | | ||||
| 39 | | ||||
| 40 | @pytest.mark.usefixtures('setup') | ||||
| 41 | class TestDockerHttpdVolumes(object): | ||||
| 42 | | ||||
| 43 | @pytest.fixture | ||||
| 44 | def setup(self, tmpdir): | ||||
| 45 | out, err, ret = system('docker run -d -p 80:80 -v %s/:/usr/local/apache2/htdocs/ httpd' % tmpdir) | ||||
| 46 | sleep(10) # wait for container | ||||
| 47 | self.container = out | ||||
| 48 | | ||||
| 49 | def teardown_method(self, test_method): | ||||
| 50 | out, err, ret = system('docker rm -f %s' % self.container) | ||||
| 51 | pass | ||||
| 52 | | ||||
| 53 | def test_working_volume_hosting(self, tmpdir): | ||||
| 54 | system("chcon -Rt svirt_sandbox_file_t %s" % tmpdir) | ||||
| 55 | system("chmod +r -R %s" % tmpdir) | ||||
| 56 | system("chmod +x %s" % tmpdir) | ||||
| 57 | | ||||
| 58 | out, err, ret = system("echo -n works > %s/index.html" % tmpdir) | ||||
| 59 | out, err, ret = system("curl localhost/index.html") | ||||
| 60 | assert out == "works" | ||||