melezhik / swat

Simple Web Application Test
48 stars 12 forks source link

Проблема при сохранении ответа #6

Closed ivanych closed 8 years ago

ivanych commented 8 years ago

Запрос, выполненный swat'ом и записанный в кеш-файл, выдает следующее:

ivanych@ivanych ~ $ cat /home/ivanych/.swat/.cache/31553/prove/hB5EL9f_Cr
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0HTTP/1.1 200 Ok
Server: nginx/1.4.6 (Ubuntu)
Date: Tue, 08 Dec 2015 07:18:37 GMT
Content-Type: text/plain; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: no-cache
Pragma: no-cache

100    74    0     3  100    71     15    376 --:--:-- --:--:-- --:--:--   377

Тот же запрос curl, вручную:

ivanych@ivanych ~ $ curl -f -X POST -k --connect-timeout 20 -m 20 -D - -L --stderr - -H 'Content-Type: application/x-www-form-urlencoded' -d 'login=visitor&pass=visitor&text=%D1%82%D0%B5%D1%81%D1%82' https://test.ru/test
HTTP/1.1 200 Ok
Server: nginx/1.4.6 (Ubuntu)
Date: Tue, 08 Dec 2015 07:20:32 GMT
Content-Type: text/plain; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: no-cache
Pragma: no-cache

523ivanych@ivanych ~ $

Обратите внимание на число 523 в теле ответа.

Куда пропало число 523 при запросе swat'ом?

(домен не настоящий, это локальная настройка в hosts)

melezhik commented 8 years ago

Можно запустить еще раз swat тест, с выставаленными переменными swat_debug=1, debug_bytes=10000, т.е. есть так:

debug_bytes=1000 swat_debug=1 swat ...

и отписать вывод в тикет ...

ivanych commented 8 years ago

Ничего не меняется, ни единой строчки дебага не появляется. Я как-то не так пишу команду?

ivanych@ivanych ~ $ debug_bytes=1000 swat_debug=1 swat ./swat_test/ https://test.ru
/home/ivanych/.swat/.cache/7434/prove/submit_message/00.POST.t .. 
ok 1 - POST https://test.ru/submit_message succeeded
# response saved to /home/ivanych/.swat/.cache/7434/prove/ht31u1VwkO
ok 2 - output match '200 Ok'
not ok 3 - output match '523'

#   Failed test 'output match '523''
#   at /usr/local/share/perl/5.18.2/swat.pm line 141.
1..3
# Looks like you failed 1 test of 3.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/3 subtests 

Test Summary Report
-------------------
/home/ivanych/.swat/.cache/7434/prove/submit_message/00.POST.t (Wstat: 256 Tests: 3 Failed: 1)
  Failed test:  3
  Non-zero exit status: 1
Files=1, Tests=3,  0 wallclock secs ( 0.02 usr  0.00 sys +  0.05 cusr  0.00 csys =  0.07 CPU)
Result: FAIL
melezhik commented 8 years ago

Извиняюсь, переменная должна называться debug, не swat_debug debug_bytes=1000 debug=1 swat ./swat_test/ https://test.ru

ivanych commented 8 years ago

Если написать не swat_debug а debug, то:

ivanych@ivanych ~ $ debug_bytes=1000 debug=1 swat ./swat_test/ https://test.ru
/home/ivanych/.swat/.cache/8110/prove/submit_message/00.POST.t .. 
ok 1 - project: /home/ivanych/swat_test
ok 2 - hostname: https://test.ru
ok 3 - resource: /submit_message
ok 4 - http method: POST
ok 5 - swat module: 0
ok 6 - debug: 1
ok 7 - try num: 2
ok 8 - ignore http errors: 0
ok 9 - POST https://test.ru/submit_message succeeded
# response saved to /home/ivanych/.swat/.cache/8110/prove/2F_P7zIyzx
ok 10 - output match '200 Ok'
not ok 11 - output match '523'

#   Failed test 'output match '523''
#   at /usr/local/share/perl/5.18.2/swat.pm line 141.
ok 12 - end of story: /home/ivanych/swat_test/submit_message/post.txt
1..12
# Looks like you failed 1 test of 12.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/12 subtests 

Test Summary Report
-------------------
/home/ivanych/.swat/.cache/8110/prove/submit_message/00.POST.t (Wstat: 256 Tests: 12 Failed: 1)
  Failed test:  11
  Non-zero exit status: 1
Files=1, Tests=12,  0 wallclock secs ( 0.02 usr  0.00 sys +  0.04 cusr  0.02 csys =  0.08 CPU)
Result: FAIL
melezhik commented 8 years ago

да и еще раз извиняюсб за неточность, запускаем с уровнем дебага 2:

debug_bytes=1000 debug=2 swat ./swat_test/ https://test.ru

ivanych commented 8 years ago
ivanych@ivanych ~ $ debug_bytes=1000 debug=2 swat ./swat_test/ https://test.ru
/home/ivanych/.swat/.cache/9006/prove/submit_message/00.POST.t .. 
ok 1 - project: /home/ivanych/swat_test
ok 2 - hostname: https://test.ru
ok 3 - resource: /submit_message
ok 4 - http method: POST
ok 5 - swat module: 0
ok 6 - debug: 2
ok 7 - try num: 2
ok 8 - ignore http errors: 0
# 
# execute cmd: curl -f -X POST -k --connect-timeout 20 -m 20 -D - -L --stderr - -H 'Content-Type: application/x-www-form-urlencoded' -d 'login=visitor&pass=visitor&text=%D1%82%D0%B5%D1%81%D1%82' 'https://test.ru/submit_message' > /home/ivanych/.swat/.cache/9006/prove/LfDlR2F0DN && test -f /home/ivanych/.swat/.cache/9006/prove/LfDlR2F0DN
#  attempt number: 1
ok 9 - POST https://test.ru/submit_message succeeded
# response saved to /home/ivanych/.swat/.cache/9006/prove/LfDlR2F0DN
#   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#                                  Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0HTTP/1.1 200 Ok
# Server: nginx/1.4.6 (Ubuntu)
# Date: Tue, 08 Dec 2015 08:43:59 GMT
# Content-Type: text/plain; charset=UTF-8
# Transfer-Encoding: chunked
# Connection: keep-alive
# Cache-Control: no-cache
# Pragma: no-cache
# 
100    74    0     3  100    71     36    858 --:--:-- --:--:-- --:--:--   865
# context populated
# lookup 200 Ok ...
# captures:
# []
ok 10 - output match '200 Ok'
# lookup 523 ...
# captures:
# []
not ok 11 - output match '523'

#   Failed test 'output match '523''
#   at /usr/local/share/perl/5.18.2/swat.pm line 141.
ok 12 - end of story: /home/ivanych/swat_test/submit_message/post.txt
1..12
# Looks like you failed 1 test of 12.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/12 subtests 

Test Summary Report
-------------------
/home/ivanych/.swat/.cache/9006/prove/submit_message/00.POST.t (Wstat: 256 Tests: 12 Failed: 1)
  Failed test:  11
  Non-zero exit status: 1
Files=1, Tests=12,  0 wallclock secs ( 0.02 usr  0.01 sys +  0.05 cusr  0.01 csys =  0.09 CPU)
Result: FAIL
melezhik commented 8 years ago

отлично, давайте увеличим debug_bytes до 10000 (10 K ) что бы увидеть весь ответ выводе от swat:

debug_bytes=10000 debug=2 swat ./swat_test/ https://test.ru

ivanych commented 8 years ago

Никаких изменений.

ivanych@ivanych ~ $ debug_bytes=10000 debug=2 swat ./swat_test/ https://test.ru
/home/ivanych/.swat/.cache/10082/prove/submit_message/00.POST.t .. 
ok 1 - project: /home/ivanych/swat_test
ok 2 - hostname: https://test.ru
ok 3 - resource: /submit_message
ok 4 - http method: POST
ok 5 - swat module: 0
ok 6 - debug: 2
ok 7 - try num: 2
ok 8 - ignore http errors: 0
# 
# execute cmd: curl -f -X POST -k --connect-timeout 20 -m 20 -D - -L --stderr - -H 'Content-Type: application/x-www-form-urlencoded' -d 'login=visitor&pass=visitor&text=%D1%82%D0%B5%D1%81%D1%82' 'https://test.ru/submit_message' > /home/ivanych/.swat/.cache/10082/prove/m519KKLhGW && test -f /home/ivanych/.swat/.cache/10082/prove/m519KKLhGW
#  attempt number: 1
ok 9 - POST https://test.ru/submit_message succeeded
# response saved to /home/ivanych/.swat/.cache/10082/prove/m519KKLhGW
#   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#                                  Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0HTTP/1.1 200 Ok
# Server: nginx/1.4.6 (Ubuntu)
# Date: Tue, 08 Dec 2015 08:50:23 GMT
# Content-Type: text/plain; charset=UTF-8
# Transfer-Encoding: chunked
# Connection: keep-alive
# Cache-Control: no-cache
# Pragma: no-cache
# 
100    74    0     3  100    71     39    925 --:--:-- --:--:-- --:--:--   934
# context populated
# lookup 200 Ok ...
# captures:
# []
ok 10 - output match '200 Ok'
# lookup 523 ...
# captures:
# []
not ok 11 - output match '523'

#   Failed test 'output match '523''
#   at /usr/local/share/perl/5.18.2/swat.pm line 141.
ok 12 - end of story: /home/ivanych/swat_test/submit_message/post.txt
1..12
# Looks like you failed 1 test of 12.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/12 subtests 

Test Summary Report
-------------------
/home/ivanych/.swat/.cache/10082/prove/submit_message/00.POST.t (Wstat: 256 Tests: 12 Failed: 1)
  Failed test:  11
  Non-zero exit status: 1
Files=1, Tests=12,  0 wallclock secs ( 0.01 usr  0.00 sys +  0.04 cusr  0.01 csys =  0.06 CPU)
Result: FAIL
melezhik commented 8 years ago

ок, а теперь руками: curl -f -X POST -k --connect-timeout 20 -m 20 -D - -L --stderr - -H 'Content-Type: application/x-www-form-urlencoded' -d 'login=visitor&pass=visitor&text=%D1%82%D0%B5%D1%81%D1%82' 'https://test.ru/submit_message

можно вывод увидеть?

ivanych commented 8 years ago
curl -f -X POST -k --connect-timeout 20 -m 20 -D - -L --stderr - -H 'Content-Type: application/x-www-form-urlencoded' -d 'login=visitor&pass=visitor&text=%D1%82%D0%B5%D1%81%D1%82' 'https://test.ru/submit_message'
HTTP/1.1 200 Ok
Server: nginx/1.4.6 (Ubuntu)
Date: Tue, 08 Dec 2015 08:55:53 GMT
Content-Type: text/plain; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: no-cache
Pragma: no-cache

523ivanych@ivanych ~ $
ivanych commented 8 years ago

После 523 нет перевода строки, может это влияет?

melezhik commented 8 years ago

может и так , сейчас подумаю ...

melezhik commented 8 years ago

похоже на это - http://stackoverflow.com/questions/12916352/shell-script-read-missing-last-line сейчас еще подумаю ...

melezhik commented 8 years ago

попробуйте обновиться из гита, переделал немного способ запуска curl, и повторите тест

perl Makefile.PL
make
make test
sudo make install
ivanych commented 8 years ago

Заработало!

melezhik commented 8 years ago

кул. кстати этот коммит закрывает #5 , сейчас туда отпишу

melezhik commented 8 years ago

Михаил, просьба еще раз обновиться из гита и проверить что вес работает, чуть чуть еще поменял способ запуска curl

ivanych commented 8 years ago

Проверил. Работает.