Make tests compose packages in temporarily directory
OpenStack Puppet CI uses packaged version of Murano, so we don't have write permissions to test directory. We need to compose Murano packages required for tests in temporarily directories to fix it. Closes-Bug: #1620706 Change-Id: I0334869237208f707b66b1e473e6044b1d3fe06f
This commit is contained in:
parent
f651c365be
commit
849b8ea600
|
@ -34,25 +34,22 @@ MANIFEST = {'Format': 'MuranoPL/1.0',
|
||||||
'Author': 'Mirantis, Inc'}
|
'Author': 'Mirantis, Inc'}
|
||||||
|
|
||||||
|
|
||||||
def compose_package(app_name, manifest, package_dir,
|
def compose_package(app_name, package_dir,
|
||||||
require=None, archive_dir=None, add_class_name=False,
|
require=None, archive_dir=None, add_class_name=False,
|
||||||
manifest_required=True, version=None):
|
manifest_required=True, version=None):
|
||||||
"""Composes a murano package
|
"""Composes a murano package
|
||||||
|
|
||||||
Composes package `app_name` with `manifest` file as a template for the
|
Composes package `app_name` manifest and files from `package_dir`.
|
||||||
manifest and files from `package_dir`.
|
|
||||||
Includes `require` section if any in the manifest file.
|
Includes `require` section if any in the manifest file.
|
||||||
Puts the resulting .zip file into `acrhive_dir` if present or in the
|
Puts the resulting .zip file into `archive_dir` if present or in the
|
||||||
`package_dir`.
|
`package_dir`.
|
||||||
"""
|
"""
|
||||||
class_file_changes = add_class_name or require
|
tmp_package_dir = os.path.join(archive_dir, os.path.basename(package_dir))
|
||||||
# store class file before changes
|
shutil.copytree(package_dir, tmp_package_dir)
|
||||||
if class_file_changes:
|
package_dir = tmp_package_dir
|
||||||
class_path = os.path.join(package_dir, 'Classes', 'mock_muranopl.yaml')
|
|
||||||
with open(class_path, 'r') as f:
|
|
||||||
class_store = f.read()
|
|
||||||
|
|
||||||
if manifest_required:
|
if manifest_required:
|
||||||
|
manifest = os.path.join(package_dir, "manifest.yaml")
|
||||||
with open(manifest, 'w') as f:
|
with open(manifest, 'w') as f:
|
||||||
fqn = 'io.murano.apps.' + app_name
|
fqn = 'io.murano.apps.' + app_name
|
||||||
mfest_copy = MANIFEST.copy()
|
mfest_copy = MANIFEST.copy()
|
||||||
|
@ -105,11 +102,6 @@ def compose_package(app_name, manifest, package_dir,
|
||||||
arcname=os.path.join(os.path.relpath(root, package_dir), f)
|
arcname=os.path.join(os.path.relpath(root, package_dir), f)
|
||||||
)
|
)
|
||||||
|
|
||||||
# restore class file after changes
|
|
||||||
if class_file_changes:
|
|
||||||
with open(class_path, 'w') as f:
|
|
||||||
f.write(class_store)
|
|
||||||
|
|
||||||
return archive_path, name
|
return archive_path, name
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,11 +116,10 @@ def prepare_package(name, require=None, add_class_name=False,
|
||||||
:return: Path to archive, directory with archive, filename of archive
|
:return: Path to archive, directory with archive, filename of archive
|
||||||
"""
|
"""
|
||||||
app_dir = acquire_package_directory(app=app)
|
app_dir = acquire_package_directory(app=app)
|
||||||
target_arc_path = app_dir.rsplit(app, 1)[0]
|
target_arc_path = tempfile.mkdtemp()
|
||||||
|
|
||||||
arc_path, filename = compose_package(
|
arc_path, filename = compose_package(
|
||||||
name, os.path.join(app_dir, 'manifest.yaml'),
|
name, app_dir, require=require, archive_dir=target_arc_path,
|
||||||
app_dir, require=require, archive_dir=target_arc_path,
|
|
||||||
add_class_name=add_class_name, manifest_required=manifest_required,
|
add_class_name=add_class_name, manifest_required=manifest_required,
|
||||||
version=version)
|
version=version)
|
||||||
return arc_path, target_arc_path, filename
|
return arc_path, target_arc_path, filename
|
||||||
|
|
Loading…
Reference in New Issue