blob: 29f4c7c667956a3a6894494324c362a90eea3bd3 [file] [log] [blame]
khenaidoobf6e7bb2018-08-14 22:27:29 -04001/*
2 * Copyright 2018-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 */
Stephane Barbarie4a2564d2018-07-26 11:02:58 -040016package model
17
18import (
19 "crypto/md5"
20 "fmt"
21 "github.com/golang/protobuf/ptypes/any"
Stephane Barbarieec0919b2018-09-05 14:14:29 -040022 "github.com/opencord/voltha-go/protos/common"
23 "github.com/opencord/voltha-go/protos/openflow_13"
24 "github.com/opencord/voltha-go/protos/voltha"
Stephane Barbarie4a2564d2018-07-26 11:02:58 -040025 "testing"
26)
27
28func Test_Node_01_New(t *testing.T) {
29 ports := []*voltha.Port{
30 {
31 PortNo: 123,
32 Label: "test-etcd_port-0",
33 Type: voltha.Port_PON_OLT,
34 AdminState: common.AdminState_ENABLED,
35 OperStatus: common.OperStatus_ACTIVE,
36 DeviceId: "etcd_port-0-device-id",
37 Peers: []*voltha.Port_PeerPort{},
38 },
39 }
40 data := &voltha.Device{
Stephane Barbarieec0919b2018-09-05 14:14:29 -040041 Id: "Config-SomeNode-01-new-test",
42 Type: "simulated_olt",
43 Root: true,
44 ParentId: "",
45 ParentPortNo: 0,
46 Vendor: "voltha-test",
47 Model: "GetLatest-voltha-simulated-olt",
48 HardwareVersion: "1.0.0",
49 FirmwareVersion: "1.0.0",
50 Images: &voltha.Images{},
51 SerialNumber: "abcdef-123456",
52 VendorId: "DEADBEEF-INC",
53 Adapter: "simulated_olt",
54 Vlan: 1234,
55 Address: &voltha.Device_HostAndPort{HostAndPort: "1.2.3.4:5555"},
56 ExtraArgs: "",
57 ProxyAddress: &voltha.Device_ProxyAddress{},
58 AdminState: voltha.AdminState_PREPROVISIONED,
59 OperStatus: common.OperStatus_ACTIVE,
60 Reason: "",
61 ConnectStatus: common.ConnectStatus_REACHABLE,
62 Custom: &any.Any{},
63 Ports: ports,
64 Flows: &openflow_13.Flows{},
65 FlowGroups: &openflow_13.FlowGroups{},
66 PmConfigs: &voltha.PmConfigs{},
67 ImageDownloads: []*voltha.ImageDownload{},
Stephane Barbarie4a2564d2018-07-26 11:02:58 -040068 }
69 root := &Root{}
70 txid := fmt.Sprintf("%x", md5.Sum([]byte("node_transaction_id")))
71
72 node := NewNode(root, data, true, txid)
73
74 t.Logf("new SomeNode created : %+v\n", node)
75}