SEBA-902 single-olt tests;
Pin protoc-gen-go to 1.3.2 to resolve compatibility issue;
Run go mod tidy / go mod vendor on importer;
Add Go Module support to demotest

Change-Id: Ifde824fc9a6317b0adc1e12bea54ee1f9b788906
diff --git a/demo_test/functional_test/importer.robot b/demo_test/functional_test/importer.robot
index 516a51e..749aa98 100644
--- a/demo_test/functional_test/importer.robot
+++ b/demo_test/functional_test/importer.robot
@@ -27,18 +27,42 @@
 
 *** Variables ***
 @{ADDR_LIST}      192.168.4.26:8888    192.168.4.27:8888
+
+# timeout: timeout for most operations.
 ${timeout}        60s
+
+# pod_timeout: timeout to bring up a new pod. It has been observed to take up to
+# 120 seconds for images to pull. Set 300 seconds to alloww room for temporary
+# network fluctuation.
+${pod_timeout}    300s
+
+# use_mock_redfish: If true, mock redfish OLTs will be used instead of a 
+#    physical device. Default: False.
 ${use_mock_redfish}    False
+
+# use_Containerized_dm: If true, then dm will be run from inside the
+#     demo-test container. Default: False.
 ${use_containerized_dm}    False
+
+# voltha_suite_setup. If true, then voltha common test suite setup will
+#     be run. Among other things, this will also check to ensure that
+#     Kubernetes is configured. Default: False.
 ${voltha_suite_setup}    False
+
+# Pod names when using the Kubernetes-based deploy-redfish-importer.yaml. See
+# the keyword "Install Mock Redfish Server" for the step that brings up these
+# pods and checks their existence.
 ${IMPORTER_POD_NAME}    redfish-importer
 ${DEMOTEST_POD_NAME}    redfish-demotest
+${MOCK1_POD_NAME}    mock-olt-1
+${MOCK2_POD_NAME}    mock-olt-2
 
 *** Test Cases ***
 Add Device to Monitor
     [Documentation]    This test case excercises the API, SendDeviceList, which registers Redfish devices to monitor.
-    ${EXPECTED}=    RUN    sed -e '/^\\/\\//d' -e 's/ip1/${IP1}/g' -e 's/port1/${PORT1}/g' -e 's/ip2/${IP2}/g' -e 's/port2/${PORT2}/g' tests/add_device_to_monitor.expected
-    ${OUTPUT}=    Run Test    tests/add_device_to_monitor.tc    ${IP1}    ${PORT1}    ${IP2}    ${PORT2}
+    ${TESTNAME}=    Set Variable If    ${multiple_olt}    tests/add_device_to_monitor    tests/add_single_device_to_monitor   
+    ${EXPECTED}=    RUN    sed -e '/^\\/\\//d' -e 's/ip1/${IP1}/g' -e 's/port1/${PORT1}/g' -e 's/ip2/${IP2}/g' -e 's/port2/${PORT2}/g' ${TESTNAME}.expected
+    ${OUTPUT}=    Run Test    ${TESTNAME}.tc    ${IP1}    ${PORT1}    ${IP2}    ${PORT2}
     Should Be Equal    ${EXPECTED}    ${OUTPUT}
 
 Clear Subscribed Events
@@ -55,14 +79,16 @@
 
 Delete Monitored Device
     [Documentation]    This test case excercises the API, DeleteDeviceList, which deletes Redfish devices being monitored.
-    ${EXPECTED}=    RUN    sed -e '/^\\/\\//d' -e 's/ip1/${IP1}/g' -e 's/port1/${PORT1}/g' -e 's/ip2/${IP2}/g' -e 's/port2/${PORT2}/g' tests/delete_monitored_device.expected
-    ${OUTPUT}=    Run Test    tests/delete_monitored_device.tc    ${IP1}    ${PORT1}    ${IP2}    ${PORT2}
+    ${TESTNAME}=    SEt Variable If    ${multiple_olt}    tests/delete_monitored_device    tests/delete_single_monitored_device
+    ${EXPECTED}=    RUN    sed -e '/^\\/\\//d' -e 's/ip1/${IP1}/g' -e 's/port1/${PORT1}/g' -e 's/ip2/${IP2}/g' -e 's/port2/${PORT2}/g' ${TESTNAME}.expected
+    ${OUTPUT}=    Run Test    ${TESTNAME}.tc    ${IP1}    ${PORT1}    ${IP2}    ${PORT2}
     Should Be Equal    ${EXPECTED}    ${OUTPUT}
 
 List Devices monitored
     [Documentation]    This test case excercises the API, GetCurrentDevices, which lists all Redfish devices being monitored.
-    ${EXPECTED}=    RUN    sed -e '/^\\/\\//d' -e 's/ip1/${IP1}/g' -e 's/port1/${PORT1}/g' -e 's/ip2/${IP2}/g' -e 's/port2/${PORT2}/g' tests/list_device_monitored.expected
-    ${OUTPUT}=    Run Test    tests/list_device_monitored.tc    ${IP1}    ${PORT1}    ${IP2}    ${PORT2}
+    ${TESTNAME}=    SEt Variable If    ${multiple_olt}    tests/list_device_monitored    tests/list_single_device_monitored
+    ${EXPECTED}=    RUN    sed -e '/^\\/\\//d' -e 's/ip1/${IP1}/g' -e 's/port1/${PORT1}/g' -e 's/ip2/${IP2}/g' -e 's/port2/${PORT2}/g' ${TESTNAME}.expected
+    ${OUTPUT}=    Run Test    ${TESTNAME}.tc    ${IP1}    ${PORT1}    ${IP2}    ${PORT2}
     Should Be Equal    ${EXPECTED}    ${OUTPUT}
 
 List Subscribed Events
@@ -110,26 +136,45 @@
     Run Keyword If    ${use_mock_redfish}    Clean Up Mock Redfish Server
 
 Install Mock Redfish Server
+    [Documentation]    Installs mock OLTS, redfish importer, demo-test
     Apply Kubernetes Resources    ../../kubernetes/deploy-redfish-importer.yaml    default
-    Wait Until Keyword Succeeds    ${timeout}    5s
+    Wait Until Keyword Succeeds    ${pod_timeout}    5s
+    ...    Validate Pod Status    ${MOCK1_POD_NAME}    default     Running
+    Wait Until Keyword Succeeds    ${pod_timeout}    5s
+    ...    Validate Pod Status    ${MOCK2_POD_NAME}    default     Running
+    Wait Until Keyword Succeeds    ${pod_timeout}    5s
     ...    Validate Pod Status    ${IMPORTER_POD_NAME}    default     Running
-    Wait Until Keyword Succeeds    ${timeout}    5s
+    Wait Until Keyword Succeeds    ${pod_timeout}    5s
     ...    Validate Pod Status    ${DEMOTEST_POD_NAME}    default     Running
+    # After the pods have come online, it may still take a few seconds
+    # before they start responding to requests.
+    Sleep    10 Seconds
 
 Clean Up Mock Redfish Server
     Delete Kubernetes Resources    ../../kubernetes/deploy-redfish-importer.yaml    default
 
 Get IP AND PORT
+    ${num_addr}=    Get Length    ${ADDR_LIST}
+    ${multiple_olt}=    Set Variable If    ${num_addr}>1    True     False
+    Set Suite Variable    ${multiple_olt}
     Sort List    ${ADDR_LIST}
     ${I1}=    Fetch From LEFT    ${ADDR_LIST}[0]    :
     Set Suite Variable    ${IP1}    ${I1}
     ${P1}=    Fetch From Right    ${ADDR_LIST}[0]    :
     Set Suite Variable    ${PORT1}    ${P1}
+    Run Keyword If    ${multiple_olt}    Get IP AND PORT Second OLT
+    ...    ELSE    Set No Second OLT
+
+Get IP AND PORT Second OLT
     ${I2}=    Fetch From LEFT    ${ADDR_LIST}[1]    :
     Set Suite Variable    ${IP2}    ${I2}
     ${P2}=    Fetch From Right    ${ADDR_LIST}[1]    :
     Set Suite Variable    ${PORT2}    ${P2}
 
+Set No Second OLT
+    Set Suite Variable    ${IP2}    None
+    Set Suite Variable    ${PORT2}    None
+
 Run Test
     [Arguments]    @{args}
     ${output}=    Run Keyword if    ${use_containerized_dm}
diff --git a/demo_test/functional_test/robot-mock-olt-single.yaml b/demo_test/functional_test/robot-mock-olt-single.yaml
new file mode 100644
index 0000000..d6a33ad
--- /dev/null
+++ b/demo_test/functional_test/robot-mock-olt-single.yaml
@@ -0,0 +1,24 @@
+---
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This yaml file overrides importer.robot to configure the robot test
+# to work with one mock redfish OLT.
+
+use_mock_redfish:    True
+use_containerized_dm:    True
+
+ADDR_LIST:
+  - mock-olt-1:8401
diff --git a/demo_test/functional_test/robot-mock-olt.yaml b/demo_test/functional_test/robot-mock-olt.yaml
index e91d76c..0036154 100644
--- a/demo_test/functional_test/robot-mock-olt.yaml
+++ b/demo_test/functional_test/robot-mock-olt.yaml
@@ -15,6 +15,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+# This yaml file overrides importer.robot to configure the robot test
+# to work with two mock redfish OLTs.
+
 use_mock_redfish:    True
 use_containerized_dm:    True
 
diff --git a/demo_test/functional_test/tests/add_single_device_to_monitor.expected b/demo_test/functional_test/tests/add_single_device_to_monitor.expected
new file mode 100644
index 0000000..8599a28
--- /dev/null
+++ b/demo_test/functional_test/tests/add_single_device_to_monitor.expected
@@ -0,0 +1,18 @@
+// Copyright 2018 Open Networking Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+ip1:port1 attached
+Device ip ip1 already registered
+Device ip ip1 already registered
+invalid command ip1:88
+ip1:port1 deleted
diff --git a/demo_test/functional_test/tests/add_single_device_to_monitor.tc b/demo_test/functional_test/tests/add_single_device_to_monitor.tc
new file mode 100755
index 0000000..67dcfad
--- /dev/null
+++ b/demo_test/functional_test/tests/add_single_device_to_monitor.tc
@@ -0,0 +1,21 @@
+#!/bin/bash  
+
+# Copyrigh/ 2019-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+./dm attach $1:$2:120
+./dm attach $1:$2:120
+./dm attach $1:88:120
+./dm attach $1:88
+./dm delete $1:$2
diff --git a/demo_test/functional_test/tests/delete_single_monitored_device.expected b/demo_test/functional_test/tests/delete_single_monitored_device.expected
new file mode 100644
index 0000000..04eaa99
--- /dev/null
+++ b/demo_test/functional_test/tests/delete_single_monitored_device.expected
@@ -0,0 +1,16 @@
+// Copyright 2018 Open Networking Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+ip1:port1 attached
+ip1:port1 deleted
+Device ip1:port1 not found
diff --git a/demo_test/functional_test/tests/delete_single_monitored_device.tc b/demo_test/functional_test/tests/delete_single_monitored_device.tc
new file mode 100755
index 0000000..7ec895e
--- /dev/null
+++ b/demo_test/functional_test/tests/delete_single_monitored_device.tc
@@ -0,0 +1,19 @@
+#!/bin/bash  
+
+# Copyrigh/ 2019-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+./dm attach $1:$2:120
+./dm delete $1:$2
+./dm delete $1:$2
diff --git a/demo_test/functional_test/tests/list_single_device_monitored.expected b/demo_test/functional_test/tests/list_single_device_monitored.expected
new file mode 100644
index 0000000..a6fb97c
--- /dev/null
+++ b/demo_test/functional_test/tests/list_single_device_monitored.expected
@@ -0,0 +1,17 @@
+// Copyright 2018 Open Networking Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+No Device found
+ip1:port1 attached
+ip1:port1
+ip1:port1 deleted
diff --git a/demo_test/functional_test/tests/list_single_device_monitored.tc b/demo_test/functional_test/tests/list_single_device_monitored.tc
new file mode 100755
index 0000000..ef5a7a8
--- /dev/null
+++ b/demo_test/functional_test/tests/list_single_device_monitored.tc
@@ -0,0 +1,20 @@
+#!/bin/bash  
+
+# Copyrigh/ 2019-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+./dm showdevices
+./dm attach $1:$2:120
+./dm showdevices
+./dm delete $1:$2