Changeset: 427934ea7ca0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=427934ea7ca0
Modified Files:
gdk/gdk_tracer.c
monetdb5/modules/mal/Tests/tracer00.malC
monetdb5/modules/mal/tracer.c
monetdb5/modules/mal/tracer.h
monetdb5/modules/mal/tracer.mal
Branch: gdk_tracer
Log Message:
Added some test cases, exposed GDKtracer_log for testing only to the MAL layer
diffs (212 lines):
diff --git a/gdk/gdk_tracer.c b/gdk/gdk_tracer.c
--- a/gdk/gdk_tracer.c
+++ b/gdk/gdk_tracer.c
@@ -545,4 +545,6 @@ GDKtracer_show_info(void)
{
mnstr_printf(GDKstdout, "# %s\n", LAYER_STR[i]);
}
+
+ return GDK_SUCCEED;
}
diff --git a/monetdb5/modules/mal/Tests/tracer00.malC
b/monetdb5/modules/mal/Tests/tracer00.malC
--- a/monetdb5/modules/mal/Tests/tracer00.malC
+++ b/monetdb5/modules/mal/Tests/tracer00.malC
@@ -1,4 +1,15 @@
-# Test SQL API for TRACER
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
+#
+# Test SQL API for TRACER:
+# In some test cases (marked with #WARNING) the argument used is supposed to
be
+# an enum entry used to count the number of elements (e.g: COMPONENTS_COUNT in
+# gdk_tracer.h). Thus, in those cases an error should be raised. However,
adding
+# new entries to the enum will affect the marked test cases and they won't
fail.
+
# logging.setcomplevel(...)
logging.setcomplevel(-1, 1); # Should raise an error
@@ -11,9 +22,19 @@ logging.setcomplevel(-10, -1); # Should
# Component -10 does not exist
# Log level -1 does not exist
+# WARNING
logging.setcomplevel(1, 5); # Should raise an error
# The last level is used for enum count
+# WARNING
+logging.setcomplevel(98, 3); # Should raise an error
+ # The last component is used for enum count
+
+# WARNING
+logging.setcomplevel(98, 5); # Should raise an error
+ # The last component is used for enum count
+ # The last level is used for enum count
+
logging.setcomplevel(1, 4); # OK
@@ -22,6 +43,10 @@ logging.setcomplevel(1, 4); # OK
logging.resetcomplevel(-1); # Should raise an error
# Component -1 does not exist
+# WARNING
+logging.resetcomplevel(98); # Should raise an error
+ # The last component is used for enum count
+
logging.resetcomplevel(1); # OK
@@ -37,17 +62,20 @@ logging.setlayerlevel(-10, -1); # Should
# Layer -10 does not exist
# Log level -1 does not exist
+# WARNING
logging.setlayerlevel(4, 2); # Should raise an error
# The last layer is used for enum count
+# WARNING
logging.setlayerlevel(1, 5); # Should raise an error
# The last level is used for enum count
+# WARNING
logging.setlayerlevel(4, 5); # Should raise an error
# The last layer is used for enum count
# The last level is used for enum count
-logging.setlayerlevel(1, 3); # OK
+logging.setlayerlevel(1, 2); # OK
@@ -55,6 +83,7 @@ logging.setlayerlevel(1, 3); # OK
logging.resetlayerlevel(-1); # Should raise an error
# Layer -1 does not exist
+# WARNING
logging.resetlayerlevel(4); # Should raise an error
# The last layer is used for enum count
@@ -66,6 +95,7 @@ logging.resetlayerlevel(1); # OK
logging.setflushlevel(-1); # Should raise an error
# Level -1 does not exist
+# WARNING
logging.setflushlevel(5); # Should raise an error
# The last level is used for enum count
@@ -81,6 +111,7 @@ logging.resetflushlevel();
logging.setadapter(-1); # Should raise an error
# Adapter -1 does not exist
+# WARNING
logging.setadapter(2); # Should raise an error
# The last adapter is used for enum count
@@ -89,3 +120,9 @@ logging.setadapter(1); # OK
logging.resetadapter();
+
+
+
+# log & flush
+logging.log();
+logging.flush();
\ No newline at end of file
diff --git a/monetdb5/modules/mal/tracer.c b/monetdb5/modules/mal/tracer.c
--- a/monetdb5/modules/mal/tracer.c
+++ b/monetdb5/modules/mal/tracer.c
@@ -4,6 +4,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
+ *
+ *
+ * GDKtracer exposes routines where an occuring failure should not reach the
client but
+ * should be made known only to the DBA. On the other hand, there are exposed
routines
+ * where the failure must also reach the client.
+ *
+ * For both cases the failures are being logged to the active adapter, or to
the fallback
+ * mechanism (mserver5). To cover the needs of the second category, an
exception is thrown.
+ * Exceptions apart from being logged by GDKtracer are also percolating up to
the client.
+ *
*/
#include "monetdb_config.h"
@@ -15,10 +25,7 @@ int GDK_result = 0;
str
TRACERflush_buffer(void)
{
- GDK_result = GDKtracer_flush_buffer();
- if(GDK_result == GDK_FAIL)
- throw(TRACER, __FUNCTION__, _OPERATION_FAILED);
-
+ GDKtracer_flush_buffer();
return MAL_SUCCEED;
}
@@ -113,3 +120,14 @@ TRACERreset_adapter(void)
return MAL_SUCCEED;
}
+
+
+// Exposed only in MAL layer - for testing
+str
+TRACERlog(void)
+{
+ TRC_CRITICAL(SQL_BAT, "A CRITICAL message\n");
+ TRC_INFO(MAL_DATAFLOW, "An INFO message\n");
+
+ return MAL_SUCCEED;
+}
\ No newline at end of file
diff --git a/monetdb5/modules/mal/tracer.h b/monetdb5/modules/mal/tracer.h
--- a/monetdb5/modules/mal/tracer.h
+++ b/monetdb5/modules/mal/tracer.h
@@ -4,6 +4,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V.
+ *
+ * All the functions correspond one by one to the API calls in gdk_tracer.h
+ * Except TRACERlog which is exposed only in the MAL layer for testing.
+ *
*/
#ifndef _TRACER_H
@@ -12,9 +16,7 @@
#include "mal.h"
#include "mal_interpreter.h"
-/*
- * All the functions correspond one by one to the API calls in gdk_tracer.h
- */
+
mal_export str TRACERflush_buffer(void);
mal_export str TRACERset_component_level(void *ret, int *comp, int *lvl);
mal_export str TRACERreset_component_level(int *comp);
@@ -25,4 +27,7 @@ mal_export str TRACERreset_flush_level(v
mal_export str TRACERset_adapter(void *ret, int *adapter);
mal_export str TRACERreset_adapter(void);
+// Exposed only in MAL layer - for testing
+mal_export str TRACERlog(void);
+
#endif /* _TRACER_H */
diff --git a/monetdb5/modules/mal/tracer.mal b/monetdb5/modules/mal/tracer.mal
--- a/monetdb5/modules/mal/tracer.mal
+++ b/monetdb5/modules/mal/tracer.mal
@@ -41,3 +41,8 @@ comment "Set the adapter";
command resetadapter()
address TRACERreset_adapter
comment "Reset the adapter";
+
+# Exposed only in MAL layer - for testing
+command log()
+address TRACERlog
+comment "Create a log message";
\ No newline at end of file
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list