Added timeout testing to service tests.

This commit is contained in:
Markus Makela
2015-02-23 11:04:16 +02:00
parent 56d810ff80
commit 578fb07370
2 changed files with 91 additions and 52 deletions

View File

@ -245,6 +245,17 @@ serverC | 10 | 18%
serverD | 20 | 36%
### `connection_timeout`
The connection_timeout parameter is used to disconnect sessions to MaxScale that have been idle for too long. The session timeouts are disabled by default. To enable them, define the timeout in seconds in the service's configuration section.
Example:
```
[Test Service]
connection_timeout=300
```
## Server
Server sections are used to define the backend database servers that can be formed into a service. A server may be a member of one or more services within MaxScale. Servers are identified by a server name which is the section name in the configuration file. Servers have a type parameter of server, plus address port and protocol parameters.
@ -1329,4 +1340,3 @@ socket=/servers/maxscale/galera.sock
TCP/IP Traffic must be permitted to 192.1681.3.33 port 4408
For Unix socket, the socket file path (example: `/servers/maxscale/galera.sock`) must be writable by the Unix user MaxScale runs as.

View File

@ -33,6 +33,17 @@
#include <maxscale_test.h>
#include <service.h>
#include <poll.h>
#include <dcb.h>
#include "housekeeper.h"
static bool success = false;
int hup(DCB* dcb)
{
success = true;
}
/**
* test1 Allocate a service and do lots of other things
*
@ -41,18 +52,23 @@ static int
test1()
{
SERVICE *service;
SESSION *session;
DCB *dcb;
int result;
int argc = 3;
char buffer[1024];
sprintf(buffer,"%s",TEST_LOG_DIR);
char* argv[] = {
char* argv[] =
{
"log_manager",
"-j",
buffer,
TEST_LOG_DIR,
NULL
};
skygw_logmanager_init(argc,argv);
poll_init();
hkinit();
/* Service tests */
ss_dfprintf(stderr,
"testservice : creating service called MyService with router nonexistent");
@ -82,6 +98,19 @@ poll_init();
skygw_log_sync_all();
ss_info_dassert(0 != result, "Start all should succeed");
ss_dfprintf(stderr, "\t..done\nTiming out a session.");
service->conn_timeout = 1;
dcb = dcb_alloc(DCB_ROLE_REQUEST_HANDLER);
ss_info_dassert(dcb != NULL, "DCB allocation failed");
session = session_alloc(service,dcb);
ss_info_dassert(session != NULL, "Session allocation failed");
session->client->state = DCB_STATE_POLLING;
session->client->func.hangup = hup;
sleep(30);
ss_info_dassert(success, "Session allocation failed");
ss_dfprintf(stderr, "\t..done\nStopping Service.");
ss_info_dassert(0 != serviceStop(service), "Stop should succeed");
ss_dfprintf(stderr, "\t..done\n");