khenaidoo | bf6e7bb | 2018-08-14 22:27:29 -0400 | [diff] [blame] | 1 | /* |
| 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 Barbarie | 4a2564d | 2018-07-26 11:02:58 -0400 | [diff] [blame] | 16 | package model |
| 17 | |
| 18 | import ( |
| 19 | "crypto/md5" |
| 20 | "fmt" |
| 21 | "github.com/golang/protobuf/ptypes/any" |
Stephane Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 22 | "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 Barbarie | 4a2564d | 2018-07-26 11:02:58 -0400 | [diff] [blame] | 25 | "testing" |
| 26 | ) |
| 27 | |
| 28 | func 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 Barbarie | ec0919b | 2018-09-05 14:14:29 -0400 | [diff] [blame] | 41 | 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 Barbarie | 4a2564d | 2018-07-26 11:02:58 -0400 | [diff] [blame] | 68 | } |
Stephane Barbarie | 06c4a74 | 2018-10-01 11:09:32 -0400 | [diff] [blame] | 69 | root := &root{} |
Stephane Barbarie | 4a2564d | 2018-07-26 11:02:58 -0400 | [diff] [blame] | 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 | } |