Class: Bunny::TestKit

Inherits:
Object
  • Object
show all
Defined in:
lib/bunny/test_kit.rb

Overview

Unit, integration and stress testing toolkit

Class Method Summary collapse

Class Method Details

.message_in_kb(a, b, i) ⇒ String

Returns Message payload of length in the given range, with non-ASCII characters.

Parameters:

  • a (Integer)

    Lower bound of message size, in KB

  • b (Integer)

    Upper bound of message size, in KB

  • i (Integer)

    Random number to use in message generation

Returns:

  • (String)

    Message payload of length in the given range, with non-ASCII characters



32
33
34
35
36
37
# File 'lib/bunny/test_kit.rb', line 32

def message_in_kb(a, b, i)
  s = "Ю#{i}"
  n = random_in_range(a, b) / s.bytesize

  s * n * 1024
end

.poll_until(timeout = 60, &probe) ⇒ Object



15
16
17
18
19
# File 'lib/bunny/test_kit.rb', line 15

def poll_until(timeout = 60, &probe)
  Timeout.timeout(timeout) {
    sleep 0.1 until probe.call
  }
end

.poll_while(timeout = 60, &probe) ⇒ Object



10
11
12
13
14
# File 'lib/bunny/test_kit.rb', line 10

def poll_while(timeout = 60, &probe)
  Timeout.timeout(timeout) {
    sleep 0.1 while probe.call
  }
end

.random_in_range(a, b) ⇒ Integer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Random integer in the range of [a, b].

Returns:

  • (Integer)

    Random integer in the range of [a, b]



23
24
25
# File 'lib/bunny/test_kit.rb', line 23

def random_in_range(a, b)
  Range.new(a, b).to_a.sample
end