示例#1
0
 def test_instantiation_not_connected(self):
     thrown = False
     try:
         DockerEnvironmentDriver(self.temp_dir,
                                 docker_socket="unix:///var/run/fooo")
     except EnvironmentInitFailed:
         thrown = True
     assert thrown
示例#2
0
 def test_init_failed(self):
     thrown = False
     try:
         test = DockerEnvironmentDriver(
             self.temp_dir, docker_socket="unix:///var/run/fooo")
         test.init()
     except EnvironmentInitFailed:
         thrown = True
     assert thrown
示例#3
0
 def test_connect_failed(self):
     thrown = False
     try:
         test = DockerEnvironmentDriver(
             self.temp_dir, ".datmo", docker_socket="unix:///var/run/fooo")
         test.connect()
     except EnvironmentConnectFailed:
         thrown = True
     assert thrown
示例#4
0
    def setup_method(self):
        self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir)
        # Test the default parameters
        self.docker_environment_driver = \
            DockerEnvironmentDriver(self.temp_dir)

        random_text = str(uuid.uuid1())
        with open(os.path.join(self.temp_dir, "Dockerfile"), "wb") as f:
            f.write(to_bytes("FROM python:3.5-alpine" + "\n"))
            f.write(to_bytes(str("RUN echo " + random_text)))
示例#5
0
def check_docker_inactive(filepath):
    try:
        test = DockerEnvironmentDriver(filepath=filepath)
        test.init()
        definition_path = os.path.join(filepath, "Dockerfile")
        if platform.system() == "Windows":
            with open(definition_path, "wb") as f:
                f.write(to_bytes("FROM python:3.5-alpine" + "\n"))
                f.write(to_bytes(str("RUN echo hello")))
            test.build("docker-test", definition_path)
        return False
    except (EnvironmentInitFailed, EnvironmentExecutionError):
        return True
示例#6
0
 def setup_method(self):
     self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir)
     # Ensure the ".datmo" directory is there (this is ensured by higher level functions
     # in practice
     os.makedirs(os.path.join(self.temp_dir, ".datmo"))
     # Test the default parameters
     self.docker_environment_driver = \
         DockerEnvironmentDriver(self.temp_dir, ".datmo")
     self.image_name = str(uuid.uuid1())
     self.random_text = str(uuid.uuid1())
     self.dockerfile_path = os.path.join(self.temp_dir, "Dockerfile")
     with open(self.dockerfile_path, "wb") as f:
         f.write(to_bytes("FROM python:3.5-alpine" + os.linesep))
         f.write(to_bytes(str("RUN echo " + self.random_text)))
示例#7
0
 def setup_method(self):
     # provide mountable tmp directory for docker
     tempfile.tempdir = "/tmp" if not platform.system(
     ) == "Windows" else None
     test_datmo_dir = os.environ.get('TEST_DATMO_DIR',
                                     tempfile.gettempdir())
     self.temp_dir = tempfile.mkdtemp(dir=test_datmo_dir)
     # Test the default parameters
     self.docker_environment_manager = \
         DockerEnvironmentDriver(self.temp_dir)
     self.init_result = self.docker_environment_manager.init()
     random_text = str(uuid.uuid1())
     with open(os.path.join(self.temp_dir, "Dockerfile"), "a+") as f:
         f.write(to_unicode("FROM datmo/xgboost:cpu" + "\n"))
         f.write(to_unicode(str("RUN echo " + random_text)))