blob: 87e0ac397906d47bbeee9bcf00aab96584172597 [file] [log] [blame]
Aaron Hay0f33e962017-09-12 14:03:37 -04001#!/usr/bin/env bash
2###############################################################################
3# Copyright 2017 Huawei Technologies Co., Ltd.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16###############################################################################
17SCRIPTS="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
18echo $SCRIPTS
19
20sdnctl_num_tables=$(docker exec -i sdnc_db_container mysql -s -D sdnctl -u sdnctl -pgamma <<<'show tables;' 2>/dev/null | grep -v ERROR | wc -l)
21
22appcctl_num_tables=$(docker exec -i sdnc_db_container mysql -s -D appcctl -u appcctl -pappcctl <<<'show tables;' 2>/dev/null | grep -v ERROR | wc -l)
23
24
25
26docker exec -i sdnc_db_container mysql -s -D sdnctl -u sdnctl -pgamma <<<"show tables" 2>/dev/null | ( while read table_name; do
27export $table_name="$(docker exec -i sdnc_db_container mysql -s -D sdnctl -u sdnctl -pgamma <<<"select count(*) from $table_name" 2>/dev/null)"
28done
29
30if [ "$sdnctl_num_tables" -ge "1" ]; then
31 echo "There are $sdnctl_num_tables tables in the sdnctl database. "
32else
33 echo "Database sdnctl is not available."
34 exit 1;
35fi
36
37if [ "$appcctl_num_tables" -ge "1" ]; then
38 echo "There is $appcctl_num_tables table in the appcctl database. "
39else
40 echo "Database appcctl is not available."
41 exit 1;
42fi
43
44if [ "$NODE_TYPES" -eq "0" ]; then
45 echo "There is no data in table NODE_TYPES. "
46 exit 1;
47fi
48
49if [ "$SVC_LOGIC" -eq "0" ] ; then
50 echo "There is no data in table SVC_LOGIC. "
51 exit 1;
52fi
53
54if [ "$VNF_DG_MAPPING" -eq "0" ]; then
55 echo "There is no data in table VNF_DG_MAPPING. "
56 exit 1;
57fi
58
59echo "Expected table data is present."
60exit 0 )
61
62if [ "$?" -eq "1" ]; then
63 exit 1;
64fi
65
66exit 0