Runs given test. Returns true on success, based on exit code.
(self)
| 776 | return self.deadline is not None and time.time() > self.deadline |
| 777 | |
| 778 | def run(self): |
| 779 | """Runs given test. Returns true on success, based on exit code.""" |
| 780 | self.deadline = time.time() + self.suite.timeout_minutes * 60 |
| 781 | test_with_docker = self.test_with_docker |
| 782 | suite = self.suite |
| 783 | envs = ["-e", "NUM_CONCURRENT_TESTS=" + str(test_with_docker.parallel_test_concurrency)] |
| 784 | for k, v in sorted(suite.envs.items()): |
| 785 | envs.append("-e") |
| 786 | envs.append("%s=%s" % (k, v)) |
| 787 | |
| 788 | self.start = time.time() |
| 789 | |
| 790 | # io-file-mgr-test expects a real-ish file system at /tmp; |
| 791 | # we mount a temporary directory into the container to appease it. |
| 792 | tmpdir = tempfile.mkdtemp(prefix=test_with_docker.name + "-" + self.name) |
| 793 | os.chmod(tmpdir, 0o1777) |
| 794 | # Container names are sometimes used as hostnames, and DNS names shouldn't |
| 795 | # have underscores. |
| 796 | container_name = test_with_docker.name + "-" + self.name.replace("_", "-") |
| 797 | |
| 798 | container = test_with_docker._create_container( |
| 799 | image=test_with_docker.image, |
| 800 | name=container_name, |
| 801 | extras=[ |
| 802 | "-v", tmpdir + ":/tmp", |
| 803 | "-u", str(os.getuid()) |
| 804 | ] + envs, |
| 805 | logdir=self.name, |
| 806 | logname="log-test-" + self.suite.name + ".txt", |
| 807 | entrypoint=["/mnt/base/entrypoint.sh", "test_suite", suite.name]) |
| 808 | |
| 809 | test_with_docker.containers.append(container) |
| 810 | test_with_docker.monitor.add(container) |
| 811 | try: |
| 812 | return test_with_docker._run_container(container) |
| 813 | except: |
| 814 | return False |
| 815 | finally: |
| 816 | logging.info("Cleaning up containers for %s" % (suite.name,)) |
| 817 | test_with_docker._stop_container(container) |
| 818 | if test_with_docker.cleanup_containers: |
| 819 | test_with_docker._rm_container(container) |
| 820 | |
| 821 | |
| 822 | if __name__ == "__main__": |
nothing calls this directly
no test coverage detected