summaryrefslogtreecommitdiffstats
path: root/csarvalidation
diff options
context:
space:
mode:
authorGao Weitao <victor.gao@huawei.com>2019-03-11 06:24:01 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-11 06:24:01 +0000
commitebb53e546c55628d718f7d4c3c8c8505cd8c3075 (patch)
tree80d447362cf7a65593944b5656c9ef29cbd3f3cc /csarvalidation
parent7a66b3f46efa4aa0a7f2c9ceb4bd423b67a8c0e7 (diff)
parentabffb74716ba22a3c083776e38744b1e80640a02 (diff)
Merge "Add README.md"
Diffstat (limited to 'csarvalidation')
-rw-r--r--csarvalidation/README.md90
-rw-r--r--csarvalidation/pom.xml4
-rw-r--r--csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java18
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/CSARArchiveTest.java45
-rw-r--r--csarvalidation/src/test/java/org/onap/cvc/csar/CsarValidatorTest.java3
-rw-r--r--csarvalidation/src/test/resources/log4j.properties12
6 files changed, 139 insertions, 33 deletions
diff --git a/csarvalidation/README.md b/csarvalidation/README.md
new file mode 100644
index 0000000..b6192f8
--- /dev/null
+++ b/csarvalidation/README.md
@@ -0,0 +1,90 @@
+CSAR Validation
+===============
+Validates CSAR based on
+* ETSI SOL004 specification
+* ONAP VNFREQS & PNFREQS
+
+Every validation aspect is modeled as one test cases using Open Command Specification (OCS) 1.o
+and by using Open CLI Platform (OCLIP), those test cases are executed similar to running commands
+
+SOL004 specification is implemented in org.onap.cvc.csar.CSARArchive class by supporting both the
+options one with TOSCA-meta and another one without TOSCA-meta. This class could be used as SDK for
+parsing the given CSAR.
+
+Every VNFREQS & PNFREQS is implemented as independent test case and following guidelines provide
+required steps to add test cases.
+
+How to add new test cases?
+--------------------------
+Assume that we want to address the VNFREQS R02454 as one test case.
+
+1. Create new OCS yaml vtp-validate-csar-r02454.yaml under src/main/resources/open-cli-schema folder
+
+NOTE:
+Name of the file should be always in the form of vtp-validate-csar-<VNFREWQS-Number>.yaml
+Inside this YAML, add name as csar-validate-<VNFREWQS-Number>.
+Remaining section would be same as other existing OCS YAML.
+
+2. Add corresponding implementation class under src/main/java/org/onap/cvc/csar/cc/VTPValidateCSARR02454.java
+
+NOTE:
+Add @OnapCommandSchema(schema = "vtp-validate-csar-r02454.yaml") annotation to the class, where the schema will
+have OCS YAML file name
+
+3. Add required CSARError inside this class and set unique error code using CSARError::setSubCode() method
+
+4. Implement the run() method in this class by using the below code snippet
+
+ protected void run() throws OnapCommandException {
+ //Read the input arguments
+ String path = (String) getParametersMap().get("csar").getValue();
+ List<CSARError> errors = new ArrayList<>();
+ //execute
+ try {
+ CSARArchive csar = new CSARArchive();
+ csar.init(path);
+ csar.parse();
+
+ // *********** ADD REQUIRED VALIDATION ************
+
+ csar.cleanup();
+ } catch (Exception e) {
+ LOG.error("R-40293: ", e);
+ throw new OnapCommandExecutionFailed(e.getMessage());
+ }
+
+ this.getResult().setOutput(errors);
+
+ //set the result
+ for (CSARError e: errors) {
+ this.getResult().getRecordsMap().get("code").getValues().add(e.getCode());
+ this.getResult().getRecordsMap().get("message").getValues().add(e.getMessage());
+ this.getResult().getRecordsMap().get("file").getValues().add(e.getFile());
+ this.getResult().getRecordsMap().get("line-no").getValues().add(Integer.toString(e.getLineNumber()));
+ }
+ }
+
+5. Add the new class into src/main/resources/META-INF/services/org.onap.cli.fw.cmd.OnapCommand file
+
+6. Run the test cases at src/test/java/org/onap/cvc/csar/CsarValidatorTest and verify that it picked up the new test cases.
+
+How to configure vnfreqs.properties
+-----------------------------------
+
+1. To enable the given vnfreqs, edit vnfreqs.enabled with required VNFREQS number
+
+2. To ignore certian errors, use errors.ignored.
+
+How to run CSAR validation
+--------------------------
+Follow the setups given below to run as csar-validate command
+
+1. Install OCLIP (wget https://raw.githubusercontent.com/onap/cli/master/deployment/zip/installer/install-latest.sh | sh)
+
+2. Run mvn clean install on this project, and copy the target/validation-csar-x.y.z.jar in to $OPEN_CLI_HOME/lib
+
+3. Run oclip --product onap-vtp csar-validate --csar <CSAR path>
+
+Contact
+-------
+Kanagaraj.Manickam@huawei.com \ No newline at end of file
diff --git a/csarvalidation/pom.xml b/csarvalidation/pom.xml
index 8b546e6..0f25ba6 100644
--- a/csarvalidation/pom.xml
+++ b/csarvalidation/pom.xml
@@ -112,7 +112,7 @@
<dependency>
<groupId>org.onap.cli</groupId>
<artifactId>cli-framework</artifactId>
- <version>2.0.5</version>
+ <version>2.0.6</version>
<!-- <exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
@@ -124,7 +124,7 @@
<dependency>
<groupId>org.onap.cli</groupId>
<artifactId>cli-main</artifactId>
- <version>2.0.5</version>
+ <version>2.0.6</version>
<scope>test</scope>
<!-- <exclusions>
<exclusion>
diff --git a/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java b/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java
index d14c14b..cfea2b4 100644
--- a/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java
+++ b/csarvalidation/src/main/java/org/onap/cvc/csar/CSARArchive.java
@@ -1309,22 +1309,4 @@ public class CSARArchive {
public File getFileFromCsar(String path) {
return new File(this.tempDir.toFile().getAbsolutePath() + File.separator + path);
}
-
- public static void main(String[] args) {
- System.out.println(CSARArchive.SOL0004_2_4_1);
-
- for (String csarFileName: Arrays.asList(new String[] {"enterprise2DC", "VoLTE", "vEPC_NS", "vIMS_NS", "sample2"})) {
- try {
- CSARArchive csar = new CSARArchive();
- System.out.println(csarFileName);
- csar.init("D:\\workspace\\onap\\1.1\\vnfsdk\\validation\\csarvalidation\\src\\test\\resources\\" + csarFileName + ".csar");
- csar.parse();
- csar.cleanup();
- System.out.println(csar.getErrors());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
}
diff --git a/csarvalidation/src/test/java/org/onap/cvc/csar/CSARArchiveTest.java b/csarvalidation/src/test/java/org/onap/cvc/csar/CSARArchiveTest.java
new file mode 100644
index 0000000..4e13093
--- /dev/null
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/CSARArchiveTest.java
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.cvc.csar;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.junit.Test;
+
+public class CSARArchiveTest {
+
+ @Test
+ public void testAll() throws IOException, InterruptedException {
+ System.out.println(CSARArchive.SOL0004_2_4_1);
+
+ for (String csarFileName: Arrays.asList(new String[] {"enterprise2DC", "VoLTE", "vEPC_NS", "vIMS_NS", "sample2"})) {
+ try {
+ CSARArchive csar = new CSARArchive();
+ System.out.println(csarFileName);
+ csar.init("./src/test/resources/" + csarFileName + ".csar");
+ csar.parse();
+ csar.cleanup();
+ System.out.println(csar.getErrors());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+
+}
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 6378c45..f7b64d1 100644
--- a/csarvalidation/src/test/java/org/onap/cvc/csar/CsarValidatorTest.java
+++ b/csarvalidation/src/test/java/org/onap/cvc/csar/CsarValidatorTest.java
@@ -27,8 +27,7 @@ public class CsarValidatorTest {
@Test
public void testAll() throws IOException, InterruptedException {
- OnapCli cli = new OnapCli(new String [] {"csar-validate", "--format", "json", "--csar", "./src/test/resources/VoLTE.csar"});
- cli.setProduct("onap-vtp");
+ OnapCli cli = new OnapCli(new String [] {"--product", "onap-vtp", "csar-validate", "--format", "json", "--csar", "./src/test/resources/VoLTE.csar"});
cli.handle();
assertEquals(0, cli.getExitCode());
}
diff --git a/csarvalidation/src/test/resources/log4j.properties b/csarvalidation/src/test/resources/log4j.properties
index 2f44a11..68212d7 100644
--- a/csarvalidation/src/test/resources/log4j.properties
+++ b/csarvalidation/src/test/resources/log4j.properties
@@ -12,20 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-log4j.rootLogger=ERROR, file
-
-log4j.logger.org.onap=ERROR, stdout
+log4j.rootLogger=INFO, stdout
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
-
-# Redirect log messages to a log file, support file rolling.
-log4j.appender.file=org.apache.log4j.RollingFileAppender
-log4j.appender.file.File=./csar-validate.log
-log4j.appender.file.MaxFileSize=5MB
-log4j.appender.file.MaxBackupIndex=10
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n