Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add a new stressing test to GRAS. Yeah, it actually breaks things quite often...
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 18 Jun 2012 09:41:07 +0000 (11:41 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 18 Jun 2012 09:41:07 +0000 (11:41 +0200)
buildtools/Cmake/MakeExe.cmake
teshsuite/gras/README
teshsuite/gras/numerous_rpc/CMakeLists.txt [new file with mode: 0644]
teshsuite/gras/numerous_rpc/numerous_rpc.c [new file with mode: 0644]
teshsuite/gras/numerous_rpc/numerous_rpc.xml [new file with mode: 0644]

index 0568e2a..ee25e10 100644 (file)
@@ -22,6 +22,7 @@ add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/gras/datadesc)
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/gras/msg_handle)\r
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/gras/empty_main)\r
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/gras/small_sleep)\r
+add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/gras/numerous_rpc)\r
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/simdag)\r
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/network)\r
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/teshsuite/simdag/network/p2p)\r
@@ -76,4 +77,4 @@ add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/simdag/metaxml)
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/simdag/properties)\r
 add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/simdag/scheduling)\r
 \r
-add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/smpi)
\ No newline at end of file
+add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/smpi)
index eca7355..7cdf135 100644 (file)
@@ -9,3 +9,7 @@ empty_main/ Once upon a time, GRAS was broken when processes did
            
 msg_handle/ Ensures the wanted semantic for gras_msg_handle(i) when
             i<0, i==0 and i>0.
+
+numerous_rpc/ Ensures that it is ok to have a very large amount of
+              very small RPC in real life (it used to be a race
+              condition in the socket mechanism stuff)
diff --git a/teshsuite/gras/numerous_rpc/CMakeLists.txt b/teshsuite/gras/numerous_rpc/CMakeLists.txt
new file mode 100644 (file)
index 0000000..9d63f38
--- /dev/null
@@ -0,0 +1,29 @@
+cmake_minimum_required(VERSION 2.6)
+
+set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/_numerous_rpc_simulator.c
+                                                       ${CMAKE_CURRENT_BINARY_DIR}/_numerous_rpc_client.c
+                                                       ${CMAKE_CURRENT_BINARY_DIR}/_numerous_rpc_server.c
+                                                       PROPERTIES GENERATED true)
+
+set(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}")
+
+add_executable(numerous_rpc_client    ${CMAKE_CURRENT_SOURCE_DIR}/numerous_rpc.c
+                                      ${CMAKE_CURRENT_BINARY_DIR}/_numerous_rpc_client.c)
+add_executable(numerous_rpc_server    ${CMAKE_CURRENT_SOURCE_DIR}/numerous_rpc.c
+                                      ${CMAKE_CURRENT_BINARY_DIR}/_numerous_rpc_server.c)
+
+add_custom_command(OUTPUT            ${CMAKE_CURRENT_BINARY_DIR}/_numerous_rpc_server.c
+                                     ${CMAKE_CURRENT_BINARY_DIR}/_numerous_rpc_client.c
+                   DEPENDS           gras_stub_generator ${CMAKE_CURRENT_SOURCE_DIR}/numerous_rpc.xml
+                   COMMAND           ${CMAKE_BINARY_DIR}/bin/gras_stub_generator numerous_rpc ${CMAKE_CURRENT_SOURCE_DIR}/numerous_rpc.xml
+                   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+)
+
+### Add definitions for compile
+if(NOT WIN32)
+  target_link_libraries(numerous_rpc_client gras m pthread )
+  target_link_libraries(numerous_rpc_server gras m pthread )
+else(NOT WIN32)
+  target_link_libraries(numerous_rpc_client gras)
+  target_link_libraries(numerous_rpc_server gras)
+endif(NOT WIN32)
diff --git a/teshsuite/gras/numerous_rpc/numerous_rpc.c b/teshsuite/gras/numerous_rpc/numerous_rpc.c
new file mode 100644 (file)
index 0000000..35d7649
--- /dev/null
@@ -0,0 +1,87 @@
+/* numerous_rpc -- ensures that no race condition occurs when there is a    */
+/*                 huge amount of very small messages                       */
+
+/* Copyright (c) 2012. The SimGrid Team. All rights reserved.               */
+/* Thanks to Soumeya Leila Hernane for reporting an issue around this       */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "gras.h"
+
+#define RPC_AMOUNT 50000 /* amount of RPC calls to do in a raw */
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(numerous_rpc,"logs attached to the RPC crash test");
+
+int give_hostname(gras_msg_cb_ctx_t ctx, void *payload);
+int server(int argc, char *argv[]);
+int client(int argc, char *argv[]);
+
+/*************************************/
+
+/* callback used for the test */
+int give_hostname(gras_msg_cb_ctx_t ctx, void *payload) {            /* rpc, return hostname */
+  const char* myself = gras_os_myname();
+
+  gras_msg_rpcreturn(-1,ctx,&myself);
+
+  gras_socket_close(gras_msg_cb_ctx_from(ctx));
+  return 0;
+}
+
+/*************************************/
+int server(int argc, char *argv[]) {
+  xbt_socket_t mysock;
+  int i;
+
+  gras_init(&argc, argv);
+  gras_msgtype_declare_rpc("give_hostname",xbt_datadesc_by_name("xbt_string_t"),xbt_datadesc_by_name("xbt_string_t"));
+  gras_cb_register("give_hostname", &give_hostname);
+
+  mysock = gras_socket_server(2222);
+
+  for (i=0;i<RPC_AMOUNT;i++)
+    gras_msg_handle(-1);
+
+  gras_socket_close(mysock);
+  gras_exit();
+  return 0;
+
+}
+
+/* ****************** Code of the client ****************************** */
+int client(int argc, char *argv[]) {
+  long int i;
+  xbt_socket_t server_sock,client_sock;
+  xbt_string_t myself = xbt_strdup(gras_os_myname());
+  xbt_string_t hostname = xbt_malloc(60);
+
+  gras_init(&argc, argv);
+  gras_msgtype_declare_rpc("give_hostname",xbt_datadesc_by_name("xbt_string_t"),xbt_datadesc_by_name("xbt_string_t"));
+
+  client_sock = gras_socket_server_range(1024, 10000, 0, 0);
+
+  for(i=0;i<RPC_AMOUNT;i++) {
+    server_sock = gras_socket_client(argv[1], 2222);
+    //if (i%1000==0)
+      XBT_INFO("iteration %ld",i);
+    gras_msg_rpccall(server_sock,-1,"give_hostname",&myself,&hostname);
+    gras_socket_close(server_sock) ;
+  }
+
+  gras_socket_close(client_sock);
+
+  xbt_free(hostname);
+  xbt_free(myself);
+  gras_exit();
+
+  return 0;
+}
+
+
+
+
+
+
+
+
diff --git a/teshsuite/gras/numerous_rpc/numerous_rpc.xml b/teshsuite/gras/numerous_rpc/numerous_rpc.xml
new file mode 100644 (file)
index 0000000..5308234
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+
+<!-- this file is not really intended to start the code in simulation
+     mode, but mainly to allow the use of the gras_stub_generator.
+     In particular, don't trust the argument passed here -->
+
+<process host='suno-9.sophia.grid5000.fr'  function='server'>
+  <argument value="Ressource_A:2222:1"/>
+  <argument value="owner"/>
+</process>
+
+<process        host='suno-9.sophia.grid5000.fr'  function='client'/>
+
+</platform>