def assert_message_is_correct(message, command): a = BashShellApp('a', 'a', command=command) b = FileDROP('b', 'b') a.addOutput(b) with DROPWaiterCtx(self, b, 100): a.execute() self.assertEquals(message, droputils.allDropContents(b))
def test_echo(self): a = FileDROP('a', 'a') b = BashShellApp('b', 'b', command='cp %i0 %o0') c = FileDROP('c', 'c') b.addInput(a) b.addOutput(c) # Random data so we always check different contents data = ''.join([random.choice(string.ascii_letters + string.digits) for _ in xrange(10)]) with DROPWaiterCtx(self, c, 100): a.write(data) a.setCompleted() self.assertEquals(data, droputils.allDropContents(c)) # We own the file, not root uid = os.getuid() self.assertEquals(uid, os.stat(c.path).st_uid)
def assert_message_is_correct(message, command): a = BashShellApp('a', 'a', command=command) b = FileDROP('b', 'b') a.addOutput(b) with DROPWaiterCtx(self, b, 100): a.async_execute() self.assertEqual(six.b(message), droputils.allDropContents(b))
def test_echo(self): a = FileDROP('a', 'a') b = BashShellApp('b', 'b', command='cp %i0 %o0') c = FileDROP('c', 'c') b.addInput(a) b.addOutput(c) # Random data so we always check different contents data = os.urandom(10) with DROPWaiterCtx(self, c, 100): a.write(data) a.setCompleted() self.assertEqual(data, droputils.allDropContents(c)) # We own the file, not root uid = os.getuid() self.assertEqual(uid, os.stat(c.path).st_uid)
# from dfms.drop import ShoreDROP from dfms.apps.bash_shell_app import BashShellApp import threading from dfms.droputils import EvtConsumer import numpy as np doid = 'abc1046' column = 'data' row = 0 rows = 1 # Create the Drops a = ShoreDROP(doid, doid, doid=doid, column=column, row=row, rows=rows) b = BashShellApp('b', 'b', command="echo hello") c = ShoreDROP(doid, doid, doid=doid, column='processed_data', row=row, rows=rows) # Wire them together b.addInput(a) b.addOutput(c) # The execution is asyncrhonously triggered by setCompleted() # so we need to wait on an event that will be set when C moves to COMPLETED # (or ERROR) finished = threading.Event()