blob: f9aeb67fe7308cfde111165b4153e3173d96fc65 [file] [log] [blame]
Stephane Barbarie4a2564d2018-07-26 11:02:58 -04001package model
2
3import (
4 "encoding/json"
5 "fmt"
6 "github.com/opencord/voltha/protos/go/voltha"
7 "testing"
8 "time"
9)
10
11var (
12 backend *Backend
13 //rootPrefix = "service/voltha/data/core/0001"
14
15 basePrefix = "service/voltha/service/vcores/data/devices"
16 deviceId = "00016f13befaedcc"
17 rootPrefix = basePrefix + "/" + deviceId
18 deviceProxy = "/devices/" + deviceId
19)
20
21func Test_NewRoot(t *testing.T) {
22 backend = NewBackend(ETCD_KV, etcd_host, etcd_port, timeout, rootPrefix)
23
24 //var msgClass *voltha.VolthaInstance
25 var msgClass *voltha.DeviceInstance
26 root := NewRoot(msgClass, backend, nil)
27
28 start := time.Now()
29
30 r := root.Load(msgClass)
31 afterLoad := time.Now()
32 fmt.Printf(">>>>>>>>>>>>> Time to load : %f\n", afterLoad.Sub(start).Seconds())
33
34 d := r.Node.Get(deviceProxy, "", 0, false, "")
35 afterGet := time.Now()
36 fmt.Printf(">>>>>>>>>>>>> Time to load and get: %f\n", afterGet.Sub(start).Seconds())
37
38 jr, _ := json.Marshal(r)
39 fmt.Printf("Content of ROOT --> \n%s\n", jr)
40
41 jd, _ := json.Marshal(d)
42 fmt.Printf("Content of GET --> \n%s\n", jd)
43
44}