@skip_backend(
        unsupported={backends.LOOPBACK},
        reason="Does not maintain compute_instance_id across restarting "
               "flocker (and didn't as of most recent release).")
    @skip_backend(
        unsupported={backends.GCE},
        # XXX: FLOC-4297: Enable this after the next marketing release.
        reason="GCE was not available during the most recent release.")
    @run_test_with(async_runner(timeout=timedelta(minutes=6)))
    @require_cluster(1)
    def test_upgrade(self, cluster):
        node = cluster.nodes[0]
        SAMPLE_STR = '123456' * 100

        upgrade_from_version = get_installable_version(HEAD_FLOCKER_VERSION)

        # Get the initial flocker version and setup a cleanup call to restore
        # flocker to that version when the test is done.
        d = cluster.client.version()
        original_package_source = [None]

        def setup_restore_original_flocker(version):
            version_bytes = version.get('flocker', u'').encode('ascii')
            original_package_source[0] = (
                self._get_package_source(
                    default_version=version_bytes or None)
            )
            self.addCleanup(
                lambda: cluster.install_flocker_version(
                    original_package_source[0]))
            return version

        d.addCallback(setup_restore_original_flocker)

        # Double check that the nodes are clean before we destroy the persisted
        # state.
        d.addCallback(lambda _: cluster.clean_nodes())

        # Downgrade flocker to the most recent released version.
        d.addCallback(
            lambda _: cluster.install_flocker_version(
                PackageSource(version=upgrade_from_version),
                destroy_persisted_state=True
            )
        )

        # Create a dataset with the code from the most recent release.
        d.addCallback(lambda _: create_dataset(self, cluster, node=node))
        first_dataset = [None]

        # Write some data to a file in the dataset.
        def write_to_file(dataset):
            first_dataset[0] = dataset
            return node.run_as_root(
                ['bash', '-c', 'echo "%s" > %s' % (
                    SAMPLE_STR, os.path.join(dataset.path.path, 'test.txt'))])
        d.addCallback(write_to_file)

        # Upgrade flocker to the code under test.
        d.addCallback(lambda _: cluster.install_flocker_version(
            original_package_source[0]))

        # Create a new dataset to convince ourselves that the new code is
        # running.
        d.addCallback(lambda _: create_dataset(self, cluster, node=node))

        # Wait for the first dataset to be mounted again.
        d.addCallback(lambda _: cluster.wait_for_dataset(first_dataset[0]))

        # Verify that the file still has its contents.
        def cat_and_verify_file(dataset):
            output = []

            file_catting = node.run_as_root(
                ['bash', '-c', 'cat %s' % (
                    os.path.join(dataset.path.path, 'test.txt'))],
                handle_stdout=output.append)

            def verify_file(_):
                file_contents = ''.join(output)
                self.assertEqual(file_contents, SAMPLE_STR)

            file_catting.addCallback(verify_file)
            return file_catting
        d.addCallback(cat_and_verify_file)
        return d
Collect all static files and move them into a temporary location.
dataset/ETHPy150Open ClusterHQ/flocker/flocker/acceptance/endtoend/test_dataset.py/DatasetAPITests.test_upgrade--crossover with--dataset/ETHPy150Open dcramer/django-static-compiler/src/static_compiler/management/commands/compilestatic.py/collect_static_files