蛋蛋星球-客户端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

131 řádky
3.3 KiB

  1. package friend_circle
  2. import (
  3. "code.fnuoos.com/EggPlanet/egg_system_rules.git/md"
  4. "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy"
  5. "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es"
  6. "fmt"
  7. "testing"
  8. )
  9. // 创建朋友圈索引
  10. func TestCreateFriendCircleIndex(t *testing.T) {
  11. es.Init("http://123.57.140.192:9200", "elastic", "fnuo123")
  12. index := md.EggFriendCircleEsIndex
  13. err := es.CreateIndexIfNotExists(index, md.EggFriendCircleEsMapping)
  14. if err != nil {
  15. fmt.Println(err)
  16. }
  17. fmt.Println("success")
  18. }
  19. // 删除朋友圈索引
  20. func TestDeleteFriendCircleIndex(t *testing.T) {
  21. es.Init("http://123.57.140.192:9200", "elastic", "fnuo123")
  22. _, err := es.DeleteIndex(md.EggFriendCircleEsIndex)
  23. if err != nil {
  24. fmt.Println(err)
  25. return
  26. }
  27. fmt.Println("success")
  28. }
  29. // 创建朋友圈点赞索引
  30. func TestCreateFriendCircleCommentLikeIndex(t *testing.T) {
  31. es.Init("http://123.57.140.192:9200", "elastic", "fnuo123")
  32. for i := 0; i < 10; i++ {
  33. index := fmt.Sprintf("%s%d", md.EggFriendCircleLikeEsIndex, i)
  34. err := es.CreateIndexIfNotExists(index, md.EggFriendCircleLikeEsMapping)
  35. if err != nil {
  36. fmt.Println(err)
  37. }
  38. }
  39. fmt.Println("success")
  40. }
  41. // 删除朋友圈点赞索引
  42. func TestDeleteFriendCircleCommentLikeIndex(t *testing.T) {
  43. es.Init("http://123.57.140.192:9200", "elastic", "fnuo123")
  44. for i := 0; i < 10; i++ {
  45. index := fmt.Sprintf("%s%d", md.EggFriendCircleLikeEsIndex, i)
  46. _, err := es.DeleteIndex(index)
  47. if err != nil {
  48. fmt.Println(err)
  49. return
  50. }
  51. }
  52. fmt.Println("success")
  53. }
  54. // 创建朋友圈评论索引
  55. func TestCreateFriendCircleCommentIndex(t *testing.T) {
  56. es.Init("http://123.57.140.192:9200", "elastic", "fnuo123")
  57. for i := 0; i < 10; i++ {
  58. index := fmt.Sprintf("%s%d", md.EggFriendCircleCommentEsIndex, i)
  59. err := es.CreateIndexIfNotExists(index, md.EggFriendCircleCommentEsMapping)
  60. if err != nil {
  61. fmt.Println(err)
  62. }
  63. }
  64. fmt.Println("success")
  65. }
  66. // 删除朋友圈评论索引
  67. func TestDeleteFriendCircleCommentIndex(t *testing.T) {
  68. es.Init("http://123.57.140.192:9200", "elastic", "fnuo123")
  69. for i := 0; i < 10; i++ {
  70. index := fmt.Sprintf("%s%d", md.EggFriendCircleCommentEsIndex, i)
  71. _, err := es.DeleteIndex(index)
  72. if err != nil {
  73. fmt.Println(err)
  74. return
  75. }
  76. }
  77. fmt.Println("success")
  78. }
  79. // 删除蛋蛋分记录
  80. func TestDeleteEggScoreIndex(t *testing.T) {
  81. es.Init("http://120.55.48.175:9200", "elastic", "fnuo123")
  82. index := fmt.Sprintf("%s_%d", md.EggEnergyUserEggScoreEsAlias, 202451)
  83. _, err := es.DeleteIndex(index)
  84. if err != nil {
  85. fmt.Println(err)
  86. return
  87. }
  88. fmt.Println("success")
  89. }
  90. // 创建临时蛋蛋分记录
  91. func TestCreateTempEggScoreIndex(t *testing.T) {
  92. es.Init("http://123.57.140.192:9200/", "elastic", "fnuo123")
  93. index := fmt.Sprintf("%s_%d", md.EggEnergyUserEggScoreEsAlias, 202451)
  94. err := es.CreateIndexIfNotExists(index, md.EggEnergyUserEggScoreEsMapping)
  95. if err != nil {
  96. fmt.Println(err)
  97. }
  98. for i := 1; i < 41; i++ {
  99. egg_energy.ExistOrDefaultUserEggScore(int64(i))
  100. }
  101. fmt.Println("success")
  102. }
  103. // 创建蛋蛋分记录
  104. func TestCreateEggScoreIndex(t *testing.T) {
  105. es.Init("http://123.57.140.192:9200/", "elastic", "fnuo123")
  106. index := fmt.Sprintf("%s_%d", md.EggEnergyUserEggScoreEsAlias, 202451)
  107. err := es.CreateIndexIfNotExists(index, md.EggEnergyUserEggScoreEsMapping)
  108. if err != nil {
  109. fmt.Println(err)
  110. }
  111. fmt.Println("success")
  112. }