Merge "Fix integration test"
[integration.git] / bootstrap / vagrant-onap / tests / test_functions
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
105     asserts_file_exist /usr/local/bin/tox
106 }
107
108 # test_install_docker() - Verify the correct installation of Docker
109 function test_install_docker {
110     install_docker
111
112     asserts_installed_package docker-ce
113 }
114
115 # test_pull_docker_image() - Verify the correct retrieve of a specific docker image
116 function test_pull_docker_image {
117     local image=attos/dmaap
118     pull_docker_image $image
119
120     asserts_image $image
121
122     docker rmi -f $image
123 }
124
125 # test_install_docker_compose() - Verify the correct installation of Docker Compose tool
126 function test_install_docker_compose {
127     install_docker_compose
128
129     asserts_file_exist /opt/docker/docker-compose
130 }
131
132 # test_configure_service() - Verify the correct configuration of a specific init service
133 function test_configure_service {
134     local service=mso
135
136     configure_service $service
137
138     asserts_file_exist /etc/init.d/$service
139
140     rm -rf /etc/init.d/$service
141 }
142
143 # test_start_ODL() - Verify the installation and configuration of OpenDayLight controller
144 function test_start_ODL {
145     start_ODL
146
147     asserts_file_exist /opt/opendaylight/current/bin/start
148 }
149
150 # test_compile_src() - Verify the compilation of java code using maven tools
151 function test_compile_src {
152     local repo=vid/asdcclient
153     clone_repo $repo
154     compile_src $git_src_folder/$repo
155
156     asserts_file_exist $git_src_folder/$repo/target/asdcclient-1.0.2-SNAPSHOT.jar
157 }
158
159 # test_build_docker_image() - Verify that a docker image is created from source code
160 function test_build_docker_image {
161     clone_repo portal
162     compile_src $git_src_folder/portal/ecomp-portal-widget-ms
163     build_docker_image $git_src_folder/portal/ecomp-portal-widget-ms
164
165     asserts_image widget-ms
166
167     docker rmi -f widget-ms
168 }
169
170 if [ "$1" != '*' ]; then
171     unset covered_functions
172     covered_functions=$1
173 fi
174 main "${covered_functions[@]}"