2
0

not-exist-upstream.t 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. BEGIN {
  18. if ($ENV{TEST_NGINX_CHECK_LEAK}) {
  19. $SkipReason = "unavailable for the hup tests";
  20. } else {
  21. $ENV{TEST_NGINX_USE_HUP} = 1;
  22. undef $ENV{TEST_NGINX_USE_STAP};
  23. }
  24. }
  25. use t::APISIX 'no_plan';
  26. repeat_each(1);
  27. log_level('info');
  28. no_root_location();
  29. no_shuffle();
  30. run_tests();
  31. __DATA__
  32. === TEST 1: set route(id: 1)
  33. --- config
  34. location /t {
  35. content_by_lua_block {
  36. local t = require("lib.test_admin").test
  37. local code, body = t('/apisix/admin/routes/1',
  38. ngx.HTTP_PUT,
  39. [[{
  40. "plugins": {},
  41. "uri": "/hello"
  42. }]]
  43. )
  44. if code >= 300 then
  45. ngx.status = code
  46. end
  47. ngx.say(body)
  48. }
  49. }
  50. --- request
  51. GET /t
  52. --- response_body
  53. passed
  54. === TEST 2: /not_found
  55. --- request
  56. GET /not_found
  57. --- error_code: 404
  58. --- response_body
  59. {"error_msg":"404 Route Not Found"}
  60. === TEST 3: hit routes
  61. --- request
  62. GET /hello
  63. --- error_code_like: ^(?:50\d)$
  64. --- response_body eval
  65. qr/502 Bad Gateway|503 Service Temporarily Unavailable/
  66. --- grep_error_log eval
  67. qr/\[error\].*/
  68. --- grep_error_log_out eval
  69. qr/missing upstream configuration in Route or Service/