donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2017 the original author or authors. |
| 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 | */ |
| 16 | package tosca_test |
| 17 | |
| 18 | import ( |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 19 | "strings" |
| 20 | "testing" |
| 21 | |
| 22 | "gerrit.opencord.org/abstract-olt/models/tosca" |
| 23 | ) |
| 24 | |
| 25 | var output = `tosca_definitions_version: tosca_simple_yaml_1_0 |
| 26 | imports: |
| 27 | - custom_types/oltdevice.yaml |
| 28 | - custom_types/onudevice.yaml |
| 29 | - custom_types/ponport.yaml |
| 30 | - custom_types/voltservice.yaml |
| 31 | description: Create a simulated OLT Device in VOLTHA |
| 32 | topology_template: |
| 33 | node_templates: |
| 34 | service#volt: |
| 35 | type: tosca.nodes.VOLTService |
| 36 | properties: |
| 37 | name: volt |
| 38 | must-exist: true |
| 39 | olt_device: |
| 40 | type: tosca.nodes.OLTDevice |
| 41 | properties: |
| 42 | name: myName |
| 43 | device_type: openolt |
| 44 | host: 192.168.1.1 |
| 45 | port: 9191 |
| 46 | outer_tpid: "0x8100" |
| 47 | uplink: "65536" |
| 48 | nas_id: my_clli |
donNewtonAlpha | e7ab5b9 | 2018-09-27 15:09:14 -0400 | [diff] [blame] | 49 | switch_datapath_id: of:0000000000000001 |
| 50 | switch_port: "1" |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 51 | requirements: |
| 52 | - volt_service: |
| 53 | node: service#volt |
| 54 | relationship: tosca.relationships.BelongsToOne |
| 55 | ` |
| 56 | |
| 57 | var olt tosca.OltProvsion |
| 58 | |
| 59 | func TestAddOlt_NewOltProvsion(t *testing.T) { |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 60 | olt = tosca.NewOltProvision("my_clli", "myName", "openolt", "192.168.1.1", 9191) |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | func TestAddOlt_ToYaml(t *testing.T) { |
| 64 | y, err := olt.ToYaml() |
| 65 | if err != nil { |
| 66 | t.Fatalf("olt.ToYaml() failed with %v\n", err) |
| 67 | } |
| 68 | x := strings.Compare(y, output) |
| 69 | if x != 0 { |
| 70 | t.Fatal("ToYaml didn't produce the expected yaml") |
| 71 | } |
donNewtonAlpha | 1d2d681 | 2018-09-14 16:00:02 -0400 | [diff] [blame] | 72 | } |