Initial feature commit
authorEduardo Ramos Testillano <eduardo.ramos.testillano@ericsson.com>
Fri, 21 Oct 2016 15:55:12 +0000 (17:55 +0200)
committerEduardo Ramos Testillano <eduardo.ramos.testillano@ericsson.com>
Fri, 21 Oct 2016 15:55:12 +0000 (17:55 +0200)
13 files changed:
SConstruct
dynamic/launcher/default/Procedure.cpp [new file with mode: 0644]
dynamic/launcher/default/Procedure.hpp [new file with mode: 0644]
dynamic/launcher/default/SConscript [new file with mode: 0644]
dynamic/launcher/default/SConstruct [new file with mode: 0644]
dynamic/launcher/gx/00001/Procedure.cpp [new file with mode: 0644]
dynamic/launcher/gx/00001/Procedure.hpp [new file with mode: 0644]
dynamic/launcher/gx/00001/SConscript [new file with mode: 0644]
dynamic/launcher/gx/00001/SConstruct [new file with mode: 0644]
example/diameter/launcher/DEPLOY.sh
example/diameter/launcher/Launcher.cpp
example/diameter/launcher/SConscript
example/diameter/launcher/deployments/basic/configure.sh

index de8c59e..e223dd8 100644 (file)
@@ -88,6 +88,29 @@ for source in sources:
 
 env.Default (libraries)
 
+#
+## Run 'scons dynamic' to compile dynamic libraries
+#
+dynamic_list = []
+dynamic = os.path.join (current_directory, "dynamic")
+# Find SConstruct files:
+dynamics=[os.path.join(r,f) for r,d,fs in os.walk(dynamic) for f in fs if f.endswith('SConstruct')]
+for dynamic in dynamics:
+  ss = str (dynamic)
+  bn_ss = os.path.basename(ss)
+  if (bn_ss == "SConstruct"):
+    dynamic_program = SConscript (ss, exports='env')
+    if dynamic_program:
+      dynamic_list.extend (dynamic_program)
+      print dynamic_program [0]
+
+#Depends (dynamic_list, compile_library)
+   
+# In order to remove dynamics objects with 'scons -c' we need to default them at built ('scons') procedure:
+env.Default (dynamic_list)
+#env.Alias ('dynamic', dynamic_list)
+
+
 #
 ## Run 'scons example' to compile examples
 #
@@ -110,7 +133,6 @@ for example in examples:
 env.Default (example_list)
 #env.Alias ('example', example_list)
 
-
 #
 # Run 'scons test' to compile unit-tests
 #
@@ -159,6 +181,7 @@ env.Alias('doc', env.Command('doc.dummy', [], 'cd docs/doxygen; doxygen'))
 # See http://www.scons.org/wiki/InstallTargets and http://www.scons.org/doc/production/HTML/scons-user/c2938.html
 install_include = env.Install (target_usr_local_include, Glob("include/anna/*"))
 install_lib =     env.Install (target_usr_local_lib, Glob("source/*/" + variant + "/*.a"))
+install_dynlib =  env.Install (target_usr_local_lib, Glob("dynamic/launcher/default/" + variant + "/*.so"))
 install_example = env.Install (target_opt_bin, Glob("example/*/*/" + variant + "/example_*"))
 postinstall_example = env.Command('./example/postinstall.out', None, './example/postinstall.sh')
 
@@ -166,10 +189,12 @@ postinstall_example = env.Command('./example/postinstall.out', None, './example/
 if test_unit_result:
   Depends (install_include, test_unit_result)
   Depends (install_lib, test_unit_result)
+  Depends (install_dynlib, test_unit_result)
   Depends (install_example, test_unit_result)
 
 ii  = env.Alias('install-include', [target_usr_local_include])
 il  = env.Alias('install-lib',     [target_usr_local_lib])
+idl = env.Alias('install-dynlib',  [target_usr_local_lib])
 iil = env.Alias('install-include-and-lib', [target_usr_local_include, target_usr_local_lib])
 iex = env.Alias('install-example', [target_opt_bin, postinstall_example])
 env.Alias('install', [iil, iex])
diff --git a/dynamic/launcher/default/Procedure.cpp b/dynamic/launcher/default/Procedure.cpp
new file mode 100644 (file)
index 0000000..57bb7e0
--- /dev/null
@@ -0,0 +1,23 @@
+// ANNA - Anna is Not Nothingness Anymore                                                         //
+//                                                                                                //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
+//                                                                                                //
+// See project site at http://redmine.teslayout.com/projects/anna-suite                           //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
+
+// Standard
+#include <iostream>
+#include <string>
+
+
+// Local
+#include "Procedure.hpp"
+
+void Procedure::execute(const std::string &args, std::string &response) throw() {
+  response = "Empty default implementation. Make dynamic library and reimplement this method.";
+  if (args != "" ) {
+    response += " Provided argument(s) ignored: ";
+    response += args;
+  }
+}
+
diff --git a/dynamic/launcher/default/Procedure.hpp b/dynamic/launcher/default/Procedure.hpp
new file mode 100644 (file)
index 0000000..91247a3
--- /dev/null
@@ -0,0 +1,26 @@
+// ANNA - Anna is Not Nothingness Anymore                                                         //
+//                                                                                                //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
+//                                                                                                //
+// See project site at http://redmine.teslayout.com/projects/anna-suite                           //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
+
+
+#ifndef dynamic_launcher_default_hpp
+#define dynamic_launcher_default_hpp
+
+// Project
+#include <anna/comm/comm.hpp>
+
+
+
+class Procedure {
+    anna::comm::Application *a_app;
+
+  public:
+    Procedure(anna::comm::Application *app) : a_app(app) {;}
+
+    virtual void execute(const std::string &args, std::string &response) throw();
+};
+
+#endif
diff --git a/dynamic/launcher/default/SConscript b/dynamic/launcher/default/SConscript
new file mode 100644 (file)
index 0000000..d9a9862
--- /dev/null
@@ -0,0 +1,8 @@
+Import ('env')
+
+sources = Glob('*.cpp')
+
+result = env.SharedLibrary ('anna_dynamicLauncherProcedure', sources);
+
+Return ('result')
+
diff --git a/dynamic/launcher/default/SConstruct b/dynamic/launcher/default/SConstruct
new file mode 100644 (file)
index 0000000..bc482f0
--- /dev/null
@@ -0,0 +1,12 @@
+release = ARGUMENTS.get ('release', 0)
+
+Import ('env')
+
+# See http://stackoverflow.com/questions/4693826/scons-binary-directory
+if int(release):
+    result = SConscript ('SConscript', exports='env', variant_dir="release", duplicate=0)
+else:
+    result = SConscript ('SConscript', exports='env', variant_dir="debug", duplicate=0)
+
+Return ('result')
+
diff --git a/dynamic/launcher/gx/00001/Procedure.cpp b/dynamic/launcher/gx/00001/Procedure.cpp
new file mode 100644 (file)
index 0000000..62975c1
--- /dev/null
@@ -0,0 +1,23 @@
+// ANNA - Anna is Not Nothingness Anymore                                                         //
+//                                                                                                //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
+//                                                                                                //
+// See project site at http://redmine.teslayout.com/projects/anna-suite                           //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
+
+// Standard
+#include <iostream>
+#include <string>
+
+
+// Local
+#include "Procedure.hpp"
+
+void Procedure::execute(const std::string &args, std::string &response) throw() {
+  response = "00001 Empty default implementation. Make dynamic library and reimplement this method.";
+  if (args != "" ) {
+    response += " Provided argument(s) ignored: ";
+    response += args;
+  }
+}
+
diff --git a/dynamic/launcher/gx/00001/Procedure.hpp b/dynamic/launcher/gx/00001/Procedure.hpp
new file mode 100644 (file)
index 0000000..884cad5
--- /dev/null
@@ -0,0 +1,26 @@
+// ANNA - Anna is Not Nothingness Anymore                                                         //
+//                                                                                                //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
+//                                                                                                //
+// See project site at http://redmine.teslayout.com/projects/anna-suite                           //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
+
+
+#ifndef dynamic_launcher_gx_00001_hpp
+#define dynamic_launcher_gx_00001_hpp
+
+// Project
+#include <anna/comm/comm.hpp>
+
+
+
+class Procedure {
+    anna::comm::Application *a_app;
+
+  public:
+    Procedure(anna::comm::Application *app) : a_app(app) {;}
+
+    virtual void execute(const std::string &args, std::string &response) throw();
+};
+
+#endif
diff --git a/dynamic/launcher/gx/00001/SConscript b/dynamic/launcher/gx/00001/SConscript
new file mode 100644 (file)
index 0000000..d9a9862
--- /dev/null
@@ -0,0 +1,8 @@
+Import ('env')
+
+sources = Glob('*.cpp')
+
+result = env.SharedLibrary ('anna_dynamicLauncherProcedure', sources);
+
+Return ('result')
+
diff --git a/dynamic/launcher/gx/00001/SConstruct b/dynamic/launcher/gx/00001/SConstruct
new file mode 100644 (file)
index 0000000..bc482f0
--- /dev/null
@@ -0,0 +1,12 @@
+release = ARGUMENTS.get ('release', 0)
+
+Import ('env')
+
+# See http://stackoverflow.com/questions/4693826/scons-binary-directory
+if int(release):
+    result = SConscript ('SConscript', exports='env', variant_dir="release", duplicate=0)
+else:
+    result = SConscript ('SConscript', exports='env', variant_dir="debug", duplicate=0)
+
+Return ('result')
+
index fe35371..906a0b2 100755 (executable)
@@ -18,6 +18,10 @@ EXECS=( $EXEC_installed ./release/example_diameter_launcher ./debug/example_diam
 STACKMGMT_EXEC_installed=/opt/bin/anna/example_diameter_stackManagement
 STACKMGMT_EXECS=( $STACKMGMT_EXEC_installed ../stackManagement/release/example_diameter_stackManagement ../stackManagement/debug/example_diameter_stackManagement )
 
+# Dynamic library:
+DYNLIB_installed=/usr/local/lib/libanna_dynamicLauncherProcedure.so
+DYNLIBS=( $DYNLIB_installed ../../../dynamic/launcher/default/release/libanna_dynamicLauncherProcedure.so ../../../dynamic/launcher/default/debug/libanna_dynamicLauncherProcedure.so )
+
 #############
 # FUNCTIONS #
 #############
@@ -70,6 +74,7 @@ STARTED=\`pgrep \$EXE$ 2>/dev/null\`
 0> launcher.trace
 rm -f counters/* test-reports/*
 # Execution line:
+export LD_LIBRARY_PATH=\$PWD
 ./\$EXE --services services.xml --cntDir counters --tmDir test-reports $other &
 echo \$! > .pid
 EOF
@@ -89,6 +94,7 @@ echo "---------------------------------------"
 echo " (--help or -h for more info)"
 echo
 echo "Basic checkings ..."
+
 # Launcher executable:
 available=
 for EXEC in ${EXECS[@]}; do
@@ -97,6 +103,7 @@ for EXEC in ${EXECS[@]}; do
   echo "not found"
 done
 [ -z "$available" ] && _exit "Anna Diameter Launcher (ADML) is not installed neither linked. See README.md (Install section)."
+
 # Dictionary creation:
 available=
 for STACKMGMT_EXEC in ${STACKMGMT_EXECS[@]}; do
@@ -107,6 +114,15 @@ done
 [ -z "$available" ] && _exit "Anna Diameter Stack Management Tool is not installed neither linked. See README.md (Install section)."
 STACKMGMT_EXEC=`readlink -f $STACKMGMT_EXEC`
 
+# Dynamic library:
+available=
+for DYNLIB in ${DYNLIBS[@]}; do
+  echo -n "Looking dynamic library at '$DYNLIB' ... "
+  [ -x $DYNLIB ] && { available=yes ; echo "available !" ; break ; }
+  echo "not found"
+done
+[ -z "$available" ] && _exit "Anna Diameter Launcher Dynamic Procedure Library (ADML) is not installed neither linked. See README.md (Install section)."
+
 [ ! -d $SETUPS_DIR ] && _exit "Diameter stacks not found ($SETUPS_DIR)."
 
 echo
@@ -176,6 +192,8 @@ mkdir -p $DPATH/stacks
 mkdir -p $DPATH/DTDs
 mkdir -p $DPATH/counters
 mkdir -p $DPATH/test-reports
+cp $DYNLIB $DPATH
+
 [ "$option" = "b" ] && mkdir -p $DPATH/services
 
 # ADML executable:
index 116c325..aebebec 100644 (file)
@@ -25,6 +25,7 @@
 #include <anna/time/functions.hpp>
 #include <anna/diameter.comm/ApplicationMessageOamModule.hpp>
 #include <anna/xml/xml.hpp>
+#include <Procedure.hpp>
 
 // Process
 #include <Launcher.hpp>
@@ -1418,6 +1419,27 @@ std::string Launcher::help() const throw() {
   result += "\n   test|report-hex[|[yes]|no]    Reports could include the diameter messages in hexadecimal format. Disabled by default.";
   result += "\n";
   result += "\n";
+  result += "\n------------------------------------------------------------------------------------- Dynamic procedure";
+  result += "\n";
+  result += "\ndynamic[|args]                   This launch an internal operation implemented in 'Procedure' class.";
+  result += "\n                                 Its default implementation does nothing, but you could create a dynamic";
+  result += "\n                                 library 'libanna_launcherDynamic.so' and replace the one in this project.";
+  result += "\n                                 One interesting application consists in the use of the diameter API and";
+  result += "\n                                 event operation to create a set of libraries as the testing framework.";
+  result += "\n                                 To execute each test case, the ADML process would be executed with a";
+  result += "\n                                 specific library path. But the main use would be the stress programming";
+  result += "\n                                 to achieve a great amount of cloned (even mixed) tests without using";
+  result += "\n                                 the management operation interface by mean http or signals: a single";
+  result += "\n                                 call to 'dynamic' would be enough to start a cascade of internally";
+  result += "\n                                 implemented operations.";
+  result += "\n                                 This operation accepts a generic string argument (piped or not, as you";
+  result += "\n                                 desire and depending on your procedure implementation).";
+  result += "\n";
+  result += "\n                                 This operation requires advanced programming and knowlegde of ANNA Diameter";
+  result += "\n                                 stack and testing framework, to take advantage of all the possibilities.";
+  result += "\n";
+  result += "\n";
+  result += "\n";
   result += "\nUSING OPERATIONS INTERFACE";
   result += "\n--------------------------";
   result += "\n";
@@ -1510,6 +1532,17 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
   ///////////////////////////////////////////////////////////////////
   // Simple operations without arguments:
 
+  // Dynamic operation:
+  if(operation.find("dynamic") == 0) {
+    Procedure p(this);
+    int op_size = operation.size();
+    std::string args = ((operation.find("dynamic|") == 0) && (op_size > 8)) ? operation.substr(8) : "";
+    if (args == "" && op_size != 7)
+      throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
+    p.execute(args, response_content);
+    return;
+  }
+
   // Help:
   if(operation == "help") {
     response_content = help();
index 249a878..d2ff2ed 100644 (file)
@@ -11,12 +11,19 @@ pPath = pName.replace("_", "/") + "/"
 pwd = str(Dir ('.').abspath);
 anna_libpaths = []
 anna_libs = []
+
 modules = [ 'core', 'io', 'xml', 'app', 'http', 'comm', 'timex', 'http', 'statistics', 'time', 'diameter', 'diameter_comm' ];
 for module in modules:
   anna_libs.append ("anna_" + module)
   module = module.replace("_", ".")
+  kk = pwd.replace (pPath, ("source/" + module + "/"))
   anna_libpaths.append (pwd.replace (pPath, ("source/" + module + "/")))
 
+# dynamic lib:
+anna_libs.append ("anna_dynamicLauncherProcedure")
+dynamic_libpath = os.path.join (pwd, "../../../../dynamic/launcher/default/debug")
+anna_libpaths.append (dynamic_libpath)
+
 anna_rlibs = list(anna_libs)
 anna_rlibs.reverse()
 
@@ -32,12 +39,14 @@ localEnv.MergeFlags (system_library)
 
 localEnv.Append(LIBPATH = anna_libpaths)
 
+
 # Linking #################################################################
 
 # Process includes (avoid mandatory using of quoted includes and ../ paths from testing directory):
 current_directory = Dir ('.').abspath
 testing_include = os.path.join (current_directory, "testing")
-localEnv.Append (CPPPATH = [current_directory, testing_include])
+dynamic_include = os.path.join (pwd, "../../../../dynamic/launcher/default/")
+localEnv.Append (CPPPATH = [current_directory, testing_include, dynamic_include])
 
 result = localEnv.Program (pName, Glob ('*.cpp') + Glob ('testing/*.cpp'))
 
index c473692..cc4fa74 100755 (executable)
@@ -29,6 +29,7 @@ STARTED=\`pgrep $1$ 2>/dev/null\`
 0> launcher.trace
 rm -f counters/* test-reports/*
 # Execution line:
+export LD_LIBRARY_PATH=\$PWD
 ./$@ --services services.xml &
 echo \$! > .pid
 EOF