'Multiple ``NodeStateCommands`` are coalesced into a single state update
broadcast to all the nodes.'

def test_nodestate_coalesces_multiple_quick(self):

    self.control_amp_service.configuration_service.save(_TEST_DEPLOYMENT)
    agents = [FakeAgent(), FakeAgent()]
    clients = list((AgentAMP(Clock(), agent) for agent in agents))
    servers = list((LoopbackAMPClient(client.locator) for client in clients))
    for server in servers:
        self.control_amp_service.connected(server)
    initial_update_counts = list((agent.cluster_updated_count for agent in agents))
    for i in xrange(10):
        new_application_name = (u'app-%d' % i)
        new_state = NODE_STATE.set('applications', NODE_STATE.applications.set(new_application_name, Application(name=new_application_name, image=DockerImage.from_string(('image-%d' % i)))))
        self.successResultOf(self.client.callRemote(NodeStateCommand, state_changes=(new_state,), eliot_context=TEST_ACTION))
    self.assertEqual(([0] * len(agents)), list(((agent.cluster_updated_count - c) for (agent, c) in zip(agents, initial_update_counts))))
    self.reactor.advance((CONTROL_SERVICE_BATCHING_DELAY * 2))
    self.assertEqual(([1] * len(agents)), list(((agent.cluster_updated_count - c) for (agent, c) in zip(agents, initial_update_counts))))
