Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | source /var/onap_tests/_test_base |
| 4 | source /var/onap/functions |
| 5 | |
| 6 | covered_functions=( |
Victor Morales | 071b81c | 2017-11-07 14:13:07 -0800 | [diff] [blame] | 7 | "create_configuration_files" "clone_repo" |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 8 | "configure_bind" "install_java" "install_maven" "install_nodejs" "install_python" |
| 9 | "install_docker" "pull_docker_image" "install_docker_compose" "configure_service" |
Victor Morales | cf26999 | 2017-10-18 09:29:55 -0700 | [diff] [blame] | 10 | "start_ODL" "compile_src" "build_docker_image" "docker_openecomp_login" |
Nate Potter | fdf88f3 | 2018-01-17 09:29:35 -0800 | [diff] [blame] | 11 | "pull_openecomp_image" "pull_onap_image" "coverity_repos" "add_no_proxy_value" |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 12 | ) |
| 13 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 14 | # test_create_configuration_files() - Verify the creation of a configuration files |
| 15 | function 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 |
| 28 | function test_docker_openecomp_login { |
| 29 | docker_openecomp_login |
| 30 | } |
| 31 | |
Victor Morales | cf26999 | 2017-10-18 09:29:55 -0700 | [diff] [blame] | 32 | # test_pull_openecomp_image() - Verify the OpenECOMP container image pulling process |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 33 | function test_pull_openecomp_image { |
Victor Morales | cf26999 | 2017-10-18 09:29:55 -0700 | [diff] [blame] | 34 | local image_name=portal-apps |
| 35 | unset docker_version |
| 36 | pull_openecomp_image $image_name |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 37 | |
Victor Morales | cf26999 | 2017-10-18 09:29:55 -0700 | [diff] [blame] | 38 | asserts_image $nexus_docker_repo/openecomp/$image_name |
| 39 | } |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 40 | |
Victor Morales | cf26999 | 2017-10-18 09:29:55 -0700 | [diff] [blame] | 41 | # test_pull_onap_image() - Verify the ONAP cointainer pulling process |
| 42 | function 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 Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | # test_clone_repo() - Verify cloning and pulling source code from repositories |
| 51 | function 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 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 58 | # test_configure_bind() - Verify the correct installation and configuration of bind |
| 59 | function test_configure_bind { |
| 60 | configure_bind |
| 61 | |
| 62 | asserts_installed_package bind9 |
| 63 | asserts_installed_package bind9utils |
| 64 | asserts_file_exist /etc/bind/zones/db.simpledemo.openecomp.org |
| 65 | asserts_file_exist /etc/bind/named.conf.options |
| 66 | asserts_file_exist /etc/bind/named.conf.local |
| 67 | |
| 68 | rm -rf /etc/bind/ |
| 69 | } |
| 70 | |
| 71 | # test_install_java() - Verify the correct installation of java |
| 72 | function test_install_java { |
| 73 | install_java |
| 74 | |
| 75 | asserts_installed_package openjdk-8-jdk |
| 76 | } |
| 77 | |
| 78 | # test_install_maven() - Verify the correct installation and configuration of maven |
| 79 | function test_install_maven { |
| 80 | install_maven |
| 81 | |
| 82 | asserts_installed_package maven3 |
| 83 | asserts_installed_package openjdk-8-jdk |
| 84 | asserts_file_exist $mvn_conf_file |
| 85 | } |
| 86 | |
| 87 | # test_install_nodejs() - Verify the correct installation of NodeJS tools |
| 88 | function test_install_nodejs { |
| 89 | install_nodejs |
| 90 | |
| 91 | asserts_installed_package nodejs |
| 92 | asserts_file_exist /usr/bin/npm |
| 93 | } |
| 94 | |
| 95 | # test_install_python() - Verify the correct installation of Python |
| 96 | function test_install_python { |
| 97 | install_python |
| 98 | asserts_installed_package python2.7 |
| 99 | asserts_installed_package python-dev |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | # test_install_docker() - Verify the correct installation of Docker |
| 103 | function test_install_docker { |
| 104 | install_docker |
| 105 | |
| 106 | asserts_installed_package docker-ce |
| 107 | } |
| 108 | |
| 109 | # test_pull_docker_image() - Verify the correct retrieve of a specific docker image |
| 110 | function test_pull_docker_image { |
| 111 | local image=attos/dmaap |
| 112 | pull_docker_image $image |
| 113 | |
| 114 | asserts_image $image |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | # test_install_docker_compose() - Verify the correct installation of Docker Compose tool |
| 118 | function test_install_docker_compose { |
| 119 | install_docker_compose |
| 120 | |
| 121 | asserts_file_exist /opt/docker/docker-compose |
| 122 | } |
| 123 | |
| 124 | # test_configure_service() - Verify the correct configuration of a specific init service |
| 125 | function test_configure_service { |
| 126 | local service=mso |
| 127 | |
| 128 | configure_service $service |
| 129 | |
| 130 | asserts_file_exist /etc/init.d/$service |
| 131 | |
| 132 | rm -rf /etc/init.d/$service |
| 133 | } |
| 134 | |
| 135 | # test_start_ODL() - Verify the installation and configuration of OpenDayLight controller |
| 136 | function test_start_ODL { |
| 137 | start_ODL |
| 138 | |
| 139 | asserts_file_exist /opt/opendaylight/current/bin/start |
| 140 | } |
| 141 | |
| 142 | # test_compile_src() - Verify the compilation of java code using maven tools |
| 143 | function test_compile_src { |
| 144 | local repo=vid/asdcclient |
| 145 | clone_repo $repo |
| 146 | compile_src $git_src_folder/$repo |
| 147 | |
| 148 | asserts_file_exist $git_src_folder/$repo/target/asdcclient-1.0.2-SNAPSHOT.jar |
| 149 | } |
| 150 | |
| 151 | # test_build_docker_image() - Verify that a docker image is created from source code |
| 152 | function test_build_docker_image { |
Victor Morales | a898f56 | 2017-09-14 15:43:21 -0700 | [diff] [blame] | 153 | clone_repo ccsdk/distribution |
| 154 | build_docker_image $git_src_folder/ccsdk/distribution/ubuntu docker |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 155 | |
Victor Morales | a898f56 | 2017-09-14 15:43:21 -0700 | [diff] [blame] | 156 | asserts_image onap/ccsdk-ubuntu-image |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 157 | } |
| 158 | |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 159 | # test_coverity_repos() - Verify that all the repos are covered by scripts |
| 160 | function test_coverity_repos { |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 161 | pushd /var/onap_tests/ |
| 162 | cp projects.txt remaining_projects.txt |
Victor Morales | 5464664 | 2017-12-08 11:57:42 -0800 | [diff] [blame] | 163 | for project in "${repos[@]}"; do |
| 164 | for covered_repo in $project; do |
| 165 | sed -i '/^'${covered_repo//\//\\/}'$/d' remaining_projects.txt |
| 166 | done |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 167 | done |
| 168 | |
| 169 | threshold=75 |
| 170 | num_projects=$(wc -l < projects.txt) |
| 171 | num_remaining_projects=$(wc -l < remaining_projects.txt) |
| 172 | coverage=`echo "scale=2; 100-($num_remaining_projects/$num_projects*100)" | bc | cut -d . -f 1` |
| 173 | if [ $coverage -lt $threshold ]; then |
| 174 | raise_error "There are repositories that are not covered by scripts" |
| 175 | fi |
| 176 | popd |
| 177 | } |
| 178 | |
Nate Potter | fdf88f3 | 2018-01-17 09:29:35 -0800 | [diff] [blame] | 179 | # test_add_no_proxy_value - Verify that the no_proxy value is correctly set |
| 180 | function test_add_no_proxy_value { |
| 181 | local ip="172.16.0.3" |
| 182 | add_no_proxy_value $ip |
| 183 | |
| 184 | asserts_env_set no_proxy |
| 185 | } |
| 186 | |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 187 | if [ "$1" != '*' ]; then |
| 188 | unset covered_functions |
| 189 | covered_functions=$1 |
| 190 | fi |
| 191 | main "${covered_functions[@]}" |