route-delete.t 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. use t::APISIX 'no_plan';
  18. repeat_each(2);
  19. log_level('info');
  20. worker_connections(256);
  21. no_root_location();
  22. no_shuffle();
  23. run_tests();
  24. __DATA__
  25. === TEST 1: clear all routes
  26. --- config
  27. location /t {
  28. content_by_lua_block {
  29. local t = require("lib.test_admin").test
  30. for i = 1, 200 do
  31. t('/apisix/admin/routes/' .. i, ngx.HTTP_DELETE)
  32. end
  33. ngx.say("done")
  34. }
  35. }
  36. --- request
  37. GET /t
  38. --- response_body
  39. done
  40. --- timeout: 5
  41. === TEST 2: create 106 routes + delete them
  42. --- config
  43. location /t {
  44. content_by_lua_block {
  45. local t = require("lib.test_admin").test
  46. for i = 1, 106 do
  47. local code, body = t('/apisix/admin/routes/' .. i,
  48. ngx.HTTP_PUT,
  49. [[{
  50. "upstream": {
  51. "nodes": {
  52. "127.0.0.1:1980": 1
  53. },
  54. "type": "roundrobin"
  55. },
  56. "uri": "/hello]] .. i .. [["
  57. }]]
  58. )
  59. end
  60. ngx.sleep(0.5)
  61. for i = 1, 106 do
  62. local code, body = t('/apisix/admin/routes/' .. i,
  63. ngx.HTTP_PUT,
  64. [[{
  65. "upstream": {
  66. "nodes": {
  67. "127.0.0.1:1980": 1
  68. },
  69. "type": "roundrobin"
  70. },
  71. "uri": "/hello]] .. i .. [["
  72. }]]
  73. )
  74. end
  75. ngx.sleep(0.5)
  76. for i = 1, 106 do
  77. local code, body = t('/apisix/admin/routes/' .. i,
  78. ngx.HTTP_DELETE
  79. )
  80. end
  81. ngx.sleep(0.5)
  82. for i = 1, 106 do
  83. local code, body = t('/apisix/admin/routes/' .. i,
  84. ngx.HTTP_PUT,
  85. [[{
  86. "upstream": {
  87. "nodes": {
  88. "127.0.0.1:1980": 1
  89. },
  90. "type": "roundrobin"
  91. },
  92. "uri": "/hello]] .. i .. [["
  93. }]]
  94. )
  95. end
  96. ngx.sleep(0.5)
  97. for i = 1, 106 do
  98. local code, body = t('/apisix/admin/routes/' .. i,
  99. ngx.HTTP_DELETE
  100. )
  101. end
  102. ngx.say("done")
  103. }
  104. }
  105. --- request
  106. GET /t
  107. --- response_body
  108. done
  109. --- wait: 1
  110. --- grep_error_log eval
  111. qr/\w+ (data by key: 103)/
  112. --- grep_error_log_out
  113. insert data by key: 103
  114. insert data by key: 103
  115. update data by key: 103
  116. update data by key: 103
  117. delete data by key: 103
  118. delete data by key: 103
  119. insert data by key: 103
  120. insert data by key: 103
  121. delete data by key: 103
  122. delete data by key: 103
  123. --- timeout: 30