Merge "Clean autotest folder"
[nonrtric.git] / test / cr / basic_test.sh
1 #!/bin/bash
2
3 #  ============LICENSE_START===============================================
4 #  Copyright (C) 2020 Nordix Foundation. All rights reserved.
5 #  ========================================================================
6 #  Licensed under the Apache License, Version 2.0 (the "License");
7 #  you may not use this file except in compliance with the License.
8 #  You may obtain a copy of the License at
9 #
10 #       http://www.apache.org/licenses/LICENSE-2.0
11 #
12 #  Unless required by applicable law or agreed to in writing, software
13 #  distributed under the License is distributed on an "AS IS" BASIS,
14 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 #  See the License for the specific language governing permissions and
16 #  limitations under the License.
17 #  ============LICENSE_END=================================================
18 #
19
20 # Automated test script for callback receiver container
21
22 # callbackreciver port
23 export PORT=8090
24
25 # source function to do curl and check result
26 . ../common/do_curl_function.sh
27
28 echo "=== CR hello world ==="
29 RESULT="OK"
30 do_curl GET / 200
31
32
33 echo "=== Get counter - callbacks ==="
34 RESULT="0"
35 do_curl GET /counter/received_callbacks 200
36
37 echo "=== Get counter - fetched events ==="
38 RESULT="0"
39 do_curl GET /counter/fetched_callbacks 200
40
41 echo "=== Get counter - current events ==="
42 RESULT="0"
43 do_curl GET /counter/current_messages 200
44
45
46 echo "=== Send a request ==="
47 RESULT="*"
48 #create payload
49 echo "\"DATA-MSG\"" > .tmp.json
50 do_curl POST '/callbacks/test' 200 .tmp.json
51
52
53 echo "=== Fetch an event, wrong id==="
54 RESULT="*"
55 do_curl GET '/get-event/wrongid' 204
56
57
58 echo "=== Get counter - callbacks ==="
59 RESULT="1"
60 do_curl GET /counter/received_callbacks 200
61
62 echo "=== Get counter - fetched events ==="
63 RESULT="0"
64 do_curl GET /counter/fetched_callbacks 200
65
66 echo "=== Get counter - current events ==="
67 RESULT="1"
68 do_curl GET /counter/current_messages 200
69
70
71 echo "=== Fetch an event ==="
72 RESULT="DATA-MSG"
73 do_curl GET '/get-event/test' 200
74
75 echo "=== Fetch an event again ==="
76 RESULT="*"
77 do_curl GET '/get-event/test' 204
78
79 echo "=== Get counter - callbacks ==="
80 RESULT="1"
81 do_curl GET /counter/received_callbacks 200
82
83 echo "=== Get counter - fetched events ==="
84 RESULT="1"
85 do_curl GET /counter/fetched_callbacks 200
86
87 echo "=== Get counter - current events ==="
88 RESULT="0"
89 do_curl GET /counter/current_messages 200
90
91 echo "=== CR reset ==="
92 RESULT="OK"
93 do_curl GET /reset 200
94
95 echo "=== Get counter - callbacks ==="
96 RESULT="0"
97 do_curl GET /counter/received_callbacks 200
98
99 echo "=== Get counter - fetched events ==="
100 RESULT="0"
101 do_curl GET /counter/fetched_callbacks 200
102
103 echo "=== Get counter - current events ==="
104 RESULT="0"
105 do_curl GET /counter/current_messages 200
106
107
108 echo "********************"
109 echo "*** All tests ok ***"
110 echo "********************"