aboutsummaryrefslogtreecommitdiffstats
path: root/bootstrap/vagrant-onap/lib/asserts
blob: 02c269b4c3c53dd5a686577df1d55be41de48b44 (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
@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight:
#!/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
}