def test_override_uses_with(docs): flow = Flow().add( name='executor1', uses=UpdateExecutor, replicas=2, parallel=3, ) with flow: # test rolling update does not hang ret1 = flow.search(docs, return_results=True) flow.rolling_update( 'executor1', dump_path='/tmp/dump_path2/', uses_with={'argument1': 'version2', 'argument2': 'version2'}, ) ret2 = flow.search(docs, return_results=True) assert len(ret1) > 0 assert len(ret1[0].docs) > 0 for doc in ret1[0].docs: assert doc.tags['dump_path'] == '/tmp/dump_path1/' assert doc.tags['arg1'] == 'version1' assert doc.tags['arg2'] == 'version1' assert len(ret2) > 0 assert len(ret2[0].docs) > 0 for doc in ret2[0].docs: assert doc.tags['dump_path'] == '/tmp/dump_path2/' assert doc.tags['arg1'] == 'version2' assert doc.tags['arg2'] == 'version2'
def test_scale_after_rolling_update( docs, replicas, scale_to, expected_before_scale, expected_after_scale ): flow = Flow().add( name='executor1', uses=DummyMarkExecutor, replicas=replicas, ) with flow: ret1 = flow.search(docs, return_results=True, request_size=1) flow.rolling_update('executor1', None) flow.scale('executor1', replicas=scale_to) ret2 = flow.search(docs, return_results=True, request_size=1) replica_ids = set() for r in ret1: for replica_id in r.docs.get_attributes('tags__replica'): replica_ids.add(replica_id) assert replica_ids == expected_before_scale replica_ids = set() for r in ret2: for replica_id in r.docs.get_attributes('tags__replica'): replica_ids.add(replica_id) assert replica_ids == expected_after_scale
def test_scale_after_rolling_update(docs, replicas, scale_to): flow = Flow(port_expose=exposed_port).add( name='executor1', uses=DummyMarkExecutor, replicas=replicas, ) with flow: ret1 = Client(port=exposed_port).search(docs, return_results=True, request_size=1) flow.rolling_update('executor1', None) flow.scale('executor1', replicas=scale_to) ret2 = Client(port=exposed_port).search(docs, return_results=True, request_size=1) replicas_before = set() for r in ret1: for replica in r.docs[:, 'tags__replica']: replicas_before.add(replica) assert len(replicas_before) == replicas replicas_after = set() for r in ret2: for replica in r.docs[:, 'tags__replica']: replicas_after.add(replica) assert len(replicas_after) == scale_to
def test_simple_run(docs): flow = Flow().add( name='pod1', replicas=2, parallel=3, ) with flow: # test rolling update does not hang flow.search(docs) flow.rolling_update('pod1', None) flow.search(docs)
def test_simple_run(docs): flow = Flow().add( name='executor1', replicas=2, shards=3, ) with flow: # test rolling update does not hang flow.search(docs) flow.rolling_update('executor1', None) flow.search(docs)