blob: edf32b7f7732203d1e62b2150bbcfed98972e614 [file] [log] [blame]
Felipe Vicensf96bb452020-06-22 08:12:30 +02001#!/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
21cat /dev/zero | ssh-keygen -q -N "" > /dev/null
22
23install_osmclient(){
24 echo -e "\nInstalling osmclient ${OSMCLIENT}"
25 python3 -m pip install git+https://osm.etsi.org/gerrit/osm/osmclient@${OSMCLIENT}
26}
27
28download_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
beierlm3f0e8842020-06-26 14:57:09 -040035create_vim(){
36 echo -e "\nCreating VIM ${VIM_TARGET}"
37 osm vim-create --name ${VIM_TARGET} --user ${OS_USERNAME} --password ${OS_PASSWORD} --tenant ${OS_PROJECT_NAME} \
38 --auth_url ${OS_AUTH_URL} --account_type openstack --description vim \
39 --config "{management_network_name: ${VIM_MGMT_NET}}" || true
40}
41
Felipe Vicensf96bb452020-06-22 08:12:30 +020042PARAMS=""
43
44while (( "$#" )); do
45 case "$1" in
46 -t|--testingtags)
47 TEST=$2
48 shift 2
49 ;;
50 -p|--packagesbranch)
51 PACKAGES=$2 && download_packages
52 shift 2
53 ;;
54 -o|--osmclientversion)
beierlm3f0e8842020-06-26 14:57:09 -040055 OSMCLIENT=$2 && install_osmclient
Felipe Vicensf96bb452020-06-22 08:12:30 +020056 shift 2
57 ;;
beierlm3f0e8842020-06-26 14:57:09 -040058 -c|--createvim)
59 create_vim
60 shift 1
61 ;;
Felipe Vicensf96bb452020-06-22 08:12:30 +020062 -h|--help)
63 echo "OSM TESTS TOOL
64
65Usage:
66 docker run --rm=true -t osmtests --env-file <env_file> \\
Felipe Vicens5c54d272020-06-23 15:55:08 +020067 -v <path_to_reports>:/reports osmtests \\
68 -v <path_to_clouds.yaml>:/robot-systest/clouds.yaml \\
69 -v <path_to_kubeconfig>:/root/.kube/config \\
70 -o <osmclient_version> \\
71 -p <package_branch> \\
72 -t <testing_tags>
beierlm3f0e8842020-06-26 14:57:09 -040073
Felipe Vicensf96bb452020-06-22 08:12:30 +020074Options:
75 --env-file: It is the environmental file where is described the OSM target and VIM
76 -o <osmclient_version> [OPTIONAL]: It is used to specify a particular osmclient version. Default: latest
77 -p <package_branch> [OPTIONAL]: OSM packages repository branch. Default: master
78 -t <testing_tags> [OPTIONAL]: Robot tests tags. [sanity, regression, particular_test]. Default: sanity
beierlm3f0e8842020-06-26 14:57:09 -040079 -c To create a VIM for the tests
Felipe Vicensf96bb452020-06-22 08:12:30 +020080
81Volumes:
82 <path_to_reports> [OPTIONAL]: It is the absolute path to reports location in the host
Felipe Vicens5c54d272020-06-23 15:55:08 +020083 <path_to_clouds.yaml> [OPTIONAL]: It is the absolute path to the clouds.yaml file in the host
84 <path_to_kubeconfig> [OPTIONAL]: It is the kubeconfig file to be used for k8s clusters"
Felipe Vicensf96bb452020-06-22 08:12:30 +020085
86 exit 0
87 ;;
88 -*|--*=)
89 echo "Error: Unsupported flag $1" >&2
90 exit 1
91 ;;
92 *)
93 PARAMS="$PARAMS $1"
94 shift
95 ;;
96 esac
97done
98
99eval set -- "$PARAMS"
100
beierlm3f0e8842020-06-26 14:57:09 -0400101if [[ -n "$BRANCH_NAME" ]]; then
102 PACKAGES=$BRANCH_NAME && download_packages
103 OSMCLIENT=$BRANCH_NAME && install_osmclient
104fi
105
106if [[ -z "${TEST}" ]]; then
Felipe Vicensf96bb452020-06-22 08:12:30 +0200107 printf "Test not provided. \nRunning default test: sanity\n"
108 TEST="sanity"
109fi
110
beierlm3f0e8842020-06-26 14:57:09 -0400111if [[ -n "${TEST}" ]]; then
Felipe Vicensf96bb452020-06-22 08:12:30 +0200112 robot -d ${ROBOT_DEVOPS_FOLDER}/reports -i ${TEST} ${ROBOT_DEVOPS_FOLDER}/testsuite/
113 exit 0
114else
115 echo "Wrong test provided"
116 exit 1
117fi
118
119exit 1