aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLianhao Lu <lianhao.lu@intel.com>2017-09-14 15:48:04 +0800
committerLianhao Lu <lianhao.lu@intel.com>2017-09-14 16:57:30 +0800
commitc2fc078e7f97766223ac942cddf0842f3aae4882 (patch)
tree397f5ed26e1390f7abe1975f25bb3f63791e5358 /tests
parent4d6f1bc25bd38ae68f3ecb73d9b79ffd5a067afb (diff)
Update to align with package model in R1
1. Added the support of manifest file, change history file, test directory, license directory. 2. Added the support of including empty directories in the final csar package. Change-Id: I639110b2e92c91ec9c6bf5c505a60bb1d3b63599 Signed-off-by: Lianhao Lu <lianhao.lu@intel.com> Issue-Id: VNFSDK-52
Diffstat (limited to 'tests')
-rw-r--r--tests/packager/test_package.py55
-rw-r--r--tests/resources/csar/ChangeLog.txt0
-rw-r--r--tests/resources/csar/Tests/test0
-rw-r--r--tests/resources/csar/test_entry.mf5
4 files changed, 53 insertions, 7 deletions
diff --git a/tests/packager/test_package.py b/tests/packager/test_package.py
index f0c27d4..b4c4526 100644
--- a/tests/packager/test_package.py
+++ b/tests/packager/test_package.py
@@ -13,25 +13,66 @@
# License for the specific language governing permissions and limitations
# under the License.
#
+import collections
import filecmp
-from packager import csar
import logging
+import os
import tempfile
import shutil
-def test_CSARWrite():
- CSAR_RESOURCE_DIR = 'tests/resources/csar'
- CSAR_ENTRY_FILE = 'test_entry.yaml'
- CSAR_OUTPUT_FILE = 'output.csar'
+from packager import csar
+
+CSAR_RESOURCE_DIR = 'tests/resources/csar'
+CSAR_ENTRY_FILE = 'test_entry.yaml'
+CSAR_OUTPUT_FILE = 'output.csar'
+
+Args = collections.namedtuple('Args',
+ ['source', 'entry', 'manifest', 'history', 'tests', 'licenses'])
+
+ARGS_MANIFEST = {
+ 'source': CSAR_RESOURCE_DIR,
+ 'entry': CSAR_ENTRY_FILE,
+ 'manifest': 'test_entry.mf',
+ 'history': 'ChangeLog.txt',
+ 'tests': 'Tests',
+ 'licenses': 'Licenses',
+ }
+ARGS_NO_MANIFEST = {
+ 'source': CSAR_RESOURCE_DIR,
+ 'entry': CSAR_ENTRY_FILE,
+ 'manifest': None,
+ 'history': None,
+ 'tests': None,
+ 'licenses': None,
+ }
+
+
+def csar_write_test(args):
csar_target_dir = tempfile.mkdtemp()
csar_extract_dir = tempfile.mkdtemp()
try:
- csar.write(CSAR_RESOURCE_DIR, CSAR_ENTRY_FILE, csar_target_dir + '/' + CSAR_OUTPUT_FILE, logging)
+ csar.write(args.source, args.entry, csar_target_dir + '/' + CSAR_OUTPUT_FILE, logging, args)
csar.read(csar_target_dir + '/' + CSAR_OUTPUT_FILE, csar_extract_dir, logging)
- assert filecmp.cmp(CSAR_RESOURCE_DIR + '/' + CSAR_ENTRY_FILE, csar_extract_dir + '/' + CSAR_ENTRY_FILE )
+ assert filecmp.cmp(args.source + '/' + args.entry, csar_extract_dir + '/' + args.entry)
+ if(args.manifest):
+ assert filecmp.cmp(args.source + '/' + args.manifest,
+ csar_extract_dir + '/' + args.manifest)
+ if(args.history):
+ assert filecmp.cmp(args.source + '/' + args.history,
+ csar_extract_dir + '/' + args.history)
finally:
shutil.rmtree(csar_target_dir, ignore_errors=True)
shutil.rmtree(csar_extract_dir, ignore_errors=True)
+def test_CSARWrite():
+ csar_write_test(Args(**ARGS_NO_MANIFEST))
+
+
+def test_CSARWrite_manifest():
+ # Because git can not store emptry directory, we need to create manually here
+ license_path = ARGS_MANIFEST['source'] + '/' + ARGS_MANIFEST['licenses']
+ if not os.path.exists(license_path):
+ os.makedirs(license_path)
+ csar_write_test(Args(**ARGS_MANIFEST))
diff --git a/tests/resources/csar/ChangeLog.txt b/tests/resources/csar/ChangeLog.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/resources/csar/ChangeLog.txt
diff --git a/tests/resources/csar/Tests/test b/tests/resources/csar/Tests/test
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/resources/csar/Tests/test
diff --git a/tests/resources/csar/test_entry.mf b/tests/resources/csar/test_entry.mf
new file mode 100644
index 0000000..710d1a2
--- /dev/null
+++ b/tests/resources/csar/test_entry.mf
@@ -0,0 +1,5 @@
+metadata:
+vnf_product_name: test
+vnf_provider_id: test
+vnf_pacakage_version: 1.0
+vnf_release_date_time: 2017.09.15T15:00+8:00