def test_done(command): """Receive completed test artifacts from client""" db.update_test_status(command['test_id'], command['status']) # Record test failure message, if any: if command['status'] == 'failed': msg = (command.get('message','') + "\n" + command.get('stacktrace','')).strip() db.update_test_artifact(command['test_id'], 'failure', msg) # Send response: command.respond(test_id=command['test_id'], message='test_update', done=True)
def receive_artifact_chunk_complete(command): db.update_test_artifact(command['test_id'], command['kind'], None, command['name'], available=command['successful'], object_id=command['object_id']) command.respond(message='ok', stored_chunk_shas=_get_stored_chunks( command['object_id']), done=True)
def test_done(command): """Receive completed test artifacts from client""" db.update_test_status(command['test_id'], command['status']) # Record test failure message, if any: if command['status'] == 'failed': msg = (command.get('message', '') + "\n" + command.get('stacktrace', '')).strip() db.update_test_artifact(command['test_id'], 'failure', msg) # Send response: command.respond(test_id=command['test_id'], message='test_update', done=True)
def receive_stream(command): """Receive a stream of data""" command.respond(message="ready", follow_up=False) log.debug("Receving data stream ....") if command['kind'] == 'console': console_dir = os.path.join(os.path.expanduser("~"), ".cstar_perf", "console_out") try: os.makedirs(console_dir) except OSError: pass console = open(os.path.join(console_dir, command['test_id']), "w") tmp = cStringIO.StringIO() sha = hashlib.sha256() try: def frame_callback(frame, binary): if not binary: frame = frame.encode("utf-8") if command['kind'] == 'console': console.write(frame) console_publish(context['cluster'], { 'job_id': command['test_id'], 'msg': frame }) console.flush() else: console_publish(context['cluster'], { 'job_id': command['test_id'], 'ctl': 'IN_PROGRESS' }) sha.update(frame) tmp.write(frame) socket_comms.receive_stream(ws, command, frame_callback) if command['kind'] == 'console': console.close() # TODO: confirm with the client that the sha is correct # before storing finally: # In the event of a socket error, we always want to commit # what we have of the artifact to the database. Better to # have something than nothing. It's the client's # responsibility to resend artifacts that failed. db.update_test_artifact(command['test_id'], command['kind'], tmp, command['name']) command.respond(message='stream_received', done=True, sha256=sha.hexdigest())
def receive_stream(command): """Receive a stream of data""" command.respond(message="ready", follow_up=False) log.debug("Receving data stream ....") if command['kind'] == 'console': console_dir = os.path.join(os.path.expanduser("~"), ".cstar_perf", "console_out") try: os.makedirs(console_dir) except OSError: pass console = open(os.path.join(console_dir, command['test_id']), "w") tmp = cStringIO.StringIO() sha = hashlib.sha256() try: def frame_callback(frame, binary): if not binary: frame = frame.encode("utf-8") if command['kind'] == 'console': console.write(frame) console_publish(context['cluster'], {'job_id':command['test_id'], 'msg':frame}) console.flush() else: console_publish(context['cluster'], {'job_id':command['test_id'], 'ctl':'IN_PROGRESS'}) sha.update(frame) tmp.write(frame) socket_comms.receive_stream(ws, command, frame_callback) if command['kind'] == 'console': console.close() # TODO: confirm with the client that the sha is correct # before storing finally: # In the event of a socket error, we always want to commit # what we have of the artifact to the database. Better to # have something than nothing. It's the client's # responsibility to resend artifacts that failed. db.update_test_artifact(command['test_id'], command['kind'], tmp, command['name']) command.respond(message='stream_received', done=True, sha256=sha.hexdigest())
def receive_artifact_chunk_complete(command): db.update_test_artifact(command['test_id'], command['kind'], None, command['name'], available=command['successful'], object_id=command['object_id']) command.respond(message='ok', stored_chunk_shas=_get_stored_chunks(command['object_id']), done=True)