From abffb74716ba22a3c083776e38744b1e80640a02 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Wed, 6 Mar 2019 17:16:54 +0530 Subject: Add README.md Issue-ID: VNFSDK-276 Change-Id: I4917b8bf484feaf34a8bcdead677cd12cfb18057 Signed-off-by: Kanagaraj Manickam k00365106 --- csarvalidation/README.md | 90 ++++++++++++++++++++++ csarvalidation/pom.xml | 4 +- .../main/java/org/onap/cvc/csar/CSARArchive.java | 18 ----- .../java/org/onap/cvc/csar/CSARArchiveTest.java | 45 +++++++++++ .../java/org/onap/cvc/csar/CsarValidatorTest.java | 3 +- csarvalidation/src/test/resources/log4j.properties | 12 +-- 6 files changed, 139 insertions(+), 33 deletions(-) create mode 100644 csarvalidation/README.md create mode 100644 csarvalidation/src/test/java/org/onap/cvc/csar/CSARArchiveTest.java 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-.yaml +Inside this YAML, add name as csar-validate-. +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 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 + +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 @@ org.onap.cli cli-framework - 2.0.5 + 2.0.6