load tester got a "shutdown_when_complete" option, allows performance test using "time"
This commit is contained in:
@@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
#include "load_tester_listener.h"
|
#include "load_tester_listener.h"
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
|
||||||
#include <daemon.h>
|
#include <daemon.h>
|
||||||
#include <processing/jobs/delete_ike_sa_job.h>
|
#include <processing/jobs/delete_ike_sa_job.h>
|
||||||
|
|
||||||
@@ -35,6 +37,16 @@ struct private_load_tester_listener_t {
|
|||||||
* Delete IKE_SA after it has been established
|
* Delete IKE_SA after it has been established
|
||||||
*/
|
*/
|
||||||
bool delete_after_established;
|
bool delete_after_established;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of established SAs
|
||||||
|
*/
|
||||||
|
u_int established;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shutdown the daemon if we have established this SA count
|
||||||
|
*/
|
||||||
|
u_int shutdown_on;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,10 +55,24 @@ struct private_load_tester_listener_t {
|
|||||||
static bool ike_state_change(private_load_tester_listener_t *this,
|
static bool ike_state_change(private_load_tester_listener_t *this,
|
||||||
ike_sa_t *ike_sa, ike_sa_state_t state)
|
ike_sa_t *ike_sa, ike_sa_state_t state)
|
||||||
{
|
{
|
||||||
if (this->delete_after_established && state == IKE_ESTABLISHED)
|
if (state == IKE_ESTABLISHED)
|
||||||
{
|
{
|
||||||
charon->processor->queue_job(charon->processor,
|
ike_sa_id_t *id = ike_sa->get_id(ike_sa);
|
||||||
(job_t*)delete_ike_sa_job_create(ike_sa->get_id(ike_sa), TRUE));
|
|
||||||
|
if (this->delete_after_established)
|
||||||
|
{
|
||||||
|
charon->processor->queue_job(charon->processor,
|
||||||
|
(job_t*)delete_ike_sa_job_create(id, TRUE));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id->is_initiator(id))
|
||||||
|
{
|
||||||
|
if (this->shutdown_on == ++this->established)
|
||||||
|
{
|
||||||
|
DBG1(DBG_CFG, "load-test complete, raising SIGTERM");
|
||||||
|
pthread_kill(charon->main_thread_id, SIGTERM);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -59,7 +85,7 @@ static void destroy(private_load_tester_listener_t *this)
|
|||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
load_tester_listener_t *load_tester_listener_create()
|
load_tester_listener_t *load_tester_listener_create(u_int shutdown_on)
|
||||||
{
|
{
|
||||||
private_load_tester_listener_t *this = malloc_thing(private_load_tester_listener_t);
|
private_load_tester_listener_t *this = malloc_thing(private_load_tester_listener_t);
|
||||||
|
|
||||||
@@ -70,6 +96,9 @@ load_tester_listener_t *load_tester_listener_create()
|
|||||||
this->delete_after_established = lib->settings->get_bool(lib->settings,
|
this->delete_after_established = lib->settings->get_bool(lib->settings,
|
||||||
"charon.plugins.load_tester.delete_after_established", FALSE);
|
"charon.plugins.load_tester.delete_after_established", FALSE);
|
||||||
|
|
||||||
|
this->shutdown_on = shutdown_on;
|
||||||
|
this->established = 0;
|
||||||
|
|
||||||
return &this->public;
|
return &this->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,9 @@ struct load_tester_listener_t {
|
|||||||
/**
|
/**
|
||||||
* Create a listener to handle special events during load test
|
* Create a listener to handle special events during load test
|
||||||
*
|
*
|
||||||
* @return listener
|
* @param shutdown_on shut down the daemon after this many SAs are established
|
||||||
|
* @return listener
|
||||||
*/
|
*/
|
||||||
load_tester_listener_t *load_tester_listener_create();
|
load_tester_listener_t *load_tester_listener_create(u_int shutdown_on);
|
||||||
|
|
||||||
#endif /* LOAD_TESTER_LISTENER_H_ @}*/
|
#endif /* LOAD_TESTER_LISTENER_H_ @}*/
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ static void destroy(private_load_tester_plugin_t *this)
|
|||||||
plugin_t *plugin_create()
|
plugin_t *plugin_create()
|
||||||
{
|
{
|
||||||
private_load_tester_plugin_t *this;
|
private_load_tester_plugin_t *this;
|
||||||
int i;
|
u_int i, shutdown_on = 0;
|
||||||
|
|
||||||
if (!lib->settings->get_bool(lib->settings,
|
if (!lib->settings->get_bool(lib->settings,
|
||||||
"charon.plugins.load_tester.enable", FALSE))
|
"charon.plugins.load_tester.enable", FALSE))
|
||||||
@@ -192,27 +192,33 @@ plugin_t *plugin_create()
|
|||||||
lib->crypto->add_dh(lib->crypto, MODP_NULL,
|
lib->crypto->add_dh(lib->crypto, MODP_NULL,
|
||||||
(dh_constructor_t)load_tester_diffie_hellman_create);
|
(dh_constructor_t)load_tester_diffie_hellman_create);
|
||||||
|
|
||||||
|
this->delay = lib->settings->get_int(lib->settings,
|
||||||
|
"charon.plugins.load_tester.delay", 0);
|
||||||
|
this->iterations = lib->settings->get_int(lib->settings,
|
||||||
|
"charon.plugins.load_tester.iterations", 1);
|
||||||
|
this->initiators = lib->settings->get_int(lib->settings,
|
||||||
|
"charon.plugins.load_tester.initiators", 0);
|
||||||
|
if (lib->settings->get_bool(lib->settings,
|
||||||
|
"charon.plugins.load_tester.shutdown_when_complete", 0))
|
||||||
|
{
|
||||||
|
shutdown_on = this->iterations * this->initiators;
|
||||||
|
}
|
||||||
|
|
||||||
this->mutex = mutex_create(MUTEX_DEFAULT);
|
this->mutex = mutex_create(MUTEX_DEFAULT);
|
||||||
this->condvar = condvar_create(CONDVAR_DEFAULT);
|
this->condvar = condvar_create(CONDVAR_DEFAULT);
|
||||||
this->config = load_tester_config_create();
|
this->config = load_tester_config_create();
|
||||||
this->creds = load_tester_creds_create();
|
this->creds = load_tester_creds_create();
|
||||||
this->listener = load_tester_listener_create();
|
this->listener = load_tester_listener_create(shutdown_on);
|
||||||
charon->backends->add_backend(charon->backends, &this->config->backend);
|
charon->backends->add_backend(charon->backends, &this->config->backend);
|
||||||
charon->credentials->add_set(charon->credentials, &this->creds->credential_set);
|
charon->credentials->add_set(charon->credentials, &this->creds->credential_set);
|
||||||
charon->bus->add_listener(charon->bus, &this->listener->listener);
|
charon->bus->add_listener(charon->bus, &this->listener->listener);
|
||||||
|
|
||||||
if (lib->settings->get_bool(lib->settings,
|
if (lib->settings->get_bool(lib->settings,
|
||||||
"charon.plugins.load_tester.fake_kernel", FALSE))
|
"charon.plugins.load_tester.fake_kernel", FALSE))
|
||||||
{
|
{
|
||||||
charon->kernel_interface->add_ipsec_interface(charon->kernel_interface,
|
charon->kernel_interface->add_ipsec_interface(charon->kernel_interface,
|
||||||
(kernel_ipsec_constructor_t)load_tester_ipsec_create);
|
(kernel_ipsec_constructor_t)load_tester_ipsec_create);
|
||||||
}
|
}
|
||||||
this->delay = lib->settings->get_int(lib->settings,
|
|
||||||
"charon.plugins.load_tester.delay", 0);
|
|
||||||
this->iterations = lib->settings->get_int(lib->settings,
|
|
||||||
"charon.plugins.load_tester.iterations", 1);
|
|
||||||
this->initiators = lib->settings->get_int(lib->settings,
|
|
||||||
"charon.plugins.load_tester.initiators", 0);
|
|
||||||
this->running = 0;
|
this->running = 0;
|
||||||
for (i = 0; i < this->initiators; i++)
|
for (i = 0; i < this->initiators; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user