Newer
Older
/*
* Copyright (c) 2020 InterDigital Communications, Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import (
"encoding/json"
"fmt"
"strconv"
"testing"
"context"
"time"
log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger"
rnisClient "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-rnis-client"
)
var rnisAppClient *rnisClient.APIClient
var rnisServerUrl string
func init() {
err := startSystemTest()
if err != nil {
log.Error("Cannot start system test: ", err)
}
//create client
rnisAppClientCfg := rnisClient.NewConfiguration()
if hostUrlStr == "" {
hostUrlStr = "http://localhost"
}
rnisAppClientCfg.BasePath = hostUrlStr + "/" + sandboxName + "/rni/v2"
rnisAppClient = rnisClient.NewAPIClient(rnisAppClientCfg)
if rnisAppClient == nil {
log.Error("Failed to create RNIS App REST API client: ", rnisAppClientCfg.BasePath)
}
//NOTE: if localhost is set as the hostUrl, might not be reachable from the service, export MEEP_HOST_TEST_URL ="http://[yourhost]"
rnisServerUrl = hostUrlStr + ":" + httpListenerPort
}
func initialiseRnisTest() {
log.Info("activating Scenario")
err := activateScenario("rnis-system-test")
if err != nil {
log.Fatal("Scenario cannot be activated: ", err)
}
time.Sleep(1000 * time.Millisecond)
if isAutomationReady(true, 10, 0) {
geAutomationUpdate(true, false, true, true)
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
}
}
func clearUpRnisTest() {
log.Info("terminating Scenario")
terminateScenario()
time.Sleep(1000 * time.Millisecond)
}
//no really a test, but loading the scenarios needed that will be used in the following tests
//deletion of those scenarios at the end
func Test_RNIS_load_scenarios(t *testing.T) {
// no override if the name is already in the DB.. security not to override something important
err := createScenario("rnis-system-test", "rnis-system-test.yaml")
if err != nil {
t.Fatal("Cannot create scenario, keeping the one already there and continuing testing with it :", err)
}
}
func Test_RNIS_4g_to_4g_same_zone(t *testing.T) {
fmt.Println("--- ", t.Name())
log.MeepTextLogInit(t.Name())
initialiseRnisTest()
defer clearUpRnisTest()
testAddress := "ue1"
testAssociateId := rnisClient.AssociateId{Type_: 1, Value: testAddress}
testSrcEcgi := rnisClient.Ecgi{CellId: "4000001", Plmn: &rnisClient.Plmn{"001", "001"}}
testTrgEcgi := rnisClient.Ecgi{CellId: "4000002", Plmn: &rnisClient.Plmn{"001", "001"}}
testErabId := int32(1)
//moving to initial position
geMoveAssetCoordinates(testAddress, 7.413917, 43.733505)
time.Sleep(2000 * time.Millisecond)
//subscriptions to test
err := rnisSubscriptionRabEst(rnisServerUrl)
if err != nil {
t.Fatal("Subscription failed: ", err)
}
err = rnisSubscriptionRabRel(testErabId, rnisServerUrl)
if err != nil {
t.Fatal("Subscription failed: ", err)
}
err = rnisSubscriptionCellChange(testAssociateId, rnisServerUrl)
if err != nil {
t.Fatal("Subscription failed: ", err)
}
log.Info("moving asset")
geMoveAssetCoordinates(testAddress, 7.415917, 43.733505)
time.Sleep(2000 * time.Millisecond)
if len(httpReqBody) == 1 {
var body rnisClient.CellChangeNotification
err = json.Unmarshal([]byte(httpReqBody[0]), &body)
if err != nil {
t.Fatalf("cannot unmarshall response")
}
errStr := validateCellChangeNotification(&body, &testAssociateId, &testSrcEcgi, &testTrgEcgi)
if errStr != "" {
printHttpReqBody()
t.Fatalf(errStr)
}
} else {
printHttpReqBody()
t.Fatalf("Number of expected notifications not received")
}
}
func Test_RNIS_4g_to_4g_diff_zone(t *testing.T) {
fmt.Println("--- ", t.Name())
log.MeepTextLogInit(t.Name())
initialiseRnisTest()
defer clearUpRnisTest()
testAddress := "ue1"
testAssociateId := rnisClient.AssociateId{Type_: 1, Value: testAddress}
testSrcEcgi := rnisClient.Ecgi{CellId: "4000001", Plmn: &rnisClient.Plmn{"001", "001"}}
testTrgEcgi := rnisClient.Ecgi{CellId: "4000003", Plmn: &rnisClient.Plmn{"001", "001"}}
testErabId := int32(1)
//moving to initial position
geMoveAssetCoordinates(testAddress, 7.413917, 43.733505)
time.Sleep(2000 * time.Millisecond)
//subscriptions to test
err := rnisSubscriptionRabEst(rnisServerUrl)
if err != nil {
t.Fatal("Subscription failed: ", err)
}
err = rnisSubscriptionRabRel(testErabId, rnisServerUrl)
if err != nil {
t.Fatal("Subscription failed: ", err)
}
err = rnisSubscriptionCellChange(testAssociateId, rnisServerUrl)
if err != nil {
t.Fatal("Subscription failed: ", err)
}
log.Info("moving asset")
geMoveAssetCoordinates(testAddress, 7.417917, 43.733505)
time.Sleep(2000 * time.Millisecond)
if len(httpReqBody) == 1 {
var body rnisClient.CellChangeNotification
err = json.Unmarshal([]byte(httpReqBody[0]), &body)
if err != nil {
t.Fatalf("cannot unmarshall response")
}
errStr := validateCellChangeNotification(&body, &testAssociateId, &testSrcEcgi, &testTrgEcgi)
if errStr != "" {
printHttpReqBody()
t.Fatalf(errStr)
}
} else {
printHttpReqBody()
t.Fatalf("Number of expected notifications not received")
}
}
func Test_RNIS_4g_to_5g(t *testing.T) {
fmt.Println("--- ", t.Name())
log.MeepTextLogInit(t.Name())
initialiseRnisTest()
defer clearUpRnisTest()
testAddress := "ue1"
testAssociateId := rnisClient.AssociateId{Type_: 1, Value: testAddress}
testSrcEcgi := rnisClient.Ecgi{CellId: "4000001", Plmn: &rnisClient.Plmn{"001", "001"}}
testErabId := int32(1)
Loading
Loading full blame…