blob: 7e96d92b65e0b7c322f1107fdde5854bab3c4c26 [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
Felipe Vicens55b61582020-06-24 21:23:44 +020035create_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 \
garciaale764873c2020-07-02 17:42:00 -040039 --config "{management_network_name: ${VIM_MGMT_NET}, dataplane_physical_net: ${DATAPLANE:-physnet2}}" || true
Felipe Vicens02300c02020-07-02 12:19:28 +020040 STATUS="PROCESSING"
41 i=0
42 while [[ ${STATUS} != "ENABLED" ]]
43 do
44 ((i++))
45 if [[ $i -eq 5 ]]; then
46 echo "VIM stuck in PROCESSING after 100 seconds"
47 exit 1
48 fi
49 sleep 20
50 STATUS=`osm vim-list --long | grep ${VIM_TARGET} | awk '{print $9}'`
51 done
Felipe Vicens55b61582020-06-24 21:23:44 +020052}
53
Felipe Vicensf96bb452020-06-22 08:12:30 +020054PARAMS=""
55
56while (( "$#" )); do
57 case "$1" in
58 -t|--testingtags)
59 TEST=$2
60 shift 2
61 ;;
62 -p|--packagesbranch)
63 PACKAGES=$2 && download_packages
64 shift 2
65 ;;
66 -o|--osmclientversion)
Felipe Vicens24e3d152020-06-25 21:52:06 +020067 OSMCLIENT=$2 && install_osmclient
Felipe Vicensf96bb452020-06-22 08:12:30 +020068 shift 2
69 ;;
Felipe Vicens55b61582020-06-24 21:23:44 +020070 -c|--createvim)
71 create_vim
72 shift 1
73 ;;
Felipe Vicensf96bb452020-06-22 08:12:30 +020074 -h|--help)
75 echo "OSM TESTS TOOL
76
77Usage:
78 docker run --rm=true -t osmtests --env-file <env_file> \\
Felipe Vicens5c54d272020-06-23 15:55:08 +020079 -v <path_to_reports>:/reports osmtests \\
80 -v <path_to_clouds.yaml>:/robot-systest/clouds.yaml \\
81 -v <path_to_kubeconfig>:/root/.kube/config \\
82 -o <osmclient_version> \\
83 -p <package_branch> \\
84 -t <testing_tags>
Felipe Vicens6366c682020-06-25 20:12:16 +020085
Felipe Vicensf96bb452020-06-22 08:12:30 +020086Options:
87 --env-file: It is the environmental file where is described the OSM target and VIM
88 -o <osmclient_version> [OPTIONAL]: It is used to specify a particular osmclient version. Default: latest
89 -p <package_branch> [OPTIONAL]: OSM packages repository branch. Default: master
90 -t <testing_tags> [OPTIONAL]: Robot tests tags. [sanity, regression, particular_test]. Default: sanity
Felipe Vicens55b61582020-06-24 21:23:44 +020091 -c To create a VIM for the tests
Felipe Vicensf96bb452020-06-22 08:12:30 +020092
93Volumes:
94 <path_to_reports> [OPTIONAL]: It is the absolute path to reports location in the host
Felipe Vicens5c54d272020-06-23 15:55:08 +020095 <path_to_clouds.yaml> [OPTIONAL]: It is the absolute path to the clouds.yaml file in the host
96 <path_to_kubeconfig> [OPTIONAL]: It is the kubeconfig file to be used for k8s clusters"
Felipe Vicensf96bb452020-06-22 08:12:30 +020097
98 exit 0
99 ;;
100 -*|--*=)
101 echo "Error: Unsupported flag $1" >&2
102 exit 1
103 ;;
104 *)
105 PARAMS="$PARAMS $1"
106 shift
107 ;;
108 esac
109done
110
111eval set -- "$PARAMS"
112
Felipe Vicens24e3d152020-06-25 21:52:06 +0200113if [[ -n "$BRANCH_NAME" ]]; then
114 PACKAGES=$BRANCH_NAME && download_packages
115 OSMCLIENT=$BRANCH_NAME && install_osmclient
Felipe Vicens6366c682020-06-25 20:12:16 +0200116fi
117
118if [[ -z "${TEST}" ]]; then
Felipe Vicensf96bb452020-06-22 08:12:30 +0200119 printf "Test not provided. \nRunning default test: sanity\n"
120 TEST="sanity"
121fi
122
Felipe Vicens6366c682020-06-25 20:12:16 +0200123if [[ -n "${TEST}" ]]; then
Felipe Vicensf96bb452020-06-22 08:12:30 +0200124 robot -d ${ROBOT_DEVOPS_FOLDER}/reports -i ${TEST} ${ROBOT_DEVOPS_FOLDER}/testsuite/
125 exit 0
126else
127 echo "Wrong test provided"
128 exit 1
129fi
130
131exit 1