2
/*___INFO__MARK_BEGIN__*/
3
/*************************************************************************
5
* The Contents of this file are made available subject to the terms of
6
* the Sun Industry Standards Source License Version 1.2
8
* Sun Microsystems Inc., March, 2001
11
* Sun Industry Standards Source License Version 1.2
12
* =================================================
13
* The contents of this file are subject to the Sun Industry Standards
14
* Source License Version 1.2 (the "License"); You may not use this file
15
* except in compliance with the License. You may obtain a copy of the
16
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
18
* Software provided under this License is provided on an "AS IS" basis,
19
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
20
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
21
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
22
* See the License for the specific provisions governing your rights and
23
* obligations concerning the Software.
25
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
27
* Copyright: 2001 by Sun Microsystems, Inc.
29
* All Rights Reserved.
31
************************************************************************/
32
/*___INFO__MARK_END__*/
40
#include <sys/resource.h>
42
#include "cl_commlib.h"
43
#include "cl_log_list.h"
44
#include "cl_endpoint_list.h"
45
#include "uti/sge_profiling.h"
48
void sighandler_issue_tests(int sig);
50
static int do_shutdown = 0;
52
void sighandler_issue_tests(int sig) {
66
extern int main(int argc, char** argv)
70
cl_com_handle_t* handle = NULL;
71
cl_com_handle_t* handle1 = NULL;
72
cl_com_handle_t* handle2 = NULL;
74
cl_com_message_t* message = NULL;
75
cl_com_endpoint_t* sender = NULL;
78
cl_framework_t framework = CL_CT_TCP;
79
cl_bool_t server_mode = CL_FALSE;
81
char* com_host = NULL;
84
struct rlimit64 test_issues_limits;
86
struct rlimit test_issues_limits;
91
printf("param1=debug_level param2=framework(TCP/SSL) param3=server/client param4=port param5=hostname\n");
96
framework = CL_CT_UNDEFINED;
97
if (strcmp(argv[2], "TCP") == 0) {
99
printf("using TCP framework\n");
101
if (strcmp(argv[2], "SSL") == 0) {
103
printf("using SSL framework\n");
105
if (framework == CL_CT_UNDEFINED) {
106
printf("unexpected framework type\n");
112
if (strcmp(argv[3], "server") == 0) {
118
com_port = atoi(argv[4]);
127
/* setup signalhandling */
128
memset(&sa, 0, sizeof(sa));
129
sa.sa_handler = sighandler_issue_tests; /* one handler for all signals */
130
sigemptyset(&sa.sa_mask);
131
sigaction(SIGINT, &sa, NULL);
132
sigaction(SIGTERM, &sa, NULL);
133
sigaction(SIGHUP, &sa, NULL);
134
sigaction(SIGPIPE, &sa, NULL);
136
#if defined(RLIMIT_VMEM)
138
getrlimit64(RLIMIT_VMEM, &test_issues_limits);
140
getrlimit(RLIMIT_VMEM, &test_issues_limits);
142
test_issues_limits.rlim_max = RLIM_INFINITY;
143
test_issues_limits.rlim_cur = RLIM_INFINITY;
145
setrlimit64(RLIMIT_VMEM, &test_issues_limits);
147
setrlimit(RLIMIT_VMEM, &test_issues_limits);
150
#else /* if defined(RLIMIT_VMEM) */
151
#if defined(RLIMIT_AS)
153
getrlimit64(RLIMIT_AS, &test_issues_limits);
155
getrlimit(RLIMIT_AS, &test_issues_limits);
157
test_issues_limits.rlim_max = RLIM_INFINITY;
158
test_issues_limits.rlim_cur = RLIM_INFINITY;
160
setrlimit64(RLIMIT_AS, &test_issues_limits);
162
setrlimit(RLIMIT_AS, &test_issues_limits);
164
#endif /* if defined(RLIMIT_AS) */
165
#endif /* if defined(RLIMIT_VMEM) */
167
#if defined(RLIMIT_VMEM)
169
getrlimit64(RLIMIT_VMEM, &test_issues_limits);
171
getrlimit(RLIMIT_VMEM, &test_issues_limits);
173
printf("vmem limit is set to %ld\n", (unsigned long) test_issues_limits.rlim_cur);
174
#else /* if defined(RLIMIT_VMEM) */
175
#if defined(RLIMIT_AS)
177
getrlimit64(RLIMIT_AS, &test_issues_limits);
179
getrlimit(RLIMIT_AS, &test_issues_limits);
181
printf("vmem limit is set to %ld\n", (unsigned long) test_issues_limits.rlim_cur);
182
#endif /* if defined(RLIMIT_AS) */
183
#endif /* if defined(RLIMIT_VMEM) */
187
getrlimit64(RLIMIT_STACK, &test_issues_limits);
189
getrlimit(RLIMIT_STACK, &test_issues_limits);
191
test_issues_limits.rlim_cur = test_issues_limits.rlim_max;
193
setrlimit64(RLIMIT_STACK, &test_issues_limits);
195
setrlimit(RLIMIT_STACK, &test_issues_limits);
199
getrlimit64(RLIMIT_STACK, &test_issues_limits);
201
getrlimit(RLIMIT_STACK, &test_issues_limits);
203
printf("stacksize limit is set to %ld\n", (unsigned long) test_issues_limits.rlim_cur);
206
getrlimit64(RLIMIT_DATA, &test_issues_limits);
208
getrlimit(RLIMIT_DATA, &test_issues_limits);
210
test_issues_limits.rlim_max = RLIM_INFINITY;
211
test_issues_limits.rlim_cur = RLIM_INFINITY;
213
setrlimit64(RLIMIT_DATA, &test_issues_limits);
215
setrlimit(RLIMIT_DATA, &test_issues_limits);
219
getrlimit64(RLIMIT_DATA, &test_issues_limits);
221
getrlimit(RLIMIT_DATA, &test_issues_limits);
223
printf("data size limit is set to %ld\n", (unsigned long) test_issues_limits.rlim_cur);
226
#if defined(RLIMIT_RSS)
228
getrlimit64(RLIMIT_RSS, &test_issues_limits);
230
getrlimit(RLIMIT_RSS, &test_issues_limits);
232
test_issues_limits.rlim_cur = test_issues_limits.rlim_max;
234
setrlimit64(RLIMIT_RSS, &test_issues_limits);
236
setrlimit(RLIMIT_RSS, &test_issues_limits);
240
getrlimit64(RLIMIT_RSS, &test_issues_limits);
242
getrlimit(RLIMIT_RSS, &test_issues_limits);
244
printf("residet set size limit is set to %ld\n", (unsigned long) test_issues_limits.rlim_cur);
249
getrlimit64(RLIMIT_FSIZE, &test_issues_limits);
251
getrlimit(RLIMIT_FSIZE, &test_issues_limits);
253
test_issues_limits.rlim_cur = test_issues_limits.rlim_max;
255
setrlimit64(RLIMIT_FSIZE, &test_issues_limits);
257
setrlimit(RLIMIT_FSIZE, &test_issues_limits);
261
getrlimit64(RLIMIT_FSIZE, &test_issues_limits);
263
getrlimit(RLIMIT_FSIZE, &test_issues_limits);
265
printf("file size size limit is set to %ld\n", (unsigned long) test_issues_limits.rlim_cur);
269
printf("commlib setup ...\n");
270
/* this is for compiler warning on irix65 */
272
switch(atoi(argv[1])) {
274
log_level=CL_LOG_OFF;
277
log_level=CL_LOG_ERROR;
280
log_level=CL_LOG_WARNING;
283
log_level=CL_LOG_INFO;
286
log_level=CL_LOG_DEBUG;
289
log_level=CL_LOG_OFF;
292
cl_com_setup_commlib(CL_RW_THREAD, log_level, NULL);
294
if (server_mode == CL_TRUE) {
295
handle=cl_com_create_handle(NULL, framework, CL_CM_CT_MESSAGE, CL_TRUE, com_port, CL_TCP_DEFAULT, "server", 1, 1, 0 );
296
cl_com_set_max_connection_close_mode(handle,CL_ON_MAX_COUNT_DISABLE_ACCEPT);
298
handle=cl_com_create_handle(NULL, framework, CL_CM_CT_MESSAGE, CL_FALSE, com_port, CL_TCP_DEFAULT, "client", 0, 1, 0 );
300
if (handle == NULL) {
301
printf("could not get handle\n");
306
cl_com_get_service_port(handle,&i),
307
printf("running on host \"%s\", port %d, component name is \"%s\", id is %ld\n",
308
handle->local->comp_host,
310
handle->local->comp_name,
311
handle->local->comp_id);
313
if (server_mode == CL_TRUE) {
314
int actual_issue = 0;
315
int max_con_test_count = 2;
316
unsigned long max_connection_count;
318
while(do_shutdown != 1) {
321
if (actual_issue == 1400) {
322
cl_raw_list_lock(handle->connection_list);
323
printf("actual connection count = %lu\n", cl_raw_list_get_elem_count(handle->connection_list) );
324
printf("actual max connection count = %lu\n", handle->max_open_connections);
325
if (cl_raw_list_get_elem_count(handle->connection_list) > handle->max_open_connections) {
326
printf("issue 1400 error found\n");
329
cl_raw_list_unlock(handle->connection_list);
332
cl_commlib_trigger(handle, 1);
334
ret_val = cl_commlib_receive_message(handle,NULL, NULL, 0, CL_FALSE, 0, &message, &sender);
335
if (message != NULL) {
337
CL_LOG_STR(CL_LOG_INFO,"received message from",sender->comp_host);
338
if (strstr((char*)message->message,"#1400i") && actual_issue != 1400) {
339
printf("switching to test #1400\n");
342
cl_com_get_max_connections(handle,&max_connection_count);
343
printf("setting max_connection_count from %lu to %lu\n", (unsigned long)max_connection_count, (unsigned long)max_con_test_count);
344
cl_com_set_max_connections(handle,max_con_test_count);
347
if (strstr((char*)message->message,"#1400r")) {
348
printf("resetting to defaults\n");
351
printf("setting max_connection_count from %lu to %lu\n", (unsigned long)max_con_test_count, (unsigned long)max_connection_count);
352
cl_com_set_max_connections(handle,max_connection_count);
357
ret_val = cl_commlib_send_message(handle,
360
sender->comp_id, CL_MIH_MAT_NAK,
362
message->message_length,
365
if (ret_val != CL_RETVAL_OK) {
366
CL_LOG_STR(CL_LOG_ERROR,"cl_commlib_send_message() returned:",cl_get_error_text(ret_val));
369
cl_com_free_message(&message);
370
cl_com_free_endpoint(&sender);
376
unsigned long data_size = 1024*1024;
378
struct timeval start;
380
char iz1400_data[7] = "#1400i";
381
cl_byte_t* iz1400_pointer = (cl_byte_t *)iz1400_data;
382
char test_data[5] = "test";
383
cl_byte_t* test_pointer = (cl_byte_t *)test_data;
385
printf("\ntesting issue #1389 ...\n");
388
while(runtime < 45 && do_shutdown == 0 && main_return == 0) {
389
data = malloc(data_size * sizeof(char));
391
printf("malloc() error: can't malloc(%ld)\n", data_size * sizeof(char) );
392
printf("issue #1389 failed\n");
396
printf("malloced %.2f MB\n", (double) (data_size*sizeof(char))/(1024*1024) );
398
sprintf(data,"hallo du");
400
cl_commlib_send_message(handle, com_host, "server", 1,
402
(cl_byte_t**)&data, data_size,
403
NULL, 0,0, CL_FALSE, CL_FALSE);
405
printf("starting measurement...\n");
406
gettimeofday(&start,NULL);
407
while(do_shutdown == 0 ) {
408
cl_commlib_trigger(handle, 1);
409
ret_val = cl_commlib_receive_message(handle,NULL, NULL, 0, CL_FALSE, 0, &message, &sender);
410
if (ret_val != CL_RETVAL_OK && ret_val != CL_RETVAL_NO_MESSAGE) {
411
printf("cl_commlib_receive_message returned: %s\n", cl_get_error_text(ret_val));
412
printf("issue #1389 failed\n");
416
if (message != NULL) {
417
printf("received response message from %s with size %lu\n", sender->comp_host, message->message_length);
418
message->message = NULL;
419
cl_com_free_message(&message);
420
cl_com_free_endpoint(&sender);
424
gettimeofday(&now,NULL);
425
runtime = now.tv_sec - start.tv_sec;
426
printf("send/receive took %d seconds\n", runtime );
427
if (data_size < 30*1024*1024) {
428
data_size = data_size * 2;
430
data_size = data_size + 16*1024*1024;
435
printf("\ntesting issue #1400 ...\n");
438
printf("setting up server for test 1400 ...\n");
439
cl_commlib_send_message(handle, com_host, "server", 1,
442
NULL, 0,0, CL_TRUE, CL_TRUE);
445
printf("creating new connections ...\n");
447
handle1=cl_com_create_handle(NULL, framework, CL_CM_CT_MESSAGE, CL_FALSE, com_port, CL_TCP_DEFAULT, "client1", 0, 1, 0 );
448
handle2=cl_com_create_handle(NULL, framework, CL_CM_CT_MESSAGE, CL_FALSE, com_port, CL_TCP_DEFAULT, "client2", 0, 1, 0 );
450
printf("sending via connection 1 ...\n");
451
cl_commlib_send_message(handle, com_host, "server", 1,
454
NULL, 0,0, CL_TRUE, CL_TRUE);
456
printf("sending via connection 2 ...\n");
457
cl_commlib_send_message(handle1, com_host, "server", 1,
460
NULL, 0,0, CL_TRUE, CL_TRUE);
462
printf("sending via connection 3 ...\n");
463
ret_val = cl_commlib_send_message(handle2, com_host, "server", 1,
466
NULL, 0,0, CL_TRUE, CL_TRUE);
468
if (ret_val == CL_RETVAL_OK) {
469
printf("issue #1400 failed\n");
472
printf("3. connection send returned: \"%s\" and failed - ok\n" , cl_get_error_text(ret_val));
475
printf("resetting server ...\n");
477
iz1400_data[5] = 'r';
478
cl_commlib_send_message(handle, com_host, "server", 1,
481
NULL, 0,0, CL_TRUE, CL_TRUE);
486
printf("shutting down ...\n");
487
cl_commlib_shutdown_handle(handle, CL_FALSE);
489
printf("commlib cleanup ...\n");
490
cl_com_cleanup_commlib();
492
printf("main done\n");