淇敼锛?. 鏂板浜嗛攣鏈哄埗浠ラ槻姝㈠苟鍙戣闂啿绐侊紱2. 淇敼浜嗕竴浜涘彉閲忓悕浠ユ彁楂樹唬鐮佸彲璇绘€э紱 3. 淇浜嗕竴涓彲鑳藉鑷寸紦鍐插尯婧㈠嚭鐨?bug锛屽皢缂撳啿鍖哄ぇ灏忚缃负 4096锛?. 瀵逛唬鐮佽繘琛屼簡涓€浜涘叾浠栫殑灏忔敼杩涘拰浼樺寲銆?
git-svn-id: svn://47.119.165.148/zhub@121 e63fbceb-bcc3-4977-ac22-735b83d8d0f4
This commit is contained in:
32
cli_test.go
32
cli_test.go
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"testing"
|
||||
@@ -108,12 +109,13 @@ func TestTimer(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendCmd(t *testing.T) {
|
||||
client, err := cli.Create(addr, "")
|
||||
client, err := cli.Create(addr, "group-admin")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
client.Cmd("reload-timer")
|
||||
//client.Cmd("reload-timer")
|
||||
client.Cmd("shutdown")
|
||||
}
|
||||
|
||||
func TestPublish(t *testing.T) {
|
||||
@@ -127,3 +129,29 @@ func TestPublish(t *testing.T) {
|
||||
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
|
||||
func TestLock(t *testing.T) {
|
||||
client, _ := cli.Create(addr, "xx")
|
||||
|
||||
client.Subscribe("lock", func(v string) {
|
||||
|
||||
})
|
||||
|
||||
var fun = func(x string) {
|
||||
log.Println("lock", time.Now().UnixNano()/1e6)
|
||||
lock := client.Lock("a", 30)
|
||||
defer client.Unlock(lock)
|
||||
//client.Lock("a", 5)
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
time.Sleep(time.Second * 1)
|
||||
fmt.Println(x + ":" + strconv.Itoa(i+1))
|
||||
}
|
||||
}
|
||||
|
||||
go fun("x")
|
||||
go fun("y")
|
||||
go fun("z")
|
||||
|
||||
time.Sleep(time.Second * 30 * 10)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user