blob: 3ab5828cb9e8c88933f58e792cce5dba22882fa2 [file] [log] [blame]
Victor Moralesdd074802017-07-26 16:06:35 -05001#!/bin/bash
2
3source /var/onap_tests/_test_base
4source /var/onap/functions
5
6covered_functions=(
7"create_configuration_files" "clone_repo" "install_dev_tools"
8"configure_bind" "install_java" "install_maven" "install_nodejs" "install_python"
9"install_docker" "pull_docker_image" "install_docker_compose" "configure_service"
Victor Moralescf269992017-10-18 09:29:55 -070010"start_ODL" "compile_src" "build_docker_image" "docker_openecomp_login"
Victor Morales21404d72017-10-20 13:18:26 -070011"pull_openecomp_image" "pull_onap_image" "coverity_repos"
Victor Moralesdd074802017-07-26 16:06:35 -050012)
13
Victor Moralesdd074802017-07-26 16:06:35 -050014# test_create_configuration_files() - Verify the creation of a configuration files
15function test_create_configuration_files {
16 create_configuration_files
17
18 asserts_file_exist /opt/config/nexus_docker_repo.txt
19 asserts_file_exist /opt/config/nexus_username.txt
20 asserts_file_exist /opt/config/nexus_password.txt
21 asserts_file_exist /opt/config/openstack_username.txt
22 asserts_file_exist /opt/config/tenant_id.txt
23 asserts_file_exist /opt/config/dmaap_topic.txt
24 asserts_file_exist /opt/config/docker_version.txt
25}
26
27# test_docker_openecomp_login() - Verify the proper login to OpenECOMP Docker Hub
28function test_docker_openecomp_login {
29 docker_openecomp_login
30}
31
Victor Moralescf269992017-10-18 09:29:55 -070032# test_pull_openecomp_image() - Verify the OpenECOMP container image pulling process
Victor Moralesdd074802017-07-26 16:06:35 -050033function test_pull_openecomp_image {
Victor Moralescf269992017-10-18 09:29:55 -070034 local image_name=portal-apps
35 unset docker_version
36 pull_openecomp_image $image_name
Victor Moralesdd074802017-07-26 16:06:35 -050037
Victor Moralescf269992017-10-18 09:29:55 -070038 asserts_image $nexus_docker_repo/openecomp/$image_name
39}
Victor Moralesdd074802017-07-26 16:06:35 -050040
Victor Moralescf269992017-10-18 09:29:55 -070041# test_pull_onap_image() - Verify the ONAP cointainer pulling process
42function test_pull_onap_image {
43 local image_name=portal-apps
44 unset docker_version
45 pull_onap_image $image_name
46
47 asserts_image $nexus_docker_repo/onap/$image_name
Victor Moralesdd074802017-07-26 16:06:35 -050048}
49
50# test_clone_repo() - Verify cloning and pulling source code from repositories
51function test_clone_repo {
52 clone_repo demo
53
54 asserts_installed_package git
55 asserts_file_exist $git_src_folder/demo/LICENSE.TXT
56}
57
58# test_install_dev_tools() - Verify the correct installation of developer tools
59function test_install_dev_tools {
60 install_dev_tools
61
62 asserts_installed_package apt-transport-https
63 asserts_installed_package ca-certificates
64 asserts_installed_package curl
65}
66
67# test_configure_bind() - Verify the correct installation and configuration of bind
68function test_configure_bind {
69 configure_bind
70
71 asserts_installed_package bind9
72 asserts_installed_package bind9utils
73 asserts_file_exist /etc/bind/zones/db.simpledemo.openecomp.org
74 asserts_file_exist /etc/bind/named.conf.options
75 asserts_file_exist /etc/bind/named.conf.local
76
77 rm -rf /etc/bind/
78}
79
80# test_install_java() - Verify the correct installation of java
81function test_install_java {
82 install_java
83
84 asserts_installed_package openjdk-8-jdk
85}
86
87# test_install_maven() - Verify the correct installation and configuration of maven
88function test_install_maven {
89 install_maven
90
91 asserts_installed_package maven3
92 asserts_installed_package openjdk-8-jdk
93 asserts_file_exist $mvn_conf_file
94}
95
96# test_install_nodejs() - Verify the correct installation of NodeJS tools
97function test_install_nodejs {
98 install_nodejs
99
100 asserts_installed_package nodejs
101 asserts_file_exist /usr/bin/npm
102}
103
104# test_install_python() - Verify the correct installation of Python
105function test_install_python {
106 install_python
107 asserts_installed_package python2.7
108 asserts_installed_package python-dev
Victor Moralesdd074802017-07-26 16:06:35 -0500109}
110
111# test_install_docker() - Verify the correct installation of Docker
112function test_install_docker {
113 install_docker
114
115 asserts_installed_package docker-ce
116}
117
118# test_pull_docker_image() - Verify the correct retrieve of a specific docker image
119function test_pull_docker_image {
120 local image=attos/dmaap
121 pull_docker_image $image
122
123 asserts_image $image
Victor Moralesdd074802017-07-26 16:06:35 -0500124}
125
126# test_install_docker_compose() - Verify the correct installation of Docker Compose tool
127function test_install_docker_compose {
128 install_docker_compose
129
130 asserts_file_exist /opt/docker/docker-compose
131}
132
133# test_configure_service() - Verify the correct configuration of a specific init service
134function test_configure_service {
135 local service=mso
136
137 configure_service $service
138
139 asserts_file_exist /etc/init.d/$service
140
141 rm -rf /etc/init.d/$service
142}
143
144# test_start_ODL() - Verify the installation and configuration of OpenDayLight controller
145function test_start_ODL {
146 start_ODL
147
148 asserts_file_exist /opt/opendaylight/current/bin/start
149}
150
151# test_compile_src() - Verify the compilation of java code using maven tools
152function test_compile_src {
153 local repo=vid/asdcclient
154 clone_repo $repo
155 compile_src $git_src_folder/$repo
156
157 asserts_file_exist $git_src_folder/$repo/target/asdcclient-1.0.2-SNAPSHOT.jar
158}
159
160# test_build_docker_image() - Verify that a docker image is created from source code
161function test_build_docker_image {
Victor Moralesa898f562017-09-14 15:43:21 -0700162 clone_repo ccsdk/distribution
163 build_docker_image $git_src_folder/ccsdk/distribution/ubuntu docker
Victor Moralesdd074802017-07-26 16:06:35 -0500164
Victor Moralesa898f562017-09-14 15:43:21 -0700165 asserts_image onap/ccsdk-ubuntu-image
Victor Moralesdd074802017-07-26 16:06:35 -0500166}
167
Victor Morales21404d72017-10-20 13:18:26 -0700168# test_coverity_repos() - Verify that all the repos are covered by scripts
169function test_coverity_repos {
170 # Get repositories list from source code files
171 repos_list=()
172 for module in $( stat -c "%F %n" /var/onap/* | grep -v "_\|functions\|commons\|files" | cut -d' ' -f 3-); do
173 source $module
174 module_repo_list=$(eval echo \${$(basename $module)_repos[@]})
175 repos_list=(${repos_list[@]} ${module_repo_list[@]})
176 done
177
178 pushd /var/onap_tests/
179 cp projects.txt remaining_projects.txt
180 for covered_repo in "${repos_list[@]}"; do
Victor Moralesf6c0bf12017-10-27 11:08:04 -0700181 sed -i '/^'${covered_repo//\//\\/}'$/d' remaining_projects.txt
Victor Morales21404d72017-10-20 13:18:26 -0700182 done
183
184 threshold=75
185 num_projects=$(wc -l < projects.txt)
186 num_remaining_projects=$(wc -l < remaining_projects.txt)
187 coverage=`echo "scale=2; 100-($num_remaining_projects/$num_projects*100)" | bc | cut -d . -f 1`
188 if [ $coverage -lt $threshold ]; then
189 raise_error "There are repositories that are not covered by scripts"
190 fi
191 popd
192}
193
Victor Moralesdd074802017-07-26 16:06:35 -0500194if [ "$1" != '*' ]; then
195 unset covered_functions
196 covered_functions=$1
197fi
198main "${covered_functions[@]}"