File: batch_requests.rb

package info (click to toggle)
ruby-excon 1.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,240 kB
  • sloc: ruby: 7,970; makefile: 5
file content (133 lines) | stat: -rw-r--r-- 4,454 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
require 'shindo'

Shindo.tests('Batch Requests') do
  with_server('good_ipv4') do
    tests('with batch request size 2') do
      returns(%w{ 1 2 1 2 }, 'batch request size 2') do
        connection = Excon.new('http://127.0.0.1:9292')

        ret = []
        ret << connection.batch_requests([
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'}
        ], 2).map(&:body)

        ret.flatten
      end
    end

    tests('peristent with batch request size 2') do
      returns(%w{ 1 2 3 4 }, 'persistent batch request size 2') do
        connection = Excon.new('http://127.0.0.1:9292', :persistent => true)

        ret = []
        ret << connection.batch_requests([
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'}
        ], 2).map(&:body)

        ret.flatten
      end
    end

    tests('with batch request size 3') do
      returns(%w{ 1 2 3 1 }, 'batch request size 3') do
        connection = Excon.new('http://127.0.0.1:9292')

        ret = []
        ret << connection.batch_requests([
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'}
        ], 3).map(&:body)

        ret.flatten
      end
    end

    tests('persistent with batch request size 3') do
      returns(%w{ 1 2 3 4 }, 'persistent batch request size 3') do
        connection = Excon.new('http://127.0.0.1:9292', :persistent => true)

        ret = []
        ret << connection.batch_requests([
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'}
        ], 3).map(&:body)

        ret.flatten
      end
    end

    tests('with batch request size 4') do
      returns(%w{ 1 2 3 4 }, 'batch request size 4') do
        connection = Excon.new('http://127.0.0.1:9292')

        ret = []
        ret << connection.batch_requests([
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'}
        ], 4).map(&:body)

        ret.flatten
      end
    end

    tests('persistent with batch request size 4') do
      returns(%w{ 1 2 3 4 }, 'persistent batch request size 4') do
        connection = Excon.new('http://127.0.0.1:9292', :persistent => true)

        ret = []
        ret << connection.batch_requests([
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'}
        ], 4).map(&:body)

        ret.flatten
      end
    end

    tests('with batch request size 8') do
      returns(%w{ 1 2 3 4 }, 'batch request size 8') do
        connection = Excon.new('http://127.0.0.1:9292')

        ret = []
        ret << connection.batch_requests([
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'}
        ], 8).map(&:body)

        ret.flatten
      end
    end

    tests('persistent with batch request size 8') do
      returns(%w{ 1 2 3 4 }, 'persistent batch request size 8') do
        connection = Excon.new('http://127.0.0.1:9292', :persistent => true)

        ret = []
        ret << connection.batch_requests([
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'},
          {:method => :get, :path => '/echo/request_count'}
        ], 8).map(&:body)

        ret.flatten
      end
    end
  end
end