Project

General

Profile

Bug #5903 » test_http_streaming_slow.cpp

J n, 09/01/2017 10:29 PM

 
1
#if defined(HAVE_CONFIG_H)
2
    #include "config.h"
3
#endif
4

    
5
#include "IntegrationTestHelper.hpp"
6
#include <chrono>
7

    
8
BOOST_FIXTURE_TEST_SUITE(HttpSuite, IntegrationFixture)
9

    
10
BOOST_AUTO_TEST_CASE(simple_continuation_ignores_abort_writes_short_body)
11
{
12
    std::string payload{"HelloHelloHelloHelloHelloHelloHelloHelloHelloHello"};
13
    int success = 0;
14
    int failure = 0;
15
    int resets  = 0;
16
    for(int i=0; i!= 10000; ++i)
17
    {
18
        BOOST_TEST_CONTEXT("client: [" << i << "] of " << m_clients.size()<<" ")
19
        {
20
            BOOST_TEST_INFO("testing streaming download, aborting after headers ");
21
            BOOST_REQUIRE_EQUAL(i,require_http_get_url_scheduled("/test?stream=",eCancelledDownload));
22
            BOOST_REQUIRE_EQUAL(200,nth_msg(i).status());
23
            if(!nth_err(i))
24
            {
25
                ++success;
26
                BOOST_REQUIRE_EQUAL(boost::system::error_code(),nth_err(i));
27
                BOOST_REQUIRE_EQUAL(payload,nth_msg(i).body());
28
            }
29
            else
30
            {
31
                BOOST_REQUIRE((boost::asio::error::connection_reset  == nth_err(i)) || (boost::asio::error::operation_aborted == nth_err(i)));
32
                if(boost::asio::error::connection_reset  == nth_err(i))
33
                {
34
                    ++resets;
35
                    BOOST_REQUIRE(payload != nth_msg(i).body());
36
                }
37
                if(boost::asio::error::operation_aborted == nth_err(i))
38
                {
39
                    ++failure;
40
                    BOOST_REQUIRE_EQUAL(payload,nth_msg(i).body());
41
                    BOOST_REQUIRE(!nth_msg(i).body().empty());
42
                }
43
            }
44
        }
45
    }
46
    BOOST_REQUIRE_EQUAL(failure,aborted_count());
47
}
48
BOOST_AUTO_TEST_SUITE_END()
(1-1/2)