Validates CSAR based on
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.
Assume that we want to address the VNFREQS R02454 as one test case.
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.
NOTE: Add @OnapCommandSchema(schema = "vtp-validate-csar-r02454.yaml") annotation to the class, where the schema will have OCS YAML file name
Add required CSARError inside this class and set unique error code using CSARError::setCode() method
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())); }
}
Add the new class into src/main/resources/META-INF/services/org.onap.cli.fw.cmd.OnapCommand file
Run the test cases at src/test/java/org/onap/cvc/csar/CsarValidatorTest and verify that it picked up the new test cases.
To enable the given vnfreqs, edit vnfreqs.enabled with required VNFREQS number
To ignore certian errors, use errors.ignored.
Follow the setups given below to run as csar-validate command.
Warning !!! Be default, during project building, documentation generation is being disabled (see point "Documentation generation" for more details). In order to enable this process, add parameter -DskipDocsGeneration=false
to mvn command, example: mvn clean package -DskipDocsGeneration=false
Install OCLIP (wget -O - https://raw.githubusercontent.com/onap/cli/master/deployment/zip/installer/install-latest.sh | sh
)
Run mvn clean install
on this project, and copy the target/validation-csar-x.y.z.jar in to $OPEN_CLI_HOME/lib
Run oclip --product onap-vtp csar-validate --csar <CSAR path>
During project build, automated generation of tables, containing supported rules, is being performed. Created tables are being saved in target directory, target/generated-docs/{current_release}
. This generation is being performed by exec-maven-plugin
, defined in pom.xml.
In order to generate tables python3 and pip3 are required.