예제 #1
0
    def test_deployment_create_workflow_and_source_plugin(self):
        # Get the whole directory
        dsl_path = get_resource('dsl/plugin_tests')

        # Copy the blueprint folder into a temp dir, because we want to
        # create a plugin zip, in order to install it from source
        base_temp_dir = tempfile.mkdtemp()
        blueprint_dir = os.path.join(base_temp_dir, 'blueprint')
        shutil.copytree(dsl_path, blueprint_dir)

        blueprint_path = os.path.join(blueprint_dir, 'source_plugin.yaml')

        # Create a zip archive of the
        source_plugin = os.path.join(blueprint_dir, 'plugins', 'mock-plugin')
        plugin_zip = '{0}.zip'.format(source_plugin)

        try:
            create_zip(source_plugin, plugin_zip)

            deployment, _ = self.deploy_application(blueprint_path)
            deployment_folder = self._get_deployment_folder(deployment)
            plugin_path = self._get_plugin_path(deployment)

            # assert plugin installer installed the necessary plugin
            self._assert_path_exists_on_manager(deployment_folder, True)
            self._assert_path_exists_on_manager(plugin_path)

            self.undeploy_application(deployment.id, is_delete_deployment=True)

            # Retry several times, because uninstalling plugins may take time
            self._assert_paths_removed(deployment_folder, plugin_path)

        finally:
            shutil.rmtree(base_temp_dir)
예제 #2
0
def _corrupt_plugin(wagon_archive, package_name):
    temp_dir = tempfile.mkdtemp()
    utils.unzip(wagon_archive, temp_dir)
    shutil.rmtree(os.path.join(temp_dir, package_name, 'wheels'))
    utils.create_zip(os.path.join(temp_dir, '.'), wagon_archive)
    shutil.rmtree(temp_dir)