1Perlbal::Test(3)      User Contributed Perl Documentation     Perlbal::Test(3)
2
3
4

NAME

6       Perlbal::Test - Test harness for perlbal server
7

SYNOPSIS

9       #  my $msock = Perlbal::Test::start_server();
10

DESCRIPTION

12       Perlbal::Test provides access to a perlbal server running on the local
13       host, for testing purposes.
14
15       The server can be an already-existing server, a child process, or the
16       current process.
17
18       Various functions are provided to interact with the server.
19

FUNCTIONS

mgmt_port()

22       Return the current management port number.
23

dump_res($http_response)

25       Return a readable string formatted from an HTTP::Response object.  Only
26       the first 80 characters of returned content are returned.
27

tempdir()

29       Return a newly created temporary directory. The directory will be
30       removed automatically upon program exit.
31

new_port()

33       Return the next free port number in the series. Port numbers are
34       assigned starting at 60000.
35

test_port()

37       Return 1 if the port is free to use for listening on $free_port else
38       return 0.
39

filecontent($file>

41       Return a string containing the contents of the file $file. If $file
42       cannot be opened, then return undef.
43

foreach_aio($callback)

45       Set the server into each AIO mode (none, ioaio) and call the specified
46       callback function with the mode name as argument.
47

manage($cmd, %opts)

49       Send a command $cmd to the server, and return the response line from
50       the server.
51
52       Optional arguments are:
53
54         quiet_failure => 1
55
56       Output a warning if the response indicated an error, unless
57       $opts{quiet_failure} is true, or the command was 'shutdown' (which
58       doesn't return a response).
59

manage_multi($cmd)

61       Send a command $cmd to the server, and return a multi-line response.
62       Return the number zero if there was an error or no response.
63

start_server($conf)

65       Optionally start a perlbal server and return a socket connected to its
66       management port.
67
68       The argument $conf is a string specifying initial configuration
69       commands.
70
71       If the environment variable TEST_PERLBAL_FOREGROUND is set to a true
72       value then a server will be started in the foreground, in which case
73       this function does not return. When the server function finishes,
74       exit() will be called to terminate the process.
75
76       If the environment variable TEST_PERLBAL_USE_EXISTING is set to a true
77       value then a socket will be returned which is connected to an existing
78       server's management port.
79
80       Otherwise, a child process is forked and a socket is returned which is
81       connected to the child's management port.
82
83       The management port is assigned automatically, a new port number each
84       time this function is called. The starting port number is 60000.
85

msock()

87       Return a reference to the socket connected to the server's management
88       port.
89

ua()

91       Return a new instance of LWP::UserAgent.
92

wait_on_child($pid, $port)

94       Return a socket which is connected to a child process.
95
96       $pid specifies the child process id, and $port is the port number on
97       which the child is listening.
98
99       Several attempts are made; if the child dies or a connection cannot be
100       made within 5 seconds then this function dies with an error message.
101

resp_from_sock($sock)

103       Read an HTTP response from a socket and return it as an HTTP::Response
104       object
105
106       In scalar mode, return only the $http_response object.
107
108       In array mode, return an array of ($http_response, $firstline) where
109       $firstline is the first line read from the socket, for example:
110
111       "HTTP/1.1 200 OK"
112
113
114
115perl v5.34.0                      2021-07-21                  Perlbal::Test(3)
Impressum