main_dev_test.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package main
  2. import (
  3. "f1-game/tool/client-cli/cli"
  4. "fmt"
  5. "math/rand"
  6. "sync"
  7. "testing"
  8. "time"
  9. cherryTime "github.com/cherry-game/cherry/extend/time"
  10. cherryLogger "github.com/cherry-game/cherry/logger"
  11. )
  12. // TestDev_10001 dev环境连10001服
  13. func TestDev_10001(t *testing.T) {
  14. var (
  15. url = "http://192.168.1.232:18080"
  16. addr = "192.168.1.232:30001"
  17. gameNodeID = "1"
  18. pid = "2188001"
  19. userAndPwd = "su1002"
  20. )
  21. cli.RegisterDevAccounts(url, map[string]string{
  22. userAndPwd: userAndPwd,
  23. })
  24. wg := &sync.WaitGroup{}
  25. wg.Add(1)
  26. robot := cli.EnterServer(url, pid, userAndPwd, userAndPwd, addr, gameNodeID, true)
  27. if robot != nil {
  28. robot.ChargeCreate(80006)
  29. }
  30. wg.Wait()
  31. }
  32. func TestDev_10001_10000_EnterServer(t *testing.T) {
  33. var (
  34. url = "http://192.168.1.232:18080"
  35. addr = "192.168.1.232:30001"
  36. gameNodeID = "1"
  37. testAccounts = make(map[string]string)
  38. pid = "2188001"
  39. maxAccountNum = 10000
  40. )
  41. for i := 1; i <= maxAccountNum; i++ {
  42. key := fmt.Sprintf("susu%d", i)
  43. testAccounts[key] = key
  44. }
  45. now := cherryTime.Now()
  46. wg := &sync.WaitGroup{}
  47. wg.Add(1)
  48. for userName, password := range testAccounts {
  49. time.Sleep(time.Duration(rand.Int31n(2)) * time.Millisecond)
  50. go func(userName, password string) {
  51. cli.EnterServer(url, pid, userName, password, addr, gameNodeID, false)
  52. //wg.Done()
  53. }(userName, password)
  54. }
  55. wg.Wait()
  56. cherryLogger.Infof("elapsedTime = %dms", now.NowDiffMillisecond())
  57. }
  58. // TestDev_10002 dev环境连10002服
  59. func TestDev_10002(t *testing.T) {
  60. var (
  61. url = "http://192.168.1.232:18080"
  62. addr = "192.168.1.232:30001"
  63. gameNodeID = "10002"
  64. pid = "2188001"
  65. userAndPwd = "su1001"
  66. )
  67. cli.RegisterDevAccount(url, userAndPwd, userAndPwd)
  68. wg := &sync.WaitGroup{}
  69. wg.Add(1)
  70. robot := cli.EnterServer(url, pid, userAndPwd, userAndPwd, addr, gameNodeID, true)
  71. if robot != nil {
  72. //robot.ItemUse(3003, 208)
  73. robot.ChargeCreate(80006)
  74. //robot.Time()
  75. //robot.ItemUse(21001)
  76. //robot.GuideUpdate()
  77. //robot.BuyEP(1)
  78. //robot.ItemUse()
  79. //robot.ChapterEnter()
  80. //robot.ChapterExit()
  81. }
  82. wg.Wait()
  83. }