'If sending state to the control node fails the next iteration will send
state even if the state is the same as the last acknowledge state.
The situation this is intended to model is the following sequence:
1. Agent sends original state to control node, which records and
acknowledges it.
2. Agent sends changed state to control node, which records it, but
errors out before acknowledging it.
3. State returns to original state. If we don\'t clear the acknowledged
state, the agent won\'t send a state update, but the control node
will think the state is still the changed state.'

def test_convergence_sent_state_fail_resends_alternating(self):

    local_state = NodeState(hostname=u'192.0.2.123', applications=pset())
    changed_local_state = local_state.set(applications={Application(name=u'app', image=DockerImage.from_string(u'nginx'))})
    configuration = Deployment(nodes=[to_node(local_state)])
    state = DeploymentState(nodes=[local_state])
    changed_state = DeploymentState(nodes=[changed_local_state])
    deployer = ControllableDeployer(local_state.hostname, [succeed(local_state), succeed(changed_local_state), succeed(local_state)], [no_action(), no_action(), no_action()])
    client = self.make_amp_client([local_state, changed_local_state], successes=[True, False])
    reactor = Clock()
    loop = build_convergence_loop_fsm(reactor, deployer)
    loop.receive(_ClientStatusUpdate(client=client, configuration=configuration, state=state))
    reactor.advance(_UNCONVERGED_DELAY)
    reactor.advance((_UNCONVERGED_DELAY * _UNCONVERGED_BACKOFF_FACTOR))
    self.assertTupleEqual((deployer.calculate_inputs, client.calls), ([(local_state, configuration, state), (changed_local_state, configuration, changed_state), (local_state, configuration, state)], [(NodeStateCommand, dict(state_changes=(local_state,))), (NodeStateCommand, dict(state_changes=(changed_local_state,))), (NodeStateCommand, dict(state_changes=(local_state,)))]))
