summaryrefslogtreecommitdiffstats
path: root/bootstrap/vagrant-onap/tests
diff options
context:
space:
mode:
authorGary Wu <gary.i.wu@huawei.com>2017-08-31 17:17:21 +0000
committerGerrit Code Review <gerrit@onap.org>2017-08-31 17:17:21 +0000
commit7bf702df84d8cff152e95346ce65d847286a5bf9 (patch)
tree91729ba6f74ba13f0fe098cd7003562663f19e0b /bootstrap/vagrant-onap/tests
parentc08380f4fffdda0b5a0ea330b89d1cd5bdfb152b (diff)
parente746700a7dfe469bb65a54d04a5d2202d7f56e9e (diff)
Merge "Create UTs for SDC"
Diffstat (limited to 'bootstrap/vagrant-onap/tests')
-rw-r--r--bootstrap/vagrant-onap/tests/_test_base2
-rwxr-xr-xbootstrap/vagrant-onap/tests/asserts74
-rw-r--r--bootstrap/vagrant-onap/tests/test_sdc69
3 files changed, 144 insertions, 1 deletions
diff --git a/bootstrap/vagrant-onap/tests/_test_base b/bootstrap/vagrant-onap/tests/_test_base
index 19cc8ef11..155de98bb 100644
--- a/bootstrap/vagrant-onap/tests/_test_base
+++ b/bootstrap/vagrant-onap/tests/_test_base
@@ -1,6 +1,6 @@
#!/bin/bash
-source /var/onap/asserts
+source /var/onap_tests/asserts
# main() - Starting point for Unit Tests
function main {
diff --git a/bootstrap/vagrant-onap/tests/asserts b/bootstrap/vagrant-onap/tests/asserts
new file mode 100755
index 000000000..02c269b4c
--- /dev/null
+++ b/bootstrap/vagrant-onap/tests/asserts
@@ -0,0 +1,74 @@
+#!/bin/bash
+
+set -o xtrace
+
+source /var/onap/commons
+
+# asserts_process() - Function that verifies if a specific process is running
+function asserts_process {
+ local process=$1
+ local error_msg=${2:-"There is no $process running process"}
+
+ if [[ "ps -ef | grep $process" == "" ]]; then
+ raise_error $error_msg
+ fi
+}
+
+# asserts_java_process() - Function that verifies if a specific java process is running
+function asserts_java_process {
+ local process=$1
+ local error_msg=${2:-"There is no $process java running process"}
+
+ install_java
+ if [[ "jps | grep $process" == "" ]]; then
+ raise_error $error_msg
+ fi
+}
+
+# asserts_image_running() - Function that verifies if a specific image is running
+function asserts_image_running {
+ local image=$1
+ local error_msg=${2:-"There is no process with $image image running"}
+
+ asserts_image $image
+ if [[ "$(docker ps -q --filter=ancestor=$image 2> /dev/null)" == "" ]]; then
+ raise_error $error_msg
+ fi
+}
+
+# asserts_image() - Function that verifies if a specific image was created
+function asserts_image {
+ local image=$1
+ local error_msg=${2:-"There is no $image image"}
+
+ install_docker
+ if [[ "$(docker images -q $image 2> /dev/null)" == "" ]]; then
+ raise_error $error_msg
+ fi
+}
+
+# asserts_installed_package() - Function that verifies if a specific package was installed.
+function asserts_installed_package {
+ local package=$1
+ local error_msg=${2:-"$package wasn't installed"}
+
+ if ! is_package_installed $package; then
+ raise_error $error_msg
+ fi
+}
+
+# asserts_file_exist() - Function that verifies if a specific file exists
+function asserts_file_exist {
+ local file=$1
+ local error_msg=${2:-"$file doesn't exist"}
+
+ if [ ! -f $file ]; then
+ raise_error $error_msg
+ fi
+}
+
+# raise_error() - Function that prints and exits the execution
+function raise_error {
+ echo $@
+ exit 1
+}
diff --git a/bootstrap/vagrant-onap/tests/test_sdc b/bootstrap/vagrant-onap/tests/test_sdc
new file mode 100644
index 000000000..bb0cd7010
--- /dev/null
+++ b/bootstrap/vagrant-onap/tests/test_sdc
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+source /var/onap_tests/_test_base
+source /var/onap/asdc
+
+covered_functions=(
+"clone_all_sdc_repos" "compile_all_sdc_repos" "get_sdc_images" "install_sdc"
+)
+
+# test_clone_all_sdc_repos() - Verifies the retrieval of SDC source code repos
+function test_clone_all_sdc_repos {
+ clone_all_sdc_repos
+
+ asserts_file_exist $sdc_src_folder/pom.xml
+ asserts_file_exist $sdc_src_folder/sdc-os-chef/pom.xml
+ asserts_file_exist $sdc_src_folder/jtosca/pom.xml
+ asserts_file_exist $sdc_src_folder/sdc-distribution-client/pom.xml
+ asserts_file_exist $sdc_src_folder/sdc-titan-cassandra/pom.xml
+ asserts_file_exist $sdc_src_folder/sdc-tosca/pom.xml
+ asserts_file_exist $sdc_src_folder/sdc_common/pom.xml
+}
+
+# test_compile_all_sdc_repos() - Verifies the correct compilation of SDC repositories
+function test_compile_all_sdc_repos {
+ clone_all_sdc_repos
+ compile_all_sdc_repos
+
+ asserts_file_exist $sdc_src_folder/jtosca/target/jtosca-1.1.10-SNAPSHOT.jar
+ asserts_file_exist $sdc_src_folder/sdc-distribution-client/sdc-distribution-ci/target/sdc-distribution-ci-1.1.32-SNAPSHOT.jar
+ asserts_file_exist $sdc_src_folder/sdc-distribution-client/sdc-distribution-client/target/sdc-distribution-client-1.1.32-SNAPSHOT.jar
+ asserts_file_exist $sdc_src_folder/sdc-os-chef/target/sdc-os-chef-1.1.0-SNAPSHOT.jar
+ asserts_file_exist $sdc_src_folder/sdc-titan-cassandra/target/sdc-titan-cassandra-1.0.0.jar
+ asserts_file_exist $sdc_src_folder/sdc-tosca/target/sdc-tosca-1.1.50-SNAPSHOT.jar
+
+ for dirc in logging sdc-artifact-generator; do
+ name="openecomp-$dirc"
+ for module in api core; do
+ fullname="$name-$module"
+ asserts_file_exist $sdc_src_folder/sdc_common/$name-lib/$fullname/target/$fullname-1.1.0-SNAPSHOT.jar
+ done
+ done
+}
+
+# test_get_sdc_images() - Verifies the correct retrieval of SDC Docker images
+function test_get_sdc_images {
+ clone_all_sdc_repos
+ get_sdc_images
+
+ for image in backend frontend elasticsearch kibana cassandra sanity; do
+ asserts_image openecomp/sdc-$image
+ done
+}
+
+# test_install_sdc() - Verifies that SDC services are up and running
+function test_install_sdc {
+ clone_all_sdc_repos
+ get_sdc_images
+ install_sdc
+
+ for image in backend frontend elasticsearch kibana cassandra sanity; do
+ asserts_image_running openecomp/sdc-$image
+ done
+}
+
+if [ "$1" != '*' ]; then
+ unset covered_functions
+ covered_functions=$1
+fi
+main "${covered_functions[@]}"