'Create a container with an attached dataset, write some data,
shut it down, create a new container with same dataset, make sure
the data is still there.'

@require_cluster(1, require_container_agent=True)
def test_create_container_with_dataset(self, cluster):

    data = {u'the    data': u'sample    written    data'}
    post_data = {'data': dumps(data)}
    node = cluster.nodes[0]
    container_name = random_name(self)
    creating_dataset = create_dataset(self, cluster)
    self.dataset_id = None
    def create_container(dataset):
        self.dataset_id = unicode(dataset.dataset_id)
        d = create_python_container(self, cluster, {u'name': container_name, u'ports': [{u'internal': 8080, u'external': 8080}], u'node_uuid': node.uuid, u'volumes': [{u'dataset_id': self.dataset_id, u'mountpoint': u'/data'}]}, SCRIPTS.child('datahttp.py'), additional_arguments=[u'/data'], cleanup=False)
        return d
    creating_dataset.addCallback(create_container)
    creating_dataset.addCallback((lambda _: post_http_server(self, node.public_address, 8080, post_data)))
    creating_dataset.addCallback((lambda _: assert_http_server(self, node.public_address, 8080, expected_response=post_data['data'])))
    creating_dataset.addCallback((lambda _: cluster.remove_container(container_name)))
    def create_second_container(_):
        d = create_python_container(self, cluster, {u'ports': [{u'internal': 8080, u'external': 8081}], u'node_uuid': node.uuid, u'volumes': [{u'dataset_id': self.dataset_id, u'mountpoint': u'/data'}]}, SCRIPTS.child('datahttp.py'), additional_arguments=[u'/data'])
        return d
    creating_dataset.addCallback(create_second_container)
    creating_dataset.addCallback((lambda _: assert_http_server(self, node.public_address, 8081, expected_response=post_data['data'])))
    return creating_dataset
