summaryrefslogtreecommitdiffstats
path: root/bootstrap/vagrant-onap/tests/test_functions
blob: 9411b46f448390bb23ce15467261b4dc26dd6da6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/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 {
    pushd /var/onap_tests/
    cp projects.txt remaining_projects.txt
    for project in "${repos[@]}"; do
        for covered_repo in $project; do
            sed -i '/^'${covered_repo//\//\\/}'$/d' remaining_projects.txt
        done
    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[@]}"