123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- package report
- import (
- "sync"
- "testing"
- "time"
- "go-common/library/queue/databus"
- xtime "go-common/library/time"
- )
- var (
- mnOnce sync.Once
- mnUatOnce sync.Once
- userOnce sync.Once
- userUatOnce sync.Once
- )
- func newManager() {
- InitManager(nil)
- }
- func newUatManager() {
- InitManager(&databus.Config{
- Key: "2511663d546f1413",
- Secret: "cde3b480836cc76df3d635470f991caa",
- Group: "LogAudit-MainSearch-P",
- Topic: "LogAudit-T",
- Action: "pub",
- Buffer: 10240,
- Name: "log-audit/log-sub",
- Proto: "tcp",
- Addr: "172.18.33.50:6205",
- Active: 100,
- Idle: 100,
- DialTimeout: xtime.Duration(time.Millisecond * 200),
- ReadTimeout: xtime.Duration(time.Millisecond * 200),
- WriteTimeout: xtime.Duration(time.Millisecond * 200),
- IdleTimeout: xtime.Duration(time.Second * 80),
- })
- }
- func newUser() {
- InitUser(nil)
- }
- func newUatUser() {
- InitManager(&databus.Config{
- Key: "2511663d546f1413",
- Secret: "cde3b480836cc76df3d635470f991caa",
- Group: "LogUserAction-MainSearch-P",
- Topic: "LogUserAction-T",
- Action: "pub",
- Buffer: 10240,
- Name: "log-user-action/log-sub",
- Proto: "tcp",
- Addr: "172.18.33.50:6205",
- Active: 100,
- Idle: 100,
- DialTimeout: xtime.Duration(time.Millisecond * 200),
- ReadTimeout: xtime.Duration(time.Millisecond * 200),
- WriteTimeout: xtime.Duration(time.Millisecond * 200),
- IdleTimeout: xtime.Duration(time.Second * 80),
- })
- }
- func Test_Manager(b *testing.T) {
- mnOnce.Do(newManager)
- Manager(&ManagerInfo{
- Uname: "dz",
- UID: 64,
- Business: 0,
- Type: 1,
- Oid: 2,
- Action: "action",
- Ctime: time.Now(),
- Index: []interface{}{5, 6, 7, "a", "b", "c"},
- Content: map[string]interface{}{
- "json": "json",
- },
- })
- }
- func Test_UatManager(b *testing.T) {
- mnUatOnce.Do(newUatManager)
- Manager(&ManagerInfo{
- Uname: "dz",
- UID: 64,
- Business: 0,
- Type: 1,
- Oid: 2,
- Action: "action",
- Ctime: time.Now(),
- Index: []interface{}{5, 6, 7, "a", "b", "c"},
- Content: map[string]interface{}{
- "json": "json",
- },
- })
- }
- func Test_User(b *testing.T) {
- userOnce.Do(newUser)
- User(&UserInfo{
- Mid: 1,
- Platform: "platform",
- Build: 2,
- Buvid: "buvid",
- Business: 0,
- Type: 3,
- Oid: 4,
- Action: "action",
- Ctime: time.Now(),
- IP: "127.0.0.1",
- // extra
- Index: []interface{}{5, 6, 7, "a", "b", "c"},
- Content: map[string]interface{}{
- "json": "json",
- },
- })
- }
- func Test_UatUser(b *testing.T) {
- userUatOnce.Do(newUatUser)
- User(&UserInfo{
- Mid: 1,
- Platform: "platform",
- Build: 2,
- Buvid: "buvid",
- Business: 0,
- Type: 3,
- Oid: 4,
- Action: "action",
- Ctime: time.Now(),
- IP: "127.0.0.1",
- // extra
- Index: []interface{}{5, 6, 7, "a", "b", "c"},
- Content: map[string]interface{}{
- "json": "json",
- },
- })
- }
|