[RIC-621] Add redis monitor verification to automation tests
[ric-plt/e2mgr.git] / Automation / deprecated / Scripts / loadscripts.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 #   This source code is part of the near-RT RIC (RAN Intelligent Controller)
20 #   platform project (RICP).
21 #
22
23
24 import redis
25 import config
26
27 def getRedisClient():
28
29     c = config.redis_ip_address
30
31     p = config.redis_ip_port
32
33     return redis.Redis(host=c, port=p, db=0)
34
35
36 def verify_value():
37
38     r = getRedisClient()
39
40     value = "\b\x98\xf7\xdd\xa3\xc7\xb4\x83\xde\x15\x12\x11\n\x0f02f829:0007ab00"
41
42     if r.get("{e2Manager},LOAD:test1") != value:
43         return True
44     else:
45         return False
46
47
48 def add():
49
50     r = getRedisClient()
51
52     r.set("{e2Manager},LOAD:test1", "\b\x98\xf7\xdd\xa3\xc7\xb4\x83\xde\x15\x12\x11\n\x0f02f829:0007ab00")
53
54     if r.exists("{e2Manager},LOAD:test1"):
55         return True
56     else:
57         return False
58
59
60 def verify():
61
62     r = getRedisClient()
63
64     if r.exists("{e2Manager},LOAD:test1"):
65         return True
66     else:
67         return False
68