'ReadRequest probe returns the cluster state.'

def test_read_request(self):

    control_service = FastConvergingFakeFlockerClient(FakeFlockerClient())
    primary = uuid4()
    d = control_service.create_dataset(primary=primary)
    def start_read_request(result):
        cluster = BenchmarkCluster(IPAddress('10.0.0.1'), (lambda reactor: control_service), {}, None)
        request = ReadRequest(Clock(), cluster, 'list_datasets_state')
        return request.get_probe()
    d.addCallback(start_read_request)
    def run_probe(probe):
        def cleanup(result):
            cleaned_up = probe.cleanup()
            cleaned_up.addCallback((lambda _ignored: result))
            return cleaned_up
        d = probe.run()
        d.addCallback(cleanup)
        return d
    d.addCallback(run_probe)
    def state_to_primary(states):
        return [state.primary for state in states]
    d.addCallback(state_to_primary)
    self.assertEqual(self.successResultOf(d), [primary])
