blob: ec7961f903992e0babb02ea0b78df1f9c2c82355 [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 (
19 "github.com/opencord/voltha-go/common/log"
20 "github.com/opencord/voltha-go/rw_core/coreIf"
21 "github.com/opencord/voltha-protos/go/voltha"
22 "github.com/stretchr/testify/assert"
23 "reflect"
24 "testing"
25)
26
27var transitionMap *TransitionMap
28var tdm coreIf.DeviceManager
29
30type testDeviceManager struct {
31}
32
33func newTestDeviceManager() *testDeviceManager {
34 return &testDeviceManager{}
35}
36
37func (tdm *testDeviceManager) GetDevice(string) (*voltha.Device, error) {
38 return nil, nil
39}
40
41func (tdm *testDeviceManager) IsRootDevice(string) (bool, error) {
42 return false, nil
43}
44
45func (tdm *testDeviceManager) NotifyInvalidTransition(pto *voltha.Device) error {
46 return nil
47}
48
49func (tdm *testDeviceManager) SetAdminStateToEnable(to *voltha.Device) error {
50 return nil
51}
52
53func (tdm *testDeviceManager) CreateLogicalDevice(to *voltha.Device) error {
54 return nil
55}
56
57func (tdm *testDeviceManager) SetupUNILogicalPorts(to *voltha.Device) error {
58 return nil
59}
60
61func (tdm *testDeviceManager) DisableAllChildDevices(to *voltha.Device) error {
62 return nil
63}
64
65func (tdm *testDeviceManager) DeleteLogicalDevice(to *voltha.Device) error {
66 return nil
67}
68
69func (tdm *testDeviceManager) DeleteLogicalPorts(to *voltha.Device) error {
70 return nil
71}
72
73func (tdm *testDeviceManager) DeleteAllChildDevices(to *voltha.Device) error {
74 return nil
75}
76
77func (tdm *testDeviceManager) RunPostDeviceDelete(to *voltha.Device) error {
78 return nil
79}
80
khenaidoo59ef7be2019-06-21 12:40:28 -040081func (tdm *testDeviceManager) MarkChildDevicesAsUnReachable(to *voltha.Device) error {
82 return nil
83}
84
khenaidoo0a822f92019-05-08 15:15:57 -040085func init() {
86 log.AddPackage(log.JSON, log.WarnLevel, nil)
87 //log.UpdateAllLoggers(log.Fields{"instanceId": "device-state-transition"})
88 //log.SetAllLogLevel(log.DebugLevel)
89 tdm = newTestDeviceManager()
90 transitionMap = NewTransitionMap(tdm)
91}
92
93func getDevice(root bool, admin voltha.AdminState_AdminState, conn voltha.ConnectStatus_ConnectStatus, oper voltha.OperStatus_OperStatus) *voltha.Device {
94 return &voltha.Device{
95 Id: "test",
96 Root: root,
97 AdminState: admin,
98 ConnectStatus: conn,
99 OperStatus: oper,
100 }
101}
102
103func assertInvalidTransition(t *testing.T, from *voltha.Device, to *voltha.Device) {
104 handlers := transitionMap.GetTransitionHandler(from, to)
105 assert.Equal(t, 1, len(handlers))
106 assert.True(t, reflect.ValueOf(tdm.NotifyInvalidTransition).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
107}
108
109func assertNoOpTransition(t *testing.T, from *voltha.Device, to *voltha.Device) {
110 handlers := transitionMap.GetTransitionHandler(from, to)
111 assert.Equal(t, 0, len(handlers))
112}
113
114func TestValidTransitions(t *testing.T) {
khenaidoo59ef7be2019-06-21 12:40:28 -0400115 from := getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
116 to := getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVE)
khenaidoo0a822f92019-05-08 15:15:57 -0400117 handlers := transitionMap.GetTransitionHandler(from, to)
118 assert.Equal(t, 1, len(handlers))
khenaidoo59ef7be2019-06-21 12:40:28 -0400119 assert.True(t, reflect.ValueOf(tdm.CreateLogicalDevice).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
khenaidoo0a822f92019-05-08 15:15:57 -0400120
khenaidoo59ef7be2019-06-21 12:40:28 -0400121 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
122 to = getDevice(true, 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.CreateLogicalDevice).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
126
127 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
128 to = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVE)
129 handlers = transitionMap.GetTransitionHandler(from, to)
130 assert.Equal(t, 1, len(handlers))
131 assert.True(t, reflect.ValueOf(tdm.CreateLogicalDevice).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
132
133 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVATING)
134 to = getDevice(true, 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.CreateLogicalDevice).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
138
139 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVATING)
khenaidoo0a822f92019-05-08 15:15:57 -0400140 to = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVE)
141 handlers = transitionMap.GetTransitionHandler(from, to)
142 assert.Equal(t, 1, len(handlers))
143 assert.True(t, reflect.ValueOf(tdm.CreateLogicalDevice).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
144
khenaidoo59ef7be2019-06-21 12:40:28 -0400145 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_DISCOVERED)
khenaidoo0a822f92019-05-08 15:15:57 -0400146 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, 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
khenaidoo59ef7be2019-06-21 12:40:28 -0400151 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_DISCOVERED)
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
157 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_DISCOVERED)
158 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE)
159 handlers = transitionMap.GetTransitionHandler(from, to)
160 assert.Equal(t, 1, len(handlers))
161 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
162
163 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_DISCOVERED)
164 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE)
165 handlers = transitionMap.GetTransitionHandler(from, to)
166 assert.Equal(t, 1, len(handlers))
167 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
168
169 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_DISCOVERED)
170 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE)
171 handlers = transitionMap.GetTransitionHandler(from, to)
172 assert.Equal(t, 1, len(handlers))
173 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
174
175 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
176 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVE)
177 handlers = transitionMap.GetTransitionHandler(from, to)
178 assert.Equal(t, 1, len(handlers))
179 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
180
181 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
182 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVE)
183 handlers = transitionMap.GetTransitionHandler(from, to)
184 assert.Equal(t, 1, len(handlers))
185 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
186
187 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
188 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE)
189 handlers = transitionMap.GetTransitionHandler(from, to)
190 assert.Equal(t, 1, len(handlers))
191 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
192
193 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVATING)
194 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVE)
195 handlers = transitionMap.GetTransitionHandler(from, to)
196 assert.Equal(t, 1, len(handlers))
197 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
198
199 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVATING)
200 to = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVE)
201 handlers = transitionMap.GetTransitionHandler(from, to)
202 assert.Equal(t, 1, len(handlers))
203 assert.True(t, reflect.ValueOf(tdm.SetupUNILogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
204
khenaidoo0a822f92019-05-08 15:15:57 -0400205 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
206 to = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
207 handlers = transitionMap.GetTransitionHandler(from, to)
208 assert.Equal(t, 1, len(handlers))
khenaidoo59ef7be2019-06-21 12:40:28 -0400209 assert.True(t, reflect.ValueOf(tdm.MarkChildDevicesAsUnReachable).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
khenaidoo0a822f92019-05-08 15:15:57 -0400210
khenaidoo59ef7be2019-06-21 12:40:28 -0400211 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE)
212 to = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVE)
khenaidoo0a822f92019-05-08 15:15:57 -0400213 handlers = transitionMap.GetTransitionHandler(from, to)
214 assert.Equal(t, 1, len(handlers))
khenaidoo59ef7be2019-06-21 12:40:28 -0400215 assert.True(t, reflect.ValueOf(tdm.MarkChildDevicesAsUnReachable).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
khenaidoo0a822f92019-05-08 15:15:57 -0400216
khenaidoo59ef7be2019-06-21 12:40:28 -0400217 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVE)
218 to = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_UNKNOWN)
khenaidoo0a822f92019-05-08 15:15:57 -0400219 handlers = transitionMap.GetTransitionHandler(from, to)
220 assert.Equal(t, 1, len(handlers))
khenaidoo59ef7be2019-06-21 12:40:28 -0400221 assert.True(t, reflect.ValueOf(tdm.MarkChildDevicesAsUnReachable).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
222
223 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_UNKNOWN)
224 to = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_ACTIVE)
225 handlers = transitionMap.GetTransitionHandler(from, to)
226 assert.Equal(t, 1, len(handlers))
227 assert.True(t, reflect.ValueOf(tdm.MarkChildDevicesAsUnReachable).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
228
229 from = getDevice(true, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
230 to = getDevice(true, voltha.AdminState_DELETED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
231 handlers = transitionMap.GetTransitionHandler(from, to)
232 assert.Equal(t, 1, len(handlers))
233 assert.True(t, reflect.ValueOf(tdm.RunPostDeviceDelete).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
234
235 from = getDevice(false, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
236 to = getDevice(false, voltha.AdminState_DELETED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
237 handlers = transitionMap.GetTransitionHandler(from, to)
238 assert.Equal(t, 1, len(handlers))
239 assert.True(t, reflect.ValueOf(tdm.RunPostDeviceDelete).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
khenaidoo0a822f92019-05-08 15:15:57 -0400240
241 from = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
242 to = getDevice(true, voltha.AdminState_DELETED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
243 handlers = transitionMap.GetTransitionHandler(from, to)
244 assert.Equal(t, 3, len(handlers))
245 assert.True(t, reflect.ValueOf(tdm.DeleteAllChildDevices).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
246 assert.True(t, reflect.ValueOf(tdm.DeleteLogicalDevice).Pointer() == reflect.ValueOf(handlers[1]).Pointer())
247 assert.True(t, reflect.ValueOf(tdm.RunPostDeviceDelete).Pointer() == reflect.ValueOf(handlers[2]).Pointer())
248
khenaidoo59ef7be2019-06-21 12:40:28 -0400249 from = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_UNKNOWN)
250 to = getDevice(true, voltha.AdminState_DELETED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_UNKNOWN)
251 handlers = transitionMap.GetTransitionHandler(from, to)
252 assert.Equal(t, 3, len(handlers))
253 assert.True(t, reflect.ValueOf(tdm.DeleteAllChildDevices).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
254 assert.True(t, reflect.ValueOf(tdm.DeleteLogicalDevice).Pointer() == reflect.ValueOf(handlers[1]).Pointer())
255 assert.True(t, reflect.ValueOf(tdm.RunPostDeviceDelete).Pointer() == reflect.ValueOf(handlers[2]).Pointer())
256
257 from = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_UNKNOWN)
258 to = getDevice(true, voltha.AdminState_DELETED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_FAILED)
259 handlers = transitionMap.GetTransitionHandler(from, to)
260 assert.Equal(t, 3, len(handlers))
261 assert.True(t, reflect.ValueOf(tdm.DeleteAllChildDevices).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
262 assert.True(t, reflect.ValueOf(tdm.DeleteLogicalDevice).Pointer() == reflect.ValueOf(handlers[1]).Pointer())
263 assert.True(t, reflect.ValueOf(tdm.RunPostDeviceDelete).Pointer() == reflect.ValueOf(handlers[2]).Pointer())
264
khenaidoo0a822f92019-05-08 15:15:57 -0400265 from = getDevice(false, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
266 to = getDevice(false, voltha.AdminState_DELETED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
267 handlers = transitionMap.GetTransitionHandler(from, to)
268 assert.Equal(t, 2, len(handlers))
269 assert.True(t, reflect.ValueOf(tdm.DeleteLogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
270 assert.True(t, reflect.ValueOf(tdm.RunPostDeviceDelete).Pointer() == reflect.ValueOf(handlers[1]).Pointer())
khenaidoo59ef7be2019-06-21 12:40:28 -0400271
272 from = getDevice(false, voltha.AdminState_DISABLED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_UNKNOWN)
273 to = getDevice(false, voltha.AdminState_DELETED, voltha.ConnectStatus_UNREACHABLE, voltha.OperStatus_UNKNOWN)
274 handlers = transitionMap.GetTransitionHandler(from, to)
275 assert.Equal(t, 2, len(handlers))
276 assert.True(t, reflect.ValueOf(tdm.DeleteLogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
277 assert.True(t, reflect.ValueOf(tdm.RunPostDeviceDelete).Pointer() == reflect.ValueOf(handlers[1]).Pointer())
278
279 from = getDevice(false, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVE)
280 to = getDevice(false, voltha.AdminState_DELETED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_FAILED)
281 handlers = transitionMap.GetTransitionHandler(from, to)
282 assert.Equal(t, 2, len(handlers))
283 assert.True(t, reflect.ValueOf(tdm.DeleteLogicalPorts).Pointer() == reflect.ValueOf(handlers[0]).Pointer())
284 assert.True(t, reflect.ValueOf(tdm.RunPostDeviceDelete).Pointer() == reflect.ValueOf(handlers[1]).Pointer())
khenaidoo0a822f92019-05-08 15:15:57 -0400285}
286
287func TestInvalidTransitions(t *testing.T) {
khenaidoo59ef7be2019-06-21 12:40:28 -0400288 from := getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVE)
289 to := getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
khenaidoo0a822f92019-05-08 15:15:57 -0400290 assertInvalidTransition(t, from, to)
291
khenaidoo59ef7be2019-06-21 12:40:28 -0400292 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
293 to = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
khenaidoo0a822f92019-05-08 15:15:57 -0400294 assertInvalidTransition(t, from, to)
295
khenaidoo59ef7be2019-06-21 12:40:28 -0400296 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
khenaidoo0a822f92019-05-08 15:15:57 -0400297 to = getDevice(true, voltha.AdminState_UNKNOWN, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
298 assertInvalidTransition(t, from, to)
299
khenaidoo59ef7be2019-06-21 12:40:28 -0400300 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
khenaidoo0a822f92019-05-08 15:15:57 -0400301 to = getDevice(true, voltha.AdminState_DOWNLOADING_IMAGE, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
302 assertInvalidTransition(t, from, to)
303
304 from = getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
305 to = getDevice(true, voltha.AdminState_UNKNOWN, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
306 assertInvalidTransition(t, from, to)
307
308 from = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
309 to = getDevice(true, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
310 assertInvalidTransition(t, from, to)
311
312 from = getDevice(true, voltha.AdminState_DOWNLOADING_IMAGE, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
313 to = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
314 assertInvalidTransition(t, from, to)
315}
316
317func TestNoOpTransitions(t *testing.T) {
318 from := getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
319 to := getDevice(true, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
320 assertNoOpTransition(t, from, to)
321
322 from = getDevice(true, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
323 to = getDevice(true, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
324 assertNoOpTransition(t, from, to)
325
326 from = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
327 to = getDevice(true, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
328 assertNoOpTransition(t, from, to)
329
330 from = getDevice(false, voltha.AdminState_ENABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
331 to = getDevice(false, voltha.AdminState_DISABLED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_UNKNOWN)
332 assertNoOpTransition(t, from, to)
333
334 from = getDevice(false, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_UNKNOWN, voltha.OperStatus_ACTIVATING)
335 to = getDevice(false, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_DISCOVERED)
336 assertNoOpTransition(t, from, to)
337
338 from = getDevice(false, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_DISCOVERED)
339 to = getDevice(false, voltha.AdminState_PREPROVISIONED, voltha.ConnectStatus_REACHABLE, voltha.OperStatus_ACTIVATING)
340 assertNoOpTransition(t, from, to)
341}