Add Automation for E2T init
[ric-plt/e2mgr.git] / Automation / Tests / Scripts / e2t_init_script.py
1 ##############################################################################
2 #
3 #   Copyright (c) 2019 AT&T Intellectual Property.
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 #
17 ##############################################################################
18
19 import config
20 import redis
21
22
23 def getRedisClientDecodeResponse():
24
25     c = config.redis_ip_address
26
27     p = config.redis_ip_port
28
29     return redis.Redis(host=c, port=p, db=0, decode_responses=True)
30
31
32 def verify_db_e2t_addresses():
33
34     r = getRedisClientDecodeResponse()
35     
36     value = "[\"e2t.att.com:38000\"]"
37
38     return r.get("{e2Manager},E2TAddresses") == value
39
40
41 def verify_db_e2t_instance():
42
43     r = getRedisClientDecodeResponse()
44
45     e2_address = "\"address\":\"e2t.att.com:38000\""
46     e2_associated_ran_list = "\"associatedRanList\":[]"
47     e2_state = "\"state\":\"ACTIVE\""
48
49     e2_db_instance = r.get("{e2Manager},E2TInstance:e2t.att.com:38000")
50
51     if e2_db_instance.find(e2_address) < 0:
52         return False
53     if e2_db_instance.find(e2_associated_ran_list) < 0:
54         return False
55     if e2_db_instance.find(e2_state) < 0:
56         return False
57
58     return True