blob: f7e94fbc77e788985647f4b132c444715611aaa5 [file] [log] [blame]
khenaidoo0a822f92019-05-08 15:15:57 -04001/*
2 * Copyright 2019-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package core
17
18import (
khenaidoo442e7c72020-03-10 16:13:48 -040019 "fmt"
npujar1d86a522019-11-14 17:11:16 +053020 "reflect"
21 "testing"
22
23 "github.com/opencord/voltha-go/rw_core/coreif"
khenaidooab1f7bd2019-11-14 14:00:27 -050024 "github.com/opencord/voltha-go/rw_core/mocks"
serkant.uluderya2ae470f2020-01-21 11:13:09 -080025 "github.com/opencord/voltha-protos/v3/go/voltha"
khenaidoo0a822f92019-05-08 15:15:57 -040026 "github.com/stretchr/testify/assert"
khenaidoo0a822f92019-05-08 15:15:57 -040027)
28
29var transitionMap *TransitionMap
npujar1d86a522019-11-14 17:11:16 +053030var tdm coreif.DeviceManager
khenaidoo0a822f92019-05-08 15:15:57 -040031
32type testDeviceManager struct {
khenaidooab1f7bd2019-11-14 14:00:27 -050033 mocks.DeviceManager
khenaidoo0a822f92019-05-08 15:15:57 -040034}
35
36func newTestDeviceManager() *testDeviceManager {
37 return &testDeviceManager{}
38}
39
khenaidoo0a822f92019-05-08 15:15:57 -040040func init() {
khenaidoo0a822f92019-05-08 15:15:57 -040041 tdm = newTestDeviceManager()
42 transitionMap = NewTransitionMap(tdm)
43}
44
serkant.uluderya2ae470f2020-01-21 11:13:09 -080045func getDevice(root bool, admin voltha.AdminState_Types, conn voltha.ConnectStatus_Types, oper voltha.OperStatus_Types) *voltha.Device {
khenaidoo0a822f92019-05-08 15:15:57 -040046 return &voltha.Device{
47 Id: "test",
48 Root: root,
49 AdminState: admin,
50 ConnectStatus: conn,
51 OperStatus: oper,
52 }
53}
54
55func assertInvalidTransition(t *testing.T, from *voltha.Device, to *voltha.Device) {
56 handlers := transitionMap.GetTransitionHandler(from, to)
57 assert.Equal(t, 1, len(handlers))
58 assert.True(t, reflect.ValueOf(tdm.NotifyInvalidTransition).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
59}
60
61func assertNoOpTransition(t *testing.T, from *voltha.Device, to *voltha.Device) {
62 handlers := transitionMap.GetTransitionHandler(from, to)
63 assert.Equal(t, 0, len(handlers))
64}
65
66func TestValidTransitions(t *testing.T) {
khenaidoo59ef7be2019-06-21 12:40:28 -040067 from := getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
68 to := getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVE)
khenaidoo0a822f92019-05-08 15:15:57 -040069 handlers := transitionMap.GetTransitionHandler(from, to)
70 assert.Equal(t, 1, len(handlers))
khenaidoo59ef7be2019-06-21 12:40:28 -040071 assert.True(t, reflect.ValueOf(tdm.CreateLogicalDevice).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
khenaidoo0a822f92019-05-08 15:15:57 -040072
khenaidoo59ef7be2019-06-21 12:40:28 -040073 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
74 to = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE)
75 handlers = transitionMap.GetTransitionHandler(from, to)
76 assert.Equal(t, 1, len(handlers))
77 assert.True(t, reflect.ValueOf(tdm.CreateLogicalDevice).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
78
79 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
80 to = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVE)
81 handlers = transitionMap.GetTransitionHandler(from, to)
82 assert.Equal(t, 1, len(handlers))
83 assert.True(t, reflect.ValueOf(tdm.CreateLogicalDevice).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
84
85 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVATING)
86 to = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVE)
87 handlers = transitionMap.GetTransitionHandler(from, to)
88 assert.Equal(t, 1, len(handlers))
89 assert.True(t, reflect.ValueOf(tdm.CreateLogicalDevice).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
90
91 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVATING)
khenaidoo0a822f92019-05-08 15:15:57 -040092 to = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVE)
93 handlers = transitionMap.GetTransitionHandler(from, to)
94 assert.Equal(t, 1, len(handlers))
95 assert.True(t, reflect.ValueOf(tdm.CreateLogicalDevice).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
96
khenaidoo59ef7be2019-06-21 12:40:28 -040097 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_DISCOVERED)
khenaidoo0a822f92019-05-08 15:15:57 -040098 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVE)
99 handlers = transitionMap.GetTransitionHandler(from, to)
100 assert.Equal(t, 1, len(handlers))
101 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
102
khenaidoo59ef7be2019-06-21 12:40:28 -0400103 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_DISCOVERED)
104 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVE)
105 handlers = transitionMap.GetTransitionHandler(from, to)
106 assert.Equal(t, 1, len(handlers))
107 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
108
109 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_DISCOVERED)
110 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE)
111 handlers = transitionMap.GetTransitionHandler(from, to)
112 assert.Equal(t, 1, len(handlers))
113 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
114
115 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_DISCOVERED)
116 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE)
117 handlers = transitionMap.GetTransitionHandler(from, to)
118 assert.Equal(t, 1, len(handlers))
119 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
120
121 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_DISCOVERED)
122 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE)
123 handlers = transitionMap.GetTransitionHandler(from, to)
124 assert.Equal(t, 1, len(handlers))
125 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
126
127 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
128 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVE)
129 handlers = transitionMap.GetTransitionHandler(from, to)
130 assert.Equal(t, 1, len(handlers))
131 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
132
133 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
134 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVE)
135 handlers = transitionMap.GetTransitionHandler(from, to)
136 assert.Equal(t, 1, len(handlers))
137 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
138
139 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
140 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE)
141 handlers = transitionMap.GetTransitionHandler(from, to)
142 assert.Equal(t, 1, len(handlers))
143 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
144
145 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVATING)
146 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVE)
147 handlers = transitionMap.GetTransitionHandler(from, to)
148 assert.Equal(t, 1, len(handlers))
149 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
150
151 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVATING)
152 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVE)
153 handlers = transitionMap.GetTransitionHandler(from, to)
154 assert.Equal(t, 1, len(handlers))
155 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
156
khenaidoo59ef7be2019-06-21 12:40:28 -0400157 from = getDevice(true, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
158 to = getDevice(true, voltha.AdminState_DELETED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
159 handlers = transitionMap.GetTransitionHandler(from, to)
160 assert.Equal(t, 1, len(handlers))
161 assert.True(t, reflect.ValueOf(tdm.RunPostDeviceDelete).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
162
163 from = getDevice(false, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
164 to = getDevice(false, voltha.AdminState_DELETED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
165 handlers = transitionMap.GetTransitionHandler(from, to)
166 assert.Equal(t, 1, len(handlers))
167 assert.True(t, reflect.ValueOf(tdm.RunPostDeviceDelete).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
Girish Gowdra408cd962020-03-11 14:31:31 -0700168 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVE)
169
170 to = getDevice(false, voltha.AdminState_DELETED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_FAILED)
171 handlers = transitionMap.GetTransitionHandler(from, to)
172 assert.Equal(t, 3, len(handlers))
173 assert.True(t, reflect.ValueOf(tdm.ChildDeviceLost).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
174 assert.True(t, reflect.ValueOf(tdm.DeleteLogicalPorts).Pointer() == reflect.ValueOf(handlers[1]).Pointer())
175 assert.True(t, reflect.ValueOf(tdm.RunPostDeviceDelete).Pointer() == reflect.ValueOf(handlers[2]).Pointer())
176
177 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE)
178 to = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_UNKNOWN)
179 handlers = transitionMap.GetTransitionHandler(from, to)
180 assert.Equal(t, 4, len(handlers))
181 assert.True(t, reflect.ValueOf(tdm.DeleteAllLogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
182 assert.True(t, reflect.ValueOf(tdm.DeleteLogicalDevice).Pointer() == reflect.ValueOf(handlers[1]).Pointer())
183 assert.True(t, reflect.ValueOf(tdm.DeleteAllChildDevices).Pointer() == reflect.ValueOf(handlers[2]).Pointer())
184 assert.True(t, reflect.ValueOf(tdm.DeleteAllDeviceFlows).Pointer() == reflect.ValueOf(handlers[3]).Pointer())
185
186 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_UNKNOWN)
187 to = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE)
188 handlers = transitionMap.GetTransitionHandler(from, to)
189 assert.Equal(t, 1, len(handlers))
190 assert.True(t, reflect.ValueOf(tdm.CreateLogicalDevice).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
khenaidoo0a822f92019-05-08 15:15:57 -0400191
khenaidoo442e7c72020-03-10 16:13:48 -0400192 var deleteDeviceTest = struct {
193 from []*voltha.Device
194 to []*voltha.Device
195 expectedParentHandlers []TransitionHandler
196 expectedChildHandlers []TransitionHandler
197 }{
198 from: []*voltha.Device{
199 getDevice(false, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_FAILED),
200 getDevice(false, voltha.AdminState_UNKNOWN, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN),
201 getDevice(false, voltha.AdminState_DOWNLOADING_IMAGE, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN),
202 getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN),
203 getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE),
204 getDevice(false, voltha.AdminState_DISABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_UNKNOWN),
205 getDevice(false, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_UNKNOWN),
206 },
207 to: []*voltha.Device{
208 getDevice(false, voltha.AdminState_DELETED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN),
209 getDevice(false, voltha.AdminState_DELETED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_UNKNOWN),
210 getDevice(false, voltha.AdminState_DELETED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_FAILED),
211 },
212 expectedParentHandlers: []TransitionHandler{
213 tdm.DisableAllChildDevices,
214 tdm.DeleteAllUNILogicalPorts,
215 tdm.DeleteAllChildDevices,
Andrea Campanella09400bd2020-04-02 11:58:04 +0200216 tdm.DeleteAllLogicalPorts,
khenaidoo442e7c72020-03-10 16:13:48 -0400217 tdm.DeleteLogicalDevice,
218 tdm.RunPostDeviceDelete,
219 },
220 expectedChildHandlers: []TransitionHandler{
221 tdm.ChildDeviceLost,
222 tdm.DeleteLogicalPorts,
223 tdm.RunPostDeviceDelete,
224 },
225 }
khenaidoo0a822f92019-05-08 15:15:57 -0400226
khenaidoo442e7c72020-03-10 16:13:48 -0400227 testName := "delete-parent-device-post-provisioning"
228 for _, from := range deleteDeviceTest.from {
229 from.Root = true
230 for _, to := range deleteDeviceTest.to {
231 to.Root = true
232 t.Run(testName, func(t *testing.T) {
233 handlers = transitionMap.GetTransitionHandler(from, to)
Andrea Campanella09400bd2020-04-02 11:58:04 +0200234 assert.Equal(t, 6, len(handlers))
khenaidoo442e7c72020-03-10 16:13:48 -0400235 for idx, expHandler := range deleteDeviceTest.expectedParentHandlers {
236 assert.True(t, reflect.ValueOf(expHandler).Pointer() == reflect.ValueOf(handlers[idx]).Pointer())
237 }
238 })
239 }
240 }
khenaidoo59ef7be2019-06-21 12:40:28 -0400241
khenaidoo442e7c72020-03-10 16:13:48 -0400242 testName = "delete-child-device"
243 for _, from := range deleteDeviceTest.from {
244 from.Root = false
245 for _, to := range deleteDeviceTest.to {
246 to.Root = false
247 t.Run(testName, func(t *testing.T) {
248 handlers = transitionMap.GetTransitionHandler(from, to)
249 assert.Equal(t, 3, len(handlers))
250 for idx, expHandler := range deleteDeviceTest.expectedChildHandlers {
251 assert.True(t, reflect.ValueOf(expHandler).Pointer() == reflect.ValueOf(handlers[idx]).Pointer())
252 }
253 })
254 }
255 }
khenaidoo0a822f92019-05-08 15:15:57 -0400256}
257
258func TestInvalidTransitions(t *testing.T) {
khenaidoo59ef7be2019-06-21 12:40:28 -0400259 from := getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVE)
260 to := getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
khenaidoo0a822f92019-05-08 15:15:57 -0400261 assertInvalidTransition(t, from, to)
262
khenaidoo59ef7be2019-06-21 12:40:28 -0400263 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
264 to = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
khenaidoo0a822f92019-05-08 15:15:57 -0400265 assertInvalidTransition(t, from, to)
266
khenaidoo59ef7be2019-06-21 12:40:28 -0400267 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
khenaidoo0a822f92019-05-08 15:15:57 -0400268 to = getDevice(true, voltha.AdminState_UNKNOWN, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
269 assertInvalidTransition(t, from, to)
270
khenaidoo59ef7be2019-06-21 12:40:28 -0400271 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
khenaidoo0a822f92019-05-08 15:15:57 -0400272 to = getDevice(true, voltha.AdminState_DOWNLOADING_IMAGE, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
273 assertInvalidTransition(t, from, to)
274
275 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
276 to = getDevice(true, voltha.AdminState_UNKNOWN, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
277 assertInvalidTransition(t, from, to)
278
279 from = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
280 to = getDevice(true, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
281 assertInvalidTransition(t, from, to)
282
283 from = getDevice(true, voltha.AdminState_DOWNLOADING_IMAGE, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
284 to = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
285 assertInvalidTransition(t, from, to)
286}
287
288func TestNoOpTransitions(t *testing.T) {
289 from := getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
290 to := getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
291 assertNoOpTransition(t, from, to)
292
293 from = getDevice(true, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
294 to = getDevice(true, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
295 assertNoOpTransition(t, from, to)
296
297 from = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
298 to = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
299 assertNoOpTransition(t, from, to)
300
301 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
302 to = getDevice(false, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
303 assertNoOpTransition(t, from, to)
304
305 from = getDevice(false, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
306 to = getDevice(false, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_DISCOVERED)
307 assertNoOpTransition(t, from, to)
308
309 from = getDevice(false, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_DISCOVERED)
310 to = getDevice(false, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVATING)
311 assertNoOpTransition(t, from, to)
312}
khenaidoo442e7c72020-03-10 16:13:48 -0400313
314func TestMatch(t *testing.T) {
315 best := &match{admin: currPrevStateMatch, oper: currPrevStateMatch, conn: currPrevStateMatch}
316 m := &match{admin: currStateOnlyMatch, oper: currWildcardMatch, conn: currWildcardMatch}
317 fmt.Println(m.isBetterMatch(best), m.toInt(), best.toInt())
318}