| #!/bin/bash |
| |
| source /var/onap_tests/_test_base |
| source /var/onap/functions |
| |
| covered_functions=( |
| "create_configuration_files" "clone_repo" |
| "configure_bind" "install_java" "install_maven" "install_nodejs" "install_python" |
| "install_docker" "pull_docker_image" "install_docker_compose" "configure_service" |
| "start_ODL" "compile_src" "build_docker_image" "docker_openecomp_login" |
| "pull_openecomp_image" "pull_onap_image" "coverity_repos" |
| ) |
| |
| # test_create_configuration_files() - Verify the creation of a configuration files |
| function test_create_configuration_files { |
| create_configuration_files |
| |
| asserts_file_exist /opt/config/nexus_docker_repo.txt |
| asserts_file_exist /opt/config/nexus_username.txt |
| asserts_file_exist /opt/config/nexus_password.txt |
| asserts_file_exist /opt/config/openstack_username.txt |
| asserts_file_exist /opt/config/tenant_id.txt |
| asserts_file_exist /opt/config/dmaap_topic.txt |
| asserts_file_exist /opt/config/docker_version.txt |
| } |
| |
| # test_docker_openecomp_login() - Verify the proper login to OpenECOMP Docker Hub |
| function test_docker_openecomp_login { |
| docker_openecomp_login |
| } |
| |
| # test_pull_openecomp_image() - Verify the OpenECOMP container image pulling process |
| function test_pull_openecomp_image { |
| local image_name=portal-apps |
| unset docker_version |
| pull_openecomp_image $image_name |
| |
| asserts_image $nexus_docker_repo/openecomp/$image_name |
| } |
| |
| # test_pull_onap_image() - Verify the ONAP cointainer pulling process |
| function test_pull_onap_image { |
| local image_name=portal-apps |
| unset docker_version |
| pull_onap_image $image_name |
| |
| asserts_image $nexus_docker_repo/onap/$image_name |
| } |
| |
| # test_clone_repo() - Verify cloning and pulling source code from repositories |
| function test_clone_repo { |
| clone_repo demo |
| |
| asserts_installed_package git |
| asserts_file_exist $git_src_folder/demo/LICENSE.TXT |
| } |
| |
| # test_configure_bind() - Verify the correct installation and configuration of bind |
| function test_configure_bind { |
| configure_bind |
| |
| asserts_installed_package bind9 |
| asserts_installed_package bind9utils |
| asserts_file_exist /etc/bind/zones/db.simpledemo.openecomp.org |
| asserts_file_exist /etc/bind/named.conf.options |
| asserts_file_exist /etc/bind/named.conf.local |
| |
| rm -rf /etc/bind/ |
| } |
| |
| # test_install_java() - Verify the correct installation of java |
| function test_install_java { |
| install_java |
| |
| asserts_installed_package openjdk-8-jdk |
| } |
| |
| # test_install_maven() - Verify the correct installation and configuration of maven |
| function test_install_maven { |
| install_maven |
| |
| asserts_installed_package maven3 |
| asserts_installed_package openjdk-8-jdk |
| asserts_file_exist $mvn_conf_file |
| } |
| |
| # test_install_nodejs() - Verify the correct installation of NodeJS tools |
| function test_install_nodejs { |
| install_nodejs |
| |
| asserts_installed_package nodejs |
| asserts_file_exist /usr/bin/npm |
| } |
| |
| # test_install_python() - Verify the correct installation of Python |
| function test_install_python { |
| install_python |
| asserts_installed_package python2.7 |
| asserts_installed_package python-dev |
| } |
| |
| # test_install_docker() - Verify the correct installation of Docker |
| function test_install_docker { |
| install_docker |
| |
| asserts_installed_package docker-ce |
| } |
| |
| # test_pull_docker_image() - Verify the correct retrieve of a specific docker image |
| function test_pull_docker_image { |
| local image=attos/dmaap |
| pull_docker_image $image |
| |
| asserts_image $image |
| } |
| |
| # test_install_docker_compose() - Verify the correct installation of Docker Compose tool |
| function test_install_docker_compose { |
| install_docker_compose |
| |
| asserts_file_exist /opt/docker/docker-compose |
| } |
| |
| # test_configure_service() - Verify the correct configuration of a specific init service |
| function test_configure_service { |
| local service=mso |
| |
| configure_service $service |
| |
| asserts_file_exist /etc/init.d/$service |
| |
| rm -rf /etc/init.d/$service |
| } |
| |
| # test_start_ODL() - Verify the installation and configuration of OpenDayLight controller |
| function test_start_ODL { |
| start_ODL |
| |
| asserts_file_exist /opt/opendaylight/current/bin/start |
| } |
| |
| # test_compile_src() - Verify the compilation of java code using maven tools |
| function test_compile_src { |
| local repo=vid/asdcclient |
| clone_repo $repo |
| compile_src $git_src_folder/$repo |
| |
| asserts_file_exist $git_src_folder/$repo/target/asdcclient-1.0.2-SNAPSHOT.jar |
| } |
| |
| # test_build_docker_image() - Verify that a docker image is created from source code |
| function test_build_docker_image { |
| clone_repo ccsdk/distribution |
| build_docker_image $git_src_folder/ccsdk/distribution/ubuntu docker |
| |
| asserts_image onap/ccsdk-ubuntu-image |
| } |
| |
| # test_coverity_repos() - Verify that all the repos are covered by scripts |
| function test_coverity_repos { |
| # Get repositories list from source code files |
| repos_list=() |
| for module in $( stat -c "%F %n" /var/onap/* | grep -v "_\|functions\|commons\|files" | cut -d' ' -f 3-); do |
| source $module |
| module_repo_list=$(eval echo \${$(basename $module)_repos[@]}) |
| repos_list=(${repos_list[@]} ${module_repo_list[@]}) |
| done |
| |
| pushd /var/onap_tests/ |
| cp projects.txt remaining_projects.txt |
| for covered_repo in "${repos_list[@]}"; do |
| sed -i '/^'${covered_repo//\//\\/}'$/d' remaining_projects.txt |
| done |
| |
| threshold=75 |
| num_projects=$(wc -l < projects.txt) |
| num_remaining_projects=$(wc -l < remaining_projects.txt) |
| coverage=`echo "scale=2; 100-($num_remaining_projects/$num_projects*100)" | bc | cut -d . -f 1` |
| if [ $coverage -lt $threshold ]; then |
| raise_error "There are repositories that are not covered by scripts" |
| fi |
| popd |
| } |
| |
| if [ "$1" != '*' ]; then |
| unset covered_functions |
| covered_functions=$1 |
| fi |
| main "${covered_functions[@]}" |