summaryrefslogtreecommitdiffstats
path: root/csarvalidation
diff options
context:
space:
mode:
authorBogumil Zebek <bogumil.zebek@nokia.com>2019-03-15 10:43:42 +0100
committerZebek Bogumil <bogumil.zebek@nokia.com>2019-03-18 08:02:39 +0100
commit0d4544eb82a2ca79d7724e5c1da70d3943db76eb (patch)
tree3d18b7a0f8ee1edf20476c60828b0e80042e9b9e /csarvalidation
parentcb83eef8ba8f479576a07d08cf9b5c48b737778c (diff)
Update manifest parser
Change-Id: I420fd9fb97450cbcc2afc15632717182e18f0333 Issue-ID: VNFSDK-384 Signed-off-by: Zebek Bogumil <bogumil.zebek@nokia.com>
Diffstat (limited to 'csarvalidation')
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/PnfManifestParser.java43
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java23
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java19
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/PnfMetadataParserTest.java37
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java9
-rw-r--r--csarvalidation/src/test/resources/pnf/MainServiceTemplate.mf35
-rw-r--r--csarvalidation/src/test/resources/pnf/dummyPnfv2.csarbin3889 -> 4039 bytes
7 files changed, 97 insertions, 69 deletions
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/PnfManifestParser.java b/csarvalidation/src/main/java/org/onap/cvc/csar/PnfManifestParser.java
index a92ebd4..5694049 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/PnfManifestParser.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/PnfManifestParser.java
@@ -28,11 +28,15 @@ import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-public class PnfManifestParser {
+class PnfManifestParser {
- public static final String METADATA_SECTION = "metadata";
- public static final String NON_MANO_ARTIFACT_SETS_SECTION = "non_mano_artifact_sets";
+ private static final String METADATA_SECTION = "metadata";
+ private static final String NON_MANO_ARTIFACT_SETS_SECTION = "non_mano_artifact_sets";
+ private static final String PRODUCT_NAME = "pnfd_name";
+ private static final String PROVIDER_ID = "pnfd_provider";
+ private static final String VERSION = "pnfd_archive_version";
+ private static final String RELEASE_DATE_TIME = "pnfd_release_date_time";
private final List<String> lines;
private final String fileName;
@@ -42,7 +46,7 @@ public class PnfManifestParser {
this.fileName = fileName;
}
- public static PnfManifestParser getInstance(String fileName) throws IOException {
+ static PnfManifestParser getInstance(String fileName) throws IOException {
try (Stream<String> stream = Files.lines(Paths.get(fileName))) {
List<String> lines = stream
.map(String::trim)
@@ -52,7 +56,7 @@ public class PnfManifestParser {
}
}
- public Pair<CSARArchive.Manifest.Metadata, List<CSARArchive.CSARError>> fetchMetadata() {
+ Pair<CSARArchive.Manifest.Metadata, List<CSARArchive.CSARError>> fetchMetadata() {
CSARArchive.Manifest.Metadata metadata = new CSARArchive.Manifest.Metadata();
List<CSARArchive.CSARError> errors = new ArrayList<>();
@@ -60,11 +64,10 @@ public class PnfManifestParser {
int lineNumber = 0;
for (String line : lines) {
lineNumber++;
- if (line.trim().isEmpty()){
+ if (line.trim().isEmpty() || line.trim().startsWith("#")){
continue;
} else if (line.startsWith(METADATA_SECTION)) {
isMetadataSectionAvailable = true;
- continue;
}else if (isMetadataSectionAvailable) {
Pair<String, String> data = parseLine(line);
@@ -87,7 +90,7 @@ public class PnfManifestParser {
}
- public Pair<Map<String, Map<String, List<String>>>, List<CSARArchive.CSARError>> fetchNonManoArtifacts() {
+ Pair<Map<String, Map<String, List<String>>>, List<CSARArchive.CSARError>> fetchNonManoArtifacts() {
Map<String, Map<String, List<String>>> nonManoArtifacts = new HashMap<>();
List<CSARArchive.CSARError> errors = new ArrayList<>();
@@ -96,11 +99,10 @@ public class PnfManifestParser {
for (String line : lines) {
- if (line.trim().isEmpty()) {
+ if (line.trim().isEmpty() || line.trim().startsWith("#")) {
continue;
} else if (line.startsWith(NON_MANO_ARTIFACT_SETS_SECTION)) {
isNonManoArtifactsSectionAvailable = true;
- continue;
} else if (isNonManoArtifactsSectionAvailable) {
Pair<String, String> data = parseLine(line);
@@ -130,16 +132,16 @@ public class PnfManifestParser {
String value = data.getValue();
switch (paramName) {
- case "pnf_product_name":
+ case PRODUCT_NAME:
metadata.setProductName(value);
break;
- case "pnf_provider_id":
+ case PROVIDER_ID:
metadata.setProviderId(value);
break;
- case "pnf_package_version":
+ case VERSION:
metadata.setPackageVersion(value);
break;
- case "pnf_release_date_time":
+ case RELEASE_DATE_TIME:
metadata.setReleaseDateTime(value);
break;
default:
@@ -172,8 +174,9 @@ public class PnfManifestParser {
private boolean isNewSection(Pair<String, String> data) {
+ String key = data.getKey().trim();
String value = data.getValue().trim();
- return value.isEmpty() || value.startsWith("#");
+ return key.matches("[a-zA-z_0-9]+") && (value.isEmpty() || value.startsWith("#"));
}
@@ -191,7 +194,7 @@ public class PnfManifestParser {
}
private static class PnfCSARError extends CSARArchive.CSARError {
- public PnfCSARError(String errorCode, String message, int lineNumber, String file) {
+ PnfCSARError(String errorCode, String message, int lineNumber, String file) {
super(errorCode);
this.message = message;
this.file = file;
@@ -199,20 +202,20 @@ public class PnfManifestParser {
}
}
- public static class PnfCSARErrorInvalidEntry extends PnfCSARError {
- public PnfCSARErrorInvalidEntry(String entry, String file, int lineNumber) {
+ private static class PnfCSARErrorInvalidEntry extends PnfCSARError {
+ PnfCSARErrorInvalidEntry(String entry, String file, int lineNumber) {
super("0x2000", "Invalid. Entry [" + entry + "]", lineNumber, file);
}
}
private static class PnfCSARErrorWarning extends PnfCSARError {
- public PnfCSARErrorWarning(String entry, String file, int lineNumber) {
+ PnfCSARErrorWarning(String entry, String file, int lineNumber) {
super("0x2001", "Warning. Entry [" + entry + "]", lineNumber, file);
}
}
private static class PnfCSARErrorEntryMissing extends PnfCSARError {
- public PnfCSARErrorEntryMissing(String entry, String file, int lineNumber) {
+ PnfCSARErrorEntryMissing(String entry, String file, int lineNumber) {
super("0x2002", "Missing. Entry [" + entry + "]", lineNumber, file);
}
}
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java
index 4a211a5..d7370e4 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfCSARArchiveTest.java
@@ -50,18 +50,23 @@ public class PnfCSARArchiveTest {
private void verifyThatNonManoArtifactsWereSet(PnfCSARArchive pnfCSARArchive) {
Map<String, Map<String, List<String>>> nonManoArtifacts = pnfCSARArchive.getManifest().getNonMano();
- assertThat(nonManoArtifacts.get("prv.onap.ves_event").get("Source"))
- .isEqualTo(Lists.newArrayList("Artifacts/Deployment/Events/RadioNode_Pnf_v1.yml")
+ assertThat(nonManoArtifacts.get("onap_ves_events").get("source"))
+ .isEqualTo(Lists.newArrayList("Artifacts/Events/VES_registration.yml")
);
- assertThat(nonManoArtifacts.get("prv.onap.pm_dictionary").get("Source"))
- .isEqualTo(Lists.newArrayList("Artifacts/Deployment/Measurements/PM_Dictionary.yml")
+ assertThat(nonManoArtifacts.get("onap_pm_dictionary").get("source"))
+ .isEqualTo(Lists.newArrayList("Artifacts/Measurements/PM_Dictionary.yaml")
);
- assertThat(nonManoArtifacts.get("prv.onap.yang_modules").get("Source"))
+ assertThat(nonManoArtifacts.get("onap_yang_module").get("source"))
+ .isEqualTo(Lists.newArrayList("Artifacts/Yang_module/Yang_module.yaml")
+ );
+ assertThat(nonManoArtifacts.get("onap_others").get("source"))
.isEqualTo(Lists.newArrayList(
- "Artifacts/Deployment/Yang_module/yang-module1.yang",
- "Artifacts/Deployment/Yang_module/yang-module2.yang"
- )
- );
+ "Artifacts/scripts/install.sh",
+ "Artifacts/Informational/user_guide.txt",
+ "Artifacts/Other/installation_guide.txt",
+ "Artifacts/Other/review_log.txt"
+ )
+ );
}
private void verifyThatMetadataWasSet(PnfCSARArchive pnfCSARArchive) {
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java
index 96a66c3..f680438 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfManifestParserTest.java
@@ -57,16 +57,21 @@ public class PnfManifestParserTest {
Map<String, Map<String, List<String>>> nonManoArtifacts = mapListPair.getKey();
List<CSARArchive.CSARError> errors= mapListPair.getValue();
- assertThat(nonManoArtifacts.get("prv.onap.ves_event").get("Source"))
- .isEqualTo(Lists.newArrayList("Artifacts/Deployment/Events/RadioNode_Pnf_v1.yml")
+ assertThat(nonManoArtifacts.get("onap_ves_events").get("source"))
+ .isEqualTo(Lists.newArrayList("Artifacts/Events/VES_registration.yml")
);
- assertThat(nonManoArtifacts.get("prv.onap.pm_dictionary").get("Source"))
- .isEqualTo(Lists.newArrayList("Artifacts/Deployment/Measurements/PM_Dictionary.yml")
+ assertThat(nonManoArtifacts.get("onap_pm_dictionary").get("source"))
+ .isEqualTo(Lists.newArrayList("Artifacts/Measurements/PM_Dictionary.yaml")
);
- assertThat(nonManoArtifacts.get("prv.onap.yang_modules").get("Source"))
+ assertThat(nonManoArtifacts.get("onap_yang_module").get("source"))
+ .isEqualTo(Lists.newArrayList("Artifacts/Yang_module/Yang_module.yaml")
+ );
+ assertThat(nonManoArtifacts.get("onap_others").get("source"))
.isEqualTo(Lists.newArrayList(
- "Artifacts/Deployment/Yang_module/yang-module1.yang",
- "Artifacts/Deployment/Yang_module/yang-module2.yang"
+ "Artifacts/scripts/install.sh",
+ "Artifacts/Informational/user_guide.txt",
+ "Artifacts/Other/installation_guide.txt",
+ "Artifacts/Other/review_log.txt"
)
);
assertThat(errors.size()).isEqualTo(0);
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfMetadataParserTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfMetadataParserTest.java
index 500fdd6..3d46334 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfMetadataParserTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfMetadataParserTest.java
@@ -55,10 +55,10 @@ public class PnfMetadataParserTest {
// given
List<String> lines = Lists.newArrayList(
"metadata:",
- "pnf_product_name: RadioNode",
- "pnf_provider_id: Ericsson",
- "pnf_package_version: 1.0",
- "pnf_release_date_time: 2019-01-14T11:25:00+00:00",
+ "pnfd_name: RadioNode",
+ "pnfd_provider: Ericsson",
+ "pnfd_archive_version: 1.0",
+ "pnfd_release_date_time: 2019-01-14T11:25:00+00:00",
"extra_param_1: some value",
"extra_param_2: some value"
);
@@ -83,10 +83,11 @@ public class PnfMetadataParserTest {
// given
List<String> lines = Lists.newArrayList(
"metadata:",
- "pnf_product_name: RadioNode",
- "pnf_provider_id: Ericsson",
- "pnf_package_version: 1.0",
- "pnf_release_date_time: 2019-01-14T11:25:00+00:00",
+ "pnfd_name: RadioNode",
+ "pnfd_provider: Ericsson",
+ "pnfd_archive_version: 1.0",
+ "# Ignore this comment",
+ "pnfd_release_date_time: 2019-01-14T11:25:00+00:00",
"non_mano_artifact_sets:",
"param_name: some value"
);
@@ -108,10 +109,10 @@ public class PnfMetadataParserTest {
// given
List<String> lines = Lists.newArrayList(
"metadata:",
- "pnf_product_name: RadioNode",
- "pnf_provider_id: Ericsson",
- "pnf_package_version: 1.0",
- "pnf_release_date_time: 2019-01-14T11:25:00+00:00",
+ "pnfd_name: RadioNode",
+ "pnfd_provider: Ericsson",
+ "pnfd_archive_version: 1.0",
+ "pnfd_release_date_time: 2019-01-14T11:25:00+00:00",
"unknown_section:",
"param_name: some value"
);
@@ -130,14 +131,14 @@ public class PnfMetadataParserTest {
@Test
- public void shouldReportAWarningWhenTokenWithOutColonWasFoundDuringMetadataProcessing() {
+ public void shouldReportAInvalidWhenTokenWithOutColonWasFoundDuringMetadataProcessing() {
// given
List<String> lines = Lists.newArrayList(
"metadata:",
- "pnf_product_name RadioNode",
- "pnf_provider_id: Ericsson",
- "pnf_package_version: 1.0",
- "pnf_release_date_time: 2019-01-14T11:25:00+00:00"
+ "pnfd_name RadioNode",
+ "pnfd_provider: Ericsson",
+ "pnfd_archive_version: 1.0",
+ "pnfd_release_date_time: 2019-01-14T11:25:00+00:00"
);
// when
@@ -148,7 +149,7 @@ public class PnfMetadataParserTest {
List<CSARArchive.CSARError> errors = data.getRight();
assertThat(errors.size()).isEqualTo(1);
assertThat(errors.stream().map(CSARArchive.CSARError::getMessage).collect(Collectors.toList())).contains(
- "Warning. Entry [pnf_product_name RadioNode]"
+ "Invalid. Entry [pnfd_name RadioNode]"
);
}
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java
index 95526bb..91d2648 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/PnfNonManoArtifactsParserTest.java
@@ -56,12 +56,13 @@ public class PnfNonManoArtifactsParserTest {
// given
List<String> lines = Lists.newArrayList(
"non_mano_artifact_sets:",
- "prv.onap.ves_event: # if private else onap_ves_event if public",
- "Source: Artifacts/Deployment/Events/RadioNode_Pnf_v1.yml",
+ "# Ignore this comment",
+ "onap_ves_events: # if private else onap_ves_event if public",
+ "source: Artifacts/Events/VES_registration.yml",
"extra_param_1: some value",
"extra_param_2: some value",
- "prv.onap.pm_dictionary: # if private else onap_pm_dictionary if public",
- "Source: Artifacts/Deployment/Measurements/PM_Dictionary.yml",
+ "onap_pm_dictionary: # if private else onap_pm_dictionary if public",
+ "source: Artifacts/Measurements/PM_Dictionary.yaml",
"param name: # if private else onap_yang_modules if public",
"key: value"
);
diff --git a/csarvalidation/src/test/resources/pnf/MainServiceTemplate.mf b/csarvalidation/src/test/resources/pnf/MainServiceTemplate.mf
index c5a498c..c0c0f97 100644
--- a/csarvalidation/src/test/resources/pnf/MainServiceTemplate.mf
+++ b/csarvalidation/src/test/resources/pnf/MainServiceTemplate.mf
@@ -1,14 +1,27 @@
metadata:
- pnf_product_name: RadioNode
- pnf_provider_id: Ericsson
- pnf_package_version: 1.0
- pnf_release_date_time: 2019-01-14T11:25:00+00:00
+ pnfd_name: RadioNode
+ pnfd_provider: Ericsson
+ pnfd_archive_version: 1.0
+ pnfd_release_date_time: 2019-01-14T11:25:00+00:00
+
+#The manifest file shall include a list of all files contained in or referenced from the VNF package with their location
+#source: Definitions/MainServiceTemplate.yaml
+#source: Definitions/etsi_nfv_sol001_vnfd_2_5_1_types.yaml
non_mano_artifact_sets:
- prv.onap.ves_event: # if private else onap_ves_event if public
- Source: Artifacts/Deployment/Events/RadioNode_Pnf_v1.yml
- prv.onap.pm_dictionary: # if private else onap_pm_dictionary if public
- Source: Artifacts/Deployment/Measurements/PM_Dictionary.yml
- prv.onap.yang_modules: # if private else onap_yang_modules if public
- Source: Artifacts/Deployment/Yang_module/yang-module1.yang
- Source: Artifacts/Deployment/Yang_module/yang-module2.yang \ No newline at end of file
+
+ onap_ves_events:
+ source: Artifacts/Events/VES_registration.yml
+
+ onap_pm_dictionary:
+ source: Artifacts/Measurements/PM_Dictionary.yaml
+
+ onap_yang_module:
+ source: Artifacts/Yang_module/Yang_module.yaml
+
+ onap_others:
+ source: Artifacts/scripts/install.sh
+ source: Artifacts/Informational/user_guide.txt
+ source: Artifacts/Other/installation_guide.txt
+ source: Artifacts/Other/review_log.txt
+
diff --git a/csarvalidation/src/test/resources/pnf/dummyPnfv2.csar b/csarvalidation/src/test/resources/pnf/dummyPnfv2.csar
index cc48435..778f45c 100644
--- a/csarvalidation/src/test/resources/pnf/dummyPnfv2.csar
+++ b/csarvalidation/src/test/resources/pnf/dummyPnfv2.csar
Binary files differ