1 # Copyright 2019 AT&T Intellectual Property. All rights reserved.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 from robot.api.deco import keyword
19 VVP_URL = "https://gerrit.onap.org/r/vvp/validation-scripts"
22 # use this to import and run validation from robot
23 class HeatValidationScripts:
28 def validate(self, build_dir, template_directory, output_directory):
30 keyword invoked by robot to execute VVP validation scripts
32 :build_dir: directory to install virtualenv
33 and clone validation scripts
34 :template_directory: directory with heat templates
35 :output_directory: directory to store output files
37 t = VVP(build_dir, template_directory, output_directory)
38 t.install_requirements()
45 def __init__(self, build_dir, template_directory, output_directory):
46 self._build_dir = build_dir
49 self.virtualenv = "{}/test_env".format(build_dir)
50 self.vvp = "{}/validation_scripts".format(build_dir)
51 self.template_directory = template_directory
52 self.output_directory = output_directory
55 self.create_venv(self._build_dir)
56 self.clone_vvp(self._build_dir)
58 def create_venv(self, build_dir):
61 ["python3.7", "-m", "virtualenv", "--clear", "{}/test_env".format(build_dir)]
64 print("error creating virtual environment for vvp {}".format(e))
67 def clone_vvp(self, build_dir):
68 if not os.path.exists("{}/validation_scripts".format(build_dir)):
77 "{}/validation_scripts".format(build_dir),
81 print("error cloning vvp validation scripts {}".format(e))
84 def install_requirements(self):
88 "{}/bin/python".format(self.virtualenv),
99 "{}/bin/python".format(self.virtualenv),
105 "{}/requirements.txt".format(self.vvp),
109 print("error installing vvp requirements {}".format(e))
114 ret = subprocess.call(
116 "{}/bin/python".format(self.virtualenv),
119 "--rootdir={}/ice_validator/".format(self.vvp),
120 "--template-directory={}".format(self.template_directory),
121 "--output-directory={}".format(self.output_directory),
122 "{}/ice_validator/tests/".format(self.vvp),
126 print("error running vvp validation scripts {}".format(e))
130 raise ValueError("Validation Script error detected")