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=( |
| 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" |
| 10 | "start_ODL" "compile_src" "build_docker_image" |
| 11 | ) |
| 12 | |
| 13 | # TODO(electrocucaracha): Remove/Modify functions that doesn't support proxy settings |
| 14 | if [ -z $http_proxy ] & [ -z $https_proxy ]; then |
| 15 | covered_functions=(${covered_functions[@]} "docker_openecomp_login" "pull_openecomp_image") |
| 16 | fi |
| 17 | |
| 18 | # test_create_configuration_files() - Verify the creation of a configuration files |
| 19 | function test_create_configuration_files { |
| 20 | create_configuration_files |
| 21 | |
| 22 | asserts_file_exist /opt/config/nexus_docker_repo.txt |
| 23 | asserts_file_exist /opt/config/nexus_username.txt |
| 24 | asserts_file_exist /opt/config/nexus_password.txt |
| 25 | asserts_file_exist /opt/config/openstack_username.txt |
| 26 | asserts_file_exist /opt/config/tenant_id.txt |
| 27 | asserts_file_exist /opt/config/dmaap_topic.txt |
| 28 | asserts_file_exist /opt/config/docker_version.txt |
| 29 | } |
| 30 | |
| 31 | # test_docker_openecomp_login() - Verify the proper login to OpenECOMP Docker Hub |
| 32 | function test_docker_openecomp_login { |
| 33 | docker_openecomp_login |
| 34 | } |
| 35 | |
| 36 | # test_pull_openecomp_image() - Verify the addition of a OpenECOMP container image |
| 37 | function test_pull_openecomp_image { |
| 38 | pull_openecomp_image portalapps ep:1610-1 |
| 39 | |
| 40 | asserts_installed_package docker-ce |
| 41 | asserts_image ep:1610-1 |
| 42 | |
| 43 | docker rmi -f ep:1610-1 |
| 44 | } |
| 45 | |
| 46 | # test_clone_repo() - Verify cloning and pulling source code from repositories |
| 47 | function test_clone_repo { |
| 48 | clone_repo demo |
| 49 | |
| 50 | asserts_installed_package git |
| 51 | asserts_file_exist $git_src_folder/demo/LICENSE.TXT |
| 52 | } |
| 53 | |
| 54 | # test_install_dev_tools() - Verify the correct installation of developer tools |
| 55 | function test_install_dev_tools { |
| 56 | install_dev_tools |
| 57 | |
| 58 | asserts_installed_package apt-transport-https |
| 59 | asserts_installed_package ca-certificates |
| 60 | asserts_installed_package curl |
| 61 | } |
| 62 | |
| 63 | # test_configure_bind() - Verify the correct installation and configuration of bind |
| 64 | function test_configure_bind { |
| 65 | configure_bind |
| 66 | |
| 67 | asserts_installed_package bind9 |
| 68 | asserts_installed_package bind9utils |
| 69 | asserts_file_exist /etc/bind/zones/db.simpledemo.openecomp.org |
| 70 | asserts_file_exist /etc/bind/named.conf.options |
| 71 | asserts_file_exist /etc/bind/named.conf.local |
| 72 | |
| 73 | rm -rf /etc/bind/ |
| 74 | } |
| 75 | |
| 76 | # test_install_java() - Verify the correct installation of java |
| 77 | function test_install_java { |
| 78 | install_java |
| 79 | |
| 80 | asserts_installed_package openjdk-8-jdk |
| 81 | } |
| 82 | |
| 83 | # test_install_maven() - Verify the correct installation and configuration of maven |
| 84 | function test_install_maven { |
| 85 | install_maven |
| 86 | |
| 87 | asserts_installed_package maven3 |
| 88 | asserts_installed_package openjdk-8-jdk |
| 89 | asserts_file_exist $mvn_conf_file |
| 90 | } |
| 91 | |
| 92 | # test_install_nodejs() - Verify the correct installation of NodeJS tools |
| 93 | function test_install_nodejs { |
| 94 | install_nodejs |
| 95 | |
| 96 | asserts_installed_package nodejs |
| 97 | asserts_file_exist /usr/bin/npm |
| 98 | } |
| 99 | |
| 100 | # test_install_python() - Verify the correct installation of Python |
| 101 | function test_install_python { |
| 102 | install_python |
| 103 | asserts_installed_package python2.7 |
| 104 | asserts_installed_package python-dev |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | # test_install_docker() - Verify the correct installation of Docker |
| 108 | function test_install_docker { |
| 109 | install_docker |
| 110 | |
| 111 | asserts_installed_package docker-ce |
| 112 | } |
| 113 | |
| 114 | # test_pull_docker_image() - Verify the correct retrieve of a specific docker image |
| 115 | function test_pull_docker_image { |
| 116 | local image=attos/dmaap |
| 117 | pull_docker_image $image |
| 118 | |
| 119 | asserts_image $image |
| 120 | |
| 121 | docker rmi -f $image |
| 122 | } |
| 123 | |
| 124 | # test_install_docker_compose() - Verify the correct installation of Docker Compose tool |
| 125 | function test_install_docker_compose { |
| 126 | install_docker_compose |
| 127 | |
| 128 | asserts_file_exist /opt/docker/docker-compose |
| 129 | } |
| 130 | |
| 131 | # test_configure_service() - Verify the correct configuration of a specific init service |
| 132 | function test_configure_service { |
| 133 | local service=mso |
| 134 | |
| 135 | configure_service $service |
| 136 | |
| 137 | asserts_file_exist /etc/init.d/$service |
| 138 | |
| 139 | rm -rf /etc/init.d/$service |
| 140 | } |
| 141 | |
| 142 | # test_start_ODL() - Verify the installation and configuration of OpenDayLight controller |
| 143 | function test_start_ODL { |
| 144 | start_ODL |
| 145 | |
| 146 | asserts_file_exist /opt/opendaylight/current/bin/start |
| 147 | } |
| 148 | |
| 149 | # test_compile_src() - Verify the compilation of java code using maven tools |
| 150 | function test_compile_src { |
| 151 | local repo=vid/asdcclient |
| 152 | clone_repo $repo |
| 153 | compile_src $git_src_folder/$repo |
| 154 | |
| 155 | asserts_file_exist $git_src_folder/$repo/target/asdcclient-1.0.2-SNAPSHOT.jar |
| 156 | } |
| 157 | |
| 158 | # test_build_docker_image() - Verify that a docker image is created from source code |
| 159 | function test_build_docker_image { |
Victor Morales | a898f56 | 2017-09-14 15:43:21 -0700 | [diff] [blame^] | 160 | clone_repo ccsdk/distribution |
| 161 | build_docker_image $git_src_folder/ccsdk/distribution/ubuntu docker |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 162 | |
Victor Morales | a898f56 | 2017-09-14 15:43:21 -0700 | [diff] [blame^] | 163 | asserts_image onap/ccsdk-ubuntu-image |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 164 | |
Victor Morales | a898f56 | 2017-09-14 15:43:21 -0700 | [diff] [blame^] | 165 | docker rmi -f onap/ccsdk-ubuntu-image |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | if [ "$1" != '*' ]; then |
| 169 | unset covered_functions |
| 170 | covered_functions=$1 |
| 171 | fi |
| 172 | main "${covered_functions[@]}" |