def _upload_mock_plugin(self): wagon_path = self._create_test_wagon('target-aware-mock') self.downloaded_archive_path = os.path.join( self.workdir, os.path.basename(wagon_path)) yaml_path = test_utils.get_resource('plugins/target-aware-mock/' 'plugin.yaml') with utils.zip_files([wagon_path, yaml_path]) as zip_path: self.client.plugins.upload(zip_path)
def upload_mock_plugin(package_name, package_version): client = create_rest_client() temp_file_path = utils._create_mock_wagon(package_name, package_version) yaml_path = get_resource('plugins/plugin.yaml') with utils.zip_files([temp_file_path, yaml_path]) as zip_path: response = client.plugins.upload(zip_path) os.remove(temp_file_path) return response
def test_wagon_plugin_requires_old_package(self): wagon_path = self._get_plugin_wagon( 'requires_old_package_plugin-1.0-py27-none-any.wgn') plugin_yaml = join(self.BLUEPRINTS, 'plugins', 'old_package_wagon_plugin.yaml') yaml_path = resource(plugin_yaml) with utils.zip_files([wagon_path, yaml_path]) as zip_path: self.client.plugins.upload(zip_path) self._test_host_plugin_requires_old_package( join(self.BLUEPRINTS, 'wagon_plugin_blueprint.yaml'))
def _upload_v_2_plugin(self): plugin_name = 'version_aware_v2' plugins_dir = os.path.dirname(integration_tests_plugins.__file__) plugin_source = os.path.join(plugins_dir, plugin_name) wagon_paths = self._get_or_create_wagon(plugin_source) for wagon_path in wagon_paths: yaml_path = os.path.join(plugin_source, 'plugin.yaml') with zip_files([wagon_path, yaml_path]) as zip_path: self.client.plugins.upload(zip_path, visibility='global') self.logger.info( 'Finished uploading {0}...'.format(plugin_name))
def test_plugins_sort(self): for i in range(1, 11): tmpdir = tempfile.mkdtemp(prefix='test-sort-') with open(os.path.join(tmpdir, 'setup.py'), 'w') as f: f.write('from setuptools import setup\n') f.write('setup(name="some-package", version={0})'.format(i)) wagon_path = wagon.create(tmpdir, archive_destination_dir=tmpdir) yaml_path = resource('plugins/plugin.yaml') with utils.zip_files([wagon_path, yaml_path]) as zip_path: self.client.plugins.upload(zip_path) shutil.rmtree(tmpdir) self._test_sort('plugins', 'id')
def test_wagon_plugin_requires_old_package(self): wagon_path = self._get_plugin_wagon( 'requires_old_package_plugin-1.0-py27-none-any.wgn' ) plugin_yaml = join(self.BLUEPRINTS, 'plugins', 'old_package_wagon_plugin.yaml') yaml_path = resource(plugin_yaml) with utils.zip_files([wagon_path, yaml_path]) as zip_path: self.client.plugins.upload(zip_path) self._test_host_plugin_requires_old_package( join(self.BLUEPRINTS, 'wagon_plugin_blueprint.yaml') )
def test_plugins_sort(self): for i in range(1, 11): tmpdir = tempfile.mkdtemp(prefix='test-sort-') with open(os.path.join(tmpdir, 'setup.py'), 'w') as f: f.write('from setuptools import setup\n') f.write('setup(name="cloudify-script-plugin", version={0})' .format(i)) wagon_path = wagon.create(tmpdir, archive_destination_dir=tmpdir) yaml_path = resource('plugins/plugin.yaml') with utils.zip_files([wagon_path, yaml_path]) as zip_path: self.client.plugins.upload(zip_path) shutil.rmtree(tmpdir) self._test_sort('plugins', 'id')
def upload_mock_plugin(package_name, package_version): client = create_rest_client() temp_file_path = _create_mock_wagon(package_name, package_version) try: # Path relative to resources folder yaml_path = get_resource( path.join('plugins', package_name, 'plugin.yaml')) except RuntimeError: # Default to the script-plugin if package-name has no plugin.yaml yaml_path = get_resource('plugins/plugin.yaml') with utils.zip_files([temp_file_path, yaml_path]) as zip_path: response = client.plugins.upload(zip_path) os.remove(temp_file_path) return response
def test_plugins_sort(self): for i in range(1, 11): tmpdir = tempfile.mkdtemp(prefix='test-sort-') with open(os.path.join(tmpdir, 'setup.py'), 'w') as f: f.write('from setuptools import setup\n') f.write('setup(name="cloudify-script-plugin", version={0})' .format(i)) wagon_path = wagon.create( tmpdir, archive_destination_dir=tmpdir, # mark the wagon as windows-only, so that the manager doesn't # attempt to install it - which would be irrelevant for this # test, but add additional flakyness and runtime wheel_args=['--build-option', '--plat-name=win']) yaml_path = resource('plugins/plugin.yaml') with utils.zip_files([wagon_path, yaml_path]) as zip_path: self.client.plugins.upload(zip_path) shutil.rmtree(tmpdir) self._test_sort('plugins', 'id')
def upload_mock_plugin(package_name, package_version): client = create_rest_client() temp_file_path = _create_mock_wagon(package_name, package_version) try: # Path relative to resources folder yaml_path = get_resource(path.join('plugins', package_name, 'plugin.yaml')) except RuntimeError: # Default to the script-plugin if package-name has no plugin.yaml yaml_path = get_resource('plugins/plugin.yaml') with utils.zip_files([temp_file_path, yaml_path]) as zip_path: response = client.plugins.upload(zip_path) os.remove(temp_file_path) return response