Exemplo n.º 1
0
 def assertMsgIsCorrect(msg, command):
     a = DockerApp("a", "a", image="ubuntu:14.04", command=command)
     b = FileDROP("b", "b")
     a.addOutput(b)
     with DROPWaiterCtx(self, b, 100):
         a.execute()
     self.assertEqual(msg.encode("utf8"), droputils.allDropContents(b))
Exemplo n.º 2
0
    def test_additional_bindings(self):

        # Some additional stuff to bind into docker
        tempDir = tempfile.mkdtemp()
        tempFile = tempfile.mktemp()
        with open(tempFile, "w") as f:
            f.write("data")

        # One binding specifies the target path in the container, the other doesn't
        # so it defaults to the same path
        a = DockerApp(
            "a",
            "a",
            image="ubuntu:14.04",
            command="cp /opt/file %s" % (tempDir, ),
            additionalBindings=[tempDir,
                                "%s:/opt/file" % (tempFile, )],
        )
        a.execute()

        # We copied the file into the directory, but since in the container the
        # file was called "file" we'll see it with that name in tempDir
        self.assertEqual(1, len(os.listdir(tempDir)))
        with open(os.path.join(tempDir, "file")) as f:
            data = f.read()
        self.assertEqual("data", data)

        # Cleanup
        os.unlink(tempFile)
        shutil.rmtree(tempDir)
Exemplo n.º 3
0
 def assertMsgIsCorrect(msg, command):
     a = DockerApp('a', 'a', image='ubuntu:14.04', command=command)
     b = FileDROP('b', 'b')
     a.addOutput(b)
     with DROPWaiterCtx(self, b, 100):
         a.execute()
     self.assertEqual(six.b(msg), droputils.allDropContents(b))
Exemplo n.º 4
0
 def _test_working_dir(self, ensureUserAndSwitch):
     # the sleep is required to make sure that the docker container exists long enough for
     # DALiuGE to get the required information (2 lines of Python code after starting the container!)
     a = DockerApp(
         "a",
         "a",
         workingDir="/mydir",
         image="ubuntu:14.04",
         command="pwd > %o0 && sleep 0.05",
         ensureUserAndSwitch=ensureUserAndSwitch,
     )
     b = FileDROP("b", "b")
     a.addOutput(b)
     with DROPWaiterCtx(self, b, 10):
         a.execute()
     self.assertEqual(b"/mydir", droputils.allDropContents(b).strip())