-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathregistry_zk_test.go
112 lines (111 loc) · 2.92 KB
/
registry_zk_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package core
//
//import (
// "testing"
// "time"
//)
//
//func TestOldZKRegisteService(t *testing.T) {
//
// // t.Log("test")
// regAddr := "localhost:2181"
// serviceUri := "/service/bibi-profile"
// protocol := "v1"
// hostport := "localhost:18000"
//
// registry := NewZkRegistry(regAddr, []string{serviceUri}, false)
//
// registry.RegisteService(serviceUri, hostport, "v1", "*", ServiceMeta{
// ServiceUri: serviceUri,
// GroupId: "",
// HostPort: hostport,
// ProtoVersion: protocol,
// IsPre: false,
// })
//
// time.Sleep(10 * time.Second)
// data, err := registry.GetService(serviceUri, protocol, "*")
// if err != nil {
// t.Fail()
// t.Logf("GetService FAIL! %s", err.Error())
// } else if len(data) > 0 {
// t.Logf("GetService %d-> %v SUCC", len(data), data)
// } else {
// t.Fail()
// }
//
// flag := registry.UnRegisteService(serviceUri, hostport, protocol, "*")
// if !flag {
// t.Fatalf("UnRegisteService %s Fail", serviceUri)
// }
//
// time.Sleep(5 * time.Second)
// data, err = registry.GetService(serviceUri, protocol, "*")
// if err != nil {
// t.Fail()
// t.Logf("GetService FAIL! %s", err.Error())
// } else if len(data) > 0 {
// t.Fail()
// t.Logf("GetService %d-> %v fail", len(data), data)
// } else {
// t.Logf("GetService %d-> %v SUCC", len(data), data)
// }
//
//}
//
//func TestGroupZKRegisteService(t *testing.T) {
//
// // t.Log("test")
// regAddr := "localhost:2181"
// serviceUri := "/service/bibi-profile"
// protocol := "v1"
// hostport := "localhost:18000"
// groupId := "s-mts-group"
//
// groupUri := BuildServiceUri("/service/bibi-profile", "s-mts-group")
// registry := NewZkRegistry(regAddr, []string{groupUri}, false)
//
// registry.RegisteService(serviceUri, hostport, protocol, groupId, ServiceMeta{
// ServiceUri: serviceUri,
// GroupId: groupId,
// HostPort: hostport,
// ProtoVersion: protocol,
// IsPre: false,
// })
// time.Sleep(10 * time.Second)
// data, err := registry.GetService(serviceUri, protocol, groupId)
// if err != nil || len(data) <= 0 {
// t.Fail()
// t.Logf("GetService FAIL! %s", err)
// } else {
// t.Logf("GetService %d-> %v SUCC", len(data), data)
// }
//
// //different groupId
// data, err = registry.GetService(serviceUri, protocol, "s-mts-group-2")
// if err != nil || len(data) <= 0 {
// t.Logf("No Group GetService [%s] SUCC", "s-mts-group-2")
// } else {
// t.Fail()
// t.Logf("amazing GetService [%s] SUCC~", "s-mts-group-2")
// return
// }
//
// flag := registry.UnRegisteService(serviceUri, hostport, protocol, groupId)
// if !flag {
// t.Fatalf("UnRegisteService %s Fail", serviceUri)
// }
//
// time.Sleep(10 * time.Second)
// data, err = registry.GetService(serviceUri, protocol, groupId)
// if err != nil {
// t.Fail()
// t.Logf("GetService FAIL! %s", err.Error())
// } else if len(data) > 0 {
// t.Fail()
// t.Logf("GetService %d-> %v fail", len(data), data)
// } else {
// t.Logf("GetService %d-> %v SUCC", len(data), data)
// }
//
//}