| Felipe Vicens | f96bb45 | 2020-06-22 08:12:30 +0200 | [diff] [blame^] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | ## |
| 4 | # Copyright 2020 ATOS |
| 5 | # |
| 6 | # All Rights Reserved. |
| 7 | # |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | # you may not use this file except in compliance with the License. |
| 10 | # You may obtain a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | # See the License for the specific language governing permissions and |
| 18 | # limitations under the License. |
| 19 | ## |
| 20 | |
| 21 | cat /dev/zero | ssh-keygen -q -N "" > /dev/null |
| 22 | |
| 23 | install_osmclient(){ |
| 24 | echo -e "\nInstalling osmclient ${OSMCLIENT}" |
| 25 | python3 -m pip install git+https://osm.etsi.org/gerrit/osm/osmclient@${OSMCLIENT} |
| 26 | } |
| 27 | |
| 28 | download_packages(){ |
| 29 | echo -e "\nDownloading packages ${PACKAGES}" |
| 30 | rm -rf ${PACKAGES_FOLDER} |
| 31 | git clone https://osm.etsi.org/gitlab/vnf-onboarding/osm-packages.git ${PACKAGES_FOLDER} && (cd ${PACKAGES_FOLDER} && \ |
| 32 | git checkout ${PACKAGES}) |
| 33 | } |
| 34 | |
| 35 | PARAMS="" |
| 36 | |
| 37 | while (( "$#" )); do |
| 38 | case "$1" in |
| 39 | -t|--testingtags) |
| 40 | TEST=$2 |
| 41 | shift 2 |
| 42 | ;; |
| 43 | -p|--packagesbranch) |
| 44 | PACKAGES=$2 && download_packages |
| 45 | shift 2 |
| 46 | ;; |
| 47 | -o|--osmclientversion) |
| 48 | OSMCLIENT=$2 install_osmclient |
| 49 | shift 2 |
| 50 | ;; |
| 51 | -h|--help) |
| 52 | echo "OSM TESTS TOOL |
| 53 | |
| 54 | Usage: |
| 55 | docker run --rm=true -t osmtests --env-file <env_file> \\ |
| 56 | -v <path_to_reports>:/reports osmtests -v <path_to_clouds.yaml>:/robot-systest/clouds.yaml \\ |
| 57 | -v <path_to_kubeconfig>:/robot-systest/kubeconfig.yaml \\ |
| 58 | -o <osmclient_version> -p <package_branch> -t <testing_tags> |
| 59 | |
| 60 | Options: |
| 61 | --env-file: It is the environmental file where is described the OSM target and VIM |
| 62 | -o <osmclient_version> [OPTIONAL]: It is used to specify a particular osmclient version. Default: latest |
| 63 | -p <package_branch> [OPTIONAL]: OSM packages repository branch. Default: master |
| 64 | -t <testing_tags> [OPTIONAL]: Robot tests tags. [sanity, regression, particular_test]. Default: sanity |
| 65 | |
| 66 | Volumes: |
| 67 | <path_to_reports> [OPTIONAL]: It is the absolute path to reports location in the host |
| 68 | <path_to_clouds.yaml> [OPTIONAL]: It is the absolute path to the clouds.yaml file in the host" |
| 69 | |
| 70 | exit 0 |
| 71 | ;; |
| 72 | -*|--*=) |
| 73 | echo "Error: Unsupported flag $1" >&2 |
| 74 | exit 1 |
| 75 | ;; |
| 76 | *) |
| 77 | PARAMS="$PARAMS $1" |
| 78 | shift |
| 79 | ;; |
| 80 | esac |
| 81 | done |
| 82 | |
| 83 | eval set -- "$PARAMS" |
| 84 | |
| 85 | if [[ -z $TEST ]]; then |
| 86 | printf "Test not provided. \nRunning default test: sanity\n" |
| 87 | TEST="sanity" |
| 88 | fi |
| 89 | |
| 90 | |
| 91 | if [[ -n "$TEST" ]]; then |
| 92 | robot -d ${ROBOT_DEVOPS_FOLDER}/reports -i ${TEST} ${ROBOT_DEVOPS_FOLDER}/testsuite/ |
| 93 | exit 0 |
| 94 | else |
| 95 | echo "Wrong test provided" |
| 96 | exit 1 |
| 97 | fi |
| 98 | |
| 99 | exit 1 |