示例#1
0
func TestAuthorityWithZk(t *testing.T) {
	coor := c.NewCenterAgent("192.168.13.157:50001", "192.168.13.157:60000")

	if nil == coor {
		t.Errorf("Failed to init coordinator with ttmv_uuid_zk:2181 and ttmv_uuid_redis:6379")
	}

	err := a.InitAuthority(coor)
	if err != nil {
		t.Errorf("Failed to get data from %s or %s", global.VERIFY_INFO_PATH, global.PERMISSION_INFO_PATH)
	}

	if !a.Verify("CID64", "123456") {
		t.Errorf("Failed to verify \"bizCode\" ")
		for key, value := range global.LegalUser {
			t.Errorf(key + ":" + value)
		}
	}

	if !a.Permission("0101", "CID64") {
		t.Errorf("Failed to give \"bizCode\" permission \"0101\" ")
		for key, value := range global.Permission {
			t.Errorf(key + ":" + value)
		}
	}
}
示例#2
0
package count_test

import (
	"coordinate"
	"count"
	"testing"
)

var centerAgent = coordinate.NewCenterAgent("192.168.13.157:50001", "192.168.13.157:60000")

func TestSequentialCount32(t *testing.T) {
	if nil == centerAgent {
		t.Errorf("Failed to connect zk_test:2181 or redis_test:6379")
	}
	numberNextMax, err := count.SequentialCount(centerAgent, "php-biz", 1, 0, 9999, 3)
	if err != nil {
		t.Errorf("Failed to count sequential: " + err.Error())
	}

	t.Errorf(numberNextMax)
}

func TestSequentialCount64(t *testing.T) {
	if nil == centerAgent {
		t.Errorf("Failed to connect zk_test:2181 or redis_test:6379")
	}
	numberNextMin, err := count.SequentialCount(centerAgent, "cpp-biz", -1, 9999, 0, 3)
	if err != nil {
		t.Errorf("Failed to count sequential: " + err.Error())
	}
示例#3
0
package coordinate_test

import (
	"coordinate"
	"strconv"
	"testing"
	"time"
)

var centerAgent = coordinate.NewCenterAgent("zk_test:2181", "redis_test:6379")

func TestGetDataInPath(t *testing.T) {
	if centerAgent == nil {
		t.Errorf("Faild to connect zk_test:2181 or redis_test:6379")
	}

	data, err := centerAgent.GetDataInPath("/")
	if err != nil || nil == data {
		t.Errorf("Faild to get data from /")
	}

}

func TestCountNum(t *testing.T) {
	if centerAgent == nil {
		t.Errorf("Faild to connect zk_test:2181 or redis_test:6379")
	}

	var numberNow, numberNext int64
	numberNow = 5
	for i := 0; i < 3; i++ {