[SEBA-627] Add more test case of testing of importer
Change-Id: Ief2671f7ba1d4855066a8cc28d41b8e3b5f6983f
diff --git a/demo_test/cmd_client/Makefile b/demo_test/cmd_client/Makefile
new file mode 100644
index 0000000..4c9a95e
--- /dev/null
+++ b/demo_test/cmd_client/Makefile
@@ -0,0 +1,17 @@
+# Copyright 2018-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.
+
+cmd_cl:
+ go build -i -v -o $@
+
diff --git a/demo_test/cmd_client/Note b/demo_test/cmd_client/Note
new file mode 100644
index 0000000..74b6916
--- /dev/null
+++ b/demo_test/cmd_client/Note
@@ -0,0 +1,96 @@
+// 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.
+
+At the root of the device-management source tree
+1. cd demotest
+ make demotest
+ ./demotest
+2. Create another ssh session
+ cd ./demotest/cmd_cleint
+ make cmd_cl
+ ./cmd_cl
+
+ then it will have "CMD to send:" prompt
+ You can use the following "client cmd" to test.
+
+ Example:
+
+ For the first time, you need to use "attach:ipaddress:port:vendorname:freq" to set the device's IP related info.
+ If successful, you will get "[ipaddress:port]CMD to send:" prompt to indicate what device you attached now.
+ This attach will subscribe default 3 types events into the server.
+ You can use the following wget to check if any events subscriptions on the device.
+
+ wget --no-check-certificate \
+ -qO- https://RFSERVERIP:8888/redfish/v1/EventService/Subscriptions/ \
+ | python -m json.tool
+
+ You can also use "unsub:add:rm:alert" to unsubscribe all 3 types of event subscriptions on the device.
+
+ And use "QUIT" to leave test.
+
+--------------------------------------------------------------------------------------
+Test items client cmd
+--------------------------------------------------------------------------------------
+set device info Example:
+
+Set IP 192.168.4.27 port 8888 vendor "edgecore" freq 180
+ attach:192.168.4.27:8888:edgecore:180
+--------------------------------------------------------------------------------------
+set multi-deivies info Example:
+
+ attach:192.168.4.27:8888:edgecore:180
+ attach:192.168.3.34:8888:edgecore:180
+--------------------------------------------------------------------------------------
+UnSubscribe all events(ResourceAdded/ResourceRemoved/Alert) unsub:add:rm:alert
+--------------------------------------------------------------------------------------
+Subscribe all events(ResourceAdded/ResourceRemoved/Alert) sub:add:rm:alert
+--------------------------------------------------------------------------------------
+Subscribe and unsubscribe an event Example:
+
+Subscribe ResourceAdded event sub:add
+Subscribe ResourceRemoved event sub:rm
+Subscribe Alert event sub:alert
+Unsubscribe ResourceAdded event unsub:add
+Unsubscribe ResourceRemoved event unsub:rm
+Unsubscribe Alert event unsub:alert
+--------------------------------------------------------------------------------------
+Subscribe and unsubscribe multiple events, out of order Use the above commands to do test.
+--------------------------------------------------------------------------------------
+Subscribe an unsupported event sub:update
+--------------------------------------------------------------------------------------
+Subscribe to an already subscribed event Example:
+
+ sub:add
+ sub:add
+--------------------------------------------------------------------------------------
+Unsubscribe an unsupported event unsub:update
+--------------------------------------------------------------------------------------
+Unsubscribe a supported but not-subscribed event Example:
+
+ unsub:add:rm:alert
+ unsub:add
+ unsub:rm
+ unsub:alert
+--------------------------------------------------------------------------------------
+Change polling interval Example:
+
+Set frequecny to 30 seconds
+ period:30
+--------------------------------------------------------------------------------------
+Show support event list showeventlist
+--------------------------------------------------------------------------------------
+* During and after each test, verify the list of events subscribed wget --no-check-certificate \
+ -qO- https://192.168.4.27:8888/redfish/v1/EventService/Subscriptions/ \
+ | python -m json.tool
+--------------------------------------------------------------------------------------
diff --git a/demo_test/cmd_client/cmd_cl.go b/demo_test/cmd_client/cmd_cl.go
new file mode 100644
index 0000000..e1ee3bb
--- /dev/null
+++ b/demo_test/cmd_client/cmd_cl.go
@@ -0,0 +1,60 @@
+// Copyright 2018-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.
+
+package main
+
+import "net"
+import "fmt"
+import "bufio"
+import "os"
+import "strings"
+
+var attach_ip string = ""
+
+func main() {
+ // connect to this socket
+ var message string = ""
+ conn, _ := net.Dial("tcp", "127.0.0.1:9999")
+ reader := bufio.NewReader(os.Stdin)
+ for {
+ // read in input from stdin
+ if(attach_ip != ""){
+ fmt.Printf("[%v] CMD to send :", attach_ip)
+ }else{
+ fmt.Print("CMD to send :")
+ }
+ text, _ := reader.ReadString('\n')
+
+ // send to socket
+ fmt.Fprintf(conn, text + "\n")
+
+ cmd := strings.TrimSuffix(text, "\n")
+ s := strings.Split(cmd, ":")
+ cmd = s[0]
+
+ if(cmd == "attach"){
+ // listen for reply
+ t_attach_ip, _ := bufio.NewReader(conn).ReadString('\n')
+ attach_ip = strings.TrimSuffix(t_attach_ip, "\n")
+ }else{
+ // listen for reply
+ message, _ = bufio.NewReader(conn).ReadString('\n')
+ fmt.Print("Return from server: " + message)
+ }
+
+ if message == "QUIT\n"{
+ break
+ }
+ }
+}