Stephane Barbarie | 4a2564d | 2018-07-26 11:02:58 -0400 | [diff] [blame] | 1 | package model |
| 2 | |
| 3 | import ( |
| 4 | "encoding/json" |
| 5 | "fmt" |
| 6 | "github.com/opencord/voltha/protos/go/voltha" |
| 7 | "testing" |
| 8 | "time" |
| 9 | ) |
| 10 | |
| 11 | var ( |
| 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 | |
| 21 | func 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 | } |