summaryrefslogtreecommitdiffstats
path: root/csarvalidation/src
diff options
context:
space:
mode:
Diffstat (limited to 'csarvalidation/src')
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java30
-rw-r--r--csarvalidation/src/main/resources/open-cli-schema/vtp-validate-csar.yaml6
-rw-r--r--csarvalidation/src/main/resources/vnfreqs.properties6
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/CsarValidatorTest.java32
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/IntegrationTestUtils.java4
5 files changed, 49 insertions, 29 deletions
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java b/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java
index 006d78d..d348235 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/VTPValidateCSAR.java
@@ -16,7 +16,6 @@
package org.onap.cvc.csar;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -185,13 +184,13 @@ public class VTPValidateCSAR extends OnapCommand {
protected void run() throws OnapCommandException {
//Read the input arguments
String path = (String) getParametersMap().get("csar").getValue();
+ boolean isPnf = (boolean) getParametersMap().get("pnf").getValue();
boolean overallPass = true;
- try {
- CSARArchive csar = new CSARArchive();
+ try(CSARArchive csar = isPnf ? new PnfCSARArchive(): new CSARArchive()){
csar.init(path);
csar.parse();
- csar.cleanup();
+
//Fill up the basic details
CSARValidation validation = new CSARValidation();
@@ -201,7 +200,8 @@ public class VTPValidateCSAR extends OnapCommand {
validation.getVnf().setType("TOSCA");
validation.getVnf().setMode(csar.getToscaMeta().getMode().name());
- List <String> ignoreCodes = this.getIgnoreErrorCodes();
+ String keyErrors = isPnf ? "pnferrors.ignored" : "vnferrors.ignored";
+ List <String> ignoreCodes = this.getPropertiesList(keyErrors);
//Add SOL004 error codes
CSARValidation.Result resultSOL004 = new CSARValidation.Result();
@@ -214,12 +214,13 @@ public class VTPValidateCSAR extends OnapCommand {
overallPass = false;
}
}
- resultSOL004.setPassed(resultSOL004.getErrors().size() == 0);
+ resultSOL004.setPassed(resultSOL004.getErrors().isEmpty());
validation.getResults().add(resultSOL004);
//Run thru the vnfreqs requirement checks
- for (String vnfreq: this.getEnabledReqs()) {
+ String keyReqs = isPnf ? "pnfreqs.enabled" : "vnfreqs.enabled";
+ for (String vnfreq: this.getPropertiesList(keyReqs)) {
CSARValidation.Result result = new CSARValidation.Result();
result.setVnfreqName(vnfreq);
@@ -237,7 +238,7 @@ public class VTPValidateCSAR extends OnapCommand {
}
}
- result.setPassed(result.getErrors().size() == 0);
+ result.setPassed(result.getErrors().isEmpty());
validation.getResults().add(result);
} catch (Exception e) {
result.setPassed(false);
@@ -265,21 +266,12 @@ public class VTPValidateCSAR extends OnapCommand {
}
}
- private List<String> getEnabledReqs() throws IOException {
- String[] enabledReqs = prp.getProperty("vnfreqs.enabled", "").split(",");
+ private List<String> getPropertiesList(String key) {
+ String[] enabledReqs = prp.getProperty(key, "").split(",");
List<String> list = new ArrayList<>();
for(String req: enabledReqs) {
if (!req.isEmpty()) list.add(req);
}
return list;
}
-
- private List<String> getIgnoreErrorCodes() throws IOException {
- String[] errorsToIgnore = prp.getProperty("errors.ignored", "").split(",");
- List<String> list = new ArrayList<>();
- for(String req: errorsToIgnore) {
- if (!req.isEmpty()) list.add(req);
- }
- return list;
- }
}
diff --git a/csarvalidation/src/main/resources/open-cli-schema/vtp-validate-csar.yaml b/csarvalidation/src/main/resources/open-cli-schema/vtp-validate-csar.yaml
index 709af93..b8a4cb1 100644
--- a/csarvalidation/src/main/resources/open-cli-schema/vtp-validate-csar.yaml
+++ b/csarvalidation/src/main/resources/open-cli-schema/vtp-validate-csar.yaml
@@ -31,6 +31,12 @@ parameters:
short_option: b
type: binary
is_optional: false
+ - name: pnf
+ description: CSAR file contains PNF
+ long_option: pnf
+ type: bool
+ is_optional: true
+ default_value: false
results:
direction: portrait
diff --git a/csarvalidation/src/main/resources/vnfreqs.properties b/csarvalidation/src/main/resources/vnfreqs.properties
index e7d71c7..8f45363 100644
--- a/csarvalidation/src/main/resources/vnfreqs.properties
+++ b/csarvalidation/src/main/resources/vnfreqs.properties
@@ -1,3 +1,5 @@
-vnfreqs.enabled=r02454,r04298,r07879,r09467,r13390,r23823,r26881,r27310,r35851,r40293,r43958,r66070,r77707,r77786,r87234,r10087,r21322,r26885,r40820,r35854,r65486,r17852,r46527,r15837,r54356,r67895,r95321,r32155,r01123,r51347,r293901,r146092,r57019
+vnfreqs.enabled=r02454,r04298,r07879,r09467,r13390,r23823,r26881,r27310,r35851,r40293,r43958,r66070,r77707,r77786,r87234,r10087,r21322,r26885,r40820,r35854,r65486,r17852,r46527,r15837,r54356,r67895,r95321,r32155,r01123,r51347
+pnfreqs.enabled=r293901,r146092,r57019
# ignored all chef and ansible related tests
-errors.ignored=0x1005,0x1006,r07879-0x1000,r13390-0x1000,r27310-0x1000,r40293-0x1000,r77786-0x1000,r04298-0x1000,r07879-0x1000,r10087-0x1000,r13390-0x1000,r23823-0x1000,r26881-0x1000,r40820-0x1000,r35851-0x1000,r32155-0x1000,r54356-0x1000,r67895-0x1000,r95321-0x1000,r46527-0x1000,r02454-0x1000
+vnferrors.ignored=0x1005,0x1006,r07879-0x1000,r13390-0x1000,r27310-0x1000,r40293-0x1000,r77786-0x1000,r04298-0x1000,r07879-0x1000,r10087-0x1000,r13390-0x1000,r23823-0x1000,r26881-0x1000,r40820-0x1000,r35851-0x1000,r32155-0x1000,r54356-0x1000,r67895-0x1000,r95321-0x1000,r46527-0x1000,r02454-0x1000
+pnferrors.ignored= \ No newline at end of file
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/CsarValidatorTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/CsarValidatorTest.java
index f7b64d1..c441b80 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/CsarValidatorTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/CsarValidatorTest.java
@@ -16,18 +16,38 @@
package org.onap.cvc.csar;
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-
import org.junit.Test;
import org.onap.cli.main.OnapCli;
+import java.net.URISyntaxException;
+
+import static org.junit.Assert.assertEquals;
+import static org.onap.cvc.csar.cc.sol004.IntegrationTestUtils.absoluteFilePath;
+
+
public class CsarValidatorTest {
+
+ @Test
+ public void testAllTestCasesForVNF() throws URISyntaxException {
+ OnapCli cli = new OnapCli(new String [] {
+ "--product", "onap-vtp",
+ "csar-validate",
+ "--format", "json",
+ "--csar", absoluteFilePath("VoLTE.csar")});
+ cli.handle();
+ assertEquals(0, cli.getExitCode());
+ }
+
+
@Test
- public void testAll() throws IOException, InterruptedException {
- OnapCli cli = new OnapCli(new String [] {"--product", "onap-vtp", "csar-validate", "--format", "json", "--csar", "./src/test/resources/VoLTE.csar"});
+ public void testAllTestCasesForPNF() throws URISyntaxException {
+ OnapCli cli = new OnapCli(new String [] {
+ "--product", "onap-vtp",
+ "csar-validate",
+ "--format", "json",
+ "--pnf",
+ "--csar", absoluteFilePath("pnf/r57019/allMandatoryEntriesDefinedInMetadataManifest.csar")});
cli.handle();
assertEquals(0, cli.getExitCode());
}
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/IntegrationTestUtils.java b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/IntegrationTestUtils.java
index 32ac187..5e1c836 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/IntegrationTestUtils.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/cc/sol004/IntegrationTestUtils.java
@@ -31,13 +31,13 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
-class IntegrationTestUtils {
+public class IntegrationTestUtils {
private IntegrationTestUtils() {
}
- private static String absoluteFilePath(String relativeFilePath) throws URISyntaxException {
+ public static String absoluteFilePath(String relativeFilePath) throws URISyntaxException {
return VTPValidatePnfCSARBase.class.getClassLoader().getResource(relativeFilePath)
.toURI().getPath();
}